aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2006-02-07 01:47:12 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-02-07 01:47:12 -0500
commit3c9b3a8575b4f2551e3b5b74ffa1c3559c6338eb (patch)
tree7f8d84353852401ec74e005f6f0b1eb958b9a70d
parentc0d3c0c0ce94d3db893577ae98e64414d92e49d8 (diff)
parentc03296a868ae7c91aa2d8b372184763b18f16d7a (diff)
Merge branch 'master'
-rw-r--r--CREDITS2
-rw-r--r--Documentation/RCU/RTFP.txt25
-rw-r--r--Documentation/RCU/checklist.txt6
-rw-r--r--Documentation/RCU/listRCU.txt21
-rw-r--r--Documentation/RCU/rcu.txt5
-rw-r--r--Documentation/RCU/rcuref.txt31
-rw-r--r--Documentation/RCU/whatisRCU.txt29
-rw-r--r--Documentation/cputopology.txt41
-rw-r--r--Documentation/driver-model/overview.txt57
-rw-r--r--Documentation/feature-removal-schedule.txt15
-rw-r--r--Documentation/filesystems/configfs/configfs_example.c2
-rw-r--r--Documentation/filesystems/ocfs2.txt1
-rw-r--r--Documentation/kernel-doc-nano-HOWTO.txt39
-rw-r--r--Documentation/kernel-parameters.txt5
-rw-r--r--Documentation/networking/ip-sysctl.txt17
-rw-r--r--Documentation/parport-lowlevel.txt8
-rw-r--r--Documentation/pci-error-recovery.txt472
-rw-r--r--Documentation/power/interface.txt2
-rw-r--r--Documentation/power/swsusp.txt2
-rw-r--r--Documentation/powerpc/booting-without-of.txt1420
-rw-r--r--Documentation/scsi/ChangeLog.megaraid_sas24
-rw-r--r--Documentation/scsi/aic79xx.txt93
-rw-r--r--Documentation/scsi/aic7xxx.txt86
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt10
-rw-r--r--Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl4
-rw-r--r--Documentation/sysctl/vm.txt56
-rw-r--r--Documentation/usb/et61x251.txt306
-rw-r--r--Documentation/usb/sn9c102.txt95
-rw-r--r--Documentation/usb/w9968cf.txt30
-rw-r--r--Documentation/vm/page_migration129
-rw-r--r--Documentation/x86_64/boot-options.txt12
-rw-r--r--MAINTAINERS20
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/kernel/asm-offsets.c1
-rw-r--r--arch/alpha/kernel/entry.S16
-rw-r--r--arch/alpha/kernel/irq.c36
-rw-r--r--arch/arm/configs/at91rm9200dk_defconfig1
-rw-r--r--arch/arm/configs/at91rm9200ek_defconfig1
-rw-r--r--arch/arm/configs/bast_defconfig5
-rw-r--r--arch/arm/configs/collie_defconfig7
-rw-r--r--arch/arm/configs/csb337_defconfig1
-rw-r--r--arch/arm/configs/csb637_defconfig1
-rw-r--r--arch/arm/configs/s3c2410_defconfig5
-rw-r--r--arch/arm/kernel/calls.S661
-rw-r--r--arch/arm/kernel/entry-common.S4
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c4
-rw-r--r--arch/arm/mach-pxa/pxa27x.c2
-rw-r--r--arch/arm/mach-s3c2410/Makefile5
-rw-r--r--arch/arm/mach-s3c2410/cpu.c18
-rw-r--r--arch/arm/mach-s3c2410/cpu.h3
-rw-r--r--arch/arm/mach-s3c2410/devs.c57
-rw-r--r--arch/arm/mach-s3c2410/dma.c2
-rw-r--r--arch/arm/mach-s3c2410/gpio.c72
-rw-r--r--arch/arm/mach-s3c2410/s3c2400-gpio.c45
-rw-r--r--arch/arm/mach-s3c2410/s3c2410-gpio.c93
-rw-r--r--arch/arm/mach-s3c2410/sleep.S8
-rw-r--r--arch/arm/mm/cache-v6.S18
-rw-r--r--arch/arm/mm/ioremap.c2
-rw-r--r--arch/arm/mm/mm-armv.c6
-rw-r--r--arch/arm/mm/proc-xscale.S16
-rw-r--r--arch/arm/oprofile/common.c5
-rw-r--r--arch/arm26/Kconfig6
-rw-r--r--arch/arm26/kernel/fiq.c32
-rw-r--r--arch/arm26/kernel/signal.c3
-rw-r--r--arch/i386/Kconfig56
-rw-r--r--arch/i386/kernel/acpi/Makefile2
-rw-r--r--arch/i386/kernel/acpi/boot.c19
-rw-r--r--arch/i386/kernel/acpi/cstate.c58
-rw-r--r--arch/i386/kernel/acpi/processor.c75
-rw-r--r--arch/i386/kernel/apic.c5
-rw-r--r--arch/i386/kernel/cpu/amd.c8
-rw-r--r--arch/i386/kernel/cpu/centaur.c12
-rw-r--r--arch/i386/kernel/cpu/common.c11
-rw-r--r--arch/i386/kernel/cpu/cpufreq/Kconfig1
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c71
-rw-r--r--arch/i386/kernel/cpu/cpufreq/p4-clockmod.c9
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c12
-rw-r--r--arch/i386/kernel/cpu/cyrix.c18
-rw-r--r--arch/i386/kernel/cpu/intel_cacheinfo.c12
-rw-r--r--arch/i386/kernel/cpu/mtrr/main.c15
-rw-r--r--arch/i386/kernel/cpu/nexgen.c8
-rw-r--r--arch/i386/kernel/cpu/rise.c8
-rw-r--r--arch/i386/kernel/cpu/transmeta.c10
-rw-r--r--arch/i386/kernel/cpu/umc.c8
-rw-r--r--arch/i386/kernel/mpparse.c8
-rw-r--r--arch/i386/kernel/nmi.c2
-rw-r--r--arch/i386/kernel/process.c6
-rw-r--r--arch/i386/kernel/timers/timer_tsc.c14
-rw-r--r--arch/i386/kernel/traps.c9
-rw-r--r--arch/i386/oprofile/backtrace.c19
-rw-r--r--arch/i386/pci/irq.c5
-rw-r--r--arch/i386/pci/mmconfig.c15
-rw-r--r--arch/ia64/Kconfig4
-rw-r--r--arch/ia64/kernel/Makefile5
-rw-r--r--arch/ia64/kernel/acpi-ext.c22
-rw-r--r--arch/ia64/kernel/acpi-processor.c67
-rw-r--r--arch/ia64/kernel/acpi.c6
-rw-r--r--arch/ia64/kernel/cpufreq/Makefile1
-rw-r--r--arch/ia64/kernel/cpufreq/acpi-cpufreq.c51
-rw-r--r--arch/ia64/kernel/mca_asm.S2
-rw-r--r--arch/ia64/kernel/sal.c75
-rw-r--r--arch/ia64/kernel/topology.c18
-rw-r--r--arch/ia64/kernel/unaligned.c3
-rw-r--r--arch/ia64/pci/pci.c10
-rw-r--r--arch/ia64/sn/Makefile2
-rw-r--r--arch/ia64/sn/kernel/Makefile2
-rw-r--r--arch/ia64/sn/kernel/bte.c17
-rw-r--r--arch/ia64/sn/kernel/io_init.c45
-rw-r--r--arch/ia64/sn/kernel/irq.c21
-rw-r--r--arch/ia64/sn/kernel/klconflib.c29
-rw-r--r--arch/ia64/sn/kernel/setup.c19
-rw-r--r--arch/ia64/sn/kernel/sn2/Makefile2
-rw-r--r--arch/ia64/sn/kernel/sn2/sn2_smp.c196
-rw-r--r--arch/ia64/sn/kernel/xpc_channel.c6
-rw-r--r--arch/ia64/sn/kernel/xpc_main.c19
-rw-r--r--arch/ia64/sn/pci/Makefile2
-rw-r--r--arch/ia64/sn/pci/pci_dma.c4
-rw-r--r--arch/ia64/sn/pci/pcibr/Makefile2
-rw-r--r--arch/mips/kernel/gdb-stub.c2
-rw-r--r--arch/parisc/Kconfig20
-rw-r--r--arch/parisc/Kconfig.debug10
-rw-r--r--arch/parisc/configs/b180_defconfig182
-rw-r--r--arch/parisc/hpux/entry_hpux.S3
-rw-r--r--arch/parisc/kernel/drivers.c3
-rw-r--r--arch/parisc/kernel/parisc_ksyms.c3
-rw-r--r--arch/parisc/kernel/pci.c13
-rw-r--r--arch/parisc/kernel/perf.c38
-rw-r--r--arch/parisc/kernel/perf_images.h4
-rw-r--r--arch/parisc/kernel/process.c35
-rw-r--r--arch/parisc/kernel/ptrace.c8
-rw-r--r--arch/parisc/kernel/signal.c2
-rw-r--r--arch/parisc/kernel/signal32.c102
-rw-r--r--arch/parisc/kernel/signal32.h127
-rw-r--r--arch/parisc/kernel/syscall.S2
-rw-r--r--arch/parisc/kernel/syscall_table.S19
-rw-r--r--arch/parisc/kernel/traps.c3
-rw-r--r--arch/parisc/math-emu/decode_exc.c1
-rw-r--r--arch/parisc/mm/init.c35
-rw-r--r--arch/powerpc/kernel/legacy_serial.c4
-rw-r--r--arch/powerpc/kernel/signal_32.c4
-rw-r--r--arch/powerpc/platforms/powermac/pfunc_core.c13
-rw-r--r--arch/powerpc/platforms/pseries/pci_dlpar.c3
-rw-r--r--arch/s390/defconfig40
-rw-r--r--arch/s390/kernel/compat_signal.c102
-rw-r--r--arch/s390/kernel/compat_wrapper.S137
-rw-r--r--arch/s390/kernel/entry.S51
-rw-r--r--arch/s390/kernel/entry64.S75
-rw-r--r--arch/s390/kernel/signal.c146
-rw-r--r--arch/s390/kernel/syscalls.S22
-rw-r--r--arch/s390/kernel/time.c11
-rw-r--r--arch/s390/lib/Makefile2
-rw-r--r--arch/sh/Kconfig6
-rw-r--r--arch/sh/boards/superh/microdev/io.c192
-rw-r--r--arch/sh/boards/superh/microdev/irq.c2
-rw-r--r--arch/sh/boards/superh/microdev/setup.c166
-rw-r--r--arch/sh/boards/unknown/Makefile2
-rw-r--r--arch/sh/boards/unknown/io.c46
-rw-r--r--arch/sh/boards/unknown/mach.c67
-rw-r--r--arch/sh/boards/unknown/setup.c12
-rw-r--r--arch/sh/cchips/voyagergx/consistent.c15
-rw-r--r--arch/sh/cchips/voyagergx/irq.c7
-rw-r--r--arch/sh/configs/microdev_defconfig410
-rw-r--r--arch/sh/kernel/Makefile2
-rw-r--r--arch/sh/kernel/cpu/Makefile2
-rw-r--r--arch/sh/kernel/cpu/bus.c197
-rw-r--r--arch/sh/kernel/cpu/clock.c13
-rw-r--r--arch/sh/kernel/cpu/irq/ipr.c59
-rw-r--r--arch/sh/kernel/entry.S18
-rw-r--r--arch/sh/kernel/process.c54
-rw-r--r--arch/sh/kernel/setup.c51
-rw-r--r--arch/sh64/kernel/time.c1
-rw-r--r--arch/sparc/kernel/entry.S2
-rw-r--r--arch/sparc/math-emu/math.c10
-rw-r--r--arch/sparc64/boot/.gitignore4
-rw-r--r--arch/sparc64/defconfig21
-rw-r--r--arch/sparc64/kernel/entry.S2
-rw-r--r--arch/sparc64/kernel/sys32.S1
-rw-r--r--arch/sparc64/kernel/systbls.S2
-rw-r--r--arch/um/Makefile23
-rw-r--r--arch/um/drivers/chan_kern.c6
-rw-r--r--arch/um/drivers/daemon_kern.c4
-rw-r--r--arch/um/drivers/line.c2
-rw-r--r--arch/um/drivers/mcast_kern.c4
-rw-r--r--arch/um/drivers/mconsole_kern.c11
-rw-r--r--arch/um/drivers/slip_common.h13
-rw-r--r--arch/um/drivers/slip_kern.c15
-rw-r--r--arch/um/drivers/slirp_kern.c13
-rw-r--r--arch/um/drivers/ssl.c6
-rw-r--r--arch/um/include/kern_util.h2
-rw-r--r--arch/um/kernel/exec_kern.c2
-rw-r--r--arch/um/kernel/physmem.c2
-rw-r--r--arch/um/kernel/reboot.c1
-rw-r--r--arch/um/kernel/tt/syscall_kern.c8
-rw-r--r--arch/um/sys-i386/ldt.c2
-rw-r--r--arch/v850/kernel/simcons.c25
-rw-r--r--arch/x86_64/Kconfig.debug7
-rw-r--r--arch/x86_64/defconfig21
-rw-r--r--arch/x86_64/ia32/ia32entry.S2
-rw-r--r--arch/x86_64/kernel/acpi/Makefile5
-rw-r--r--arch/x86_64/kernel/acpi/processor.c72
-rw-r--r--arch/x86_64/kernel/apic.c89
-rw-r--r--arch/x86_64/kernel/entry.S7
-rw-r--r--arch/x86_64/kernel/io_apic.c18
-rw-r--r--arch/x86_64/kernel/mce.c2
-rw-r--r--arch/x86_64/kernel/mpparse.c8
-rw-r--r--arch/x86_64/kernel/nmi.c7
-rw-r--r--arch/x86_64/kernel/pci-dma.c3
-rw-r--r--arch/x86_64/kernel/pci-gart.c19
-rw-r--r--arch/x86_64/kernel/pci-nommu.c7
-rw-r--r--arch/x86_64/kernel/pci-swiotlb.c2
-rw-r--r--arch/x86_64/kernel/pmtimer.c25
-rw-r--r--arch/x86_64/kernel/process.c4
-rw-r--r--arch/x86_64/kernel/setup.c8
-rw-r--r--arch/x86_64/kernel/time.c59
-rw-r--r--arch/x86_64/kernel/traps.c21
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S10
-rw-r--r--arch/x86_64/lib/Makefile2
-rw-r--r--arch/x86_64/lib/clear_page.S38
-rw-r--r--arch/x86_64/lib/copy_page.S87
-rw-r--r--arch/x86_64/lib/copy_user.S247
-rw-r--r--arch/x86_64/lib/iomap_copy.S26
-rw-r--r--arch/x86_64/lib/memcpy.S93
-rw-r--r--arch/x86_64/lib/memset.S94
-rw-r--r--arch/x86_64/mm/fault.c3
-rw-r--r--arch/x86_64/mm/srat.c45
-rw-r--r--arch/x86_64/pci/mmconfig.c19
-rw-r--r--arch/xtensa/platform-iss/console.c4
-rw-r--r--block/elevator.c48
-rw-r--r--block/ll_rw_blk.c49
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/acpi/Kconfig1
-rw-r--r--drivers/acpi/acpi_memhotplug.c17
-rw-r--r--drivers/acpi/asus_acpi.c35
-rw-r--r--drivers/acpi/dispatcher/dsfield.c37
-rw-r--r--drivers/acpi/dispatcher/dsinit.c51
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c360
-rw-r--r--drivers/acpi/dispatcher/dsmthdat.c37
-rw-r--r--drivers/acpi/dispatcher/dsobject.c106
-rw-r--r--drivers/acpi/dispatcher/dsopcode.c58
-rw-r--r--drivers/acpi/dispatcher/dsutils.c33
-rw-r--r--drivers/acpi/dispatcher/dswexec.c80
-rw-r--r--drivers/acpi/dispatcher/dswload.c270
-rw-r--r--drivers/acpi/dispatcher/dswscope.c6
-rw-r--r--drivers/acpi/dispatcher/dswstate.c128
-rw-r--r--drivers/acpi/ec.c291
-rw-r--r--drivers/acpi/events/evevent.c63
-rw-r--r--drivers/acpi/events/evgpe.c54
-rw-r--r--drivers/acpi/events/evgpeblk.c215
-rw-r--r--drivers/acpi/events/evmisc.c26
-rw-r--r--drivers/acpi/events/evregion.c63
-rw-r--r--drivers/acpi/events/evrgnini.c8
-rw-r--r--drivers/acpi/events/evsci.c6
-rw-r--r--drivers/acpi/events/evxface.c19
-rw-r--r--drivers/acpi/events/evxfevnt.c34
-rw-r--r--drivers/acpi/events/evxfregn.c2
-rw-r--r--drivers/acpi/executer/exconfig.c8
-rw-r--r--drivers/acpi/executer/exconvrt.c36
-rw-r--r--drivers/acpi/executer/excreate.c6
-rw-r--r--drivers/acpi/executer/exdump.c671
-rw-r--r--drivers/acpi/executer/exfield.c11
-rw-r--r--drivers/acpi/executer/exfldio.c93
-rw-r--r--drivers/acpi/executer/exmisc.c113
-rw-r--r--drivers/acpi/executer/exmutex.c28
-rw-r--r--drivers/acpi/executer/exnames.c23
-rw-r--r--drivers/acpi/executer/exoparg1.c72
-rw-r--r--drivers/acpi/executer/exoparg2.c46
-rw-r--r--drivers/acpi/executer/exoparg3.c12
-rw-r--r--drivers/acpi/executer/exoparg6.c16
-rw-r--r--drivers/acpi/executer/exprep.c34
-rw-r--r--drivers/acpi/executer/exregion.c35
-rw-r--r--drivers/acpi/executer/exresnte.c51
-rw-r--r--drivers/acpi/executer/exresolv.c35
-rw-r--r--drivers/acpi/executer/exresop.c143
-rw-r--r--drivers/acpi/executer/exstore.c27
-rw-r--r--drivers/acpi/executer/exstoren.c24
-rw-r--r--drivers/acpi/executer/exstorob.c6
-rw-r--r--drivers/acpi/executer/exsystem.c6
-rw-r--r--drivers/acpi/executer/exutils.c20
-rw-r--r--drivers/acpi/glue.c8
-rw-r--r--drivers/acpi/hardware/hwacpi.c25
-rw-r--r--drivers/acpi/hardware/hwgpe.c2
-rw-r--r--drivers/acpi/hardware/hwregs.c59
-rw-r--r--drivers/acpi/hardware/hwsleep.c23
-rw-r--r--drivers/acpi/hardware/hwtimer.c2
-rw-r--r--drivers/acpi/motherboard.c30
-rw-r--r--drivers/acpi/namespace/nsaccess.c35
-rw-r--r--drivers/acpi/namespace/nsalloc.c11
-rw-r--r--drivers/acpi/namespace/nsdump.c13
-rw-r--r--drivers/acpi/namespace/nsdumpdv.c2
-rw-r--r--drivers/acpi/namespace/nseval.c5
-rw-r--r--drivers/acpi/namespace/nsinit.c105
-rw-r--r--drivers/acpi/namespace/nsload.c10
-rw-r--r--drivers/acpi/namespace/nsnames.c14
-rw-r--r--drivers/acpi/namespace/nsobject.c13
-rw-r--r--drivers/acpi/namespace/nsparse.c2
-rw-r--r--drivers/acpi/namespace/nssearch.c30
-rw-r--r--drivers/acpi/namespace/nsutils.c43
-rw-r--r--drivers/acpi/namespace/nswalk.c2
-rw-r--r--drivers/acpi/namespace/nsxfeval.c29
-rw-r--r--drivers/acpi/namespace/nsxfname.c5
-rw-r--r--drivers/acpi/namespace/nsxfobj.c2
-rw-r--r--drivers/acpi/osl.c10
-rw-r--r--drivers/acpi/parser/psargs.c358
-rw-r--r--drivers/acpi/parser/psloop.c39
-rw-r--r--drivers/acpi/parser/psopcode.c4
-rw-r--r--drivers/acpi/parser/psparse.c55
-rw-r--r--drivers/acpi/parser/psscope.c2
-rw-r--r--drivers/acpi/parser/pstree.c5
-rw-r--r--drivers/acpi/parser/psutils.c2
-rw-r--r--drivers/acpi/parser/pswalk.c2
-rw-r--r--drivers/acpi/parser/psxface.c144
-rw-r--r--drivers/acpi/pci_irq.c48
-rw-r--r--drivers/acpi/pci_link.c100
-rw-r--r--drivers/acpi/pci_root.c8
-rw-r--r--drivers/acpi/processor_core.c30
-rw-r--r--drivers/acpi/processor_idle.c139
-rw-r--r--drivers/acpi/processor_perflib.c4
-rw-r--r--drivers/acpi/processor_thermal.c7
-rw-r--r--drivers/acpi/processor_throttling.c7
-rw-r--r--drivers/acpi/resources/Makefile2
-rw-r--r--drivers/acpi/resources/rsaddr.c1164
-rw-r--r--drivers/acpi/resources/rscalc.c831
-rw-r--r--drivers/acpi/resources/rscreate.c231
-rw-r--r--drivers/acpi/resources/rsdump.c1399
-rw-r--r--drivers/acpi/resources/rsinfo.c204
-rw-r--r--drivers/acpi/resources/rsio.c544
-rw-r--r--drivers/acpi/resources/rsirq.c568
-rw-r--r--drivers/acpi/resources/rslist.c534
-rw-r--r--drivers/acpi/resources/rsmemory.c517
-rw-r--r--drivers/acpi/resources/rsmisc.c860
-rw-r--r--drivers/acpi/resources/rsutils.c390
-rw-r--r--drivers/acpi/resources/rsxface.c230
-rw-r--r--drivers/acpi/scan.c2
-rw-r--r--drivers/acpi/sleep/poweroff.c15
-rw-r--r--drivers/acpi/sleep/sleep.h2
-rw-r--r--drivers/acpi/sleep/wakeup.c6
-rw-r--r--drivers/acpi/tables/tbconvrt.c23
-rw-r--r--drivers/acpi/tables/tbget.c39
-rw-r--r--drivers/acpi/tables/tbgetall.c27
-rw-r--r--drivers/acpi/tables/tbinstal.c12
-rw-r--r--drivers/acpi/tables/tbrsdt.c30
-rw-r--r--drivers/acpi/tables/tbutils.c50
-rw-r--r--drivers/acpi/tables/tbxface.c18
-rw-r--r--drivers/acpi/tables/tbxfroot.c35
-rw-r--r--drivers/acpi/utilities/Makefile5
-rw-r--r--drivers/acpi/utilities/utalloc.c61
-rw-r--r--drivers/acpi/utilities/utcache.c2
-rw-r--r--drivers/acpi/utilities/utcopy.c27
-rw-r--r--drivers/acpi/utilities/utdebug.c2
-rw-r--r--drivers/acpi/utilities/utdelete.c15
-rw-r--r--drivers/acpi/utilities/uteval.c46
-rw-r--r--drivers/acpi/utilities/utglobal.c108
-rw-r--r--drivers/acpi/utilities/utinit.c13
-rw-r--r--drivers/acpi/utilities/utmath.c10
-rw-r--r--drivers/acpi/utilities/utmisc.c209
-rw-r--r--drivers/acpi/utilities/utmutex.c58
-rw-r--r--drivers/acpi/utilities/utobject.c33
-rw-r--r--drivers/acpi/utilities/utresrc.c554
-rw-r--r--drivers/acpi/utilities/utstate.c4
-rw-r--r--drivers/acpi/utilities/utxface.c69
-rw-r--r--drivers/acpi/video.c8
-rw-r--r--drivers/base/Makefile1
-rw-r--r--drivers/base/topology.c148
-rw-r--r--drivers/block/Kconfig8
-rw-r--r--drivers/block/pktcdvd.c58
-rw-r--r--drivers/block/ub.c139
-rw-r--r--drivers/block/umem.c2
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/agp/amd64-agp.c24
-rw-r--r--drivers/char/agp/ati-agp.c20
-rw-r--r--drivers/char/agp/frontend.c28
-rw-r--r--drivers/char/agp/intel-agp.c15
-rw-r--r--drivers/char/agp/isoch.c4
-rw-r--r--drivers/char/cyclades.c6
-rw-r--r--drivers/char/drm/ati_pcigart.c17
-rw-r--r--drivers/char/drm/drmP.h5
-rw-r--r--drivers/char/drm/drm_auth.c20
-rw-r--r--drivers/char/drm/drm_bufs.c80
-rw-r--r--drivers/char/drm/drm_context.c52
-rw-r--r--drivers/char/drm/drm_drv.c4
-rw-r--r--drivers/char/drm/drm_fops.c12
-rw-r--r--drivers/char/drm/drm_ioctl.c18
-rw-r--r--drivers/char/drm/drm_irq.c16
-rw-r--r--drivers/char/drm/drm_pciids.h2
-rw-r--r--drivers/char/drm/drm_proc.c28
-rw-r--r--drivers/char/drm/drm_stub.c4
-rw-r--r--drivers/char/drm/drm_vm.c12
-rw-r--r--drivers/char/drm/i810_dma.c2
-rw-r--r--drivers/char/drm/i810_drv.h2
-rw-r--r--drivers/char/drm/i830_dma.c2
-rw-r--r--drivers/char/drm/i830_drv.h3
-rw-r--r--drivers/char/drm/i915_dma.c42
-rw-r--r--drivers/char/drm/i915_drm.h33
-rw-r--r--drivers/char/drm/i915_drv.h6
-rw-r--r--drivers/char/drm/i915_mem.c31
-rw-r--r--drivers/char/drm/radeon_cp.c2
-rw-r--r--drivers/char/drm/savage_bci.c4
-rw-r--r--drivers/char/drm/savage_drv.h1
-rw-r--r--drivers/char/drm/via_dma.c10
-rw-r--r--drivers/char/drm/via_dmablit.c6
-rw-r--r--drivers/char/drm/via_drv.h7
-rw-r--r--drivers/char/drm/via_irq.c2
-rw-r--r--drivers/char/esp.c4
-rw-r--r--drivers/char/hangcheck-timer.c12
-rw-r--r--drivers/char/hpet.c26
-rw-r--r--drivers/char/ip2/i2cmd.c1
-rw-r--r--drivers/char/ip2main.c67
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c4
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c32
-rw-r--r--drivers/char/rio/cirrus.h142
-rw-r--r--drivers/char/rio/defaults.h7
-rw-r--r--drivers/char/rio/link.h34
-rw-r--r--drivers/char/rio/list.h140
-rw-r--r--drivers/char/rio/parmmap.h5
-rw-r--r--drivers/char/rio/phb.h133
-rw-r--r--drivers/char/rio/pkt.h27
-rw-r--r--drivers/char/rio/qbuf.h4
-rw-r--r--drivers/char/rio/riotypes.h66
-rw-r--r--drivers/char/rio/rup.h5
-rw-r--r--drivers/char/rio/sam.h4
-rw-r--r--drivers/char/rocket.c2
-rw-r--r--drivers/char/sx.c6
-rw-r--r--drivers/char/tpm/tpm_bios.c25
-rw-r--r--drivers/char/tpm/tpm_infineon.c2
-rw-r--r--drivers/char/tty_io.c77
-rw-r--r--drivers/char/vt.c1
-rw-r--r--drivers/char/watchdog/sbc_epx_c3.c13
-rw-r--r--drivers/cpufreq/cpufreq.c70
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c52
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c41
-rw-r--r--drivers/cpufreq/cpufreq_userspace.c78
-rw-r--r--drivers/edac/Kconfig3
-rw-r--r--drivers/edac/e752x_edac.c8
-rw-r--r--drivers/edac/edac_mc.c1
-rw-r--r--drivers/ide/Kconfig25
-rw-r--r--drivers/ide/ide-disk.c8
-rw-r--r--drivers/ide/ide-io.c5
-rw-r--r--drivers/ide/ide-iops.c1
-rw-r--r--drivers/ide/ide-probe.c51
-rw-r--r--drivers/ide/ide.c1
-rw-r--r--drivers/ide/pci/aec62xx.c15
-rw-r--r--drivers/ide/pci/hpt366.c4
-rw-r--r--drivers/ide/pci/it821x.c2
-rw-r--r--drivers/ide/pci/pdc202xx_new.c6
-rw-r--r--drivers/ide/pci/pdc202xx_old.c15
-rw-r--r--drivers/ide/pci/piix.c4
-rw-r--r--drivers/ide/pci/sgiioc4.c9
-rw-r--r--drivers/infiniband/core/sa_query.c2
-rw-r--r--drivers/infiniband/core/uverbs_main.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_av.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c13
-rw-r--r--drivers/infiniband/hw/mthca/mthca_dev.h8
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c10
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mcg.c20
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c36
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.h7
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c6
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c25
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c14
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h5
-rw-r--r--drivers/input/joystick/a3d.c88
-rw-r--r--drivers/input/joystick/db9.c85
-rw-r--r--drivers/input/joystick/gamecon.c361
-rw-r--r--drivers/input/joystick/grip.c11
-rw-r--r--drivers/input/joystick/iforce/iforce-main.c2
-rw-r--r--drivers/input/joystick/iforce/iforce-packets.c4
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c1
-rw-r--r--drivers/input/joystick/sidewinder.c10
-rw-r--r--drivers/input/joystick/tmdc.c15
-rw-r--r--drivers/input/joystick/turbografx.c20
-rw-r--r--drivers/input/joystick/twidjoy.c4
-rw-r--r--drivers/input/misc/Kconfig12
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/ixp4xx-beeper.c183
-rw-r--r--drivers/input/mouse/psmouse-base.c1
-rw-r--r--drivers/input/mousedev.c9
-rw-r--r--drivers/input/touchscreen/ads7846.c9
-rw-r--r--drivers/input/touchscreen/mk712.c2
-rw-r--r--drivers/isdn/hisax/hisax.h2
-rw-r--r--drivers/isdn/sc/ioctl.c4
-rw-r--r--drivers/macintosh/macio_asic.c72
-rw-r--r--drivers/md/dm-ioctl.c14
-rw-r--r--drivers/md/dm-log.c48
-rw-r--r--drivers/md/dm-snap.c29
-rw-r--r--drivers/md/dm-snap.h4
-rw-r--r--drivers/md/dm-table.c2
-rw-r--r--drivers/md/dm.c39
-rw-r--r--drivers/md/md.c48
-rw-r--r--drivers/md/raid0.c2
-rw-r--r--drivers/md/raid10.c2
-rw-r--r--drivers/md/raid5.c3
-rw-r--r--drivers/md/raid6main.c152
-rw-r--r--drivers/media/video/hexium_orion.c2
-rw-r--r--drivers/message/fusion/Makefile2
-rw-r--r--drivers/message/fusion/mptbase.c184
-rw-r--r--drivers/message/fusion/mptbase.h16
-rw-r--r--drivers/message/fusion/mptfc.c203
-rw-r--r--drivers/message/fusion/mptsas.c241
-rw-r--r--drivers/message/fusion/mptscsih.c116
-rw-r--r--drivers/message/fusion/mptscsih.h1
-rw-r--r--drivers/message/fusion/mptspi.c10
-rw-r--r--drivers/message/i2o/core.h3
-rw-r--r--drivers/message/i2o/i2o_scsi.c2
-rw-r--r--drivers/message/i2o/pci.c47
-rw-r--r--drivers/misc/ibmasm/uart.c2
-rw-r--r--drivers/mmc/au1xmmc.c59
-rw-r--r--drivers/mmc/mmc.c28
-rw-r--r--drivers/mmc/mmc_block.c8
-rw-r--r--drivers/mmc/mmci.c11
-rw-r--r--drivers/mmc/pxamci.c9
-rw-r--r--drivers/mmc/wbsd.c8
-rw-r--r--drivers/mtd/maps/dc21285.c9
-rw-r--r--drivers/mtd/maps/tsunami_flash.c2
-rw-r--r--drivers/net/3c59x.c33
-rw-r--r--drivers/net/bnx2.c308
-rw-r--r--drivers/net/bnx2.h34
-rw-r--r--drivers/net/bnx2_fw.h825
-rw-r--r--drivers/net/lp486e.c2
-rw-r--r--drivers/net/ppp_generic.c3
-rw-r--r--drivers/net/tg3.c30
-rw-r--r--drivers/net/tg3.h1
-rw-r--r--drivers/net/wireless/ipw2200.c2
-rw-r--r--drivers/parisc/ccio-dma.c7
-rw-r--r--drivers/parisc/dino.c4
-rw-r--r--drivers/parisc/hppb.c3
-rw-r--r--drivers/parisc/iosapic.c8
-rw-r--r--drivers/parisc/lasi.c5
-rw-r--r--drivers/parisc/lba_pci.c6
-rw-r--r--drivers/parisc/pdc_stable.c356
-rw-r--r--drivers/parisc/sba_iommu.c3
-rw-r--r--drivers/parisc/superio.c41
-rw-r--r--drivers/parisc/wax.c2
-rw-r--r--drivers/parport/Kconfig9
-rw-r--r--drivers/parport/Makefile1
-rw-r--r--drivers/parport/ieee1284.c10
-rw-r--r--drivers/parport/parport_gsc.c2
-rw-r--r--drivers/parport/parport_ip32.c2253
-rw-r--r--drivers/parport/parport_serial.c4
-rw-r--r--drivers/parport/probe.c4
-rw-r--r--drivers/pci/hotplug/Kconfig3
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c21
-rw-r--r--drivers/pci/hotplug/ibmphp_core.c4
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c64
-rw-r--r--drivers/pci/hotplug/rpaphp.h14
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c114
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c267
-rw-r--r--drivers/pci/hotplug/rpaphp_slot.c17
-rw-r--r--drivers/pci/hotplug/shpchp.h94
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c12
-rw-r--r--drivers/pci/msi.c14
-rw-r--r--drivers/pci/msi.h6
-rw-r--r--drivers/pci/pci.c2
-rw-r--r--drivers/pci/setup-res.c1
-rw-r--r--drivers/pnp/card.c9
-rw-r--r--drivers/pnp/pnpacpi/core.c14
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c547
-rw-r--r--drivers/s390/Kconfig7
-rw-r--r--drivers/s390/block/Kconfig14
-rw-r--r--drivers/s390/block/Makefile2
-rw-r--r--drivers/s390/block/dasd.c122
-rw-r--r--drivers/s390/block/dasd_3370_erp.c1
-rw-r--r--drivers/s390/block/dasd_3990_erp.c4
-rw-r--r--drivers/s390/block/dasd_9336_erp.c1
-rw-r--r--drivers/s390/block/dasd_9343_erp.c1
-rw-r--r--drivers/s390/block/dasd_cmb.c2
-rw-r--r--drivers/s390/block/dasd_devmap.c1
-rw-r--r--drivers/s390/block/dasd_diag.c1
-rw-r--r--drivers/s390/block/dasd_diag.h1
-rw-r--r--drivers/s390/block/dasd_eckd.c1
-rw-r--r--drivers/s390/block/dasd_eckd.h2
-rw-r--r--drivers/s390/block/dasd_eer.c1090
-rw-r--r--drivers/s390/block/dasd_erp.c1
-rw-r--r--drivers/s390/block/dasd_fba.c1
-rw-r--r--drivers/s390/block/dasd_fba.h1
-rw-r--r--drivers/s390/block/dasd_genhd.c1
-rw-r--r--drivers/s390/block/dasd_int.h38
-rw-r--r--drivers/s390/block/dasd_ioctl.c11
-rw-r--r--drivers/s390/block/dasd_proc.c1
-rw-r--r--drivers/s390/char/con3215.c3
-rw-r--r--drivers/s390/char/con3270.c3
-rw-r--r--drivers/s390/char/keyboard.c6
-rw-r--r--drivers/s390/char/tape_34xx.c5
-rw-r--r--drivers/s390/char/tape_class.c4
-rw-r--r--drivers/s390/char/tape_class.h2
-rw-r--r--drivers/s390/char/tape_core.c5
-rw-r--r--drivers/s390/cio/airq.c2
-rw-r--r--drivers/s390/cio/blacklist.c1
-rw-r--r--drivers/s390/cio/ccwgroup.c1
-rw-r--r--drivers/s390/cio/chsc.c1
-rw-r--r--drivers/s390/cio/chsc.h2
-rw-r--r--drivers/s390/cio/cio.c1
-rw-r--r--drivers/s390/cio/cmf.c2
-rw-r--r--drivers/s390/cio/css.c1
-rw-r--r--drivers/s390/cio/device.c5
-rw-r--r--drivers/s390/cio/device_ops.c2
-rw-r--r--drivers/s390/cio/qdio.c5
-rw-r--r--drivers/s390/cio/qdio.h2
-rw-r--r--drivers/s390/crypto/z90common.h2
-rw-r--r--drivers/s390/crypto/z90crypt.h2
-rw-r--r--drivers/s390/crypto/z90hardware.c6
-rw-r--r--drivers/s390/crypto/z90main.c10
-rw-r--r--drivers/s390/net/claw.c11
-rw-r--r--drivers/s390/net/claw.h2
-rw-r--r--drivers/s390/net/ctcdbug.c5
-rw-r--r--drivers/s390/net/ctcdbug.h4
-rw-r--r--drivers/s390/net/ctcmain.c19
-rw-r--r--drivers/s390/net/ctcmain.h4
-rw-r--r--drivers/s390/net/ctctty.c2
-rw-r--r--drivers/s390/net/ctctty.h2
-rw-r--r--drivers/s390/net/cu3088.c2
-rw-r--r--drivers/s390/net/fsm.c2
-rw-r--r--drivers/s390/net/fsm.h2
-rw-r--r--drivers/s390/net/iucv.c16
-rw-r--r--drivers/s390/net/lcs.c5
-rw-r--r--drivers/s390/net/lcs.h2
-rw-r--r--drivers/s390/net/netiucv.c15
-rw-r--r--drivers/s390/net/qeth.h2
-rw-r--r--drivers/s390/net/qeth_eddp.c5
-rw-r--r--drivers/s390/net/qeth_eddp.h6
-rw-r--r--drivers/s390/net/qeth_fs.h5
-rw-r--r--drivers/s390/net/qeth_main.c13
-rw-r--r--drivers/s390/net/qeth_mpc.c2
-rw-r--r--drivers/s390/net/qeth_mpc.h4
-rw-r--r--drivers/s390/net/qeth_proc.c4
-rw-r--r--drivers/s390/net/qeth_sys.c4
-rw-r--r--drivers/s390/net/qeth_tso.h4
-rw-r--r--drivers/s390/s390_rdev.c1
-rw-r--r--drivers/s390/s390mach.h17
-rw-r--r--drivers/s390/scsi/zfcp_aux.c2
-rw-r--r--drivers/s390/scsi/zfcp_ccw.c2
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c2
-rw-r--r--drivers/s390/scsi/zfcp_def.h2
-rw-r--r--drivers/s390/scsi/zfcp_erp.c2
-rw-r--r--drivers/s390/scsi/zfcp_ext.h2
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c2
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c2
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c2
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_adapter.c2
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_driver.c2
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_port.c2
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_unit.c2
-rw-r--r--drivers/scsi/ahci.c19
-rw-r--r--drivers/scsi/aic7xxx/Kconfig.aic79xx4
-rw-r--r--drivers/scsi/aic7xxx/aic79xx.h3
-rw-r--r--drivers/scsi/aic7xxx/aic79xx.reg29
-rw-r--r--drivers/scsi/aic7xxx/aic79xx.seq143
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_core.c286
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_inline.h7
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c43
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.h10
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm_pci.c17
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.c11
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_reg.h_shipped27
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped21
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_seq.h_shipped881
-rw-r--r--drivers/scsi/aic7xxx/aicasm/aicasm.c23
-rw-r--r--drivers/scsi/aic7xxx/aicasm/aicasm_gram.y19
-rw-r--r--drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h88
-rw-r--r--drivers/scsi/aic7xxx/aicasm/aicasm_scan.l27
-rw-r--r--drivers/scsi/dc395x.c6
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c67
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.h3
-rw-r--r--drivers/scsi/ibmvscsi/iseries_vscsi.c13
-rw-r--r--drivers/scsi/ibmvscsi/rpa_vscsi.c22
-rw-r--r--drivers/scsi/ide-scsi.c14
-rw-r--r--drivers/scsi/ips.c54
-rw-r--r--drivers/scsi/libata-scsi.c27
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c291
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.h24
-rw-r--r--drivers/scsi/qla1280.c311
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h6
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c83
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c16
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c55
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_error.c2
-rw-r--r--drivers/scsi/scsi_lib.c5
-rw-r--r--drivers/scsi/scsi_transport_sas.c6
-rw-r--r--drivers/scsi/sg.c2
-rw-r--r--drivers/scsi/st.c2
-rw-r--r--drivers/serial/21285.c2
-rw-r--r--drivers/serial/8250.c19
-rw-r--r--drivers/serial/8250_acpi.c22
-rw-r--r--drivers/serial/8250_pci.c25
-rw-r--r--drivers/serial/Kconfig31
-rw-r--r--drivers/serial/amba-pl010.c4
-rw-r--r--drivers/serial/clps711x.c4
-rw-r--r--drivers/serial/imx.c8
-rw-r--r--drivers/serial/jsm/jsm.h1
-rw-r--r--drivers/serial/jsm/jsm_driver.c3
-rw-r--r--drivers/serial/jsm/jsm_neo.c85
-rw-r--r--drivers/serial/jsm/jsm_tty.c209
-rw-r--r--drivers/serial/mcfserial.c3
-rw-r--r--drivers/serial/s3c2410.c2
-rw-r--r--drivers/serial/sa1100.c6
-rw-r--r--drivers/serial/serial_core.c18
-rw-r--r--drivers/serial/serial_lh7a40x.c6
-rw-r--r--drivers/serial/sh-sci.c317
-rw-r--r--drivers/serial/sh-sci.h114
-rw-r--r--drivers/serial/sunsu.c14
-rw-r--r--drivers/sn/ioc3.c12
-rw-r--r--drivers/telephony/ixj.c14
-rw-r--r--drivers/usb/Makefile1
-rw-r--r--drivers/usb/atm/cxacru.c92
-rw-r--r--drivers/usb/atm/speedtch.c167
-rw-r--r--drivers/usb/atm/ueagle-atm.c96
-rw-r--r--drivers/usb/atm/usbatm.c574
-rw-r--r--drivers/usb/atm/usbatm.h59
-rw-r--r--drivers/usb/atm/xusbatm.c137
-rw-r--r--drivers/usb/class/cdc-acm.c9
-rw-r--r--drivers/usb/class/usblp.c71
-rw-r--r--drivers/usb/core/driver.c6
-rw-r--r--drivers/usb/core/message.c1
-rw-r--r--drivers/usb/core/urb.c1
-rw-r--r--drivers/usb/gadget/inode.c8
-rw-r--r--drivers/usb/gadget/net2280.c1
-rw-r--r--drivers/usb/gadget/zero.c8
-rw-r--r--drivers/usb/host/ehci-pci.c64
-rw-r--r--drivers/usb/host/ehci-sched.c4
-rw-r--r--drivers/usb/host/isp116x-hcd.c21
-rw-r--r--drivers/usb/host/ohci-au1xxx.c2
-rw-r--r--drivers/usb/host/pci-quirks.c106
-rw-r--r--drivers/usb/host/uhci-q.c4
-rw-r--r--drivers/usb/input/hid-core.c9
-rw-r--r--drivers/usb/input/hiddev.c5
-rw-r--r--drivers/usb/input/touchkitusb.c3
-rw-r--r--drivers/usb/input/yealink.c48
-rw-r--r--drivers/usb/media/Kconfig17
-rw-r--r--drivers/usb/media/Makefile2
-rw-r--r--drivers/usb/media/et61x251.h220
-rw-r--r--drivers/usb/media/et61x251_core.c2605
-rw-r--r--drivers/usb/media/et61x251_sensor.h115
-rw-r--r--drivers/usb/media/et61x251_tas5130d1b.c137
-rw-r--r--drivers/usb/media/ov511.c196
-rw-r--r--drivers/usb/media/pwc/pwc-ctrl.c264
-rw-r--r--drivers/usb/media/sn9c102.h50
-rw-r--r--drivers/usb/media/sn9c102_core.c1681
-rw-r--r--drivers/usb/media/sn9c102_hv7131d.c2
-rw-r--r--drivers/usb/media/sn9c102_mi0343.c2
-rw-r--r--drivers/usb/media/sn9c102_ov7630.c8
-rw-r--r--drivers/usb/media/sn9c102_pas106b.c2
-rw-r--r--drivers/usb/media/sn9c102_sensor.h85
-rw-r--r--drivers/usb/media/sn9c102_tas5110c1b.c2
-rw-r--r--drivers/usb/media/sn9c102_tas5130d1b.c2
-rw-r--r--drivers/usb/media/w9968cf.c128
-rw-r--r--drivers/usb/media/w9968cf.h1
-rw-r--r--drivers/usb/media/w9968cf_vpp.h3
-rw-r--r--drivers/usb/misc/auerswald.c2
-rw-r--r--drivers/usb/misc/ldusb.c2
-rw-r--r--drivers/usb/net/asix.c4
-rw-r--r--drivers/usb/serial/cp2101.c14
-rw-r--r--drivers/usb/serial/ftdi_sio.c6
-rw-r--r--drivers/usb/serial/ftdi_sio.h23
-rw-r--r--drivers/usb/serial/pl2303.c4
-rw-r--r--drivers/usb/serial/pl2303.h7
-rw-r--r--drivers/usb/storage/initializers.c73
-rw-r--r--drivers/usb/storage/initializers.h1
-rw-r--r--drivers/usb/storage/libusual.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h15
-rw-r--r--drivers/usb/usb-skeleton.c2
-rw-r--r--drivers/video/amba-clcd.c54
-rw-r--r--drivers/video/backlight/Kconfig8
-rw-r--r--drivers/video/backlight/Makefile1
-rw-r--r--drivers/video/backlight/hp680_bl.c189
-rw-r--r--drivers/video/console/sticore.c45
-rw-r--r--drivers/video/cyblafb.c1
-rw-r--r--drivers/video/i810/i810-i2c.c6
-rw-r--r--drivers/video/i810/i810.h1
-rw-r--r--drivers/video/i810/i810_main.c13
-rw-r--r--fs/9p/conv.c28
-rw-r--r--fs/9p/mux.c15
-rw-r--r--fs/9p/vfs_inode.c6
-rw-r--r--fs/Kconfig4
-rw-r--r--fs/bio.c1
-rw-r--r--fs/buffer.c65
-rw-r--r--fs/cifs/connect.c11
-rw-r--r--fs/cifs/file.c8
-rw-r--r--fs/cifs/transport.c1
-rw-r--r--fs/compat.c14
-rw-r--r--fs/configfs/configfs_internal.h11
-rw-r--r--fs/configfs/dir.c36
-rw-r--r--fs/configfs/file.c19
-rw-r--r--fs/configfs/inode.c120
-rw-r--r--fs/configfs/mount.c28
-rw-r--r--fs/configfs/symlink.c4
-rw-r--r--fs/dcache.c2
-rw-r--r--fs/direct-io.c9
-rw-r--r--fs/ext2/acl.c2
-rw-r--r--fs/ext2/ialloc.c2
-rw-r--r--fs/ext2/inode.c2
-rw-r--r--fs/ext2/super.c5
-rw-r--r--fs/ext3/acl.c2
-rw-r--r--fs/ext3/inode.c2
-rw-r--r--fs/fat/file.c50
-rw-r--r--fs/fat/misc.c14
-rw-r--r--fs/fcntl.c7
-rw-r--r--fs/file.c3
-rw-r--r--fs/fuse/dev.c40
-rw-r--r--fs/fuse/file.c9
-rw-r--r--fs/fuse/fuse_i.h3
-rw-r--r--fs/fuse/inode.c14
-rw-r--r--fs/hugetlbfs/inode.c4
-rw-r--r--fs/inode.c2
-rw-r--r--fs/jbd/transaction.c10
-rw-r--r--fs/jffs/intrep.c2
-rw-r--r--fs/libfs.c1
-rw-r--r--fs/lockd/clntproc.c11
-rw-r--r--fs/namei.c39
-rw-r--r--fs/nfs/direct.c2
-rw-r--r--fs/nfsd/nfssvc.c76
-rw-r--r--fs/ocfs2/buffer_head_io.c10
-rw-r--r--fs/ocfs2/cluster/heartbeat.c5
-rw-r--r--fs/ocfs2/cluster/tcp.c16
-rw-r--r--fs/ocfs2/dlm/dlmcommon.h1
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c18
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c24
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c250
-rw-r--r--fs/ocfs2/dlm/dlmunlock.c13
-rw-r--r--fs/ocfs2/dlm/userdlm.c2
-rw-r--r--fs/ocfs2/extent_map.c12
-rw-r--r--fs/ocfs2/file.c10
-rw-r--r--fs/ocfs2/inode.c6
-rw-r--r--fs/ocfs2/inode.h4
-rw-r--r--fs/ocfs2/journal.c32
-rw-r--r--fs/ocfs2/ocfs2.h3
-rw-r--r--fs/ocfs2/super.c11
-rw-r--r--fs/ocfs2/sysfile.c6
-rw-r--r--fs/ocfs2/uptodate.c12
-rw-r--r--fs/ocfs2/uptodate.h2
-rw-r--r--fs/proc/proc_misc.c2
-rw-r--r--fs/quota_v2.c2
-rw-r--r--fs/reiserfs/dir.c16
-rw-r--r--fs/reiserfs/file.c19
-rw-r--r--fs/reiserfs/fix_node.c50
-rw-r--r--fs/reiserfs/inode.c11
-rw-r--r--fs/reiserfs/journal.c140
-rw-r--r--fs/reiserfs/namei.c16
-rw-r--r--fs/reiserfs/procfs.c3
-rw-r--r--fs/reiserfs/super.c8
-rw-r--r--fs/reiserfs/xattr.c128
-rw-r--r--fs/smbfs/dir.c5
-rw-r--r--fs/udf/balloc.c7
-rw-r--r--fs/udf/namei.c4
-rw-r--r--fs/ufs/inode.c2
-rw-r--r--fs/ufs/super.c10
-rw-r--r--fs/ufs/truncate.c72
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c1
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c8
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c50
-rw-r--r--include/acpi/acconfig.h24
-rw-r--r--include/acpi/acdebug.h2
-rw-r--r--include/acpi/acdisasm.h81
-rw-r--r--include/acpi/acdispat.h5
-rw-r--r--include/acpi/acevents.h8
-rw-r--r--include/acpi/acexcep.h2
-rw-r--r--include/acpi/acglobal.h23
-rw-r--r--include/acpi/achware.h2
-rw-r--r--include/acpi/acinterp.h48
-rw-r--r--include/acpi/aclocal.h112
-rw-r--r--include/acpi/acmacros.h201
-rw-r--r--include/acpi/acnames.h2
-rw-r--r--include/acpi/acnamesp.h4
-rw-r--r--include/acpi/acobject.h4
-rw-r--r--include/acpi/acopcode.h2
-rw-r--r--include/acpi/acoutput.h12
-rw-r--r--include/acpi/acparser.h2
-rw-r--r--include/acpi/acpi.h2
-rw-r--r--include/acpi/acpi_drivers.h4
-rw-r--r--include/acpi/acpiosxf.h6
-rw-r--r--include/acpi/acpixf.h13
-rw-r--r--include/acpi/acresrc.h390
-rw-r--r--include/acpi/acstruct.h2
-rw-r--r--include/acpi/actables.h2
-rw-r--r--include/acpi/actbl.h8
-rw-r--r--include/acpi/actbl1.h2
-rw-r--r--include/acpi/actbl2.h2
-rw-r--r--include/acpi/actypes.h613
-rw-r--r--include/acpi/acutils.h82
-rw-r--r--include/acpi/amlcode.h2
-rw-r--r--include/acpi/amlresrc.h271
-rw-r--r--include/acpi/pdc_intel.h4
-rw-r--r--include/acpi/platform/acenv.h24
-rw-r--r--include/acpi/platform/acgcc.h10
-rw-r--r--include/acpi/platform/aclinux.h8
-rw-r--r--include/acpi/processor.h28
-rw-r--r--include/asm-alpha/dma-mapping.h1
-rw-r--r--include/asm-arm/arch-s3c2410/debug-macro.S6
-rw-r--r--include/asm-arm/arch-s3c2410/hardware.h7
-rw-r--r--include/asm-arm/arch-s3c2410/map.h38
-rw-r--r--include/asm-arm/arch-s3c2410/regs-gpio.h22
-rw-r--r--include/asm-arm/arch-s3c2410/regs-serial.h6
-rw-r--r--include/asm-arm/arch-s3c2410/uncompress.h6
-rw-r--r--include/asm-arm/checksum.h2
-rw-r--r--include/asm-arm/mach/map.h1
-rw-r--r--include/asm-arm/pgtable.h1
-rw-r--r--include/asm-arm26/bitops.h4
-rw-r--r--include/asm-arm26/hardirq.h8
-rw-r--r--include/asm-arm26/posix_types.h1
-rw-r--r--include/asm-arm26/system.h5
-rw-r--r--include/asm-cris/bitops.h2
-rw-r--r--include/asm-frv/bitops.h2
-rw-r--r--include/asm-h8300/bitops.h2
-rw-r--r--include/asm-i386/acpi.h2
-rw-r--r--include/asm-i386/page.h4
-rw-r--r--include/asm-i386/system.h2
-rw-r--r--include/asm-i386/topology.h9
-rw-r--r--include/asm-ia64/ide.h8
-rw-r--r--include/asm-ia64/processor.h17
-rw-r--r--include/asm-ia64/sal.h10
-rw-r--r--include/asm-ia64/sn/bte.h23
-rw-r--r--include/asm-ia64/sn/intr.h38
-rw-r--r--include/asm-ia64/sn/sn_feature_sets.h14
-rw-r--r--include/asm-ia64/system.h25
-rw-r--r--include/asm-ia64/topology.h7
-rw-r--r--include/asm-parisc/atomic.h84
-rw-r--r--include/asm-parisc/cacheflush.h6
-rw-r--r--include/asm-parisc/compat_ucontext.h3
-rw-r--r--include/asm-parisc/grfioctl.h2
-rw-r--r--include/asm-parisc/pci.h17
-rw-r--r--include/asm-parisc/pgalloc.h1
-rw-r--r--include/asm-parisc/pgtable.h2
-rw-r--r--include/asm-parisc/rt_sigframe.h4
-rw-r--r--include/asm-parisc/unistd.h21
-rw-r--r--include/asm-powerpc/kexec.h4
-rw-r--r--include/asm-powerpc/pmac_pfunc.h5
-rw-r--r--include/asm-s390/dasd.h15
-rw-r--r--include/asm-s390/io.h6
-rw-r--r--include/asm-s390/qdio.h2
-rw-r--r--include/asm-s390/thread_info.h6
-rw-r--r--include/asm-s390/timer.h8
-rw-r--r--include/asm-s390/unistd.h24
-rw-r--r--include/asm-sh/bus-sh.h66
-rw-r--r--include/asm-sh/cpu-sh3/mmu_context.h10
-rw-r--r--include/asm-sh/cpu-sh4/mmu_context.h8
-rw-r--r--include/asm-sh/ioctls.h2
-rw-r--r--include/asm-sh/irq-sh73180.h36
-rw-r--r--include/asm-sh/irq-sh7780.h23
-rw-r--r--include/asm-sh/irq.h10
-rw-r--r--include/asm-sh/microdev.h (renamed from include/asm-sh/microdev/irq.h)60
-rw-r--r--include/asm-sh/microdev/io.h53
-rw-r--r--include/asm-sh/processor.h36
-rw-r--r--include/asm-sh64/ioctls.h2
-rw-r--r--include/asm-sparc64/spinlock.h24
-rw-r--r--include/asm-um/ldt-x86_64.h12
-rw-r--r--include/asm-um/smp.h2
-rw-r--r--include/asm-v850/bitops.h2
-rw-r--r--include/asm-x86_64/apic.h1
-rw-r--r--include/asm-x86_64/cpufeature.h2
-rw-r--r--include/asm-x86_64/hardirq.h21
-rw-r--r--include/asm-x86_64/ia32_unistd.h2
-rw-r--r--include/asm-x86_64/kexec.h3
-rw-r--r--include/asm-x86_64/mpspec.h2
-rw-r--r--include/asm-x86_64/proto.h11
-rw-r--r--include/asm-x86_64/system.h2
-rw-r--r--include/asm-x86_64/topology.h9
-rw-r--r--include/asm-xtensa/futex.h1
-rw-r--r--include/linux/acpi.h2
-rw-r--r--include/linux/agpgart.h3
-rw-r--r--include/linux/bitops.h2
-rw-r--r--include/linux/blkdev.h6
-rw-r--r--include/linux/configfs.h2
-rw-r--r--include/linux/cpufreq.h3
-rw-r--r--include/linux/dcache.h2
-rw-r--r--include/linux/device-mapper.h2
-rw-r--r--include/linux/elfcore.h1
-rw-r--r--include/linux/fs.h8
-rw-r--r--include/linux/fuse.h16
-rw-r--r--include/linux/hrtimer.h6
-rw-r--r--include/linux/i2o.h6
-rw-r--r--include/linux/ide.h2
-rw-r--r--include/linux/io.h25
-rw-r--r--include/linux/jbd.h4
-rw-r--r--include/linux/kbd_kern.h5
-rw-r--r--include/linux/kernel.h1
-rw-r--r--include/linux/ktime.h6
-rw-r--r--include/linux/list.h14
-rw-r--r--include/linux/lockd/lockd.h2
-rw-r--r--include/linux/mmc/mmc.h35
-rw-r--r--include/linux/mmc/protocol.h2
-rw-r--r--include/linux/mmzone.h13
-rw-r--r--include/linux/netfilter/x_tables.h16
-rw-r--r--include/linux/netfilter_ipv4/ipt_connbytes.h4
-rw-r--r--include/linux/netfilter_ipv4/ipt_policy.h22
-rw-r--r--include/linux/netfilter_ipv6/ip6t_policy.h22
-rw-r--r--include/linux/parport.h6
-rw-r--r--include/linux/pci.h2
-rw-r--r--include/linux/pci_ids.h21
-rw-r--r--include/linux/pktcdvd.h8
-rw-r--r--include/linux/posix-timers.h1
-rw-r--r--include/linux/quotaops.h1
-rw-r--r--include/linux/rcupdate.h5
-rw-r--r--include/linux/reboot.h3
-rw-r--r--include/linux/reiserfs_acl.h6
-rw-r--r--include/linux/reiserfs_fs.h16
-rw-r--r--include/linux/reiserfs_fs_sb.h1
-rw-r--r--include/linux/reiserfs_xattr.h2
-rw-r--r--include/linux/rmap.h5
-rw-r--r--include/linux/security.h23
-rw-r--r--include/linux/serial_8250.h2
-rw-r--r--include/linux/serial_core.h72
-rw-r--r--include/linux/slab.h7
-rw-r--r--include/linux/sunrpc/auth.h10
-rw-r--r--include/linux/suspend.h4
-rw-r--r--include/linux/swap.h9
-rw-r--r--include/linux/syscalls.h33
-rw-r--r--include/linux/sysctl.h3
-rw-r--r--include/linux/time.h2
-rw-r--r--include/linux/tty.h2
-rw-r--r--include/linux/tty_flip.h7
-rw-r--r--include/linux/types.h2
-rw-r--r--include/linux/ufs_fs.h14
-rw-r--r--include/linux/ufs_fs_sb.h2
-rw-r--r--include/linux/usb_ch9.h6
-rw-r--r--include/linux/videodev2.h1
-rw-r--r--include/net/netfilter/nf_conntrack_l3proto.h15
-rw-r--r--include/net/route.h5
-rw-r--r--include/net/sctp/structs.h2
-rw-r--r--include/net/sock.h8
-rw-r--r--include/scsi/scsi_device.h2
-rw-r--r--include/scsi/scsi_host.h1
-rw-r--r--init/Kconfig11
-rw-r--r--kernel/cpuset.c2
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/hrtimer.c70
-rw-r--r--kernel/intermodule.c3
-rw-r--r--kernel/itimer.c11
-rw-r--r--kernel/kprobes.c36
-rw-r--r--kernel/module.c3
-rw-r--r--kernel/posix-timers.c53
-rw-r--r--kernel/power/console.c12
-rw-r--r--kernel/power/disk.c15
-rw-r--r--kernel/power/main.c4
-rw-r--r--kernel/power/power.h9
-rw-r--r--kernel/power/swsusp.c8
-rw-r--r--kernel/rcutorture.c10
-rw-r--r--kernel/sched.c24
-rw-r--r--kernel/signal.c2
-rw-r--r--kernel/sys.c25
-rw-r--r--kernel/sysctl.c12
-rw-r--r--kernel/time.c15
-rw-r--r--kernel/user.c32
-rw-r--r--lib/Makefile2
-rw-r--r--lib/int_sqrt.c2
-rw-r--r--lib/iomap_copy.c42
-rw-r--r--lib/ts_bm.c40
-rw-r--r--mm/hugetlb.c9
-rw-r--r--mm/memory.c7
-rw-r--r--mm/mempolicy.c169
-rw-r--r--mm/oom_kill.c1
-rw-r--r--mm/page_alloc.c16
-rw-r--r--mm/rmap.c51
-rw-r--r--mm/shmem.c8
-rw-r--r--mm/slab.c813
-rw-r--r--mm/swap_state.c1
-rw-r--r--mm/swapfile.c16
-rw-r--r--mm/vmscan.c343
-rw-r--r--net/802/psnap.c2
-rw-r--r--net/Kconfig7
-rw-r--r--net/bridge/br_if.c21
-rw-r--r--net/bridge/br_private.h1
-rw-r--r--net/bridge/netfilter/ebt_ulog.c10
-rw-r--r--net/bridge/netfilter/ebtables.c7
-rw-r--r--net/core/dev.c7
-rw-r--r--net/core/filter.c6
-rw-r--r--net/core/skbuff.c8
-rw-r--r--net/core/utils.c4
-rw-r--r--net/dccp/ipv4.c3
-rw-r--r--net/dccp/ipv6.c1
-rw-r--r--net/ipv4/icmp.c5
-rw-r--r--net/ipv4/igmp.c2
-rw-r--r--net/ipv4/multipath_wrandom.c8
-rw-r--r--net/ipv4/netfilter/arp_tables.c7
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c3
-rw-r--r--net/ipv4/netfilter/ip_conntrack_tftp.c1
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c4
-rw-r--r--net/ipv4/netfilter/ip_tables.c7
-rw-r--r--net/ipv4/netfilter/ipt_ULOG.c26
-rw-r--r--net/ipv4/netfilter/ipt_policy.c11
-rw-r--r--net/ipv4/proc.c2
-rw-r--r--net/ipv4/tcp_htcp.c1
-rw-r--r--net/ipv4/tcp_ipv4.c3
-rw-r--r--net/ipv6/addrconf.c6
-rw-r--r--net/ipv6/af_inet6.c6
-rw-r--r--net/ipv6/mcast.c56
-rw-r--r--net/ipv6/netfilter/ip6_tables.c7
-rw-r--r--net/ipv6/netfilter/ip6t_policy.c7
-rw-r--r--net/ipv6/proc.c2
-rw-r--r--net/ipv6/tcp_ipv6.c1
-rw-r--r--net/key/af_key.c2
-rw-r--r--net/netfilter/nf_conntrack_core.c2
-rw-r--r--net/netfilter/nf_conntrack_ftp.c2
-rw-r--r--net/netfilter/nf_conntrack_netlink.c3
-rw-r--r--net/netfilter/nfnetlink_log.c20
-rw-r--r--net/netfilter/nfnetlink_queue.c3
-rw-r--r--net/packet/af_packet.c16
-rw-r--r--net/sctp/output.c2
-rw-r--r--net/sctp/outqueue.c12
-rw-r--r--net/sctp/sm_statefuns.c8
-rw-r--r--net/sctp/socket.c2
-rw-r--r--net/socket.c2
-rw-r--r--net/sunrpc/auth.c25
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c40
-rw-r--r--net/sunrpc/auth_unix.c6
-rw-r--r--net/sunrpc/rpc_pipe.c102
-rw-r--r--net/sunrpc/sched.c9
-rw-r--r--scripts/kconfig/Makefile12
-rwxr-xr-xscripts/kernel-doc80
-rw-r--r--security/keys/keyctl.c15
-rw-r--r--security/seclvl.c4
-rw-r--r--security/selinux/Kconfig2
-rw-r--r--security/selinux/Makefile4
-rw-r--r--security/selinux/hooks.c122
-rw-r--r--security/selinux/include/objsec.h8
-rw-r--r--sound/arm/aaci.c14
-rw-r--r--sound/core/info.c33
-rw-r--r--sound/drivers/serial-u16550.c2
-rw-r--r--sound/isa/cmi8330.c6
-rw-r--r--sound/isa/cs423x/cs4236.c13
-rw-r--r--sound/isa/es18xx.c6
-rw-r--r--sound/isa/gus/gusclassic.c2
-rw-r--r--sound/isa/opl3sa2.c12
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c2
-rw-r--r--sound/isa/sb/sb16.c4
-rw-r--r--sound/isa/sscape.c6
-rw-r--r--sound/isa/wavefront/wavefront.c7
-rw-r--r--sound/isa/wavefront/wavefront_synth.c2
-rw-r--r--sound/oss/au1550_ac97.c12
-rw-r--r--sound/pci/ac97/ac97_patch.c53
-rw-r--r--sound/pci/ali5451/ali5451.c2
-rw-r--r--sound/pci/au88x0/au88x0_eq.c2
-rw-r--r--sound/pci/bt87x.c4
-rw-r--r--sound/pci/ca0106/ca0106_main.c12
-rw-r--r--sound/pci/cs46xx/dsp_spos_scb_lib.c2
-rw-r--r--sound/pci/cs5535audio/cs5535audio.c6
-rw-r--r--sound/pci/emu10k1/emumixer.c10
-rw-r--r--sound/pci/hda/hda_intel.c2
-rw-r--r--sound/pci/hda/patch_realtek.c11
-rw-r--r--sound/pci/hda/patch_si3054.c1
-rw-r--r--sound/pci/hda/patch_sigmatel.c176
-rw-r--r--sound/pci/intel8x0.c15
-rw-r--r--sound/pci/pcxhr/pcxhr.c9
-rw-r--r--sound/pci/rme9652/hdspm.c6
-rw-r--r--sound/pci/trident/trident.c8
-rw-r--r--sound/pci/via82xx.c5
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c2
-rw-r--r--sound/ppc/pmac.c2
-rw-r--r--sound/usb/usbaudio.c31
1149 files changed, 33461 insertions, 20140 deletions
diff --git a/CREDITS b/CREDITS
index 8e577ce4abeb..6957ef4efab3 100644
--- a/CREDITS
+++ b/CREDITS
@@ -3101,7 +3101,7 @@ S: Minto, NSW, 2566
3101S: Australia 3101S: Australia
3102 3102
3103N: Stephen Smalley 3103N: Stephen Smalley
3104E: sds@epoch.ncsc.mil 3104E: sds@tycho.nsa.gov
3105D: portions of the Linux Security Module (LSM) framework and security modules 3105D: portions of the Linux Security Module (LSM) framework and security modules
3106 3106
3107N: Chris Smith 3107N: Chris Smith
diff --git a/Documentation/RCU/RTFP.txt b/Documentation/RCU/RTFP.txt
index fcbcbc35b122..6221464d1a7e 100644
--- a/Documentation/RCU/RTFP.txt
+++ b/Documentation/RCU/RTFP.txt
@@ -90,16 +90,20 @@ at OLS. The resulting abundance of RCU patches was presented the
90following year [McKenney02a], and use of RCU in dcache was first 90following year [McKenney02a], and use of RCU in dcache was first
91described that same year [Linder02a]. 91described that same year [Linder02a].
92 92
93Also in 2002, Michael [Michael02b,Michael02a] presented techniques 93Also in 2002, Michael [Michael02b,Michael02a] presented "hazard-pointer"
94that defer the destruction of data structures to simplify non-blocking 94techniques that defer the destruction of data structures to simplify
95synchronization (wait-free synchronization, lock-free synchronization, 95non-blocking synchronization (wait-free synchronization, lock-free
96and obstruction-free synchronization are all examples of non-blocking 96synchronization, and obstruction-free synchronization are all examples of
97synchronization). In particular, this technique eliminates locking, 97non-blocking synchronization). In particular, this technique eliminates
98reduces contention, reduces memory latency for readers, and parallelizes 98locking, reduces contention, reduces memory latency for readers, and
99pipeline stalls and memory latency for writers. However, these 99parallelizes pipeline stalls and memory latency for writers. However,
100techniques still impose significant read-side overhead in the form of 100these techniques still impose significant read-side overhead in the
101memory barriers. Researchers at Sun worked along similar lines in the 101form of memory barriers. Researchers at Sun worked along similar lines
102same timeframe [HerlihyLM02,HerlihyLMS03]. 102in the same timeframe [HerlihyLM02,HerlihyLMS03]. These techniques
103can be thought of as inside-out reference counts, where the count is
104represented by the number of hazard pointers referencing a given data
105structure (rather than the more conventional counter field within the
106data structure itself).
103 107
104In 2003, the K42 group described how RCU could be used to create 108In 2003, the K42 group described how RCU could be used to create
105hot-pluggable implementations of operating-system functions. Later that 109hot-pluggable implementations of operating-system functions. Later that
@@ -113,7 +117,6 @@ number of operating-system kernels [PaulEdwardMcKenneyPhD], a paper
113describing how to make RCU safe for soft-realtime applications [Sarma04c], 117describing how to make RCU safe for soft-realtime applications [Sarma04c],
114and a paper describing SELinux performance with RCU [JamesMorris04b]. 118and a paper describing SELinux performance with RCU [JamesMorris04b].
115 119
116
1172005 has seen further adaptation of RCU to realtime use, permitting 1202005 has seen further adaptation of RCU to realtime use, permitting
118preemption of RCU realtime critical sections [PaulMcKenney05a, 121preemption of RCU realtime critical sections [PaulMcKenney05a,
119PaulMcKenney05b]. 122PaulMcKenney05b].
diff --git a/Documentation/RCU/checklist.txt b/Documentation/RCU/checklist.txt
index e118a7c1a092..49e27cc19385 100644
--- a/Documentation/RCU/checklist.txt
+++ b/Documentation/RCU/checklist.txt
@@ -177,3 +177,9 @@ over a rather long period of time, but improvements are always welcome!
177 177
178 If you want to wait for some of these other things, you might 178 If you want to wait for some of these other things, you might
179 instead need to use synchronize_irq() or synchronize_sched(). 179 instead need to use synchronize_irq() or synchronize_sched().
180
18112. Any lock acquired by an RCU callback must be acquired elsewhere
182 with irq disabled, e.g., via spin_lock_irqsave(). Failing to
183 disable irq on a given acquisition of that lock will result in
184 deadlock as soon as the RCU callback happens to interrupt that
185 acquisition's critical section.
diff --git a/Documentation/RCU/listRCU.txt b/Documentation/RCU/listRCU.txt
index f8a54fa0d8ab..1fd175368a87 100644
--- a/Documentation/RCU/listRCU.txt
+++ b/Documentation/RCU/listRCU.txt
@@ -232,7 +232,7 @@ entry does not exist. For this to be helpful, the search function must
232return holding the per-entry spinlock, as ipc_lock() does in fact do. 232return holding the per-entry spinlock, as ipc_lock() does in fact do.
233 233
234Quick Quiz: Why does the search function need to return holding the 234Quick Quiz: Why does the search function need to return holding the
235per-entry lock for this deleted-flag technique to be helpful? 235 per-entry lock for this deleted-flag technique to be helpful?
236 236
237If the system-call audit module were to ever need to reject stale data, 237If the system-call audit module were to ever need to reject stale data,
238one way to accomplish this would be to add a "deleted" flag and a "lock" 238one way to accomplish this would be to add a "deleted" flag and a "lock"
@@ -275,8 +275,8 @@ flag under the spinlock as follows:
275 { 275 {
276 struct audit_entry *e; 276 struct audit_entry *e;
277 277
278 /* Do not use the _rcu iterator here, since this is the only 278 /* Do not need to use the _rcu iterator here, since this
279 * deletion routine. */ 279 * is the only deletion routine. */
280 list_for_each_entry(e, list, list) { 280 list_for_each_entry(e, list, list) {
281 if (!audit_compare_rule(rule, &e->rule)) { 281 if (!audit_compare_rule(rule, &e->rule)) {
282 spin_lock(&e->lock); 282 spin_lock(&e->lock);
@@ -304,9 +304,12 @@ function to reject newly deleted data.
304 304
305 305
306Answer to Quick Quiz 306Answer to Quick Quiz
307 307 Why does the search function need to return holding the per-entry
308If the search function drops the per-entry lock before returning, then 308 lock for this deleted-flag technique to be helpful?
309the caller will be processing stale data in any case. If it is really 309
310OK to be processing stale data, then you don't need a "deleted" flag. 310 If the search function drops the per-entry lock before returning,
311If processing stale data really is a problem, then you need to hold the 311 then the caller will be processing stale data in any case. If it
312per-entry lock across all of the code that uses the value looked up. 312 is really OK to be processing stale data, then you don't need a
313 "deleted" flag. If processing stale data really is a problem,
314 then you need to hold the per-entry lock across all of the code
315 that uses the value that was returned.
diff --git a/Documentation/RCU/rcu.txt b/Documentation/RCU/rcu.txt
index 6fa092251586..02e27bf1d365 100644
--- a/Documentation/RCU/rcu.txt
+++ b/Documentation/RCU/rcu.txt
@@ -111,6 +111,11 @@ o What are all these files in this directory?
111 111
112 You are reading it! 112 You are reading it!
113 113
114 rcuref.txt
115
116 Describes how to combine use of reference counts
117 with RCU.
118
114 whatisRCU.txt 119 whatisRCU.txt
115 120
116 Overview of how the RCU implementation works. Along 121 Overview of how the RCU implementation works. Along
diff --git a/Documentation/RCU/rcuref.txt b/Documentation/RCU/rcuref.txt
index 3f60db41b2f0..451de2ad8329 100644
--- a/Documentation/RCU/rcuref.txt
+++ b/Documentation/RCU/rcuref.txt
@@ -1,7 +1,7 @@
1Refcounter design for elements of lists/arrays protected by RCU. 1Reference-count design for elements of lists/arrays protected by RCU.
2 2
3Refcounting on elements of lists which are protected by traditional 3Reference counting on elements of lists which are protected by traditional
4reader/writer spinlocks or semaphores are straight forward as in: 4reader/writer spinlocks or semaphores are straightforward:
5 5
61. 2. 61. 2.
7add() search_and_reference() 7add() search_and_reference()
@@ -28,12 +28,12 @@ release_referenced() delete()
28 ... 28 ...
29 } 29 }
30 30
31If this list/array is made lock free using rcu as in changing the 31If this list/array is made lock free using RCU as in changing the
32write_lock in add() and delete() to spin_lock and changing read_lock 32write_lock() in add() and delete() to spin_lock and changing read_lock
33in search_and_reference to rcu_read_lock(), the atomic_get in 33in search_and_reference to rcu_read_lock(), the atomic_get in
34search_and_reference could potentially hold reference to an element which 34search_and_reference could potentially hold reference to an element which
35has already been deleted from the list/array. atomic_inc_not_zero takes 35has already been deleted from the list/array. Use atomic_inc_not_zero()
36care of this scenario. search_and_reference should look as; 36in this scenario as follows:
37 37
381. 2. 381. 2.
39add() search_and_reference() 39add() search_and_reference()
@@ -51,17 +51,16 @@ add() search_and_reference()
51release_referenced() delete() 51release_referenced() delete()
52{ { 52{ {
53 ... write_lock(&list_lock); 53 ... write_lock(&list_lock);
54 atomic_dec(&el->rc, relfunc) ... 54 if (atomic_dec_and_test(&el->rc)) ...
55 ... delete_element 55 call_rcu(&el->head, el_free); delete_element
56} write_unlock(&list_lock); 56 ... write_unlock(&list_lock);
57 ... 57} ...
58 if (atomic_dec_and_test(&el->rc)) 58 if (atomic_dec_and_test(&el->rc))
59 call_rcu(&el->head, el_free); 59 call_rcu(&el->head, el_free);
60 ... 60 ...
61 } 61 }
62 62
63Sometimes, reference to the element need to be obtained in the 63Sometimes, a reference to the element needs to be obtained in the
64update (write) stream. In such cases, atomic_inc_not_zero might be an 64update (write) stream. In such cases, atomic_inc_not_zero() might be
65overkill since the spinlock serialising list updates are held. atomic_inc 65overkill, since we hold the update-side spinlock. One might instead
66is to be used in such cases. 66use atomic_inc() in such cases.
67
diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
index 15da16861fa3..5ed85af88789 100644
--- a/Documentation/RCU/whatisRCU.txt
+++ b/Documentation/RCU/whatisRCU.txt
@@ -200,10 +200,11 @@ rcu_assign_pointer()
200 the new value, and also executes any memory-barrier instructions 200 the new value, and also executes any memory-barrier instructions
201 required for a given CPU architecture. 201 required for a given CPU architecture.
202 202
203 Perhaps more important, it serves to document which pointers 203 Perhaps just as important, it serves to document (1) which
204 are protected by RCU. That said, rcu_assign_pointer() is most 204 pointers are protected by RCU and (2) the point at which a
205 frequently used indirectly, via the _rcu list-manipulation 205 given structure becomes accessible to other CPUs. That said,
206 primitives such as list_add_rcu(). 206 rcu_assign_pointer() is most frequently used indirectly, via
207 the _rcu list-manipulation primitives such as list_add_rcu().
207 208
208rcu_dereference() 209rcu_dereference()
209 210
@@ -258,9 +259,11 @@ rcu_dereference()
258 locking. 259 locking.
259 260
260 As with rcu_assign_pointer(), an important function of 261 As with rcu_assign_pointer(), an important function of
261 rcu_dereference() is to document which pointers are protected 262 rcu_dereference() is to document which pointers are protected by
262 by RCU. And, again like rcu_assign_pointer(), rcu_dereference() 263 RCU, in particular, flagging a pointer that is subject to changing
263 is typically used indirectly, via the _rcu list-manipulation 264 at any time, including immediately after the rcu_dereference().
265 And, again like rcu_assign_pointer(), rcu_dereference() is
266 typically used indirectly, via the _rcu list-manipulation
264 primitives, such as list_for_each_entry_rcu(). 267 primitives, such as list_for_each_entry_rcu().
265 268
266The following diagram shows how each API communicates among the 269The following diagram shows how each API communicates among the
@@ -327,7 +330,7 @@ for specialized uses, but are relatively uncommon.
3273. WHAT ARE SOME EXAMPLE USES OF CORE RCU API? 3303. WHAT ARE SOME EXAMPLE USES OF CORE RCU API?
328 331
329This section shows a simple use of the core RCU API to protect a 332This section shows a simple use of the core RCU API to protect a
330global pointer to a dynamically allocated structure. More typical 333global pointer to a dynamically allocated structure. More-typical
331uses of RCU may be found in listRCU.txt, arrayRCU.txt, and NMI-RCU.txt. 334uses of RCU may be found in listRCU.txt, arrayRCU.txt, and NMI-RCU.txt.
332 335
333 struct foo { 336 struct foo {
@@ -410,6 +413,8 @@ o Use synchronize_rcu() -after- removing a data element from an
410 data item. 413 data item.
411 414
412See checklist.txt for additional rules to follow when using RCU. 415See checklist.txt for additional rules to follow when using RCU.
416And again, more-typical uses of RCU may be found in listRCU.txt,
417arrayRCU.txt, and NMI-RCU.txt.
413 418
414 419
4154. WHAT IF MY UPDATING THREAD CANNOT BLOCK? 4204. WHAT IF MY UPDATING THREAD CANNOT BLOCK?
@@ -513,7 +518,7 @@ production-quality implementation, and see:
513 518
514for papers describing the Linux kernel RCU implementation. The OLS'01 519for papers describing the Linux kernel RCU implementation. The OLS'01
515and OLS'02 papers are a good introduction, and the dissertation provides 520and OLS'02 papers are a good introduction, and the dissertation provides
516more details on the current implementation. 521more details on the current implementation as of early 2004.
517 522
518 523
5195A. "TOY" IMPLEMENTATION #1: LOCKING 5245A. "TOY" IMPLEMENTATION #1: LOCKING
@@ -768,7 +773,6 @@ RCU pointer/list traversal:
768 rcu_dereference 773 rcu_dereference
769 list_for_each_rcu (to be deprecated in favor of 774 list_for_each_rcu (to be deprecated in favor of
770 list_for_each_entry_rcu) 775 list_for_each_entry_rcu)
771 list_for_each_safe_rcu (deprecated, not used)
772 list_for_each_entry_rcu 776 list_for_each_entry_rcu
773 list_for_each_continue_rcu (to be deprecated in favor of new 777 list_for_each_continue_rcu (to be deprecated in favor of new
774 list_for_each_entry_continue_rcu) 778 list_for_each_entry_continue_rcu)
@@ -807,7 +811,8 @@ Quick Quiz #1: Why is this argument naive? How could a deadlock
807Answer: Consider the following sequence of events: 811Answer: Consider the following sequence of events:
808 812
809 1. CPU 0 acquires some unrelated lock, call it 813 1. CPU 0 acquires some unrelated lock, call it
810 "problematic_lock". 814 "problematic_lock", disabling irq via
815 spin_lock_irqsave().
811 816
812 2. CPU 1 enters synchronize_rcu(), write-acquiring 817 2. CPU 1 enters synchronize_rcu(), write-acquiring
813 rcu_gp_mutex. 818 rcu_gp_mutex.
@@ -894,7 +899,7 @@ Answer: Just as PREEMPT_RT permits preemption of spinlock
894ACKNOWLEDGEMENTS 899ACKNOWLEDGEMENTS
895 900
896My thanks to the people who helped make this human-readable, including 901My thanks to the people who helped make this human-readable, including
897Jon Walpole, Josh Triplett, Serge Hallyn, and Suzanne Wood. 902Jon Walpole, Josh Triplett, Serge Hallyn, Suzanne Wood, and Alan Stern.
898 903
899 904
900For more information, see http://www.rdrop.com/users/paulmck/RCU. 905For more information, see http://www.rdrop.com/users/paulmck/RCU.
diff --git a/Documentation/cputopology.txt b/Documentation/cputopology.txt
new file mode 100644
index 000000000000..ff280e2e1613
--- /dev/null
+++ b/Documentation/cputopology.txt
@@ -0,0 +1,41 @@
1
2Export cpu topology info by sysfs. Items (attributes) are similar
3to /proc/cpuinfo.
4
51) /sys/devices/system/cpu/cpuX/topology/physical_package_id:
6represent the physical package id of cpu X;
72) /sys/devices/system/cpu/cpuX/topology/core_id:
8represent the cpu core id to cpu X;
93) /sys/devices/system/cpu/cpuX/topology/thread_siblings:
10represent the thread siblings to cpu X in the same core;
114) /sys/devices/system/cpu/cpuX/topology/core_siblings:
12represent the thread siblings to cpu X in the same physical package;
13
14To implement it in an architecture-neutral way, a new source file,
15driver/base/topology.c, is to export the 5 attributes.
16
17If one architecture wants to support this feature, it just needs to
18implement 4 defines, typically in file include/asm-XXX/topology.h.
19The 4 defines are:
20#define topology_physical_package_id(cpu)
21#define topology_core_id(cpu)
22#define topology_thread_siblings(cpu)
23#define topology_core_siblings(cpu)
24
25The type of **_id is int.
26The type of siblings is cpumask_t.
27
28To be consistent on all architectures, the 4 attributes should have
29deafult values if their values are unavailable. Below is the rule.
301) physical_package_id: If cpu has no physical package id, -1 is the
31default value.
322) core_id: If cpu doesn't support multi-core, its core id is 0.
333) thread_siblings: Just include itself, if the cpu doesn't support
34HT/multi-thread.
354) core_siblings: Just include itself, if the cpu doesn't support
36multi-core and HT/Multi-thread.
37
38So be careful when declaring the 4 defines in include/asm-XXX/topology.h.
39
40If an attribute isn't defined on an architecture, it won't be exported.
41
diff --git a/Documentation/driver-model/overview.txt b/Documentation/driver-model/overview.txt
index 44662735cf81..ac4a7a737e43 100644
--- a/Documentation/driver-model/overview.txt
+++ b/Documentation/driver-model/overview.txt
@@ -1,50 +1,43 @@
1The Linux Kernel Device Model 1The Linux Kernel Device Model
2 2
3Patrick Mochel <mochel@osdl.org> 3Patrick Mochel <mochel@digitalimplant.org>
4 4
526 August 2002 5Drafted 26 August 2002
6Updated 31 January 2006
6 7
7 8
8Overview 9Overview
9~~~~~~~~ 10~~~~~~~~
10 11
11This driver model is a unification of all the current, disparate driver models 12The Linux Kernel Driver Model is a unification of all the disparate driver
12that are currently in the kernel. It is intended to augment the 13models that were previously used in the kernel. It is intended to augment the
13bus-specific drivers for bridges and devices by consolidating a set of data 14bus-specific drivers for bridges and devices by consolidating a set of data
14and operations into globally accessible data structures. 15and operations into globally accessible data structures.
15 16
16Current driver models implement some sort of tree-like structure (sometimes 17Traditional driver models implemented some sort of tree-like structure
17just a list) for the devices they control. But, there is no linkage between 18(sometimes just a list) for the devices they control. There wasn't any
18the different bus types. 19uniformity across the different bus types.
19 20
20A common data structure can provide this linkage with little overhead: when a 21The current driver model provides a comon, uniform data model for describing
21bus driver discovers a particular device, it can insert it into the global 22a bus and the devices that can appear under the bus. The unified bus
22tree as well as its local tree. In fact, the local tree becomes just a subset 23model includes a set of common attributes which all busses carry, and a set
23of the global tree. 24of common callbacks, such as device discovery during bus probing, bus
24 25shutdown, bus power management, etc.
25Common data fields can also be moved out of the local bus models into the
26global model. Some of the manipulations of these fields can also be
27consolidated. Most likely, manipulation functions will become a set
28of helper functions, which the bus drivers wrap around to include any
29bus-specific items.
30
31The common device and bridge interface currently reflects the goals of the
32modern PC: namely the ability to do seamless Plug and Play, power management,
33and hot plug. (The model dictated by Intel and Microsoft (read: ACPI) ensures
34us that any device in the system may fit any of these criteria.)
35
36In reality, not every bus will be able to support such operations. But, most
37buses will support a majority of those operations, and all future buses will.
38In other words, a bus that doesn't support an operation is the exception,
39instead of the other way around.
40 26
27The common device and bridge interface reflects the goals of the modern
28computer: namely the ability to do seamless device "plug and play", power
29management, and hot plug. In particular, the model dictated by Intel and
30Microsoft (namely ACPI) ensures that almost every device on almost any bus
31on an x86-compatible system can work within this paradigm. Of course,
32not every bus is able to support all such operations, although most
33buses support a most of those operations.
41 34
42 35
43Downstream Access 36Downstream Access
44~~~~~~~~~~~~~~~~~ 37~~~~~~~~~~~~~~~~~
45 38
46Common data fields have been moved out of individual bus layers into a common 39Common data fields have been moved out of individual bus layers into a common
47data structure. But, these fields must still be accessed by the bus layers, 40data structure. These fields must still be accessed by the bus layers,
48and sometimes by the device-specific drivers. 41and sometimes by the device-specific drivers.
49 42
50Other bus layers are encouraged to do what has been done for the PCI layer. 43Other bus layers are encouraged to do what has been done for the PCI layer.
@@ -53,7 +46,7 @@ struct pci_dev now looks like this:
53struct pci_dev { 46struct pci_dev {
54 ... 47 ...
55 48
56 struct device device; 49 struct device dev;
57}; 50};
58 51
59Note first that it is statically allocated. This means only one allocation on 52Note first that it is statically allocated. This means only one allocation on
@@ -64,9 +57,9 @@ the two.
64 57
65The PCI bus layer freely accesses the fields of struct device. It knows about 58The PCI bus layer freely accesses the fields of struct device. It knows about
66the structure of struct pci_dev, and it should know the structure of struct 59the structure of struct pci_dev, and it should know the structure of struct
67device. PCI devices that have been converted generally do not touch the fields 60device. Individual PCI device drivers that have been converted the the current
68of struct device. More precisely, device-specific drivers should not touch 61driver model generally do not and should not touch the fields of struct device,
69fields of struct device unless there is a strong compelling reason to do so. 62unless there is a strong compelling reason to do so.
70 63
71This abstraction is prevention of unnecessary pain during transitional phases. 64This abstraction is prevention of unnecessary pain during transitional phases.
72If the name of the field changes or is removed, then every downstream driver 65If the name of the field changes or is removed, then every downstream driver
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 2be7148812ca..b47fba58d201 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -148,9 +148,24 @@ Why: The 8250 serial driver now has the ability to deal with the differences
148 brother on Alchemy SOCs. The loss of features is not considered an 148 brother on Alchemy SOCs. The loss of features is not considered an
149 issue. 149 issue.
150Who: Ralf Baechle <ralf@linux-mips.org> 150Who: Ralf Baechle <ralf@linux-mips.org>
151
151--------------------------- 152---------------------------
152 153
153What: eepro100 network driver 154What: eepro100 network driver
154When: January 2007 155When: January 2007
155Why: replaced by the e100 driver 156Why: replaced by the e100 driver
156Who: Adrian Bunk <bunk@stusta.de> 157Who: Adrian Bunk <bunk@stusta.de>
158
159---------------------------
160
161What: Legacy /proc/pci interface (PCI_LEGACY_PROC)
162When: March 2006
163Why: deprecated since 2.5.53 in favor of lspci(8)
164Who: Adrian Bunk <bunk@stusta.de>
165
166---------------------------
167
168What: pci_module_init(driver)
169When: January 2007
170Why: Is replaced by pci_register_driver(pci_driver).
171Who: Richard Knutsson <ricknu-0@student.ltu.se> and Greg Kroah-Hartman <gregkh@suse.de>
diff --git a/Documentation/filesystems/configfs/configfs_example.c b/Documentation/filesystems/configfs/configfs_example.c
index f3c6e4946f98..3d4713a6c207 100644
--- a/Documentation/filesystems/configfs/configfs_example.c
+++ b/Documentation/filesystems/configfs/configfs_example.c
@@ -320,6 +320,7 @@ static struct config_item_type simple_children_type = {
320 .ct_item_ops = &simple_children_item_ops, 320 .ct_item_ops = &simple_children_item_ops,
321 .ct_group_ops = &simple_children_group_ops, 321 .ct_group_ops = &simple_children_group_ops,
322 .ct_attrs = simple_children_attrs, 322 .ct_attrs = simple_children_attrs,
323 .ct_owner = THIS_MODULE,
323}; 324};
324 325
325static struct configfs_subsystem simple_children_subsys = { 326static struct configfs_subsystem simple_children_subsys = {
@@ -403,6 +404,7 @@ static struct config_item_type group_children_type = {
403 .ct_item_ops = &group_children_item_ops, 404 .ct_item_ops = &group_children_item_ops,
404 .ct_group_ops = &group_children_group_ops, 405 .ct_group_ops = &group_children_group_ops,
405 .ct_attrs = group_children_attrs, 406 .ct_attrs = group_children_attrs,
407 .ct_owner = THIS_MODULE,
406}; 408};
407 409
408static struct configfs_subsystem group_children_subsys = { 410static struct configfs_subsystem group_children_subsys = {
diff --git a/Documentation/filesystems/ocfs2.txt b/Documentation/filesystems/ocfs2.txt
index f2595caf052e..4389c684a80a 100644
--- a/Documentation/filesystems/ocfs2.txt
+++ b/Documentation/filesystems/ocfs2.txt
@@ -35,6 +35,7 @@ Features which OCFS2 does not support yet:
35 be cluster coherent. 35 be cluster coherent.
36 - quotas 36 - quotas
37 - cluster aware flock 37 - cluster aware flock
38 - cluster aware lockf
38 - Directory change notification (F_NOTIFY) 39 - Directory change notification (F_NOTIFY)
39 - Distributed Caching (F_SETLEASE/F_GETLEASE/break_lease) 40 - Distributed Caching (F_SETLEASE/F_GETLEASE/break_lease)
40 - POSIX ACLs 41 - POSIX ACLs
diff --git a/Documentation/kernel-doc-nano-HOWTO.txt b/Documentation/kernel-doc-nano-HOWTO.txt
index c406ce67edd0..c65233d430f0 100644
--- a/Documentation/kernel-doc-nano-HOWTO.txt
+++ b/Documentation/kernel-doc-nano-HOWTO.txt
@@ -45,10 +45,10 @@ How to extract the documentation
45 45
46If you just want to read the ready-made books on the various 46If you just want to read the ready-made books on the various
47subsystems (see Documentation/DocBook/*.tmpl), just type 'make 47subsystems (see Documentation/DocBook/*.tmpl), just type 'make
48psdocs', or 'make pdfdocs', or 'make htmldocs', depending on your 48psdocs', or 'make pdfdocs', or 'make htmldocs', depending on your
49preference. If you would rather read a different format, you can type 49preference. If you would rather read a different format, you can type
50'make sgmldocs' and then use DocBook tools to convert 50'make sgmldocs' and then use DocBook tools to convert
51Documentation/DocBook/*.sgml to a format of your choice (for example, 51Documentation/DocBook/*.sgml to a format of your choice (for example,
52'db2html ...' if 'make htmldocs' was not defined). 52'db2html ...' if 'make htmldocs' was not defined).
53 53
54If you want to see man pages instead, you can do this: 54If you want to see man pages instead, you can do this:
@@ -124,6 +124,36 @@ patterns, which are highlighted appropriately.
124Take a look around the source tree for examples. 124Take a look around the source tree for examples.
125 125
126 126
127kernel-doc for structs, unions, enums, and typedefs
128---------------------------------------------------
129
130Beside functions you can also write documentation for structs, unions,
131enums and typedefs. Instead of the function name you must write the name
132of the declaration; the struct/union/enum/typedef must always precede
133the name. Nesting of declarations is not supported.
134Use the argument mechanism to document members or constants.
135
136Inside a struct description, you can use the "private:" and "public:"
137comment tags. Structure fields that are inside a "private:" area
138are not listed in the generated output documentation.
139
140Example:
141
142/**
143 * struct my_struct - short description
144 * @a: first member
145 * @b: second member
146 *
147 * Longer description
148 */
149struct my_struct {
150 int a;
151 int b;
152/* private: */
153 int c;
154};
155
156
127How to make new SGML template files 157How to make new SGML template files
128----------------------------------- 158-----------------------------------
129 159
@@ -147,4 +177,3 @@ documentation, in <filename>, for the functions listed.
147 177
148Tim. 178Tim.
149*/ <twaugh@redhat.com> 179*/ <twaugh@redhat.com>
150
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 1cbcf65b764b..84370363da80 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -452,6 +452,11 @@ running once the system is up.
452 452
453 eata= [HW,SCSI] 453 eata= [HW,SCSI]
454 454
455 ec_intr= [HW,ACPI] ACPI Embedded Controller interrupt mode
456 Format: <int>
457 0: polling mode
458 non-0: interrupt mode (default)
459
455 eda= [HW,PS2] 460 eda= [HW,PS2]
456 461
457 edb= [HW,PS2] 462 edb= [HW,PS2]
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 2b7cf19a06ad..26364d06ae92 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -427,6 +427,23 @@ icmp_ignore_bogus_error_responses - BOOLEAN
427 will avoid log file clutter. 427 will avoid log file clutter.
428 Default: FALSE 428 Default: FALSE
429 429
430icmp_errors_use_inbound_ifaddr - BOOLEAN
431
432 If zero, icmp error messages are sent with the primary address of
433 the exiting interface.
434
435 If non-zero, the message will be sent with the primary address of
436 the interface that received the packet that caused the icmp error.
437 This is the behaviour network many administrators will expect from
438 a router. And it can make debugging complicated network layouts
439 much easier.
440
441 Note that if no primary address exists for the interface selected,
442 then the primary address of the first non-loopback interface that
443 has one will be used regarldess of this setting.
444
445 Default: 0
446
430igmp_max_memberships - INTEGER 447igmp_max_memberships - INTEGER
431 Change the maximum number of multicast groups we can subscribe to. 448 Change the maximum number of multicast groups we can subscribe to.
432 Default: 20 449 Default: 20
diff --git a/Documentation/parport-lowlevel.txt b/Documentation/parport-lowlevel.txt
index 1d40008a1926..8f2302415eff 100644
--- a/Documentation/parport-lowlevel.txt
+++ b/Documentation/parport-lowlevel.txt
@@ -1068,7 +1068,7 @@ SYNOPSIS
1068 1068
1069struct parport_operations { 1069struct parport_operations {
1070 ... 1070 ...
1071 void (*write_status) (struct parport *port, unsigned char s); 1071 void (*write_control) (struct parport *port, unsigned char s);
1072 ... 1072 ...
1073}; 1073};
1074 1074
@@ -1097,9 +1097,9 @@ SYNOPSIS
1097 1097
1098struct parport_operations { 1098struct parport_operations {
1099 ... 1099 ...
1100 void (*frob_control) (struct parport *port, 1100 unsigned char (*frob_control) (struct parport *port,
1101 unsigned char mask, 1101 unsigned char mask,
1102 unsigned char val); 1102 unsigned char val);
1103 ... 1103 ...
1104}; 1104};
1105 1105
diff --git a/Documentation/pci-error-recovery.txt b/Documentation/pci-error-recovery.txt
index d089967e4948..634d3e5b5756 100644
--- a/Documentation/pci-error-recovery.txt
+++ b/Documentation/pci-error-recovery.txt
@@ -1,246 +1,396 @@
1 1
2 PCI Error Recovery 2 PCI Error Recovery
3 ------------------ 3 ------------------
4 May 31, 2005 4 February 2, 2006
5 5
6 Current document maintainer: 6 Current document maintainer:
7 Linas Vepstas <linas@austin.ibm.com> 7 Linas Vepstas <linas@austin.ibm.com>
8 8
9 9
10Some PCI bus controllers are able to detect certain "hard" PCI errors 10Many PCI bus controllers are able to detect a variety of hardware
11on the bus, such as parity errors on the data and address busses, as 11PCI errors on the bus, such as parity errors on the data and address
12well as SERR and PERR errors. These chipsets are then able to disable 12busses, as well as SERR and PERR errors. Some of the more advanced
13I/O to/from the affected device, so that, for example, a bad DMA 13chipsets are able to deal with these errors; these include PCI-E chipsets,
14address doesn't end up corrupting system memory. These same chipsets 14and the PCI-host bridges found on IBM Power4 and Power5-based pSeries
15are also able to reset the affected PCI device, and return it to 15boxes. A typical action taken is to disconnect the affected device,
16working condition. This document describes a generic API form 16halting all I/O to it. The goal of a disconnection is to avoid system
17performing error recovery. 17corruption; for example, to halt system memory corruption due to DMA's
18 18to "wild" addresses. Typically, a reconnection mechanism is also
19The core idea is that after a PCI error has been detected, there must 19offered, so that the affected PCI device(s) are reset and put back
20be a way for the kernel to coordinate with all affected device drivers 20into working condition. The reset phase requires coordination
21so that the pci card can be made operational again, possibly after 21between the affected device drivers and the PCI controller chip.
22performing a full electrical #RST of the PCI card. The API below 22This document describes a generic API for notifying device drivers
23provides a generic API for device drivers to be notified of PCI 23of a bus disconnection, and then performing error recovery.
24errors, and to be notified of, and respond to, a reset sequence. 24This API is currently implemented in the 2.6.16 and later kernels.
25 25
26Preliminary sketch of API, cut-n-pasted-n-modified email from 26Reporting and recovery is performed in several steps. First, when
27Ben Herrenschmidt, circa 5 april 2005 27a PCI hardware error has resulted in a bus disconnect, that event
28is reported as soon as possible to all affected device drivers,
29including multiple instances of a device driver on multi-function
30cards. This allows device drivers to avoid deadlocking in spinloops,
31waiting for some i/o-space register to change, when it never will.
32It also gives the drivers a chance to defer incoming I/O as
33needed.
34
35Next, recovery is performed in several stages. Most of the complexity
36is forced by the need to handle multi-function devices, that is,
37devices that have multiple device drivers associated with them.
38In the first stage, each driver is allowed to indicate what type
39of reset it desires, the choices being a simple re-enabling of I/O
40or requesting a hard reset (a full electrical #RST of the PCI card).
41If any driver requests a full reset, that is what will be done.
42
43After a full reset and/or a re-enabling of I/O, all drivers are
44again notified, so that they may then perform any device setup/config
45that may be required. After these have all completed, a final
46"resume normal operations" event is sent out.
47
48The biggest reason for choosing a kernel-based implementation rather
49than a user-space implementation was the need to deal with bus
50disconnects of PCI devices attached to storage media, and, in particular,
51disconnects from devices holding the root file system. If the root
52file system is disconnected, a user-space mechanism would have to go
53through a large number of contortions to complete recovery. Almost all
54of the current Linux file systems are not tolerant of disconnection
55from/reconnection to their underlying block device. By contrast,
56bus errors are easy to manage in the device driver. Indeed, most
57device drivers already handle very similar recovery procedures;
58for example, the SCSI-generic layer already provides significant
59mechanisms for dealing with SCSI bus errors and SCSI bus resets.
60
61
62Detailed Design
63---------------
64Design and implementation details below, based on a chain of
65public email discussions with Ben Herrenschmidt, circa 5 April 2005.
28 66
29The error recovery API support is exposed to the driver in the form of 67The error recovery API support is exposed to the driver in the form of
30a structure of function pointers pointed to by a new field in struct 68a structure of function pointers pointed to by a new field in struct
31pci_driver. The absence of this pointer in pci_driver denotes an 69pci_driver. A driver that fails to provide the structure is "non-aware",
32"non-aware" driver, behaviour on these is platform dependant. 70and the actual recovery steps taken are platform dependent. The
33Platforms like ppc64 can try to simulate pci hotplug remove/add. 71arch/powerpc implementation will simulate a PCI hotplug remove/add.
34
35The definition of "pci_error_token" is not covered here. It is based on
36Seto's work on the synchronous error detection. We still need to define
37functions for extracting infos out of an opaque error token. This is
38separate from this API.
39 72
40This structure has the form: 73This structure has the form:
41
42struct pci_error_handlers 74struct pci_error_handlers
43{ 75{
44 int (*error_detected)(struct pci_dev *dev, pci_error_token error); 76 int (*error_detected)(struct pci_dev *dev, enum pci_channel_state);
45 int (*mmio_enabled)(struct pci_dev *dev); 77 int (*mmio_enabled)(struct pci_dev *dev);
46 int (*resume)(struct pci_dev *dev);
47 int (*link_reset)(struct pci_dev *dev); 78 int (*link_reset)(struct pci_dev *dev);
48 int (*slot_reset)(struct pci_dev *dev); 79 int (*slot_reset)(struct pci_dev *dev);
80 void (*resume)(struct pci_dev *dev);
49}; 81};
50 82
51A driver doesn't have to implement all of these callbacks. The 83The possible channel states are:
52only mandatory one is error_detected(). If a callback is not 84enum pci_channel_state {
53implemented, the corresponding feature is considered unsupported. 85 pci_channel_io_normal, /* I/O channel is in normal state */
54For example, if mmio_enabled() and resume() aren't there, then the 86 pci_channel_io_frozen, /* I/O to channel is blocked */
55driver is assumed as not doing any direct recovery and requires 87 pci_channel_io_perm_failure, /* PCI card is dead */
88};
89
90Possible return values are:
91enum pci_ers_result {
92 PCI_ERS_RESULT_NONE, /* no result/none/not supported in device driver */
93 PCI_ERS_RESULT_CAN_RECOVER, /* Device driver can recover without slot reset */
94 PCI_ERS_RESULT_NEED_RESET, /* Device driver wants slot to be reset. */
95 PCI_ERS_RESULT_DISCONNECT, /* Device has completely failed, is unrecoverable */
96 PCI_ERS_RESULT_RECOVERED, /* Device driver is fully recovered and operational */
97};
98
99A driver does not have to implement all of these callbacks; however,
100if it implements any, it must implement error_detected(). If a callback
101is not implemented, the corresponding feature is considered unsupported.
102For example, if mmio_enabled() and resume() aren't there, then it
103is assumed that the driver is not doing any direct recovery and requires
56a reset. If link_reset() is not implemented, the card is assumed as 104a reset. If link_reset() is not implemented, the card is assumed as
57not caring about link resets, in which case, if recover is supported, 105not care about link resets. Typically a driver will want to know about
58the core can try recover (but not slot_reset() unless it really did 106a slot_reset().
59reset the slot). If slot_reset() is not supported, link_reset() can 107
60be called instead on a slot reset. 108The actual steps taken by a platform to recover from a PCI error
61 109event will be platform-dependent, but will follow the general
62At first, the call will always be : 110sequence described below.
63 111
64 1) error_detected() 112STEP 0: Error Event
65 113-------------------
66 Error detected. This is sent once after an error has been detected. At 114PCI bus error is detect by the PCI hardware. On powerpc, the slot
67this point, the device might not be accessible anymore depending on the 115is isolated, in that all I/O is blocked: all reads return 0xffffffff,
68platform (the slot will be isolated on ppc64). The driver may already 116all writes are ignored.
69have "noticed" the error because of a failing IO, but this is the proper 117
70"synchronisation point", that is, it gives a chance to the driver to 118
71cleanup, waiting for pending stuff (timers, whatever, etc...) to 119STEP 1: Notification
72complete; it can take semaphores, schedule, etc... everything but touch 120--------------------
73the device. Within this function and after it returns, the driver 121Platform calls the error_detected() callback on every instance of
122every driver affected by the error.
123
124At this point, the device might not be accessible anymore, depending on
125the platform (the slot will be isolated on powerpc). The driver may
126already have "noticed" the error because of a failing I/O, but this
127is the proper "synchronization point", that is, it gives the driver
128a chance to cleanup, waiting for pending stuff (timers, whatever, etc...)
129to complete; it can take semaphores, schedule, etc... everything but
130touch the device. Within this function and after it returns, the driver
74shouldn't do any new IOs. Called in task context. This is sort of a 131shouldn't do any new IOs. Called in task context. This is sort of a
75"quiesce" point. See note about interrupts at the end of this doc. 132"quiesce" point. See note about interrupts at the end of this doc.
76 133
77 Result codes: 134All drivers participating in this system must implement this call.
78 - PCIERR_RESULT_CAN_RECOVER: 135The driver must return one of the following result codes:
79 Driever returns this if it thinks it might be able to recover 136 - PCI_ERS_RESULT_CAN_RECOVER:
137 Driver returns this if it thinks it might be able to recover
80 the HW by just banging IOs or if it wants to be given 138 the HW by just banging IOs or if it wants to be given
81 a chance to extract some diagnostic informations (see 139 a chance to extract some diagnostic information (see
82 below). 140 mmio_enable, below).
83 - PCIERR_RESULT_NEED_RESET: 141 - PCI_ERS_RESULT_NEED_RESET:
84 Driver returns this if it thinks it can't recover unless the 142 Driver returns this if it can't recover without a hard
85 slot is reset. 143 slot reset.
86 - PCIERR_RESULT_DISCONNECT: 144 - PCI_ERS_RESULT_DISCONNECT:
87 Return this if driver thinks it won't recover at all, 145 Driver returns this if it doesn't want to recover at all.
88 (this will detach the driver ? or just leave it 146
89 dangling ? to be decided) 147The next step taken will depend on the result codes returned by the
90 148drivers.
91So at this point, we have called error_detected() for all drivers 149
92on the segment that had the error. On ppc64, the slot is isolated. What 150If all drivers on the segment/slot return PCI_ERS_RESULT_CAN_RECOVER,
93happens now typically depends on the result from the drivers. If all 151then the platform should re-enable IOs on the slot (or do nothing in
94drivers on the segment/slot return PCIERR_RESULT_CAN_RECOVER, we would 152particular, if the platform doesn't isolate slots), and recovery
95re-enable IOs on the slot (or do nothing special if the platform doesn't 153proceeds to STEP 2 (MMIO Enable).
96isolate slots) and call 2). If not and we can reset slots, we go to 4), 154
97if neither, we have a dead slot. If it's an hotplug slot, we might 155If any driver requested a slot reset (by returning PCI_ERS_RESULT_NEED_RESET),
98"simulate" reset by triggering HW unplug/replug though. 156then recovery proceeds to STEP 4 (Slot Reset).
99 157
100>>> Current ppc64 implementation assumes that a device driver will 158If the platform is unable to recover the slot, the next step
101>>> *not* schedule or semaphore in this routine; the current ppc64 159is STEP 6 (Permanent Failure).
160
161>>> The current powerpc implementation assumes that a device driver will
162>>> *not* schedule or semaphore in this routine; the current powerpc
102>>> implementation uses one kernel thread to notify all devices; 163>>> implementation uses one kernel thread to notify all devices;
103>>> thus, of one device sleeps/schedules, all devices are affected. 164>>> thus, if one device sleeps/schedules, all devices are affected.
104>>> Doing better requires complex multi-threaded logic in the error 165>>> Doing better requires complex multi-threaded logic in the error
105>>> recovery implementation (e.g. waiting for all notification threads 166>>> recovery implementation (e.g. waiting for all notification threads
106>>> to "join" before proceeding with recovery.) This seems excessively 167>>> to "join" before proceeding with recovery.) This seems excessively
107>>> complex and not worth implementing. 168>>> complex and not worth implementing.
108 169
109>>> The current ppc64 implementation doesn't much care if the device 170>>> The current powerpc implementation doesn't much care if the device
110>>> attempts i/o at this point, or not. I/O's will fail, returning 171>>> attempts I/O at this point, or not. I/O's will fail, returning
111>>> a value of 0xff on read, and writes will be dropped. If the device 172>>> a value of 0xff on read, and writes will be dropped. If the device
112>>> driver attempts more than 10K I/O's to a frozen adapter, it will 173>>> driver attempts more than 10K I/O's to a frozen adapter, it will
113>>> assume that the device driver has gone into an infinite loop, and 174>>> assume that the device driver has gone into an infinite loop, and
114>>> it will panic the the kernel. 175>>> it will panic the the kernel. There doesn't seem to be any other
176>>> way of stopping a device driver that insists on spinning on I/O.
115 177
116 2) mmio_enabled() 178STEP 2: MMIO Enabled
179-------------------
180The platform re-enables MMIO to the device (but typically not the
181DMA), and then calls the mmio_enabled() callback on all affected
182device drivers.
117 183
118 This is the "early recovery" call. IOs are allowed again, but DMA is 184This is the "early recovery" call. IOs are allowed again, but DMA is
119not (hrm... to be discussed, I prefer not), with some restrictions. This 185not (hrm... to be discussed, I prefer not), with some restrictions. This
120is NOT a callback for the driver to start operations again, only to 186is NOT a callback for the driver to start operations again, only to
121peek/poke at the device, extract diagnostic information, if any, and 187peek/poke at the device, extract diagnostic information, if any, and
122eventually do things like trigger a device local reset or some such, 188eventually do things like trigger a device local reset or some such,
123but not restart operations. This is sent if all drivers on a segment 189but not restart operations. This is callback is made if all drivers on
124agree that they can try to recover and no automatic link reset was 190a segment agree that they can try to recover and if no automatic link reset
125performed by the HW. If the platform can't just re-enable IOs without 191was performed by the HW. If the platform can't just re-enable IOs without
126a slot reset or a link reset, it doesn't call this callback and goes 192a slot reset or a link reset, it wont call this callback, and instead
127directly to 3) or 4). All IOs should be done _synchronously_ from 193will have gone directly to STEP 3 (Link Reset) or STEP 4 (Slot Reset)
128within this callback, errors triggered by them will be returned via 194
129the normal pci_check_whatever() api, no new error_detected() callback 195>>> The following is proposed; no platform implements this yet:
130will be issued due to an error happening here. However, such an error 196>>> Proposal: All I/O's should be done _synchronously_ from within
131might cause IOs to be re-blocked for the whole segment, and thus 197>>> this callback, errors triggered by them will be returned via
132invalidate the recovery that other devices on the same segment might 198>>> the normal pci_check_whatever() API, no new error_detected()
133have done, forcing the whole segment into one of the next states, 199>>> callback will be issued due to an error happening here. However,
134that is link reset or slot reset. 200>>> such an error might cause IOs to be re-blocked for the whole
135 201>>> segment, and thus invalidate the recovery that other devices
136 Result codes: 202>>> on the same segment might have done, forcing the whole segment
137 - PCIERR_RESULT_RECOVERED 203>>> into one of the next states, that is, link reset or slot reset.
204
205The driver should return one of the following result codes:
206 - PCI_ERS_RESULT_RECOVERED
138 Driver returns this if it thinks the device is fully 207 Driver returns this if it thinks the device is fully
139 functionnal and thinks it is ready to start 208 functional and thinks it is ready to start
140 normal driver operations again. There is no 209 normal driver operations again. There is no
141 guarantee that the driver will actually be 210 guarantee that the driver will actually be
142 allowed to proceed, as another driver on the 211 allowed to proceed, as another driver on the
143 same segment might have failed and thus triggered a 212 same segment might have failed and thus triggered a
144 slot reset on platforms that support it. 213 slot reset on platforms that support it.
145 214
146 - PCIERR_RESULT_NEED_RESET 215 - PCI_ERS_RESULT_NEED_RESET
147 Driver returns this if it thinks the device is not 216 Driver returns this if it thinks the device is not
148 recoverable in it's current state and it needs a slot 217 recoverable in it's current state and it needs a slot
149 reset to proceed. 218 reset to proceed.
150 219
151 - PCIERR_RESULT_DISCONNECT 220 - PCI_ERS_RESULT_DISCONNECT
152 Same as above. Total failure, no recovery even after 221 Same as above. Total failure, no recovery even after
153 reset driver dead. (To be defined more precisely) 222 reset driver dead. (To be defined more precisely)
154 223
155>>> The current ppc64 implementation does not implement this callback. 224The next step taken depends on the results returned by the drivers.
225If all drivers returned PCI_ERS_RESULT_RECOVERED, then the platform
226proceeds to either STEP3 (Link Reset) or to STEP 5 (Resume Operations).
227
228If any driver returned PCI_ERS_RESULT_NEED_RESET, then the platform
229proceeds to STEP 4 (Slot Reset)
156 230
157 3) link_reset() 231>>> The current powerpc implementation does not implement this callback.
158 232
159 This is called after the link has been reset. This is typically 233
160a PCI Express specific state at this point and is done whenever a 234STEP 3: Link Reset
161non-fatal error has been detected that can be "solved" by resetting 235------------------
162the link. This call informs the driver of the reset and the driver 236The platform resets the link, and then calls the link_reset() callback
163should check if the device appears to be in working condition. 237on all affected device drivers. This is a PCI-Express specific state
164This function acts a bit like 2) mmio_enabled(), in that the driver 238and is done whenever a non-fatal error has been detected that can be
165is not supposed to restart normal driver I/O operations right away. 239"solved" by resetting the link. This call informs the driver of the
166Instead, it should just "probe" the device to check it's recoverability 240reset and the driver should check to see if the device appears to be
167status. If all is right, then the core will call resume() once all 241in working condition.
168drivers have ack'd link_reset(). 242
243The driver is not supposed to restart normal driver I/O operations
244at this point. It should limit itself to "probing" the device to
245check it's recoverability status. If all is right, then the platform
246will call resume() once all drivers have ack'd link_reset().
169 247
170 Result codes: 248 Result codes:
171 (identical to mmio_enabled) 249 (identical to STEP 3 (MMIO Enabled)
250
251The platform then proceeds to either STEP 4 (Slot Reset) or STEP 5
252(Resume Operations).
253
254>>> The current powerpc implementation does not implement this callback.
255
256
257STEP 4: Slot Reset
258------------------
259The platform performs a soft or hard reset of the device, and then
260calls the slot_reset() callback.
261
262A soft reset consists of asserting the adapter #RST line and then
263restoring the PCI BAR's and PCI configuration header to a state
264that is equivalent to what it would be after a fresh system
265power-on followed by power-on BIOS/system firmware initialization.
266If the platform supports PCI hotplug, then the reset might be
267performed by toggling the slot electrical power off/on.
172 268
173>>> The current ppc64 implementation does not implement this callback. 269It is important for the platform to restore the PCI config space
270to the "fresh poweron" state, rather than the "last state". After
271a slot reset, the device driver will almost always use its standard
272device initialization routines, and an unusual config space setup
273may result in hung devices, kernel panics, or silent data corruption.
174 274
175 4) slot_reset() 275This call gives drivers the chance to re-initialize the hardware
276(re-download firmware, etc.). At this point, the driver may assume
277that he card is in a fresh state and is fully functional. In
278particular, interrupt generation should work normally.
176 279
177 This is called after the slot has been soft or hard reset by the 280Drivers should not yet restart normal I/O processing operations
178platform. A soft reset consists of asserting the adapter #RST line 281at this point. If all device drivers report success on this
179and then restoring the PCI BARs and PCI configuration header. If the 282callback, the platform will call resume() to complete the sequence,
180platform supports PCI hotplug, then it might instead perform a hard 283and let the driver restart normal I/O processing.
181reset by toggling power on the slot off/on. This call gives drivers
182the chance to re-initialize the hardware (re-download firmware, etc.),
183but drivers shouldn't restart normal I/O processing operations at
184this point. (See note about interrupts; interrupts aren't guaranteed
185to be delivered until the resume() callback has been called). If all
186device drivers report success on this callback, the patform will call
187resume() to complete the error handling and let the driver restart
188normal I/O processing.
189 284
190A driver can still return a critical failure for this function if 285A driver can still return a critical failure for this function if
191it can't get the device operational after reset. If the platform 286it can't get the device operational after reset. If the platform
192previously tried a soft reset, it migh now try a hard reset (power 287previously tried a soft reset, it might now try a hard reset (power
193cycle) and then call slot_reset() again. It the device still can't 288cycle) and then call slot_reset() again. It the device still can't
194be recovered, there is nothing more that can be done; the platform 289be recovered, there is nothing more that can be done; the platform
195will typically report a "permanent failure" in such a case. The 290will typically report a "permanent failure" in such a case. The
196device will be considered "dead" in this case. 291device will be considered "dead" in this case.
197 292
198 Result codes: 293Drivers for multi-function cards will need to coordinate among
199 - PCIERR_RESULT_DISCONNECT 294themselves as to which driver instance will perform any "one-shot"
200 Same as above. 295or global device initialization. For example, the Symbios sym53cxx2
296driver performs device init only from PCI function 0:
201 297
202>>> The current ppc64 implementation does not try a power-cycle reset 298+ if (PCI_FUNC(pdev->devfn) == 0)
203>>> if the driver returned PCIERR_RESULT_DISCONNECT. However, it should. 299+ sym_reset_scsi_bus(np, 0);
204 300
205 5) resume() 301 Result codes:
206 302 - PCI_ERS_RESULT_DISCONNECT
207 This is called if all drivers on the segment have returned 303 Same as above.
208PCIERR_RESULT_RECOVERED from one of the 3 prevous callbacks.
209That basically tells the driver to restart activity, tht everything
210is back and running. No result code is taken into account here. If
211a new error happens, it will restart a new error handling process.
212 304
213That's it. I think this covers all the possibilities. The way those 305Platform proceeds either to STEP 5 (Resume Operations) or STEP 6 (Permanent
214callbacks are called is platform policy. A platform with no slot reset 306Failure).
215capability for example may want to just "ignore" drivers that can't 307
308>>> The current powerpc implementation does not currently try a
309>>> power-cycle reset if the driver returned PCI_ERS_RESULT_DISCONNECT.
310>>> However, it probably should.
311
312
313STEP 5: Resume Operations
314-------------------------
315The platform will call the resume() callback on all affected device
316drivers if all drivers on the segment have returned
317PCI_ERS_RESULT_RECOVERED from one of the 3 previous callbacks.
318The goal of this callback is to tell the driver to restart activity,
319that everything is back and running. This callback does not return
320a result code.
321
322At this point, if a new error happens, the platform will restart
323a new error recovery sequence.
324
325STEP 6: Permanent Failure
326-------------------------
327A "permanent failure" has occurred, and the platform cannot recover
328the device. The platform will call error_detected() with a
329pci_channel_state value of pci_channel_io_perm_failure.
330
331The device driver should, at this point, assume the worst. It should
332cancel all pending I/O, refuse all new I/O, returning -EIO to
333higher layers. The device driver should then clean up all of its
334memory and remove itself from kernel operations, much as it would
335during system shutdown.
336
337The platform will typically notify the system operator of the
338permanent failure in some way. If the device is hotplug-capable,
339the operator will probably want to remove and replace the device.
340Note, however, not all failures are truly "permanent". Some are
341caused by over-heating, some by a poorly seated card. Many
342PCI error events are caused by software bugs, e.g. DMA's to
343wild addresses or bogus split transactions due to programming
344errors. See the discussion in powerpc/eeh-pci-error-recovery.txt
345for additional detail on real-life experience of the causes of
346software errors.
347
348
349Conclusion; General Remarks
350---------------------------
351The way those callbacks are called is platform policy. A platform with
352no slot reset capability may want to just "ignore" drivers that can't
216recover (disconnect them) and try to let other cards on the same segment 353recover (disconnect them) and try to let other cards on the same segment
217recover. Keep in mind that in most real life cases, though, there will 354recover. Keep in mind that in most real life cases, though, there will
218be only one driver per segment. 355be only one driver per segment.
219 356
220Now, there is a note about interrupts. If you get an interrupt and your 357Now, a note about interrupts. If you get an interrupt and your
221device is dead or has been isolated, there is a problem :) 358device is dead or has been isolated, there is a problem :)
222 359The current policy is to turn this into a platform policy.
223After much thinking, I decided to leave that to the platform. That is, 360That is, the recovery API only requires that:
224the recovery API only precies that:
225 361
226 - There is no guarantee that interrupt delivery can proceed from any 362 - There is no guarantee that interrupt delivery can proceed from any
227device on the segment starting from the error detection and until the 363device on the segment starting from the error detection and until the
228restart callback is sent, at which point interrupts are expected to be 364resume callback is sent, at which point interrupts are expected to be
229fully operational. 365fully operational.
230 366
231 - There is no guarantee that interrupt delivery is stopped, that is, ad 367 - There is no guarantee that interrupt delivery is stopped, that is,
232river that gets an interrupts after detecting an error, or that detects 368a driver that gets an interrupt after detecting an error, or that detects
233and error within the interrupt handler such that it prevents proper 369an error within the interrupt handler such that it prevents proper
234ack'ing of the interrupt (and thus removal of the source) should just 370ack'ing of the interrupt (and thus removal of the source) should just
235return IRQ_NOTHANDLED. It's up to the platform to deal with taht 371return IRQ_NOTHANDLED. It's up to the platform to deal with that
236condition, typically by masking the irq source during the duration of 372condition, typically by masking the IRQ source during the duration of
237the error handling. It is expected that the platform "knows" which 373the error handling. It is expected that the platform "knows" which
238interrupts are routed to error-management capable slots and can deal 374interrupts are routed to error-management capable slots and can deal
239with temporarily disabling that irq number during error processing (this 375with temporarily disabling that IRQ number during error processing (this
240isn't terribly complex). That means some IRQ latency for other devices 376isn't terribly complex). That means some IRQ latency for other devices
241sharing the interrupt, but there is simply no other way. High end 377sharing the interrupt, but there is simply no other way. High end
242platforms aren't supposed to share interrupts between many devices 378platforms aren't supposed to share interrupts between many devices
243anyway :) 379anyway :)
244 380
245 381>>> Implementation details for the powerpc platform are discussed in
246Revised: 31 May 2005 Linas Vepstas <linas@austin.ibm.com> 382>>> the file Documentation/powerpc/eeh-pci-error-recovery.txt
383
384>>> As of this writing, there are six device drivers with patches
385>>> implementing error recovery. Not all of these patches are in
386>>> mainline yet. These may be used as "examples":
387>>>
388>>> drivers/scsi/ipr.c
389>>> drivers/scsi/sym53cxx_2
390>>> drivers/next/e100.c
391>>> drivers/net/e1000
392>>> drivers/net/ixgb
393>>> drivers/net/s2io.c
394
395The End
396-------
diff --git a/Documentation/power/interface.txt b/Documentation/power/interface.txt
index bd4ffb5bd49a..4117802af0f8 100644
--- a/Documentation/power/interface.txt
+++ b/Documentation/power/interface.txt
@@ -44,7 +44,7 @@ it.
44/sys/power/image_size controls the size of the image created by 44/sys/power/image_size controls the size of the image created by
45the suspend-to-disk mechanism. It can be written a string 45the suspend-to-disk mechanism. It can be written a string
46representing a non-negative integer that will be used as an upper 46representing a non-negative integer that will be used as an upper
47limit of the image size, in megabytes. The suspend-to-disk mechanism will 47limit of the image size, in bytes. The suspend-to-disk mechanism will
48do its best to ensure the image size will not exceed that number. However, 48do its best to ensure the image size will not exceed that number. However,
49if this turns out to be impossible, it will try to suspend anyway using the 49if this turns out to be impossible, it will try to suspend anyway using the
50smallest image possible. In particular, if "0" is written to this file, the 50smallest image possible. In particular, if "0" is written to this file, the
diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt
index 08c79d4dc540..b28b7f04abb8 100644
--- a/Documentation/power/swsusp.txt
+++ b/Documentation/power/swsusp.txt
@@ -27,7 +27,7 @@ echo shutdown > /sys/power/disk; echo disk > /sys/power/state
27 27
28echo platform > /sys/power/disk; echo disk > /sys/power/state 28echo platform > /sys/power/disk; echo disk > /sys/power/state
29 29
30If you want to limit the suspend image size to N megabytes, do 30If you want to limit the suspend image size to N bytes, do
31 31
32echo N > /sys/power/image_size 32echo N > /sys/power/image_size
33 33
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
new file mode 100644
index 000000000000..1284498e847c
--- /dev/null
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -0,0 +1,1420 @@
1 Booting the Linux/ppc kernel without Open Firmware
2 --------------------------------------------------
3
4
5(c) 2005 Benjamin Herrenschmidt <benh at kernel.crashing.org>,
6 IBM Corp.
7(c) 2005 Becky Bruce <becky.bruce at freescale.com>,
8 Freescale Semiconductor, FSL SOC and 32-bit additions
9
10 May 18, 2005: Rev 0.1 - Initial draft, no chapter III yet.
11
12 May 19, 2005: Rev 0.2 - Add chapter III and bits & pieces here or
13 clarifies the fact that a lot of things are
14 optional, the kernel only requires a very
15 small device tree, though it is encouraged
16 to provide an as complete one as possible.
17
18 May 24, 2005: Rev 0.3 - Precise that DT block has to be in RAM
19 - Misc fixes
20 - Define version 3 and new format version 16
21 for the DT block (version 16 needs kernel
22 patches, will be fwd separately).
23 String block now has a size, and full path
24 is replaced by unit name for more
25 compactness.
26 linux,phandle is made optional, only nodes
27 that are referenced by other nodes need it.
28 "name" property is now automatically
29 deduced from the unit name
30
31 June 1, 2005: Rev 0.4 - Correct confusion between OF_DT_END and
32 OF_DT_END_NODE in structure definition.
33 - Change version 16 format to always align
34 property data to 4 bytes. Since tokens are
35 already aligned, that means no specific
36 required alignement between property size
37 and property data. The old style variable
38 alignment would make it impossible to do
39 "simple" insertion of properties using
40 memove (thanks Milton for
41 noticing). Updated kernel patch as well
42 - Correct a few more alignement constraints
43 - Add a chapter about the device-tree
44 compiler and the textural representation of
45 the tree that can be "compiled" by dtc.
46
47
48 November 21, 2005: Rev 0.5
49 - Additions/generalizations for 32-bit
50 - Changed to reflect the new arch/powerpc
51 structure
52 - Added chapter VI
53
54
55 ToDo:
56 - Add some definitions of interrupt tree (simple/complex)
57 - Add some definitions for pci host bridges
58 - Add some common address format examples
59 - Add definitions for standard properties and "compatible"
60 names for cells that are not already defined by the existing
61 OF spec.
62 - Compare FSL SOC use of PCI to standard and make sure no new
63 node definition required.
64 - Add more information about node definitions for SOC devices
65 that currently have no standard, like the FSL CPM.
66
67
68I - Introduction
69================
70
71During the recent development of the Linux/ppc64 kernel, and more
72specifically, the addition of new platform types outside of the old
73IBM pSeries/iSeries pair, it was decided to enforce some strict rules
74regarding the kernel entry and bootloader <-> kernel interfaces, in
75order to avoid the degeneration that had become the ppc32 kernel entry
76point and the way a new platform should be added to the kernel. The
77legacy iSeries platform breaks those rules as it predates this scheme,
78but no new board support will be accepted in the main tree that
79doesn't follows them properly. In addition, since the advent of the
80arch/powerpc merged architecture for ppc32 and ppc64, new 32-bit
81platforms and 32-bit platforms which move into arch/powerpc will be
82required to use these rules as well.
83
84The main requirement that will be defined in more detail below is
85the presence of a device-tree whose format is defined after Open
86Firmware specification. However, in order to make life easier
87to embedded board vendors, the kernel doesn't require the device-tree
88to represent every device in the system and only requires some nodes
89and properties to be present. This will be described in detail in
90section III, but, for example, the kernel does not require you to
91create a node for every PCI device in the system. It is a requirement
92to have a node for PCI host bridges in order to provide interrupt
93routing informations and memory/IO ranges, among others. It is also
94recommended to define nodes for on chip devices and other busses that
95don't specifically fit in an existing OF specification. This creates a
96great flexibility in the way the kernel can then probe those and match
97drivers to device, without having to hard code all sorts of tables. It
98also makes it more flexible for board vendors to do minor hardware
99upgrades without significantly impacting the kernel code or cluttering
100it with special cases.
101
102
1031) Entry point for arch/powerpc
104-------------------------------
105
106 There is one and one single entry point to the kernel, at the start
107 of the kernel image. That entry point supports two calling
108 conventions:
109
110 a) Boot from Open Firmware. If your firmware is compatible
111 with Open Firmware (IEEE 1275) or provides an OF compatible
112 client interface API (support for "interpret" callback of
113 forth words isn't required), you can enter the kernel with:
114
115 r5 : OF callback pointer as defined by IEEE 1275
116 bindings to powerpc. Only the 32 bit client interface
117 is currently supported
118
119 r3, r4 : address & length of an initrd if any or 0
120
121 The MMU is either on or off; the kernel will run the
122 trampoline located in arch/powerpc/kernel/prom_init.c to
123 extract the device-tree and other information from open
124 firmware and build a flattened device-tree as described
125 in b). prom_init() will then re-enter the kernel using
126 the second method. This trampoline code runs in the
127 context of the firmware, which is supposed to handle all
128 exceptions during that time.
129
130 b) Direct entry with a flattened device-tree block. This entry
131 point is called by a) after the OF trampoline and can also be
132 called directly by a bootloader that does not support the Open
133 Firmware client interface. It is also used by "kexec" to
134 implement "hot" booting of a new kernel from a previous
135 running one. This method is what I will describe in more
136 details in this document, as method a) is simply standard Open
137 Firmware, and thus should be implemented according to the
138 various standard documents defining it and its binding to the
139 PowerPC platform. The entry point definition then becomes:
140
141 r3 : physical pointer to the device-tree block
142 (defined in chapter II) in RAM
143
144 r4 : physical pointer to the kernel itself. This is
145 used by the assembly code to properly disable the MMU
146 in case you are entering the kernel with MMU enabled
147 and a non-1:1 mapping.
148
149 r5 : NULL (as to differenciate with method a)
150
151 Note about SMP entry: Either your firmware puts your other
152 CPUs in some sleep loop or spin loop in ROM where you can get
153 them out via a soft reset or some other means, in which case
154 you don't need to care, or you'll have to enter the kernel
155 with all CPUs. The way to do that with method b) will be
156 described in a later revision of this document.
157
158
1592) Board support
160----------------
161
16264-bit kernels:
163
164 Board supports (platforms) are not exclusive config options. An
165 arbitrary set of board supports can be built in a single kernel
166 image. The kernel will "know" what set of functions to use for a
167 given platform based on the content of the device-tree. Thus, you
168 should:
169
170 a) add your platform support as a _boolean_ option in
171 arch/powerpc/Kconfig, following the example of PPC_PSERIES,
172 PPC_PMAC and PPC_MAPLE. The later is probably a good
173 example of a board support to start from.
174
175 b) create your main platform file as
176 "arch/powerpc/platforms/myplatform/myboard_setup.c" and add it
177 to the Makefile under the condition of your CONFIG_
178 option. This file will define a structure of type "ppc_md"
179 containing the various callbacks that the generic code will
180 use to get to your platform specific code
181
182 c) Add a reference to your "ppc_md" structure in the
183 "machines" table in arch/powerpc/kernel/setup_64.c if you are
184 a 64-bit platform.
185
186 d) request and get assigned a platform number (see PLATFORM_*
187 constants in include/asm-powerpc/processor.h
188
18932-bit embedded kernels:
190
191 Currently, board support is essentially an exclusive config option.
192 The kernel is configured for a single platform. Part of the reason
193 for this is to keep kernels on embedded systems small and efficient;
194 part of this is due to the fact the code is already that way. In the
195 future, a kernel may support multiple platforms, but only if the
196 platforms feature the same core architectire. A single kernel build
197 cannot support both configurations with Book E and configurations
198 with classic Powerpc architectures.
199
200 32-bit embedded platforms that are moved into arch/powerpc using a
201 flattened device tree should adopt the merged tree practice of
202 setting ppc_md up dynamically, even though the kernel is currently
203 built with support for only a single platform at a time. This allows
204 unification of the setup code, and will make it easier to go to a
205 multiple-platform-support model in the future.
206
207NOTE: I believe the above will be true once Ben's done with the merge
208of the boot sequences.... someone speak up if this is wrong!
209
210 To add a 32-bit embedded platform support, follow the instructions
211 for 64-bit platforms above, with the exception that the Kconfig
212 option should be set up such that the kernel builds exclusively for
213 the platform selected. The processor type for the platform should
214 enable another config option to select the specific board
215 supported.
216
217NOTE: If ben doesn't merge the setup files, may need to change this to
218point to setup_32.c
219
220
221 I will describe later the boot process and various callbacks that
222 your platform should implement.
223
224
225II - The DT block format
226========================
227
228
229This chapter defines the actual format of the flattened device-tree
230passed to the kernel. The actual content of it and kernel requirements
231are described later. You can find example of code manipulating that
232format in various places, including arch/powerpc/kernel/prom_init.c
233which will generate a flattened device-tree from the Open Firmware
234representation, or the fs2dt utility which is part of the kexec tools
235which will generate one from a filesystem representation. It is
236expected that a bootloader like uboot provides a bit more support,
237that will be discussed later as well.
238
239Note: The block has to be in main memory. It has to be accessible in
240both real mode and virtual mode with no mapping other than main
241memory. If you are writing a simple flash bootloader, it should copy
242the block to RAM before passing it to the kernel.
243
244
2451) Header
246---------
247
248 The kernel is entered with r3 pointing to an area of memory that is
249 roughtly described in include/asm-powerpc/prom.h by the structure
250 boot_param_header:
251
252struct boot_param_header {
253 u32 magic; /* magic word OF_DT_HEADER */
254 u32 totalsize; /* total size of DT block */
255 u32 off_dt_struct; /* offset to structure */
256 u32 off_dt_strings; /* offset to strings */
257 u32 off_mem_rsvmap; /* offset to memory reserve map
258*/
259 u32 version; /* format version */
260 u32 last_comp_version; /* last compatible version */
261
262 /* version 2 fields below */
263 u32 boot_cpuid_phys; /* Which physical CPU id we're
264 booting on */
265 /* version 3 fields below */
266 u32 size_dt_strings; /* size of the strings block */
267};
268
269 Along with the constants:
270
271/* Definitions used by the flattened device tree */
272#define OF_DT_HEADER 0xd00dfeed /* 4: version,
273 4: total size */
274#define OF_DT_BEGIN_NODE 0x1 /* Start node: full name
275*/
276#define OF_DT_END_NODE 0x2 /* End node */
277#define OF_DT_PROP 0x3 /* Property: name off,
278 size, content */
279#define OF_DT_END 0x9
280
281 All values in this header are in big endian format, the various
282 fields in this header are defined more precisely below. All
283 "offset" values are in bytes from the start of the header; that is
284 from the value of r3.
285
286 - magic
287
288 This is a magic value that "marks" the beginning of the
289 device-tree block header. It contains the value 0xd00dfeed and is
290 defined by the constant OF_DT_HEADER
291
292 - totalsize
293
294 This is the total size of the DT block including the header. The
295 "DT" block should enclose all data structures defined in this
296 chapter (who are pointed to by offsets in this header). That is,
297 the device-tree structure, strings, and the memory reserve map.
298
299 - off_dt_struct
300
301 This is an offset from the beginning of the header to the start
302 of the "structure" part the device tree. (see 2) device tree)
303
304 - off_dt_strings
305
306 This is an offset from the beginning of the header to the start
307 of the "strings" part of the device-tree
308
309 - off_mem_rsvmap
310
311 This is an offset from the beginning of the header to the start
312 of the reserved memory map. This map is a list of pairs of 64
313 bit integers. Each pair is a physical address and a size. The
314
315 list is terminated by an entry of size 0. This map provides the
316 kernel with a list of physical memory areas that are "reserved"
317 and thus not to be used for memory allocations, especially during
318 early initialization. The kernel needs to allocate memory during
319 boot for things like un-flattening the device-tree, allocating an
320 MMU hash table, etc... Those allocations must be done in such a
321 way to avoid overriding critical things like, on Open Firmware
322 capable machines, the RTAS instance, or on some pSeries, the TCE
323 tables used for the iommu. Typically, the reserve map should
324 contain _at least_ this DT block itself (header,total_size). If
325 you are passing an initrd to the kernel, you should reserve it as
326 well. You do not need to reserve the kernel image itself. The map
327 should be 64 bit aligned.
328
329 - version
330
331 This is the version of this structure. Version 1 stops
332 here. Version 2 adds an additional field boot_cpuid_phys.
333 Version 3 adds the size of the strings block, allowing the kernel
334 to reallocate it easily at boot and free up the unused flattened
335 structure after expansion. Version 16 introduces a new more
336 "compact" format for the tree itself that is however not backward
337 compatible. You should always generate a structure of the highest
338 version defined at the time of your implementation. Currently
339 that is version 16, unless you explicitely aim at being backward
340 compatible.
341
342 - last_comp_version
343
344 Last compatible version. This indicates down to what version of
345 the DT block you are backward compatible. For example, version 2
346 is backward compatible with version 1 (that is, a kernel build
347 for version 1 will be able to boot with a version 2 format). You
348 should put a 1 in this field if you generate a device tree of
349 version 1 to 3, or 0x10 if you generate a tree of version 0x10
350 using the new unit name format.
351
352 - boot_cpuid_phys
353
354 This field only exist on version 2 headers. It indicate which
355 physical CPU ID is calling the kernel entry point. This is used,
356 among others, by kexec. If you are on an SMP system, this value
357 should match the content of the "reg" property of the CPU node in
358 the device-tree corresponding to the CPU calling the kernel entry
359 point (see further chapters for more informations on the required
360 device-tree contents)
361
362
363 So the typical layout of a DT block (though the various parts don't
364 need to be in that order) looks like this (addresses go from top to
365 bottom):
366
367
368 ------------------------------
369 r3 -> | struct boot_param_header |
370 ------------------------------
371 | (alignment gap) (*) |
372 ------------------------------
373 | memory reserve map |
374 ------------------------------
375 | (alignment gap) |
376 ------------------------------
377 | |
378 | device-tree structure |
379 | |
380 ------------------------------
381 | (alignment gap) |
382 ------------------------------
383 | |
384 | device-tree strings |
385 | |
386 -----> ------------------------------
387 |
388 |
389 --- (r3 + totalsize)
390
391 (*) The alignment gaps are not necessarily present; their presence
392 and size are dependent on the various alignment requirements of
393 the individual data blocks.
394
395
3962) Device tree generalities
397---------------------------
398
399This device-tree itself is separated in two different blocks, a
400structure block and a strings block. Both need to be aligned to a 4
401byte boundary.
402
403First, let's quickly describe the device-tree concept before detailing
404the storage format. This chapter does _not_ describe the detail of the
405required types of nodes & properties for the kernel, this is done
406later in chapter III.
407
408The device-tree layout is strongly inherited from the definition of
409the Open Firmware IEEE 1275 device-tree. It's basically a tree of
410nodes, each node having two or more named properties. A property can
411have a value or not.
412
413It is a tree, so each node has one and only one parent except for the
414root node who has no parent.
415
416A node has 2 names. The actual node name is generally contained in a
417property of type "name" in the node property list whose value is a
418zero terminated string and is mandatory for version 1 to 3 of the
419format definition (as it is in Open Firmware). Version 0x10 makes it
420optional as it can generate it from the unit name defined below.
421
422There is also a "unit name" that is used to differenciate nodes with
423the same name at the same level, it is usually made of the node
424name's, the "@" sign, and a "unit address", which definition is
425specific to the bus type the node sits on.
426
427The unit name doesn't exist as a property per-se but is included in
428the device-tree structure. It is typically used to represent "path" in
429the device-tree. More details about the actual format of these will be
430below.
431
432The kernel powerpc generic code does not make any formal use of the
433unit address (though some board support code may do) so the only real
434requirement here for the unit address is to ensure uniqueness of
435the node unit name at a given level of the tree. Nodes with no notion
436of address and no possible sibling of the same name (like /memory or
437/cpus) may omit the unit address in the context of this specification,
438or use the "@0" default unit address. The unit name is used to define
439a node "full path", which is the concatenation of all parent node
440unit names separated with "/".
441
442The root node doesn't have a defined name, and isn't required to have
443a name property either if you are using version 3 or earlier of the
444format. It also has no unit address (no @ symbol followed by a unit
445address). The root node unit name is thus an empty string. The full
446path to the root node is "/".
447
448Every node which actually represents an actual device (that is, a node
449which isn't only a virtual "container" for more nodes, like "/cpus"
450is) is also required to have a "device_type" property indicating the
451type of node .
452
453Finally, every node that can be referenced from a property in another
454node is required to have a "linux,phandle" property. Real open
455firmware implementations provide a unique "phandle" value for every
456node that the "prom_init()" trampoline code turns into
457"linux,phandle" properties. However, this is made optional if the
458flattened device tree is used directly. An example of a node
459referencing another node via "phandle" is when laying out the
460interrupt tree which will be described in a further version of this
461document.
462
463This "linux, phandle" property is a 32 bit value that uniquely
464identifies a node. You are free to use whatever values or system of
465values, internal pointers, or whatever to generate these, the only
466requirement is that every node for which you provide that property has
467a unique value for it.
468
469Here is an example of a simple device-tree. In this example, an "o"
470designates a node followed by the node unit name. Properties are
471presented with their name followed by their content. "content"
472represents an ASCII string (zero terminated) value, while <content>
473represents a 32 bit hexadecimal value. The various nodes in this
474example will be discussed in a later chapter. At this point, it is
475only meant to give you a idea of what a device-tree looks like. I have
476purposefully kept the "name" and "linux,phandle" properties which
477aren't necessary in order to give you a better idea of what the tree
478looks like in practice.
479
480 / o device-tree
481 |- name = "device-tree"
482 |- model = "MyBoardName"
483 |- compatible = "MyBoardFamilyName"
484 |- #address-cells = <2>
485 |- #size-cells = <2>
486 |- linux,phandle = <0>
487 |
488 o cpus
489 | | - name = "cpus"
490 | | - linux,phandle = <1>
491 | | - #address-cells = <1>
492 | | - #size-cells = <0>
493 | |
494 | o PowerPC,970@0
495 | |- name = "PowerPC,970"
496 | |- device_type = "cpu"
497 | |- reg = <0>
498 | |- clock-frequency = <5f5e1000>
499 | |- linux,boot-cpu
500 | |- linux,phandle = <2>
501 |
502 o memory@0
503 | |- name = "memory"
504 | |- device_type = "memory"
505 | |- reg = <00000000 00000000 00000000 20000000>
506 | |- linux,phandle = <3>
507 |
508 o chosen
509 |- name = "chosen"
510 |- bootargs = "root=/dev/sda2"
511 |- linux,platform = <00000600>
512 |- linux,phandle = <4>
513
514This tree is almost a minimal tree. It pretty much contains the
515minimal set of required nodes and properties to boot a linux kernel;
516that is, some basic model informations at the root, the CPUs, and the
517physical memory layout. It also includes misc information passed
518through /chosen, like in this example, the platform type (mandatory)
519and the kernel command line arguments (optional).
520
521The /cpus/PowerPC,970@0/linux,boot-cpu property is an example of a
522property without a value. All other properties have a value. The
523significance of the #address-cells and #size-cells properties will be
524explained in chapter IV which defines precisely the required nodes and
525properties and their content.
526
527
5283) Device tree "structure" block
529
530The structure of the device tree is a linearized tree structure. The
531"OF_DT_BEGIN_NODE" token starts a new node, and the "OF_DT_END_NODE"
532ends that node definition. Child nodes are simply defined before
533"OF_DT_END_NODE" (that is nodes within the node). A 'token' is a 32
534bit value. The tree has to be "finished" with a OF_DT_END token
535
536Here's the basic structure of a single node:
537
538 * token OF_DT_BEGIN_NODE (that is 0x00000001)
539 * for version 1 to 3, this is the node full path as a zero
540 terminated string, starting with "/". For version 16 and later,
541 this is the node unit name only (or an empty string for the
542 root node)
543 * [align gap to next 4 bytes boundary]
544 * for each property:
545 * token OF_DT_PROP (that is 0x00000003)
546 * 32 bit value of property value size in bytes (or 0 of no
547 * value)
548 * 32 bit value of offset in string block of property name
549 * property value data if any
550 * [align gap to next 4 bytes boundary]
551 * [child nodes if any]
552 * token OF_DT_END_NODE (that is 0x00000002)
553
554So the node content can be summmarised as a start token, a full path,
555a list of properties, a list of child node and an end token. Every
556child node is a full node structure itself as defined above.
557
5584) Device tree 'strings" block
559
560In order to save space, property names, which are generally redundant,
561are stored separately in the "strings" block. This block is simply the
562whole bunch of zero terminated strings for all property names
563concatenated together. The device-tree property definitions in the
564structure block will contain offset values from the beginning of the
565strings block.
566
567
568III - Required content of the device tree
569=========================================
570
571WARNING: All "linux,*" properties defined in this document apply only
572to a flattened device-tree. If your platform uses a real
573implementation of Open Firmware or an implementation compatible with
574the Open Firmware client interface, those properties will be created
575by the trampoline code in the kernel's prom_init() file. For example,
576that's where you'll have to add code to detect your board model and
577set the platform number. However, when using the flatenned device-tree
578entry point, there is no prom_init() pass, and thus you have to
579provide those properties yourself.
580
581
5821) Note about cells and address representation
583----------------------------------------------
584
585The general rule is documented in the various Open Firmware
586documentations. If you chose to describe a bus with the device-tree
587and there exist an OF bus binding, then you should follow the
588specification. However, the kernel does not require every single
589device or bus to be described by the device tree.
590
591In general, the format of an address for a device is defined by the
592parent bus type, based on the #address-cells and #size-cells
593property. In the absence of such a property, the parent's parent
594values are used, etc... The kernel requires the root node to have
595those properties defining addresses format for devices directly mapped
596on the processor bus.
597
598Those 2 properties define 'cells' for representing an address and a
599size. A "cell" is a 32 bit number. For example, if both contain 2
600like the example tree given above, then an address and a size are both
601composed of 2 cells, and each is a 64 bit number (cells are
602concatenated and expected to be in big endian format). Another example
603is the way Apple firmware defines them, with 2 cells for an address
604and one cell for a size. Most 32-bit implementations should define
605#address-cells and #size-cells to 1, which represents a 32-bit value.
606Some 32-bit processors allow for physical addresses greater than 32
607bits; these processors should define #address-cells as 2.
608
609"reg" properties are always a tuple of the type "address size" where
610the number of cells of address and size is specified by the bus
611#address-cells and #size-cells. When a bus supports various address
612spaces and other flags relative to a given address allocation (like
613prefetchable, etc...) those flags are usually added to the top level
614bits of the physical address. For example, a PCI physical address is
615made of 3 cells, the bottom two containing the actual address itself
616while the top cell contains address space indication, flags, and pci
617bus & device numbers.
618
619For busses that support dynamic allocation, it's the accepted practice
620to then not provide the address in "reg" (keep it 0) though while
621providing a flag indicating the address is dynamically allocated, and
622then, to provide a separate "assigned-addresses" property that
623contains the fully allocated addresses. See the PCI OF bindings for
624details.
625
626In general, a simple bus with no address space bits and no dynamic
627allocation is preferred if it reflects your hardware, as the existing
628kernel address parsing functions will work out of the box. If you
629define a bus type with a more complex address format, including things
630like address space bits, you'll have to add a bus translator to the
631prom_parse.c file of the recent kernels for your bus type.
632
633The "reg" property only defines addresses and sizes (if #size-cells
634is
635non-0) within a given bus. In order to translate addresses upward
636(that is into parent bus addresses, and possibly into cpu physical
637addresses), all busses must contain a "ranges" property. If the
638"ranges" property is missing at a given level, it's assumed that
639translation isn't possible. The format of the "ranges" proprety for a
640bus is a list of:
641
642 bus address, parent bus address, size
643
644"bus address" is in the format of the bus this bus node is defining,
645that is, for a PCI bridge, it would be a PCI address. Thus, (bus
646address, size) defines a range of addresses for child devices. "parent
647bus address" is in the format of the parent bus of this bus. For
648example, for a PCI host controller, that would be a CPU address. For a
649PCI<->ISA bridge, that would be a PCI address. It defines the base
650address in the parent bus where the beginning of that range is mapped.
651
652For a new 64 bit powerpc board, I recommend either the 2/2 format or
653Apple's 2/1 format which is slightly more compact since sizes usually
654fit in a single 32 bit word. New 32 bit powerpc boards should use a
6551/1 format, unless the processor supports physical addresses greater
656than 32-bits, in which case a 2/1 format is recommended.
657
658
6592) Note about "compatible" properties
660-------------------------------------
661
662These properties are optional, but recommended in devices and the root
663node. The format of a "compatible" property is a list of concatenated
664zero terminated strings. They allow a device to express its
665compatibility with a family of similar devices, in some cases,
666allowing a single driver to match against several devices regardless
667of their actual names.
668
6693) Note about "name" properties
670-------------------------------
671
672While earlier users of Open Firmware like OldWorld macintoshes tended
673to use the actual device name for the "name" property, it's nowadays
674considered a good practice to use a name that is closer to the device
675class (often equal to device_type). For example, nowadays, ethernet
676controllers are named "ethernet", an additional "model" property
677defining precisely the chip type/model, and "compatible" property
678defining the family in case a single driver can driver more than one
679of these chips. However, the kernel doesn't generally put any
680restriction on the "name" property; it is simply considered good
681practice to follow the standard and its evolutions as closely as
682possible.
683
684Note also that the new format version 16 makes the "name" property
685optional. If it's absent for a node, then the node's unit name is then
686used to reconstruct the name. That is, the part of the unit name
687before the "@" sign is used (or the entire unit name if no "@" sign
688is present).
689
6904) Note about node and property names and character set
691-------------------------------------------------------
692
693While open firmware provides more flexibe usage of 8859-1, this
694specification enforces more strict rules. Nodes and properties should
695be comprised only of ASCII characters 'a' to 'z', '0' to
696'9', ',', '.', '_', '+', '#', '?', and '-'. Node names additionally
697allow uppercase characters 'A' to 'Z' (property names should be
698lowercase. The fact that vendors like Apple don't respect this rule is
699irrelevant here). Additionally, node and property names should always
700begin with a character in the range 'a' to 'z' (or 'A' to 'Z' for node
701names).
702
703The maximum number of characters for both nodes and property names
704is 31. In the case of node names, this is only the leftmost part of
705a unit name (the pure "name" property), it doesn't include the unit
706address which can extend beyond that limit.
707
708
7095) Required nodes and properties
710--------------------------------
711 These are all that are currently required. However, it is strongly
712 recommended that you expose PCI host bridges as documented in the
713 PCI binding to open firmware, and your interrupt tree as documented
714 in OF interrupt tree specification.
715
716 a) The root node
717
718 The root node requires some properties to be present:
719
720 - model : this is your board name/model
721 - #address-cells : address representation for "root" devices
722 - #size-cells: the size representation for "root" devices
723
724 Additionally, some recommended properties are:
725
726 - compatible : the board "family" generally finds its way here,
727 for example, if you have 2 board models with a similar layout,
728 that typically get driven by the same platform code in the
729 kernel, you would use a different "model" property but put a
730 value in "compatible". The kernel doesn't directly use that
731 value (see /chosen/linux,platform for how the kernel choses a
732 platform type) but it is generally useful.
733
734 The root node is also generally where you add additional properties
735 specific to your board like the serial number if any, that sort of
736 thing. it is recommended that if you add any "custom" property whose
737 name may clash with standard defined ones, you prefix them with your
738 vendor name and a comma.
739
740 b) The /cpus node
741
742 This node is the parent of all individual CPU nodes. It doesn't
743 have any specific requirements, though it's generally good practice
744 to have at least:
745
746 #address-cells = <00000001>
747 #size-cells = <00000000>
748
749 This defines that the "address" for a CPU is a single cell, and has
750 no meaningful size. This is not necessary but the kernel will assume
751 that format when reading the "reg" properties of a CPU node, see
752 below
753
754 c) The /cpus/* nodes
755
756 So under /cpus, you are supposed to create a node for every CPU on
757 the machine. There is no specific restriction on the name of the
758 CPU, though It's common practice to call it PowerPC,<name>. For
759 example, Apple uses PowerPC,G5 while IBM uses PowerPC,970FX.
760
761 Required properties:
762
763 - device_type : has to be "cpu"
764 - reg : This is the physical cpu number, it's a single 32 bit cell
765 and is also used as-is as the unit number for constructing the
766 unit name in the full path. For example, with 2 CPUs, you would
767 have the full path:
768 /cpus/PowerPC,970FX@0
769 /cpus/PowerPC,970FX@1
770 (unit addresses do not require leading zeroes)
771 - d-cache-line-size : one cell, L1 data cache line size in bytes
772 - i-cache-line-size : one cell, L1 instruction cache line size in
773 bytes
774 - d-cache-size : one cell, size of L1 data cache in bytes
775 - i-cache-size : one cell, size of L1 instruction cache in bytes
776 - linux, boot-cpu : Should be defined if this cpu is the boot cpu.
777
778 Recommended properties:
779
780 - timebase-frequency : a cell indicating the frequency of the
781 timebase in Hz. This is not directly used by the generic code,
782 but you are welcome to copy/paste the pSeries code for setting
783 the kernel timebase/decrementer calibration based on this
784 value.
785 - clock-frequency : a cell indicating the CPU core clock frequency
786 in Hz. A new property will be defined for 64 bit values, but if
787 your frequency is < 4Ghz, one cell is enough. Here as well as
788 for the above, the common code doesn't use that property, but
789 you are welcome to re-use the pSeries or Maple one. A future
790 kernel version might provide a common function for this.
791
792 You are welcome to add any property you find relevant to your board,
793 like some information about the mechanism used to soft-reset the
794 CPUs. For example, Apple puts the GPIO number for CPU soft reset
795 lines in there as a "soft-reset" property since they start secondary
796 CPUs by soft-resetting them.
797
798
799 d) the /memory node(s)
800
801 To define the physical memory layout of your board, you should
802 create one or more memory node(s). You can either create a single
803 node with all memory ranges in its reg property, or you can create
804 several nodes, as you wish. The unit address (@ part) used for the
805 full path is the address of the first range of memory defined by a
806 given node. If you use a single memory node, this will typically be
807 @0.
808
809 Required properties:
810
811 - device_type : has to be "memory"
812 - reg : This property contains all the physical memory ranges of
813 your board. It's a list of addresses/sizes concatenated
814 together, with the number of cells of each defined by the
815 #address-cells and #size-cells of the root node. For example,
816 with both of these properties beeing 2 like in the example given
817 earlier, a 970 based machine with 6Gb of RAM could typically
818 have a "reg" property here that looks like:
819
820 00000000 00000000 00000000 80000000
821 00000001 00000000 00000001 00000000
822
823 That is a range starting at 0 of 0x80000000 bytes and a range
824 starting at 0x100000000 and of 0x100000000 bytes. You can see
825 that there is no memory covering the IO hole between 2Gb and
826 4Gb. Some vendors prefer splitting those ranges into smaller
827 segments, but the kernel doesn't care.
828
829 e) The /chosen node
830
831 This node is a bit "special". Normally, that's where open firmware
832 puts some variable environment information, like the arguments, or
833 phandle pointers to nodes like the main interrupt controller, or the
834 default input/output devices.
835
836 This specification makes a few of these mandatory, but also defines
837 some linux-specific properties that would be normally constructed by
838 the prom_init() trampoline when booting with an OF client interface,
839 but that you have to provide yourself when using the flattened format.
840
841 Required properties:
842
843 - linux,platform : This is your platform number as assigned by the
844 architecture maintainers
845
846 Recommended properties:
847
848 - bootargs : This zero-terminated string is passed as the kernel
849 command line
850 - linux,stdout-path : This is the full path to your standard
851 console device if any. Typically, if you have serial devices on
852 your board, you may want to put the full path to the one set as
853 the default console in the firmware here, for the kernel to pick
854 it up as it's own default console. If you look at the funciton
855 set_preferred_console() in arch/ppc64/kernel/setup.c, you'll see
856 that the kernel tries to find out the default console and has
857 knowledge of various types like 8250 serial ports. You may want
858 to extend this function to add your own.
859 - interrupt-controller : This is one cell containing a phandle
860 value that matches the "linux,phandle" property of your main
861 interrupt controller node. May be used for interrupt routing.
862
863
864 Note that u-boot creates and fills in the chosen node for platforms
865 that use it.
866
867 f) the /soc<SOCname> node
868
869 This node is used to represent a system-on-a-chip (SOC) and must be
870 present if the processor is a SOC. The top-level soc node contains
871 information that is global to all devices on the SOC. The node name
872 should contain a unit address for the SOC, which is the base address
873 of the memory-mapped register set for the SOC. The name of an soc
874 node should start with "soc", and the remainder of the name should
875 represent the part number for the soc. For example, the MPC8540's
876 soc node would be called "soc8540".
877
878 Required properties:
879
880 - device_type : Should be "soc"
881 - ranges : Should be defined as specified in 1) to describe the
882 translation of SOC addresses for memory mapped SOC registers.
883
884 Recommended properties:
885
886 - reg : This property defines the address and size of the
887 memory-mapped registers that are used for the SOC node itself.
888 It does not include the child device registers - these will be
889 defined inside each child node. The address specified in the
890 "reg" property should match the unit address of the SOC node.
891 - #address-cells : Address representation for "soc" devices. The
892 format of this field may vary depending on whether or not the
893 device registers are memory mapped. For memory mapped
894 registers, this field represents the number of cells needed to
895 represent the address of the registers. For SOCs that do not
896 use MMIO, a special address format should be defined that
897 contains enough cells to represent the required information.
898 See 1) above for more details on defining #address-cells.
899 - #size-cells : Size representation for "soc" devices
900 - #interrupt-cells : Defines the width of cells used to represent
901 interrupts. Typically this value is <2>, which includes a
902 32-bit number that represents the interrupt number, and a
903 32-bit number that represents the interrupt sense and level.
904 This field is only needed if the SOC contains an interrupt
905 controller.
906
907 The SOC node may contain child nodes for each SOC device that the
908 platform uses. Nodes should not be created for devices which exist
909 on the SOC but are not used by a particular platform. See chapter VI
910 for more information on how to specify devices that are part of an
911SOC.
912
913 Example SOC node for the MPC8540:
914
915 soc8540@e0000000 {
916 #address-cells = <1>;
917 #size-cells = <1>;
918 #interrupt-cells = <2>;
919 device_type = "soc";
920 ranges = <00000000 e0000000 00100000>
921 reg = <e0000000 00003000>;
922 }
923
924
925
926IV - "dtc", the device tree compiler
927====================================
928
929
930dtc source code can be found at
931<http://ozlabs.org/~dgibson/dtc/dtc.tar.gz>
932
933WARNING: This version is still in early development stage; the
934resulting device-tree "blobs" have not yet been validated with the
935kernel. The current generated bloc lacks a useful reserve map (it will
936be fixed to generate an empty one, it's up to the bootloader to fill
937it up) among others. The error handling needs work, bugs are lurking,
938etc...
939
940dtc basically takes a device-tree in a given format and outputs a
941device-tree in another format. The currently supported formats are:
942
943 Input formats:
944 -------------
945
946 - "dtb": "blob" format, that is a flattened device-tree block
947 with
948 header all in a binary blob.
949 - "dts": "source" format. This is a text file containing a
950 "source" for a device-tree. The format is defined later in this
951 chapter.
952 - "fs" format. This is a representation equivalent to the
953 output of /proc/device-tree, that is nodes are directories and
954 properties are files
955
956 Output formats:
957 ---------------
958
959 - "dtb": "blob" format
960 - "dts": "source" format
961 - "asm": assembly language file. This is a file that can be
962 sourced by gas to generate a device-tree "blob". That file can
963 then simply be added to your Makefile. Additionally, the
964 assembly file exports some symbols that can be use
965
966
967The syntax of the dtc tool is
968
969 dtc [-I <input-format>] [-O <output-format>]
970 [-o output-filename] [-V output_version] input_filename
971
972
973The "output_version" defines what versio of the "blob" format will be
974generated. Supported versions are 1,2,3 and 16. The default is
975currently version 3 but that may change in the future to version 16.
976
977Additionally, dtc performs various sanity checks on the tree, like the
978uniqueness of linux,phandle properties, validity of strings, etc...
979
980The format of the .dts "source" file is "C" like, supports C and C++
981style commments.
982
983/ {
984}
985
986The above is the "device-tree" definition. It's the only statement
987supported currently at the toplevel.
988
989/ {
990 property1 = "string_value"; /* define a property containing a 0
991 * terminated string
992 */
993
994 property2 = <1234abcd>; /* define a property containing a
995 * numerical 32 bits value (hexadecimal)
996 */
997
998 property3 = <12345678 12345678 deadbeef>;
999 /* define a property containing 3
1000 * numerical 32 bits values (cells) in
1001 * hexadecimal
1002 */
1003 property4 = [0a 0b 0c 0d de ea ad be ef];
1004 /* define a property whose content is
1005 * an arbitrary array of bytes
1006 */
1007
1008 childnode@addresss { /* define a child node named "childnode"
1009 * whose unit name is "childnode at
1010 * address"
1011 */
1012
1013 childprop = "hello\n"; /* define a property "childprop" of
1014 * childnode (in this case, a string)
1015 */
1016 };
1017};
1018
1019Nodes can contain other nodes etc... thus defining the hierarchical
1020structure of the tree.
1021
1022Strings support common escape sequences from C: "\n", "\t", "\r",
1023"\(octal value)", "\x(hex value)".
1024
1025It is also suggested that you pipe your source file through cpp (gcc
1026preprocessor) so you can use #include's, #define for constants, etc...
1027
1028Finally, various options are planned but not yet implemented, like
1029automatic generation of phandles, labels (exported to the asm file so
1030you can point to a property content and change it easily from whatever
1031you link the device-tree with), label or path instead of numeric value
1032in some cells to "point" to a node (replaced by a phandle at compile
1033time), export of reserve map address to the asm file, ability to
1034specify reserve map content at compile time, etc...
1035
1036We may provide a .h include file with common definitions of that
1037proves useful for some properties (like building PCI properties or
1038interrupt maps) though it may be better to add a notion of struct
1039definitions to the compiler...
1040
1041
1042V - Recommendations for a bootloader
1043====================================
1044
1045
1046Here are some various ideas/recommendations that have been proposed
1047while all this has been defined and implemented.
1048
1049 - The bootloader may want to be able to use the device-tree itself
1050 and may want to manipulate it (to add/edit some properties,
1051 like physical memory size or kernel arguments). At this point, 2
1052 choices can be made. Either the bootloader works directly on the
1053 flattened format, or the bootloader has its own internal tree
1054 representation with pointers (similar to the kernel one) and
1055 re-flattens the tree when booting the kernel. The former is a bit
1056 more difficult to edit/modify, the later requires probably a bit
1057 more code to handle the tree structure. Note that the structure
1058 format has been designed so it's relatively easy to "insert"
1059 properties or nodes or delete them by just memmoving things
1060 around. It contains no internal offsets or pointers for this
1061 purpose.
1062
1063 - An example of code for iterating nodes & retreiving properties
1064 directly from the flattened tree format can be found in the kernel
1065 file arch/ppc64/kernel/prom.c, look at scan_flat_dt() function,
1066 it's usage in early_init_devtree(), and the corresponding various
1067 early_init_dt_scan_*() callbacks. That code can be re-used in a
1068 GPL bootloader, and as the author of that code, I would be happy
1069 do discuss possible free licencing to any vendor who wishes to
1070 integrate all or part of this code into a non-GPL bootloader.
1071
1072
1073
1074VI - System-on-a-chip devices and nodes
1075=======================================
1076
1077Many companies are now starting to develop system-on-a-chip
1078processors, where the processor core (cpu) and many peripheral devices
1079exist on a single piece of silicon. For these SOCs, an SOC node
1080should be used that defines child nodes for the devices that make
1081up the SOC. While platforms are not required to use this model in
1082order to boot the kernel, it is highly encouraged that all SOC
1083implementations define as complete a flat-device-tree as possible to
1084describe the devices on the SOC. This will allow for the
1085genericization of much of the kernel code.
1086
1087
10881) Defining child nodes of an SOC
1089---------------------------------
1090
1091Each device that is part of an SOC may have its own node entry inside
1092the SOC node. For each device that is included in the SOC, the unit
1093address property represents the address offset for this device's
1094memory-mapped registers in the parent's address space. The parent's
1095address space is defined by the "ranges" property in the top-level soc
1096node. The "reg" property for each node that exists directly under the
1097SOC node should contain the address mapping from the child address space
1098to the parent SOC address space and the size of the device's
1099memory-mapped register file.
1100
1101For many devices that may exist inside an SOC, there are predefined
1102specifications for the format of the device tree node. All SOC child
1103nodes should follow these specifications, except where noted in this
1104document.
1105
1106See appendix A for an example partial SOC node definition for the
1107MPC8540.
1108
1109
11102) Specifying interrupt information for SOC devices
1111---------------------------------------------------
1112
1113Each device that is part of an SOC and which generates interrupts
1114should have the following properties:
1115
1116 - interrupt-parent : contains the phandle of the interrupt
1117 controller which handles interrupts for this device
1118 - interrupts : a list of tuples representing the interrupt
1119 number and the interrupt sense and level for each interupt
1120 for this device.
1121
1122This information is used by the kernel to build the interrupt table
1123for the interrupt controllers in the system.
1124
1125Sense and level information should be encoded as follows:
1126
1127 Devices connected to openPIC-compatible controllers should encode
1128 sense and polarity as follows:
1129
1130 0 = high to low edge sensitive type enabled
1131 1 = active low level sensitive type enabled
1132 2 = low to high edge sensitive type enabled
1133 3 = active high level sensitive type enabled
1134
1135 ISA PIC interrupt controllers should adhere to the ISA PIC
1136 encodings listed below:
1137
1138 0 = active low level sensitive type enabled
1139 1 = active high level sensitive type enabled
1140 2 = high to low edge sensitive type enabled
1141 3 = low to high edge sensitive type enabled
1142
1143
1144
11453) Representing devices without a current OF specification
1146----------------------------------------------------------
1147
1148Currently, there are many devices on SOCs that do not have a standard
1149representation pre-defined as part of the open firmware
1150specifications, mainly because the boards that contain these SOCs are
1151not currently booted using open firmware. This section contains
1152descriptions for the SOC devices for which new nodes have been
1153defined; this list will expand as more and more SOC-containing
1154platforms are moved over to use the flattened-device-tree model.
1155
1156 a) MDIO IO device
1157
1158 The MDIO is a bus to which the PHY devices are connected. For each
1159 device that exists on this bus, a child node should be created. See
1160 the definition of the PHY node below for an example of how to define
1161 a PHY.
1162
1163 Required properties:
1164 - reg : Offset and length of the register set for the device
1165 - device_type : Should be "mdio"
1166 - compatible : Should define the compatible device type for the
1167 mdio. Currently, this is most likely to be "gianfar"
1168
1169 Example:
1170
1171 mdio@24520 {
1172 reg = <24520 20>;
1173
1174 ethernet-phy@0 {
1175 ......
1176 };
1177 };
1178
1179
1180 b) Gianfar-compatible ethernet nodes
1181
1182 Required properties:
1183
1184 - device_type : Should be "network"
1185 - model : Model of the device. Can be "TSEC", "eTSEC", or "FEC"
1186 - compatible : Should be "gianfar"
1187 - reg : Offset and length of the register set for the device
1188 - address : List of bytes representing the ethernet address of
1189 this controller
1190 - interrupts : <a b> where a is the interrupt number and b is a
1191 field that represents an encoding of the sense and level
1192 information for the interrupt. This should be encoded based on
1193 the information in section 2) depending on the type of interrupt
1194 controller you have.
1195 - interrupt-parent : the phandle for the interrupt controller that
1196 services interrupts for this device.
1197 - phy-handle : The phandle for the PHY connected to this ethernet
1198 controller.
1199
1200 Example:
1201
1202 ethernet@24000 {
1203 #size-cells = <0>;
1204 device_type = "network";
1205 model = "TSEC";
1206 compatible = "gianfar";
1207 reg = <24000 1000>;
1208 address = [ 00 E0 0C 00 73 00 ];
1209 interrupts = <d 3 e 3 12 3>;
1210 interrupt-parent = <40000>;
1211 phy-handle = <2452000>
1212 };
1213
1214
1215
1216 c) PHY nodes
1217
1218 Required properties:
1219
1220 - device_type : Should be "ethernet-phy"
1221 - interrupts : <a b> where a is the interrupt number and b is a
1222 field that represents an encoding of the sense and level
1223 information for the interrupt. This should be encoded based on
1224 the information in section 2) depending on the type of interrupt
1225 controller you have.
1226 - interrupt-parent : the phandle for the interrupt controller that
1227 services interrupts for this device.
1228 - reg : The ID number for the phy, usually a small integer
1229 - linux,phandle : phandle for this node; likely referenced by an
1230 ethernet controller node.
1231
1232
1233 Example:
1234
1235 ethernet-phy@0 {
1236 linux,phandle = <2452000>
1237 interrupt-parent = <40000>;
1238 interrupts = <35 1>;
1239 reg = <0>;
1240 device_type = "ethernet-phy";
1241 };
1242
1243
1244 d) Interrupt controllers
1245
1246 Some SOC devices contain interrupt controllers that are different
1247 from the standard Open PIC specification. The SOC device nodes for
1248 these types of controllers should be specified just like a standard
1249 OpenPIC controller. Sense and level information should be encoded
1250 as specified in section 2) of this chapter for each device that
1251 specifies an interrupt.
1252
1253 Example :
1254
1255 pic@40000 {
1256 linux,phandle = <40000>;
1257 clock-frequency = <0>;
1258 interrupt-controller;
1259 #address-cells = <0>;
1260 reg = <40000 40000>;
1261 built-in;
1262 compatible = "chrp,open-pic";
1263 device_type = "open-pic";
1264 big-endian;
1265 };
1266
1267
1268 e) I2C
1269
1270 Required properties :
1271
1272 - device_type : Should be "i2c"
1273 - reg : Offset and length of the register set for the device
1274
1275 Recommended properties :
1276
1277 - compatible : Should be "fsl-i2c" for parts compatible with
1278 Freescale I2C specifications.
1279 - interrupts : <a b> where a is the interrupt number and b is a
1280 field that represents an encoding of the sense and level
1281 information for the interrupt. This should be encoded based on
1282 the information in section 2) depending on the type of interrupt
1283 controller you have.
1284 - interrupt-parent : the phandle for the interrupt controller that
1285 services interrupts for this device.
1286 - dfsrr : boolean; if defined, indicates that this I2C device has
1287 a digital filter sampling rate register
1288 - fsl5200-clocking : boolean; if defined, indicated that this device
1289 uses the FSL 5200 clocking mechanism.
1290
1291 Example :
1292
1293 i2c@3000 {
1294 interrupt-parent = <40000>;
1295 interrupts = <1b 3>;
1296 reg = <3000 18>;
1297 device_type = "i2c";
1298 compatible = "fsl-i2c";
1299 dfsrr;
1300 };
1301
1302
1303 More devices will be defined as this spec matures.
1304
1305
1306Appendix A - Sample SOC node for MPC8540
1307========================================
1308
1309Note that the #address-cells and #size-cells for the SoC node
1310in this example have been explicitly listed; these are likely
1311not necessary as they are usually the same as the root node.
1312
1313 soc8540@e0000000 {
1314 #address-cells = <1>;
1315 #size-cells = <1>;
1316 #interrupt-cells = <2>;
1317 device_type = "soc";
1318 ranges = <00000000 e0000000 00100000>
1319 reg = <e0000000 00003000>;
1320
1321 mdio@24520 {
1322 reg = <24520 20>;
1323 device_type = "mdio";
1324 compatible = "gianfar";
1325
1326 ethernet-phy@0 {
1327 linux,phandle = <2452000>
1328 interrupt-parent = <40000>;
1329 interrupts = <35 1>;
1330 reg = <0>;
1331 device_type = "ethernet-phy";
1332 };
1333
1334 ethernet-phy@1 {
1335 linux,phandle = <2452001>
1336 interrupt-parent = <40000>;
1337 interrupts = <35 1>;
1338 reg = <1>;
1339 device_type = "ethernet-phy";
1340 };
1341
1342 ethernet-phy@3 {
1343 linux,phandle = <2452002>
1344 interrupt-parent = <40000>;
1345 interrupts = <35 1>;
1346 reg = <3>;
1347 device_type = "ethernet-phy";
1348 };
1349
1350 };
1351
1352 ethernet@24000 {
1353 #size-cells = <0>;
1354 device_type = "network";
1355 model = "TSEC";
1356 compatible = "gianfar";
1357 reg = <24000 1000>;
1358 address = [ 00 E0 0C 00 73 00 ];
1359 interrupts = <d 3 e 3 12 3>;
1360 interrupt-parent = <40000>;
1361 phy-handle = <2452000>;
1362 };
1363
1364 ethernet@25000 {
1365 #address-cells = <1>;
1366 #size-cells = <0>;
1367 device_type = "network";
1368 model = "TSEC";
1369 compatible = "gianfar";
1370 reg = <25000 1000>;
1371 address = [ 00 E0 0C 00 73 01 ];
1372 interrupts = <13 3 14 3 18 3>;
1373 interrupt-parent = <40000>;
1374 phy-handle = <2452001>;
1375 };
1376
1377 ethernet@26000 {
1378 #address-cells = <1>;
1379 #size-cells = <0>;
1380 device_type = "network";
1381 model = "FEC";
1382 compatible = "gianfar";
1383 reg = <26000 1000>;
1384 address = [ 00 E0 0C 00 73 02 ];
1385 interrupts = <19 3>;
1386 interrupt-parent = <40000>;
1387 phy-handle = <2452002>;
1388 };
1389
1390 serial@4500 {
1391 device_type = "serial";
1392 compatible = "ns16550";
1393 reg = <4500 100>;
1394 clock-frequency = <0>;
1395 interrupts = <1a 3>;
1396 interrupt-parent = <40000>;
1397 };
1398
1399 pic@40000 {
1400 linux,phandle = <40000>;
1401 clock-frequency = <0>;
1402 interrupt-controller;
1403 #address-cells = <0>;
1404 reg = <40000 40000>;
1405 built-in;
1406 compatible = "chrp,open-pic";
1407 device_type = "open-pic";
1408 big-endian;
1409 };
1410
1411 i2c@3000 {
1412 interrupt-parent = <40000>;
1413 interrupts = <1b 3>;
1414 reg = <3000 18>;
1415 device_type = "i2c";
1416 compatible = "fsl-i2c";
1417 dfsrr;
1418 };
1419
1420 };
diff --git a/Documentation/scsi/ChangeLog.megaraid_sas b/Documentation/scsi/ChangeLog.megaraid_sas
new file mode 100644
index 000000000000..f8c16cbf56ba
--- /dev/null
+++ b/Documentation/scsi/ChangeLog.megaraid_sas
@@ -0,0 +1,24 @@
11 Release Date : Mon Jan 23 14:09:01 PST 2006 - Sumant Patro <Sumant.Patro@lsil.com>
22 Current Version : 00.00.02.02
33 Older Version : 00.00.02.01
4
5i. New template defined to represent each family of controllers (identified by processor used).
6 The template will have defintions that will be initialised to appropritae values for a specific family of controllers. The template definition has four function pointers. During driver initialisation the function pointers will be set based on the controller family type. This change is done to support new controllers that has different processors and thus different register set.
7
8 -Sumant Patro <Sumant.Patro@lsil.com>
9
101 Release Date : Mon Dec 19 14:36:26 PST 2005 - Sumant Patro <Sumant.Patro@lsil.com>
112 Current Version : 00.00.02.00-rc4
123 Older Version : 00.00.02.01
13
14i. Code reorganized to remove code duplication in megasas_build_cmd.
15
16 "There's a lot of duplicate code megasas_build_cmd. Move that out of the different codepathes and merge the reminder of megasas_build_cmd into megasas_queue_command"
17
18 - Christoph Hellwig <hch@lst.de>
19
20ii. Defined MEGASAS_IOC_FIRMWARE32 for code paths that handles 32 bit applications in 64 bit systems.
21
22 "MEGASAS_IOC_FIRMWARE can't be redefined if CONFIG_COMPAT is set, we need to define a MEGASAS_IOC_FIRMWARE32 define so native binaries continue to work"
23
24 - Christoph Hellwig <hch@lst.de>
diff --git a/Documentation/scsi/aic79xx.txt b/Documentation/scsi/aic79xx.txt
index 0aeef740a95a..382b439b439e 100644
--- a/Documentation/scsi/aic79xx.txt
+++ b/Documentation/scsi/aic79xx.txt
@@ -1,5 +1,5 @@
1==================================================================== 1====================================================================
2= Adaptec Ultra320 Family Manager Set v1.3.11 = 2= Adaptec Ultra320 Family Manager Set =
3= = 3= =
4= README for = 4= README for =
5= The Linux Operating System = 5= The Linux Operating System =
@@ -63,6 +63,11 @@ The following information is available in this file:
63 68-pin) 63 68-pin)
642. Version History 642. Version History
65 65
66 3.0 (December 1st, 2005)
67 - Updated driver to use SCSI transport class infrastructure
68 - Upported sequencer and core fixes from adaptec released
69 version 2.0.15 of the driver.
70
66 1.3.11 (July 11, 2003) 71 1.3.11 (July 11, 2003)
67 - Fix several deadlock issues. 72 - Fix several deadlock issues.
68 - Add 29320ALP and 39320B Id's. 73 - Add 29320ALP and 39320B Id's.
@@ -194,7 +199,7 @@ The following information is available in this file:
194 supported) 199 supported)
195 - Support for the PCI-X standard up to 133MHz 200 - Support for the PCI-X standard up to 133MHz
196 - Support for the PCI v2.2 standard 201 - Support for the PCI v2.2 standard
197 - Domain Validation 202 - Domain Validation
198 203
199 2.2. Operating System Support: 204 2.2. Operating System Support:
200 - Redhat Linux 7.2, 7.3, 8.0, Advanced Server 2.1 205 - Redhat Linux 7.2, 7.3, 8.0, Advanced Server 2.1
@@ -411,77 +416,53 @@ The following information is available in this file:
411 http://www.adaptec.com. 416 http://www.adaptec.com.
412 417
413 418
4145. Contacting Adaptec 4195. Adaptec Customer Support
415 420
416 A Technical Support Identification (TSID) Number is required for 421 A Technical Support Identification (TSID) Number is required for
417 Adaptec technical support. 422 Adaptec technical support.
418 - The 12-digit TSID can be found on the white barcode-type label 423 - The 12-digit TSID can be found on the white barcode-type label
419 included inside the box with your product. The TSID helps us 424 included inside the box with your product. The TSID helps us
420 provide more efficient service by accurately identifying your 425 provide more efficient service by accurately identifying your
421 product and support status. 426 product and support status.
427
422 Support Options 428 Support Options
423 - Search the Adaptec Support Knowledgebase (ASK) at 429 - Search the Adaptec Support Knowledgebase (ASK) at
424 http://ask.adaptec.com for articles, troubleshooting tips, and 430 http://ask.adaptec.com for articles, troubleshooting tips, and
425 frequently asked questions for your product. 431 frequently asked questions about your product.
426 - For support via Email, submit your question to Adaptec's 432 - For support via Email, submit your question to Adaptec's
427 Technical Support Specialists at http://ask.adaptec.com. 433 Technical Support Specialists at http://ask.adaptec.com/.
428 434
429 North America 435 North America
430 - Visit our Web site at http://www.adaptec.com. 436 - Visit our Web site at http://www.adaptec.com/.
431 - To speak with a Fibre Channel/RAID/External Storage Technical 437 - For information about Adaptec's support options, call
432 Support Specialist, call 1-321-207-2000, 438 408-957-2550, 24 hours a day, 7 days a week.
433 Hours: Monday-Friday, 3:00 A.M. to 5:00 P.M., PST. 439 - To speak with a Technical Support Specialist,
434 (Not open on holidays) 440 * For hardware products, call 408-934-7274,
435 - For Technical Support in all other technologies including 441 Monday to Friday, 3:00 am to 5:00 pm, PDT.
436 SCSI, call 1-408-934-7274, 442 * For RAID and Fibre Channel products, call 321-207-2000,
437 Hours: Monday-Friday, 6:00 A.M. to 5:00 P.M., PST. 443 Monday to Friday, 3:00 am to 5:00 pm, PDT.
438 (Not open on holidays) 444 To expedite your service, have your computer with you.
439 - For after hours support, call 1-800-416-8066 ($99/call, 445 - To order Adaptec products, including accessories and cables,
440 $149/call on holidays) 446 call 408-957-7274. To order cables online go to
441 - To order Adaptec products including software and cables, call 447 http://www.adaptec.com/buy-cables/.
442 1-800-442-7274 or 1-408-957-7274. You can also visit our
443 online store at http://www.adaptecstore.com
444 448
445 Europe 449 Europe
446 - Visit our Web site at http://www.adaptec-europe.com. 450 - Visit our Web site at http://www.adaptec-europe.com/.
447 - English and French: To speak with a Technical Support 451 - To speak with a Technical Support Specialist, call, or email,
448 Specialist, call one of the following numbers: 452 * German: +49 89 4366 5522, Monday-Friday, 9:00-17:00 CET,
449 - English: +32-2-352-3470 453 http://ask-de.adaptec.com/.
450 - French: +32-2-352-3460 454 * French: +49 89 4366 5533, Monday-Friday, 9:00-17:00 CET,
451 Hours: Monday-Thursday, 10:00 to 12:30, 13:30 to 17:30 CET 455 http://ask-fr.adaptec.com/.
452 Friday, 10:00 to 12:30, 13:30 to 16:30 CET 456 * English: +49 89 4366 5544, Monday-Friday, 9:00-17:00 GMT,
453 - German: To speak with a Technical Support Specialist, 457 http://ask.adaptec.com/.
454 call +49-89-456-40660 458 - You can order Adaptec cables online at
455 Hours: Monday-Thursday, 09:30 to 12:30, 13:30 to 16:30 CET 459 http://www.adaptec.com/buy-cables/.
456 Friday, 09:30 to 12:30, 13:30 to 15:00 CET
457 - To order Adaptec products, including accessories and cables:
458 - UK: +0800-96-65-26 or fax +0800-731-02-95
459 - Other European countries: +32-11-300-379
460
461 Australia and New Zealand
462 - Visit our Web site at http://www.adaptec.com.au.
463 - To speak with a Technical Support Specialist, call
464 +612-9416-0698
465 Hours: Monday-Friday, 10:00 A.M. to 4:30 P.M., EAT
466 (Not open on holidays)
467 460
468 Japan 461 Japan
462 - Visit our web site at http://www.adaptec.co.jp/.
469 - To speak with a Technical Support Specialist, call 463 - To speak with a Technical Support Specialist, call
470 +81-3-5308-6120 464 +81 3 5308 6120, Monday-Friday, 9:00 a.m. to 12:00 p.m.,
471 Hours: Monday-Friday, 9:00 a.m. to 12:00 p.m., 1:00 p.m. to 465 1:00 p.m. to 6:00 p.m.
472 6:00 p.m. TSC
473
474 Hong Kong and China
475 - To speak with a Technical Support Specialist, call
476 +852-2869-7200
477 Hours: Monday-Friday, 10:00 to 17:00.
478 - Fax Technical Support at +852-2869-7100.
479
480 Singapore
481 - To speak with a Technical Support Specialist, call
482 +65-245-7470
483 Hours: Monday-Friday, 10:00 to 17:00.
484 - Fax Technical Support at +852-2869-7100
485 466
486------------------------------------------------------------------- 467-------------------------------------------------------------------
487/* 468/*
diff --git a/Documentation/scsi/aic7xxx.txt b/Documentation/scsi/aic7xxx.txt
index 47e74ddc4bc9..3481fcded4c2 100644
--- a/Documentation/scsi/aic7xxx.txt
+++ b/Documentation/scsi/aic7xxx.txt
@@ -309,81 +309,57 @@ The following information is available in this file:
309 ----------------------------------------------------------------- 309 -----------------------------------------------------------------
310 310
311 Example: 311 Example:
312 'options aic7xxx aic7xxx=verbose,no_probe,tag_info:{{},{,,10}},seltime:1" 312 'options aic7xxx aic7xxx=verbose,no_probe,tag_info:{{},{,,10}},seltime:1'
313 enables verbose logging, Disable EISA/VLB probing, 313 enables verbose logging, Disable EISA/VLB probing,
314 and set tag depth on Controller 1/Target 2 to 10 tags. 314 and set tag depth on Controller 1/Target 2 to 10 tags.
315 315
3163. Contacting Adaptec 3164. Adaptec Customer Support
317 317
318 A Technical Support Identification (TSID) Number is required for 318 A Technical Support Identification (TSID) Number is required for
319 Adaptec technical support. 319 Adaptec technical support.
320 - The 12-digit TSID can be found on the white barcode-type label 320 - The 12-digit TSID can be found on the white barcode-type label
321 included inside the box with your product. The TSID helps us 321 included inside the box with your product. The TSID helps us
322 provide more efficient service by accurately identifying your 322 provide more efficient service by accurately identifying your
323 product and support status. 323 product and support status.
324
324 Support Options 325 Support Options
325 - Search the Adaptec Support Knowledgebase (ASK) at 326 - Search the Adaptec Support Knowledgebase (ASK) at
326 http://ask.adaptec.com for articles, troubleshooting tips, and 327 http://ask.adaptec.com for articles, troubleshooting tips, and
327 frequently asked questions for your product. 328 frequently asked questions about your product.
328 - For support via Email, submit your question to Adaptec's 329 - For support via Email, submit your question to Adaptec's
329 Technical Support Specialists at http://ask.adaptec.com. 330 Technical Support Specialists at http://ask.adaptec.com/.
330 331
331 North America 332 North America
332 - Visit our Web site at http://www.adaptec.com. 333 - Visit our Web site at http://www.adaptec.com/.
333 - To speak with a Fibre Channel/RAID/External Storage Technical 334 - For information about Adaptec's support options, call
334 Support Specialist, call 1-321-207-2000, 335 408-957-2550, 24 hours a day, 7 days a week.
335 Hours: Monday-Friday, 3:00 A.M. to 5:00 P.M., PST. 336 - To speak with a Technical Support Specialist,
336 (Not open on holidays) 337 * For hardware products, call 408-934-7274,
337 - For Technical Support in all other technologies including 338 Monday to Friday, 3:00 am to 5:00 pm, PDT.
338 SCSI, call 1-408-934-7274, 339 * For RAID and Fibre Channel products, call 321-207-2000,
339 Hours: Monday-Friday, 6:00 A.M. to 5:00 P.M., PST. 340 Monday to Friday, 3:00 am to 5:00 pm, PDT.
340 (Not open on holidays) 341 To expedite your service, have your computer with you.
341 - For after hours support, call 1-800-416-8066 ($99/call, 342 - To order Adaptec products, including accessories and cables,
342 $149/call on holidays) 343 call 408-957-7274. To order cables online go to
343 - To order Adaptec products including software and cables, call 344 http://www.adaptec.com/buy-cables/.
344 1-800-442-7274 or 1-408-957-7274. You can also visit our
345 online store at http://www.adaptecstore.com
346 345
347 Europe 346 Europe
348 - Visit our Web site at http://www.adaptec-europe.com. 347 - Visit our Web site at http://www.adaptec-europe.com/.
349 - English and French: To speak with a Technical Support 348 - To speak with a Technical Support Specialist, call, or email,
350 Specialist, call one of the following numbers: 349 * German: +49 89 4366 5522, Monday-Friday, 9:00-17:00 CET,
351 - English: +32-2-352-3470 350 http://ask-de.adaptec.com/.
352 - French: +32-2-352-3460 351 * French: +49 89 4366 5533, Monday-Friday, 9:00-17:00 CET,
353 Hours: Monday-Thursday, 10:00 to 12:30, 13:30 to 17:30 CET 352 http://ask-fr.adaptec.com/.
354 Friday, 10:00 to 12:30, 13:30 to 16:30 CET 353 * English: +49 89 4366 5544, Monday-Friday, 9:00-17:00 GMT,
355 - German: To speak with a Technical Support Specialist, 354 http://ask.adaptec.com/.
356 call +49-89-456-40660 355 - You can order Adaptec cables online at
357 Hours: Monday-Thursday, 09:30 to 12:30, 13:30 to 16:30 CET 356 http://www.adaptec.com/buy-cables/.
358 Friday, 09:30 to 12:30, 13:30 to 15:00 CET
359 - To order Adaptec products, including accessories and cables:
360 - UK: +0800-96-65-26 or fax +0800-731-02-95
361 - Other European countries: +32-11-300-379
362
363 Australia and New Zealand
364 - Visit our Web site at http://www.adaptec.com.au.
365 - To speak with a Technical Support Specialist, call
366 +612-9416-0698
367 Hours: Monday-Friday, 10:00 A.M. to 4:30 P.M., EAT
368 (Not open on holidays)
369 357
370 Japan 358 Japan
359 - Visit our web site at http://www.adaptec.co.jp/.
371 - To speak with a Technical Support Specialist, call 360 - To speak with a Technical Support Specialist, call
372 +81-3-5308-6120 361 +81 3 5308 6120, Monday-Friday, 9:00 a.m. to 12:00 p.m.,
373 Hours: Monday-Friday, 9:00 a.m. to 12:00 p.m., 1:00 p.m. to 362 1:00 p.m. to 6:00 p.m.
374 6:00 p.m. TSC
375
376 Hong Kong and China
377 - To speak with a Technical Support Specialist, call
378 +852-2869-7200
379 Hours: Monday-Friday, 10:00 to 17:00.
380 - Fax Technical Support at +852-2869-7100.
381
382 Singapore
383 - To speak with a Technical Support Specialist, call
384 +65-245-7470
385 Hours: Monday-Friday, 10:00 to 17:00.
386 - Fax Technical Support at +852-2869-7100
387 363
388------------------------------------------------------------------- 364-------------------------------------------------------------------
389/* 365/*
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index d2578013e829..36b511c7cade 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -837,8 +837,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
837 837
838 Module for AC'97 motherboards from Intel and compatibles. 838 Module for AC'97 motherboards from Intel and compatibles.
839 * Intel i810/810E, i815, i820, i830, i84x, MX440 839 * Intel i810/810E, i815, i820, i830, i84x, MX440
840 ICH5, ICH6, ICH7, ESB2
840 * SiS 7012 (SiS 735) 841 * SiS 7012 (SiS 735)
841 * NVidia NForce, NForce2 842 * NVidia NForce, NForce2, NForce3, MCP04, CK804
843 CK8, CK8S, MCP501
842 * AMD AMD768, AMD8111 844 * AMD AMD768, AMD8111
843 * ALi m5455 845 * ALi m5455
844 846
@@ -868,6 +870,12 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
868 -------------------- 870 --------------------
869 871
870 Module for Intel ICH (i8x0) chipset MC97 modems. 872 Module for Intel ICH (i8x0) chipset MC97 modems.
873 * Intel i810/810E, i815, i820, i830, i84x, MX440
874 ICH5, ICH6, ICH7
875 * SiS 7013 (SiS 735)
876 * NVidia NForce, NForce2, NForce2s, NForce3
877 * AMD AMD8111
878 * ALi m5455
871 879
872 ac97_clock - AC'97 codec clock base (0 = auto-detect) 880 ac97_clock - AC'97 codec clock base (0 = auto-detect)
873 881
diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
index e651ed8d1e6f..4251085d38d3 100644
--- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
@@ -5206,14 +5206,14 @@ struct _snd_pcm_runtime {
5206 You need to pass the <function>snd_dma_pci_data(pci)</function>, 5206 You need to pass the <function>snd_dma_pci_data(pci)</function>,
5207 where pci is the struct <structname>pci_dev</structname> pointer 5207 where pci is the struct <structname>pci_dev</structname> pointer
5208 of the chip as well. 5208 of the chip as well.
5209 The <type>snd_sg_buf_t</type> instance is created as 5209 The <type>struct snd_sg_buf</type> instance is created as
5210 substream-&gt;dma_private. You can cast 5210 substream-&gt;dma_private. You can cast
5211 the pointer like: 5211 the pointer like:
5212 5212
5213 <informalexample> 5213 <informalexample>
5214 <programlisting> 5214 <programlisting>
5215<![CDATA[ 5215<![CDATA[
5216 struct snd_sg_buf *sgbuf = (struct snd_sg_buf_t*)substream->dma_private; 5216 struct snd_sg_buf *sgbuf = (struct snd_sg_buf *)substream->dma_private;
5217]]> 5217]]>
5218 </programlisting> 5218 </programlisting>
5219 </informalexample> 5219 </informalexample>
diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt
index 391dd64363e7..a46c10fcddfc 100644
--- a/Documentation/sysctl/vm.txt
+++ b/Documentation/sysctl/vm.txt
@@ -28,6 +28,7 @@ Currently, these files are in /proc/sys/vm:
28- block_dump 28- block_dump
29- drop-caches 29- drop-caches
30- zone_reclaim_mode 30- zone_reclaim_mode
31- zone_reclaim_interval
31 32
32============================================================== 33==============================================================
33 34
@@ -126,15 +127,54 @@ the high water marks for each per cpu page list.
126 127
127zone_reclaim_mode: 128zone_reclaim_mode:
128 129
129This is set during bootup to 1 if it is determined that pages from 130Zone_reclaim_mode allows to set more or less agressive approaches to
130remote zones will cause a significant performance reduction. The 131reclaim memory when a zone runs out of memory. If it is set to zero then no
132zone reclaim occurs. Allocations will be satisfied from other zones / nodes
133in the system.
134
135This is value ORed together of
136
1371 = Zone reclaim on
1382 = Zone reclaim writes dirty pages out
1394 = Zone reclaim swaps pages
1408 = Also do a global slab reclaim pass
141
142zone_reclaim_mode is set during bootup to 1 if it is determined that pages
143from remote zones will cause a measurable performance reduction. The
131page allocator will then reclaim easily reusable pages (those page 144page allocator will then reclaim easily reusable pages (those page
132cache pages that are currently not used) before going off node. 145cache pages that are currently not used) before allocating off node pages.
146
147It may be beneficial to switch off zone reclaim if the system is
148used for a file server and all of memory should be used for caching files
149from disk. In that case the caching effect is more important than
150data locality.
151
152Allowing zone reclaim to write out pages stops processes that are
153writing large amounts of data from dirtying pages on other nodes. Zone
154reclaim will write out dirty pages if a zone fills up and so effectively
155throttle the process. This may decrease the performance of a single process
156since it cannot use all of system memory to buffer the outgoing writes
157anymore but it preserve the memory on other nodes so that the performance
158of other processes running on other nodes will not be affected.
159
160Allowing regular swap effectively restricts allocations to the local
161node unless explicitly overridden by memory policies or cpuset
162configurations.
163
164It may be advisable to allow slab reclaim if the system makes heavy
165use of files and builds up large slab caches. However, the slab
166shrink operation is global, may take a long time and free slabs
167in all nodes of the system.
168
169================================================================
170
171zone_reclaim_interval:
172
173The time allowed for off node allocations after zone reclaim
174has failed to reclaim enough pages to allow a local allocation.
133 175
134The user can override this setting. It may be beneficial to switch 176Time is set in seconds and set by default to 30 seconds.
135off zone reclaim if the system is used for a file server and all
136of memory should be used for caching files from disk.
137 177
138It may be beneficial to switch this on if one wants to do zone 178Reduce the interval if undesired off node allocations occur. However, too
139reclaim regardless of the numa distances in the system. 179frequent scans will have a negative impact onoff node allocation performance.
140 180
diff --git a/Documentation/usb/et61x251.txt b/Documentation/usb/et61x251.txt
new file mode 100644
index 000000000000..b44dda407ce2
--- /dev/null
+++ b/Documentation/usb/et61x251.txt
@@ -0,0 +1,306 @@
1
2 ET61X[12]51 PC Camera Controllers
3 Driver for Linux
4 =================================
5
6 - Documentation -
7
8
9Index
10=====
111. Copyright
122. Disclaimer
133. License
144. Overview and features
155. Module dependencies
166. Module loading
177. Module parameters
188. Optional device control through "sysfs"
199. Supported devices
2010. Notes for V4L2 application developers
2111. Contact information
22
23
241. Copyright
25============
26Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it>
27
28
292. Disclaimer
30=============
31Etoms is a trademark of Etoms Electronics Corp.
32This software is not developed or sponsored by Etoms Electronics.
33
34
353. License
36==========
37This program is free software; you can redistribute it and/or modify
38it under the terms of the GNU General Public License as published by
39the Free Software Foundation; either version 2 of the License, or
40(at your option) any later version.
41
42This program is distributed in the hope that it will be useful,
43but WITHOUT ANY WARRANTY; without even the implied warranty of
44MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45GNU General Public License for more details.
46
47You should have received a copy of the GNU General Public License
48along with this program; if not, write to the Free Software
49Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
50
51
524. Overview and features
53========================
54This driver supports the video interface of the devices mounting the ET61X151
55or ET61X251 PC Camera Controllers.
56
57It's worth to note that Etoms Electronics has never collaborated with the
58author during the development of this project; despite several requests,
59Etoms Electronics also refused to release enough detailed specifications of
60the video compression engine.
61
62The driver relies on the Video4Linux2 and USB core modules. It has been
63designed to run properly on SMP systems as well.
64
65The latest version of the ET61X[12]51 driver can be found at the following URL:
66http://www.linux-projects.org/
67
68Some of the features of the driver are:
69
70- full compliance with the Video4Linux2 API (see also "Notes for V4L2
71 application developers" paragraph);
72- available mmap or read/poll methods for video streaming through isochronous
73 data transfers;
74- automatic detection of image sensor;
75- support for any window resolutions and optional panning within the maximum
76 pixel area of image sensor;
77- image downscaling with arbitrary scaling factors from 1 and 2 in both
78 directions (see "Notes for V4L2 application developers" paragraph);
79- two different video formats for uncompressed or compressed data in low or
80 high compression quality (see also "Notes for V4L2 application developers"
81 paragraph);
82- full support for the capabilities of every possible image sensors that can
83 be connected to the ET61X[12]51 bridges, including, for istance, red, green,
84 blue and global gain adjustments and exposure control (see "Supported
85 devices" paragraph for details);
86- use of default color settings for sunlight conditions;
87- dynamic I/O interface for both ET61X[12]51 and image sensor control (see
88 "Optional device control through 'sysfs'" paragraph);
89- dynamic driver control thanks to various module parameters (see "Module
90 parameters" paragraph);
91- up to 64 cameras can be handled at the same time; they can be connected and
92 disconnected from the host many times without turning off the computer, if
93 the system supports hotplugging;
94- no known bugs.
95
96
975. Module dependencies
98======================
99For it to work properly, the driver needs kernel support for Video4Linux and
100USB.
101
102The following options of the kernel configuration file must be enabled and
103corresponding modules must be compiled:
104
105 # Multimedia devices
106 #
107 CONFIG_VIDEO_DEV=m
108
109To enable advanced debugging functionality on the device through /sysfs:
110
111 # Multimedia devices
112 #
113 CONFIG_VIDEO_ADV_DEBUG=y
114
115 # USB support
116 #
117 CONFIG_USB=m
118
119In addition, depending on the hardware being used, the modules below are
120necessary:
121
122 # USB Host Controller Drivers
123 #
124 CONFIG_USB_EHCI_HCD=m
125 CONFIG_USB_UHCI_HCD=m
126 CONFIG_USB_OHCI_HCD=m
127
128And finally:
129
130 # USB Multimedia devices
131 #
132 CONFIG_USB_ET61X251=m
133
134
1356. Module loading
136=================
137To use the driver, it is necessary to load the "et61x251" module into memory
138after every other module required: "videodev", "usbcore" and, depending on
139the USB host controller you have, "ehci-hcd", "uhci-hcd" or "ohci-hcd".
140
141Loading can be done as shown below:
142
143 [root@localhost home]# modprobe et61x251
144
145At this point the devices should be recognized. You can invoke "dmesg" to
146analyze kernel messages and verify that the loading process has gone well:
147
148 [user@localhost home]$ dmesg
149
150
1517. Module parameters
152====================
153Module parameters are listed below:
154-------------------------------------------------------------------------------
155Name: video_nr
156Type: short array (min = 0, max = 64)
157Syntax: <-1|n[,...]>
158Description: Specify V4L2 minor mode number:
159 -1 = use next available
160 n = use minor number n
161 You can specify up to 64 cameras this way.
162 For example:
163 video_nr=-1,2,-1 would assign minor number 2 to the second
164 registered camera and use auto for the first one and for every
165 other camera.
166Default: -1
167-------------------------------------------------------------------------------
168Name: force_munmap
169Type: bool array (min = 0, max = 64)
170Syntax: <0|1[,...]>
171Description: Force the application to unmap previously mapped buffer memory
172 before calling any VIDIOC_S_CROP or VIDIOC_S_FMT ioctl's. Not
173 all the applications support this feature. This parameter is
174 specific for each detected camera.
175 0 = do not force memory unmapping
176 1 = force memory unmapping (save memory)
177Default: 0
178-------------------------------------------------------------------------------
179Name: debug
180Type: ushort
181Syntax: <n>
182Description: Debugging information level, from 0 to 3:
183 0 = none (use carefully)
184 1 = critical errors
185 2 = significant informations
186 3 = more verbose messages
187 Level 3 is useful for testing only, when only one device
188 is used at the same time. It also shows some more informations
189 about the hardware being detected. This module parameter can be
190 changed at runtime thanks to the /sys filesystem interface.
191Default: 2
192-------------------------------------------------------------------------------
193
194
1958. Optional device control through "sysfs"
196==========================================
197If the kernel has been compiled with the CONFIG_VIDEO_ADV_DEBUG option enabled,
198it is possible to read and write both the ET61X[12]51 and the image sensor
199registers by using the "sysfs" filesystem interface.
200
201There are four files in the /sys/class/video4linux/videoX directory for each
202registered camera: "reg", "val", "i2c_reg" and "i2c_val". The first two files
203control the ET61X[12]51 bridge, while the other two control the sensor chip.
204"reg" and "i2c_reg" hold the values of the current register index where the
205following reading/writing operations are addressed at through "val" and
206"i2c_val". Their use is not intended for end-users, unless you know what you
207are doing. Remember that you must be logged in as root before writing to them.
208
209As an example, suppose we were to want to read the value contained in the
210register number 1 of the sensor register table - which is usually the product
211identifier - of the camera registered as "/dev/video0":
212
213 [root@localhost #] cd /sys/class/video4linux/video0
214 [root@localhost #] echo 1 > i2c_reg
215 [root@localhost #] cat i2c_val
216
217Note that if the sensor registers can not be read, "cat" will fail.
218To avoid race conditions, all the I/O accesses to the files are serialized.
219
220
2219. Supported devices
222====================
223None of the names of the companies as well as their products will be mentioned
224here. They have never collaborated with the author, so no advertising.
225
226From the point of view of a driver, what unambiguously identify a device are
227its vendor and product USB identifiers. Below is a list of known identifiers of
228devices mounting the ET61X[12]51 PC camera controllers:
229
230Vendor ID Product ID
231--------- ----------
2320x102c 0x6151
2330x102c 0x6251
2340x102c 0x6253
2350x102c 0x6254
2360x102c 0x6255
2370x102c 0x6256
2380x102c 0x6257
2390x102c 0x6258
2400x102c 0x6259
2410x102c 0x625a
2420x102c 0x625b
2430x102c 0x625c
2440x102c 0x625d
2450x102c 0x625e
2460x102c 0x625f
2470x102c 0x6260
2480x102c 0x6261
2490x102c 0x6262
2500x102c 0x6263
2510x102c 0x6264
2520x102c 0x6265
2530x102c 0x6266
2540x102c 0x6267
2550x102c 0x6268
2560x102c 0x6269
257
258The following image sensors are supported:
259
260Model Manufacturer
261----- ------------
262TAS5130D1B Taiwan Advanced Sensor Corporation
263
264All the available control settings of each image sensor are supported through
265the V4L2 interface.
266
267
26810. Notes for V4L2 application developers
269========================================
270This driver follows the V4L2 API specifications. In particular, it enforces two
271rules:
272
273- exactly one I/O method, either "mmap" or "read", is associated with each
274file descriptor. Once it is selected, the application must close and reopen the
275device to switch to the other I/O method;
276
277- although it is not mandatory, previously mapped buffer memory should always
278be unmapped before calling any "VIDIOC_S_CROP" or "VIDIOC_S_FMT" ioctl's.
279The same number of buffers as before will be allocated again to match the size
280of the new video frames, so you have to map the buffers again before any I/O
281attempts on them.
282
283Consistently with the hardware limits, this driver also supports image
284downscaling with arbitrary scaling factors from 1 and 2 in both directions.
285However, the V4L2 API specifications don't correctly define how the scaling
286factor can be chosen arbitrarily by the "negotiation" of the "source" and
287"target" rectangles. To work around this flaw, we have added the convention
288that, during the negotiation, whenever the "VIDIOC_S_CROP" ioctl is issued, the
289scaling factor is restored to 1.
290
291This driver supports two different video formats: the first one is the "8-bit
292Sequential Bayer" format and can be used to obtain uncompressed video data
293from the device through the current I/O method, while the second one provides
294"raw" compressed video data (without frame headers not related to the
295compressed data). The current compression quality may vary from 0 to 1 and can
296be selected or queried thanks to the VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP
297V4L2 ioctl's.
298
299
30011. Contact information
301=======================
302The author may be contacted by e-mail at <luca.risolia@studio.unibo.it>.
303
304GPG/PGP encrypted e-mail's are accepted. The GPG key ID of the author is
305'FCE635A4'; the public 1024-bit key should be available at any keyserver;
306the fingerprint is: '88E8 F32F 7244 68BA 3958 5D40 99DA 5D2A FCE6 35A4'.
diff --git a/Documentation/usb/sn9c102.txt b/Documentation/usb/sn9c102.txt
index 3f8a119db31b..c6b76414172c 100644
--- a/Documentation/usb/sn9c102.txt
+++ b/Documentation/usb/sn9c102.txt
@@ -17,16 +17,15 @@ Index
177. Module parameters 177. Module parameters
188. Optional device control through "sysfs" 188. Optional device control through "sysfs"
199. Supported devices 199. Supported devices
2010. How to add plug-in's for new image sensors 2010. Notes for V4L2 application developers
2111. Notes for V4L2 application developers 2111. Video frame formats
2212. Video frame formats 2212. Contact information
2313. Contact information 2313. Credits
2414. Credits
25 24
26 25
271. Copyright 261. Copyright
28============ 27============
29Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> 28Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it>
30 29
31 30
322. Disclaimer 312. Disclaimer
@@ -54,9 +53,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
54 53
554. Overview and features 544. Overview and features
56======================== 55========================
57This driver attempts to support the video and audio streaming capabilities of 56This driver attempts to support the video interface of the devices mounting the
58the devices mounting the SONiX SN9C101, SN9C102 and SN9C103 PC Camera 57SONiX SN9C101, SN9C102 and SN9C103 PC Camera Controllers.
59Controllers.
60 58
61It's worth to note that SONiX has never collaborated with the author during the 59It's worth to note that SONiX has never collaborated with the author during the
62development of this project, despite several requests for enough detailed 60development of this project, despite several requests for enough detailed
@@ -78,6 +76,7 @@ Some of the features of the driver are:
78- available mmap or read/poll methods for video streaming through isochronous 76- available mmap or read/poll methods for video streaming through isochronous
79 data transfers; 77 data transfers;
80- automatic detection of image sensor; 78- automatic detection of image sensor;
79- support for built-in microphone interface;
81- support for any window resolutions and optional panning within the maximum 80- support for any window resolutions and optional panning within the maximum
82 pixel area of image sensor; 81 pixel area of image sensor;
83- image downscaling with arbitrary scaling factors from 1, 2 and 4 in both 82- image downscaling with arbitrary scaling factors from 1, 2 and 4 in both
@@ -96,7 +95,7 @@ Some of the features of the driver are:
96 parameters" paragraph); 95 parameters" paragraph);
97- up to 64 cameras can be handled at the same time; they can be connected and 96- up to 64 cameras can be handled at the same time; they can be connected and
98 disconnected from the host many times without turning off the computer, if 97 disconnected from the host many times without turning off the computer, if
99 your system supports hotplugging; 98 the system supports hotplugging;
100- no known bugs. 99- no known bugs.
101 100
102 101
@@ -112,6 +111,12 @@ corresponding modules must be compiled:
112 # 111 #
113 CONFIG_VIDEO_DEV=m 112 CONFIG_VIDEO_DEV=m
114 113
114To enable advanced debugging functionality on the device through /sysfs:
115
116 # Multimedia devices
117 #
118 CONFIG_VIDEO_ADV_DEBUG=y
119
115 # USB support 120 # USB support
116 # 121 #
117 CONFIG_USB=m 122 CONFIG_USB=m
@@ -125,6 +130,21 @@ necessary:
125 CONFIG_USB_UHCI_HCD=m 130 CONFIG_USB_UHCI_HCD=m
126 CONFIG_USB_OHCI_HCD=m 131 CONFIG_USB_OHCI_HCD=m
127 132
133The SN9C103 controller also provides a built-in microphone interface. It is
134supported by the USB Audio driver thanks to the ALSA API:
135
136 # Sound
137 #
138 CONFIG_SOUND=y
139
140 # Advanced Linux Sound Architecture
141 #
142 CONFIG_SND=m
143
144 # USB devices
145 #
146 CONFIG_SND_USB_AUDIO=m
147
128And finally: 148And finally:
129 149
130 # USB Multimedia devices 150 # USB Multimedia devices
@@ -153,7 +173,7 @@ analyze kernel messages and verify that the loading process has gone well:
153Module parameters are listed below: 173Module parameters are listed below:
154------------------------------------------------------------------------------- 174-------------------------------------------------------------------------------
155Name: video_nr 175Name: video_nr
156Type: int array (min = 0, max = 64) 176Type: short array (min = 0, max = 64)
157Syntax: <-1|n[,...]> 177Syntax: <-1|n[,...]>
158Description: Specify V4L2 minor mode number: 178Description: Specify V4L2 minor mode number:
159 -1 = use next available 179 -1 = use next available
@@ -165,19 +185,19 @@ Description: Specify V4L2 minor mode number:
165 other camera. 185 other camera.
166Default: -1 186Default: -1
167------------------------------------------------------------------------------- 187-------------------------------------------------------------------------------
168Name: force_munmap; 188Name: force_munmap
169Type: bool array (min = 0, max = 64) 189Type: bool array (min = 0, max = 64)
170Syntax: <0|1[,...]> 190Syntax: <0|1[,...]>
171Description: Force the application to unmap previously mapped buffer memory 191Description: Force the application to unmap previously mapped buffer memory
172 before calling any VIDIOC_S_CROP or VIDIOC_S_FMT ioctl's. Not 192 before calling any VIDIOC_S_CROP or VIDIOC_S_FMT ioctl's. Not
173 all the applications support this feature. This parameter is 193 all the applications support this feature. This parameter is
174 specific for each detected camera. 194 specific for each detected camera.
175 0 = do not force memory unmapping" 195 0 = do not force memory unmapping
176 1 = force memory unmapping (save memory)" 196 1 = force memory unmapping (save memory)
177Default: 0 197Default: 0
178------------------------------------------------------------------------------- 198-------------------------------------------------------------------------------
179Name: debug 199Name: debug
180Type: int 200Type: ushort
181Syntax: <n> 201Syntax: <n>
182Description: Debugging information level, from 0 to 3: 202Description: Debugging information level, from 0 to 3:
183 0 = none (use carefully) 203 0 = none (use carefully)
@@ -187,14 +207,15 @@ Description: Debugging information level, from 0 to 3:
187 Level 3 is useful for testing only, when only one device 207 Level 3 is useful for testing only, when only one device
188 is used. It also shows some more informations about the 208 is used. It also shows some more informations about the
189 hardware being detected. This parameter can be changed at 209 hardware being detected. This parameter can be changed at
190 runtime thanks to the /sys filesystem. 210 runtime thanks to the /sys filesystem interface.
191Default: 2 211Default: 2
192------------------------------------------------------------------------------- 212-------------------------------------------------------------------------------
193 213
194 214
1958. Optional device control through "sysfs" [1] 2158. Optional device control through "sysfs" [1]
196========================================== 216==========================================
197It is possible to read and write both the SN9C10x and the image sensor 217If the kernel has been compiled with the CONFIG_VIDEO_ADV_DEBUG option enabled,
218it is possible to read and write both the SN9C10x and the image sensor
198registers by using the "sysfs" filesystem interface. 219registers by using the "sysfs" filesystem interface.
199 220
200Every time a supported device is recognized, a write-only file named "green" is 221Every time a supported device is recognized, a write-only file named "green" is
@@ -236,7 +257,7 @@ serialized.
236 257
237The sysfs interface also provides the "frame_header" entry, which exports the 258The sysfs interface also provides the "frame_header" entry, which exports the
238frame header of the most recent requested and captured video frame. The header 259frame header of the most recent requested and captured video frame. The header
239is 12-bytes long and is appended to every video frame by the SN9C10x 260is always 18-bytes long and is appended to every video frame by the SN9C10x
240controllers. As an example, this additional information can be used by the user 261controllers. As an example, this additional information can be used by the user
241application for implementing auto-exposure features via software. 262application for implementing auto-exposure features via software.
242 263
@@ -250,7 +271,8 @@ Byte # Value Description
2500x03 0xC4 Frame synchronisation pattern. 2710x03 0xC4 Frame synchronisation pattern.
2510x04 0xC4 Frame synchronisation pattern. 2720x04 0xC4 Frame synchronisation pattern.
2520x05 0x96 Frame synchronisation pattern. 2730x05 0x96 Frame synchronisation pattern.
2530x06 0x00 or 0x01 Unknown meaning. The exact value depends on the chip. 2740x06 0xXX Unknown meaning. The exact value depends on the chip;
275 possible values are 0x00, 0x01 and 0x20.
2540x07 0xXX Variable value, whose bits are ff00uzzc, where ff is a 2760x07 0xXX Variable value, whose bits are ff00uzzc, where ff is a
255 frame counter, u is unknown, zz is a size indicator 277 frame counter, u is unknown, zz is a size indicator
256 (00 = VGA, 01 = SIF, 10 = QSIF) and c stands for 278 (00 = VGA, 01 = SIF, 10 = QSIF) and c stands for
@@ -267,12 +289,23 @@ Byte # Value Description
267 times the area outside of the specified AE area. For 289 times the area outside of the specified AE area. For
268 images that are not pure white, the value scales down 290 images that are not pure white, the value scales down
269 according to relative whiteness. 291 according to relative whiteness.
292 according to relative whiteness.
293
294The following bytes are used by the SN9C103 bridge only:
295
2960x0C 0xXX Unknown meaning
2970x0D 0xXX Unknown meaning
2980x0E 0xXX Unknown meaning
2990x0F 0xXX Unknown meaning
3000x10 0xXX Unknown meaning
3010x11 0xXX Unknown meaning
270 302
271The AE area (sx, sy, ex, ey) in the active window can be set by programming the 303The AE area (sx, sy, ex, ey) in the active window can be set by programming the
272registers 0x1c, 0x1d, 0x1e and 0x1f of the SN9C10x controllers, where one unit 304registers 0x1c, 0x1d, 0x1e and 0x1f of the SN9C10x controllers, where one unit
273corresponds to 32 pixels. 305corresponds to 32 pixels.
274 306
275[1] The frame header has been documented by Bertrik Sikken. 307[1] Part of the meaning of the frame header has been documented by Bertrik
308 Sikken.
276 309
277 310
2789. Supported devices 3119. Supported devices
@@ -298,6 +331,7 @@ Vendor ID Product ID
2980x0c45 0x602b 3310x0c45 0x602b
2990x0c45 0x602c 3320x0c45 0x602c
3000x0c45 0x602d 3330x0c45 0x602d
3340x0c45 0x602e
3010x0c45 0x6030 3350x0c45 0x6030
3020x0c45 0x6080 3360x0c45 0x6080
3030x0c45 0x6082 3370x0c45 0x6082
@@ -348,18 +382,7 @@ appreciated. Non-available hardware will not be supported by the author of this
348driver. 382driver.
349 383
350 384
35110. How to add plug-in's for new image sensors 38510. Notes for V4L2 application developers
352==============================================
353It should be easy to write plug-in's for new sensors by using the small API
354that has been created for this purpose, which is present in "sn9c102_sensor.h"
355(documentation is included there). As an example, have a look at the code in
356"sn9c102_pas106b.c", which uses the mentioned interface.
357
358At the moment, possible unsupported image sensors are: CIS-VF10 (VGA),
359OV7620 (VGA), OV7630 (VGA).
360
361
36211. Notes for V4L2 application developers
363========================================= 386=========================================
364This driver follows the V4L2 API specifications. In particular, it enforces two 387This driver follows the V4L2 API specifications. In particular, it enforces two
365rules: 388rules:
@@ -394,7 +417,7 @@ initialized (as described in the documentation of the API for the image sensors
394supplied by this driver). 417supplied by this driver).
395 418
396 419
39712. Video frame formats [1] 42011. Video frame formats [1]
398======================= 421=======================
399The SN9C10x PC Camera Controllers can send images in two possible video 422The SN9C10x PC Camera Controllers can send images in two possible video
400formats over the USB: either native "Sequential RGB Bayer" or Huffman 423formats over the USB: either native "Sequential RGB Bayer" or Huffman
@@ -455,7 +478,7 @@ The following Huffman codes have been found:
455 documented by Bertrik Sikken. 478 documented by Bertrik Sikken.
456 479
457 480
45813. Contact information 48112. Contact information
459======================= 482=======================
460The author may be contacted by e-mail at <luca.risolia@studio.unibo.it>. 483The author may be contacted by e-mail at <luca.risolia@studio.unibo.it>.
461 484
@@ -464,7 +487,7 @@ GPG/PGP encrypted e-mail's are accepted. The GPG key ID of the author is
464the fingerprint is: '88E8 F32F 7244 68BA 3958 5D40 99DA 5D2A FCE6 35A4'. 487the fingerprint is: '88E8 F32F 7244 68BA 3958 5D40 99DA 5D2A FCE6 35A4'.
465 488
466 489
46714. Credits 49013. Credits
468=========== 491===========
469Many thanks to following persons for their contribute (listed in alphabetical 492Many thanks to following persons for their contribute (listed in alphabetical
470order): 493order):
@@ -480,5 +503,5 @@ order):
480- Bertrik Sikken, who reverse-engineered and documented the Huffman compression 503- Bertrik Sikken, who reverse-engineered and documented the Huffman compression
481 algorithm used in the SN9C10x controllers and implemented the first decoder; 504 algorithm used in the SN9C10x controllers and implemented the first decoder;
482- Mizuno Takafumi for the donation of a webcam; 505- Mizuno Takafumi for the donation of a webcam;
483- An "anonymous" donator (who didn't want his name to be revealed) for the 506- an "anonymous" donator (who didn't want his name to be revealed) for the
484 donation of a webcam. 507 donation of a webcam.
diff --git a/Documentation/usb/w9968cf.txt b/Documentation/usb/w9968cf.txt
index 18a47738d56c..9d46cd0b19e3 100644
--- a/Documentation/usb/w9968cf.txt
+++ b/Documentation/usb/w9968cf.txt
@@ -57,16 +57,12 @@ based cameras should be supported as well.
57The driver is divided into two modules: the basic one, "w9968cf", is needed for 57The driver is divided into two modules: the basic one, "w9968cf", is needed for
58the supported devices to work; the second one, "w9968cf-vpp", is an optional 58the supported devices to work; the second one, "w9968cf-vpp", is an optional
59module, which provides some useful video post-processing functions like video 59module, which provides some useful video post-processing functions like video
60decoding, up-scaling and colour conversions. Once the driver is installed, 60decoding, up-scaling and colour conversions.
61every time an application tries to open a recognized device, "w9968cf" checks
62the presence of the "w9968cf-vpp" module and loads it automatically by default.
63 61
64Please keep in mind that official kernels do not include the second module for 62Note that the official kernels do neither include nor support the second
65performance purposes. However it is always recommended to download and install 63module for performance purposes. Therefore, it is always recommended to
66the latest and complete release of the driver, replacing the existing one, if 64download and install the latest and complete release of the driver,
67present: it will be still even possible not to load the "w9968cf-vpp" module at 65replacing the existing one, if present.
68all, if you ever want to. Another important missing feature of the version in
69the official Linux 2.4 kernels is the writeable /proc filesystem interface.
70 66
71The latest and full-featured version of the W996[87]CF driver can be found at: 67The latest and full-featured version of the W996[87]CF driver can be found at:
72http://www.linux-projects.org. Please refer to the documentation included in 68http://www.linux-projects.org. Please refer to the documentation included in
@@ -201,22 +197,6 @@ Note: The kernel must be compiled with the CONFIG_KMOD option
201 enabled for the 'ovcamchip' module to be loaded and for 197 enabled for the 'ovcamchip' module to be loaded and for
202 this parameter to be present. 198 this parameter to be present.
203------------------------------------------------------------------------------- 199-------------------------------------------------------------------------------
204Name: vppmod_load
205Type: bool
206Syntax: <0|1>
207Description: Automatic 'w9968cf-vpp' module loading: 0 disabled, 1 enabled.
208 If enabled, every time an application attempts to open a
209 camera, 'insmod' searches for the video post-processing module
210 in the system and loads it automatically (if present).
211 The optional 'w9968cf-vpp' module adds extra image manipulation
212 capabilities to the 'w9968cf' module,like software up-scaling,
213 colour conversions and video decompression for very high frame
214 rates.
215Default: 1
216Note: The kernel must be compiled with the CONFIG_KMOD option
217 enabled for the 'w9968cf-vpp' module to be loaded and for
218 this parameter to be present.
219-------------------------------------------------------------------------------
220Name: simcams 200Name: simcams
221Type: int 201Type: int
222Syntax: <n> 202Syntax: <n>
diff --git a/Documentation/vm/page_migration b/Documentation/vm/page_migration
new file mode 100644
index 000000000000..c52820fcf500
--- /dev/null
+++ b/Documentation/vm/page_migration
@@ -0,0 +1,129 @@
1Page migration
2--------------
3
4Page migration allows the moving of the physical location of pages between
5nodes in a numa system while the process is running. This means that the
6virtual addresses that the process sees do not change. However, the
7system rearranges the physical location of those pages.
8
9The main intend of page migration is to reduce the latency of memory access
10by moving pages near to the processor where the process accessing that memory
11is running.
12
13Page migration allows a process to manually relocate the node on which its
14pages are located through the MF_MOVE and MF_MOVE_ALL options while setting
15a new memory policy. The pages of process can also be relocated
16from another process using the sys_migrate_pages() function call. The
17migrate_pages function call takes two sets of nodes and moves pages of a
18process that are located on the from nodes to the destination nodes.
19
20Manual migration is very useful if for example the scheduler has relocated
21a process to a processor on a distant node. A batch scheduler or an
22administrator may detect the situation and move the pages of the process
23nearer to the new processor. At some point in the future we may have
24some mechanism in the scheduler that will automatically move the pages.
25
26Larger installations usually partition the system using cpusets into
27sections of nodes. Paul Jackson has equipped cpusets with the ability to
28move pages when a task is moved to another cpuset. This allows automatic
29control over locality of a process. If a task is moved to a new cpuset
30then also all its pages are moved with it so that the performance of the
31process does not sink dramatically (as is the case today).
32
33Page migration allows the preservation of the relative location of pages
34within a group of nodes for all migration techniques which will preserve a
35particular memory allocation pattern generated even after migrating a
36process. This is necessary in order to preserve the memory latencies.
37Processes will run with similar performance after migration.
38
39Page migration occurs in several steps. First a high level
40description for those trying to use migrate_pages() and then
41a low level description of how the low level details work.
42
43A. Use of migrate_pages()
44-------------------------
45
461. Remove pages from the LRU.
47
48 Lists of pages to be migrated are generated by scanning over
49 pages and moving them into lists. This is done by
50 calling isolate_lru_page() or __isolate_lru_page().
51 Calling isolate_lru_page increases the references to the page
52 so that it cannot vanish under us.
53
542. Generate a list of newly allocates page to move the contents
55 of the first list to.
56
573. The migrate_pages() function is called which attempts
58 to do the migration. It returns the moved pages in the
59 list specified as the third parameter and the failed
60 migrations in the fourth parameter. The first parameter
61 will contain the pages that could still be retried.
62
634. The leftover pages of various types are returned
64 to the LRU using putback_to_lru_pages() or otherwise
65 disposed of. The pages will still have the refcount as
66 increased by isolate_lru_pages()!
67
68B. Operation of migrate_pages()
69--------------------------------
70
71migrate_pages does several passes over its list of pages. A page is moved
72if all references to a page are removable at the time.
73
74Steps:
75
761. Lock the page to be migrated
77
782. Insure that writeback is complete.
79
803. Make sure that the page has assigned swap cache entry if
81 it is an anonyous page. The swap cache reference is necessary
82 to preserve the information contain in the page table maps.
83
844. Prep the new page that we want to move to. It is locked
85 and set to not being uptodate so that all accesses to the new
86 page immediately lock while we are moving references.
87
885. All the page table references to the page are either dropped (file backed)
89 or converted to swap references (anonymous pages). This should decrease the
90 reference count.
91
926. The radix tree lock is taken
93
947. The refcount of the page is examined and we back out if references remain
95 otherwise we know that we are the only one referencing this page.
96
978. The radix tree is checked and if it does not contain the pointer to this
98 page then we back out.
99
1009. The mapping is checked. If the mapping is gone then a truncate action may
101 be in progress and we back out.
102
10310. The new page is prepped with some settings from the old page so that accesses
104 to the new page will be discovered to have the correct settings.
105
10611. The radix tree is changed to point to the new page.
107
10812. The reference count of the old page is dropped because the reference has now
109 been removed.
110
11113. The radix tree lock is dropped.
112
11314. The page contents are copied to the new page.
114
11515. The remaining page flags are copied to the new page.
116
11716. The old page flags are cleared to indicate that the page does
118 not use any information anymore.
119
12017. Queued up writeback on the new page is triggered.
121
12218. If swap pte's were generated for the page then remove them again.
123
12419. The locks are dropped from the old and new page.
125
12620. The new page is moved to the LRU.
127
128Christoph Lameter, December 19, 2005.
129
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
index 9c5fc15d03d1..153740f460a6 100644
--- a/Documentation/x86_64/boot-options.txt
+++ b/Documentation/x86_64/boot-options.txt
@@ -40,6 +40,18 @@ APICs
40 no_timer_check Don't check the IO-APIC timer. This can work around 40 no_timer_check Don't check the IO-APIC timer. This can work around
41 problems with incorrect timer initialization on some boards. 41 problems with incorrect timer initialization on some boards.
42 42
43 apicmaintimer Run time keeping from the local APIC timer instead
44 of using the PIT/HPET interrupt for this. This is useful
45 when the PIT/HPET interrupts are unreliable.
46
47 noapicmaintimer Don't do time keeping using the APIC timer.
48 Useful when this option was auto selected, but doesn't work.
49
50 apicpmtimer
51 Do APIC timer calibration using the pmtimer. Implies
52 apicmaintimer. Useful when your PIT timer is totally
53 broken.
54
43Early Console 55Early Console
44 56
45 syntax: earlyprintk=vga 57 syntax: earlyprintk=vga
diff --git a/MAINTAINERS b/MAINTAINERS
index 3f8a90ac47d7..11d44daa6025 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -557,7 +557,8 @@ S: Supported
557 557
558CONFIGFS 558CONFIGFS
559P: Joel Becker 559P: Joel Becker
560M: Joel Becker <joel.becker@oracle.com> 560M: joel.becker@oracle.com
561L: linux-kernel@vger.kernel.org
561S: Supported 562S: Supported
562 563
563CIRRUS LOGIC GENERIC FBDEV DRIVER 564CIRRUS LOGIC GENERIC FBDEV DRIVER
@@ -1176,8 +1177,8 @@ T: git kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6.git
1176S: Maintained 1177S: Maintained
1177 1178
1178SN-IA64 (Itanium) SUB-PLATFORM 1179SN-IA64 (Itanium) SUB-PLATFORM
1179P: Greg Edwards 1180P: Jes Sorensen
1180M: edwardsg@sgi.com 1181M: jes@sgi.com
1181L: linux-altix@sgi.com 1182L: linux-altix@sgi.com
1182L: linux-ia64@vger.kernel.org 1183L: linux-ia64@vger.kernel.org
1183W: http://www.sgi.com/altix 1184W: http://www.sgi.com/altix
@@ -1984,7 +1985,6 @@ M: philb@gnu.org
1984P: Tim Waugh 1985P: Tim Waugh
1985M: tim@cyberelk.net 1986M: tim@cyberelk.net
1986P: David Campbell 1987P: David Campbell
1987M: campbell@torque.net
1988P: Andrea Arcangeli 1988P: Andrea Arcangeli
1989M: andrea@suse.de 1989M: andrea@suse.de
1990L: linux-parport@lists.infradead.org 1990L: linux-parport@lists.infradead.org
@@ -2298,7 +2298,7 @@ S: Supported
2298 2298
2299SELINUX SECURITY MODULE 2299SELINUX SECURITY MODULE
2300P: Stephen Smalley 2300P: Stephen Smalley
2301M: sds@epoch.ncsc.mil 2301M: sds@tycho.nsa.gov
2302P: James Morris 2302P: James Morris
2303M: jmorris@namei.org 2303M: jmorris@namei.org
2304L: linux-kernel@vger.kernel.org (kernel issues) 2304L: linux-kernel@vger.kernel.org (kernel issues)
@@ -2673,6 +2673,14 @@ M: dbrownell@users.sourceforge.net
2673L: linux-usb-devel@lists.sourceforge.net 2673L: linux-usb-devel@lists.sourceforge.net
2674S: Maintained 2674S: Maintained
2675 2675
2676USB ET61X[12]51 DRIVER
2677P: Luca Risolia
2678M: luca.risolia@studio.unibo.it
2679L: linux-usb-devel@lists.sourceforge.net
2680L: video4linux-list@redhat.com
2681W: http://www.linux-projects.org
2682S: Maintained
2683
2676USB HID/HIDBP DRIVERS 2684USB HID/HIDBP DRIVERS
2677P: Vojtech Pavlik 2685P: Vojtech Pavlik
2678M: vojtech@suse.cz 2686M: vojtech@suse.cz
@@ -2836,6 +2844,7 @@ USB SN9C10x DRIVER
2836P: Luca Risolia 2844P: Luca Risolia
2837M: luca.risolia@studio.unibo.it 2845M: luca.risolia@studio.unibo.it
2838L: linux-usb-devel@lists.sourceforge.net 2846L: linux-usb-devel@lists.sourceforge.net
2847L: video4linux-list@redhat.com
2839W: http://www.linux-projects.org 2848W: http://www.linux-projects.org
2840S: Maintained 2849S: Maintained
2841 2850
@@ -2865,6 +2874,7 @@ USB W996[87]CF DRIVER
2865P: Luca Risolia 2874P: Luca Risolia
2866M: luca.risolia@studio.unibo.it 2875M: luca.risolia@studio.unibo.it
2867L: linux-usb-devel@lists.sourceforge.net 2876L: linux-usb-devel@lists.sourceforge.net
2877L: video4linux-list@redhat.com
2868W: http://www.linux-projects.org 2878W: http://www.linux-projects.org
2869S: Maintained 2879S: Maintained
2870 2880
diff --git a/Makefile b/Makefile
index 252a659896f3..cd5b619db9d8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 16 3SUBLEVEL = 16
4EXTRAVERSION =-rc1 4EXTRAVERSION =-rc2
5NAME=Sliding Snow Leopard 5NAME=Sliding Snow Leopard
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/alpha/kernel/asm-offsets.c b/arch/alpha/kernel/asm-offsets.c
index 8f2e5c718b50..6c56c754a0b5 100644
--- a/arch/alpha/kernel/asm-offsets.c
+++ b/arch/alpha/kernel/asm-offsets.c
@@ -28,6 +28,7 @@ void foo(void)
28 DEFINE(TASK_GID, offsetof(struct task_struct, gid)); 28 DEFINE(TASK_GID, offsetof(struct task_struct, gid));
29 DEFINE(TASK_EGID, offsetof(struct task_struct, egid)); 29 DEFINE(TASK_EGID, offsetof(struct task_struct, egid));
30 DEFINE(TASK_REAL_PARENT, offsetof(struct task_struct, real_parent)); 30 DEFINE(TASK_REAL_PARENT, offsetof(struct task_struct, real_parent));
31 DEFINE(TASK_GROUP_LEADER, offsetof(struct task_struct, group_leader));
31 DEFINE(TASK_TGID, offsetof(struct task_struct, tgid)); 32 DEFINE(TASK_TGID, offsetof(struct task_struct, tgid));
32 BLANK(); 33 BLANK();
33 34
diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index e38671c922bc..7af15bf7e5ab 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -879,17 +879,19 @@ sys_getxpid:
879 879
880 /* See linux/kernel/timer.c sys_getppid for discussion 880 /* See linux/kernel/timer.c sys_getppid for discussion
881 about this loop. */ 881 about this loop. */
882 ldq $3, TASK_REAL_PARENT($2) 882 ldq $3, TASK_GROUP_LEADER($2)
8831: ldl $1, TASK_TGID($3) 883 ldq $4, TASK_REAL_PARENT($3)
884 ldl $0, TASK_TGID($2)
8851: ldl $1, TASK_TGID($4)
884#ifdef CONFIG_SMP 886#ifdef CONFIG_SMP
885 mov $3, $4 887 mov $4, $5
886 mb 888 mb
887 ldq $3, TASK_REAL_PARENT($2) 889 ldq $3, TASK_GROUP_LEADER($2)
888 cmpeq $3, $4, $4 890 ldq $4, TASK_REAL_PARENT($3)
889 beq $4, 1b 891 cmpeq $4, $5, $5
892 beq $5, 1b
890#endif 893#endif
891 stq $1, 80($sp) 894 stq $1, 80($sp)
892 ldl $0, TASK_TGID($2)
893 ret 895 ret
894.end sys_getxpid 896.end sys_getxpid
895 897
diff --git a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c
index 76be5cf0de13..9006063e7369 100644
--- a/arch/alpha/kernel/irq.c
+++ b/arch/alpha/kernel/irq.c
@@ -68,34 +68,32 @@ show_interrupts(struct seq_file *p, void *v)
68#ifdef CONFIG_SMP 68#ifdef CONFIG_SMP
69 int j; 69 int j;
70#endif 70#endif
71 int i = *(loff_t *) v; 71 int irq = *(loff_t *) v;
72 struct irqaction * action; 72 struct irqaction * action;
73 unsigned long flags; 73 unsigned long flags;
74 74
75#ifdef CONFIG_SMP 75#ifdef CONFIG_SMP
76 if (i == 0) { 76 if (irq == 0) {
77 seq_puts(p, " "); 77 seq_puts(p, " ");
78 for (i = 0; i < NR_CPUS; i++) 78 for_each_online_cpu(j)
79 if (cpu_online(i)) 79 seq_printf(p, "CPU%d ", j);
80 seq_printf(p, "CPU%d ", i);
81 seq_putc(p, '\n'); 80 seq_putc(p, '\n');
82 } 81 }
83#endif 82#endif
84 83
85 if (i < ACTUAL_NR_IRQS) { 84 if (irq < ACTUAL_NR_IRQS) {
86 spin_lock_irqsave(&irq_desc[i].lock, flags); 85 spin_lock_irqsave(&irq_desc[irq].lock, flags);
87 action = irq_desc[i].action; 86 action = irq_desc[irq].action;
88 if (!action) 87 if (!action)
89 goto unlock; 88 goto unlock;
90 seq_printf(p, "%3d: ",i); 89 seq_printf(p, "%3d: ", irq);
91#ifndef CONFIG_SMP 90#ifndef CONFIG_SMP
92 seq_printf(p, "%10u ", kstat_irqs(i)); 91 seq_printf(p, "%10u ", kstat_irqs(irq));
93#else 92#else
94 for (j = 0; j < NR_CPUS; j++) 93 for_each_online_cpu(j)
95 if (cpu_online(j)) 94 seq_printf(p, "%10u ", kstat_cpu(j).irqs[irq]);
96 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
97#endif 95#endif
98 seq_printf(p, " %14s", irq_desc[i].handler->typename); 96 seq_printf(p, " %14s", irq_desc[irq].handler->typename);
99 seq_printf(p, " %c%s", 97 seq_printf(p, " %c%s",
100 (action->flags & SA_INTERRUPT)?'+':' ', 98 (action->flags & SA_INTERRUPT)?'+':' ',
101 action->name); 99 action->name);
@@ -108,13 +106,12 @@ show_interrupts(struct seq_file *p, void *v)
108 106
109 seq_putc(p, '\n'); 107 seq_putc(p, '\n');
110unlock: 108unlock:
111 spin_unlock_irqrestore(&irq_desc[i].lock, flags); 109 spin_unlock_irqrestore(&irq_desc[irq].lock, flags);
112 } else if (i == ACTUAL_NR_IRQS) { 110 } else if (irq == ACTUAL_NR_IRQS) {
113#ifdef CONFIG_SMP 111#ifdef CONFIG_SMP
114 seq_puts(p, "IPI: "); 112 seq_puts(p, "IPI: ");
115 for (i = 0; i < NR_CPUS; i++) 113 for_each_online_cpu(j)
116 if (cpu_online(i)) 114 seq_printf(p, "%10lu ", cpu_data[j].ipi_count);
117 seq_printf(p, "%10lu ", cpu_data[i].ipi_count);
118 seq_putc(p, '\n'); 115 seq_putc(p, '\n');
119#endif 116#endif
120 seq_printf(p, "ERR: %10lu\n", irq_err_count); 117 seq_printf(p, "ERR: %10lu\n", irq_err_count);
@@ -122,7 +119,6 @@ unlock:
122 return 0; 119 return 0;
123} 120}
124 121
125
126/* 122/*
127 * handle_irq handles all normal device IRQ's (the special 123 * handle_irq handles all normal device IRQ's (the special
128 * SMP cross-CPU interrupts have their own specific 124 * SMP cross-CPU interrupts have their own specific
diff --git a/arch/arm/configs/at91rm9200dk_defconfig b/arch/arm/configs/at91rm9200dk_defconfig
index 5cdd13acf8ff..1fe73d198888 100644
--- a/arch/arm/configs/at91rm9200dk_defconfig
+++ b/arch/arm/configs/at91rm9200dk_defconfig
@@ -85,7 +85,6 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
85# CONFIG_ARCH_CLPS711X is not set 85# CONFIG_ARCH_CLPS711X is not set
86# CONFIG_ARCH_CO285 is not set 86# CONFIG_ARCH_CO285 is not set
87# CONFIG_ARCH_EBSA110 is not set 87# CONFIG_ARCH_EBSA110 is not set
88# CONFIG_ARCH_CAMELOT is not set
89# CONFIG_ARCH_FOOTBRIDGE is not set 88# CONFIG_ARCH_FOOTBRIDGE is not set
90# CONFIG_ARCH_INTEGRATOR is not set 89# CONFIG_ARCH_INTEGRATOR is not set
91# CONFIG_ARCH_IOP3XX is not set 90# CONFIG_ARCH_IOP3XX is not set
diff --git a/arch/arm/configs/at91rm9200ek_defconfig b/arch/arm/configs/at91rm9200ek_defconfig
index 20838ccf1da7..b7d934cdb1b7 100644
--- a/arch/arm/configs/at91rm9200ek_defconfig
+++ b/arch/arm/configs/at91rm9200ek_defconfig
@@ -85,7 +85,6 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
85# CONFIG_ARCH_CLPS711X is not set 85# CONFIG_ARCH_CLPS711X is not set
86# CONFIG_ARCH_CO285 is not set 86# CONFIG_ARCH_CO285 is not set
87# CONFIG_ARCH_EBSA110 is not set 87# CONFIG_ARCH_EBSA110 is not set
88# CONFIG_ARCH_CAMELOT is not set
89# CONFIG_ARCH_FOOTBRIDGE is not set 88# CONFIG_ARCH_FOOTBRIDGE is not set
90# CONFIG_ARCH_INTEGRATOR is not set 89# CONFIG_ARCH_INTEGRATOR is not set
91# CONFIG_ARCH_IOP3XX is not set 90# CONFIG_ARCH_IOP3XX is not set
diff --git a/arch/arm/configs/bast_defconfig b/arch/arm/configs/bast_defconfig
index 6886001b5366..4a8564f386af 100644
--- a/arch/arm/configs/bast_defconfig
+++ b/arch/arm/configs/bast_defconfig
@@ -14,8 +14,7 @@ CONFIG_GENERIC_IOMAP=y
14# Code maturity level options 14# Code maturity level options
15# 15#
16CONFIG_EXPERIMENTAL=y 16CONFIG_EXPERIMENTAL=y
17# CONFIG_CLEAN_COMPILE is not set 17CONFIG_CLEAN_COMPILE=y
18CONFIG_BROKEN=y
19CONFIG_BROKEN_ON_SMP=y 18CONFIG_BROKEN_ON_SMP=y
20 19
21# 20#
@@ -360,7 +359,6 @@ CONFIG_BLK_DEV_IDE_BAST=y
360# 359#
361# IEEE 1394 (FireWire) support 360# IEEE 1394 (FireWire) support
362# 361#
363# CONFIG_IEEE1394 is not set
364 362
365# 363#
366# I2O device support 364# I2O device support
@@ -781,7 +779,6 @@ CONFIG_SYSFS=y
781# CONFIG_DEVFS_FS is not set 779# CONFIG_DEVFS_FS is not set
782# CONFIG_DEVPTS_FS_XATTR is not set 780# CONFIG_DEVPTS_FS_XATTR is not set
783# CONFIG_TMPFS is not set 781# CONFIG_TMPFS is not set
784# CONFIG_HUGETLBFS is not set
785# CONFIG_HUGETLB_PAGE is not set 782# CONFIG_HUGETLB_PAGE is not set
786CONFIG_RAMFS=y 783CONFIG_RAMFS=y
787 784
diff --git a/arch/arm/configs/collie_defconfig b/arch/arm/configs/collie_defconfig
index 15468a0cf70e..c9aa878e610a 100644
--- a/arch/arm/configs/collie_defconfig
+++ b/arch/arm/configs/collie_defconfig
@@ -13,8 +13,7 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
13# Code maturity level options 13# Code maturity level options
14# 14#
15CONFIG_EXPERIMENTAL=y 15CONFIG_EXPERIMENTAL=y
16# CONFIG_CLEAN_COMPILE is not set 16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN=y
18CONFIG_BROKEN_ON_SMP=y 17CONFIG_BROKEN_ON_SMP=y
19CONFIG_LOCK_KERNEL=y 18CONFIG_LOCK_KERNEL=y
20CONFIG_INIT_ENV_ARG_LIMIT=32 19CONFIG_INIT_ENV_ARG_LIMIT=32
@@ -308,9 +307,7 @@ CONFIG_MTD_CFI_I2=y
308# CONFIG_MTD_ROM is not set 307# CONFIG_MTD_ROM is not set
309# CONFIG_MTD_ABSENT is not set 308# CONFIG_MTD_ABSENT is not set
310CONFIG_MTD_OBSOLETE_CHIPS=y 309CONFIG_MTD_OBSOLETE_CHIPS=y
311# CONFIG_MTD_AMDSTD is not set
312CONFIG_MTD_SHARP=y 310CONFIG_MTD_SHARP=y
313# CONFIG_MTD_JEDEC is not set
314 311
315# 312#
316# Mapping drivers for chip access 313# Mapping drivers for chip access
@@ -396,7 +393,6 @@ CONFIG_ATA_OVER_ETH=m
396# 393#
397# IEEE 1394 (FireWire) support 394# IEEE 1394 (FireWire) support
398# 395#
399# CONFIG_IEEE1394 is not set
400 396
401# 397#
402# I2O device support 398# I2O device support
@@ -741,7 +737,6 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
741CONFIG_PROC_FS=y 737CONFIG_PROC_FS=y
742CONFIG_SYSFS=y 738CONFIG_SYSFS=y
743CONFIG_TMPFS=y 739CONFIG_TMPFS=y
744# CONFIG_HUGETLBFS is not set
745# CONFIG_HUGETLB_PAGE is not set 740# CONFIG_HUGETLB_PAGE is not set
746CONFIG_RAMFS=y 741CONFIG_RAMFS=y
747# CONFIG_RELAYFS_FS is not set 742# CONFIG_RELAYFS_FS is not set
diff --git a/arch/arm/configs/csb337_defconfig b/arch/arm/configs/csb337_defconfig
index 885a3184830a..94bd9932a402 100644
--- a/arch/arm/configs/csb337_defconfig
+++ b/arch/arm/configs/csb337_defconfig
@@ -85,7 +85,6 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
85# CONFIG_ARCH_CLPS711X is not set 85# CONFIG_ARCH_CLPS711X is not set
86# CONFIG_ARCH_CO285 is not set 86# CONFIG_ARCH_CO285 is not set
87# CONFIG_ARCH_EBSA110 is not set 87# CONFIG_ARCH_EBSA110 is not set
88# CONFIG_ARCH_CAMELOT is not set
89# CONFIG_ARCH_FOOTBRIDGE is not set 88# CONFIG_ARCH_FOOTBRIDGE is not set
90# CONFIG_ARCH_INTEGRATOR is not set 89# CONFIG_ARCH_INTEGRATOR is not set
91# CONFIG_ARCH_IOP3XX is not set 90# CONFIG_ARCH_IOP3XX is not set
diff --git a/arch/arm/configs/csb637_defconfig b/arch/arm/configs/csb637_defconfig
index 95a96a5462a0..1519124c5501 100644
--- a/arch/arm/configs/csb637_defconfig
+++ b/arch/arm/configs/csb637_defconfig
@@ -85,7 +85,6 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
85# CONFIG_ARCH_CLPS711X is not set 85# CONFIG_ARCH_CLPS711X is not set
86# CONFIG_ARCH_CO285 is not set 86# CONFIG_ARCH_CO285 is not set
87# CONFIG_ARCH_EBSA110 is not set 87# CONFIG_ARCH_EBSA110 is not set
88# CONFIG_ARCH_CAMELOT is not set
89# CONFIG_ARCH_FOOTBRIDGE is not set 88# CONFIG_ARCH_FOOTBRIDGE is not set
90# CONFIG_ARCH_INTEGRATOR is not set 89# CONFIG_ARCH_INTEGRATOR is not set
91# CONFIG_ARCH_IOP3XX is not set 90# CONFIG_ARCH_IOP3XX is not set
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index 33f31080a98c..1964ccd8a71f 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -13,8 +13,7 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
13# Code maturity level options 13# Code maturity level options
14# 14#
15CONFIG_EXPERIMENTAL=y 15CONFIG_EXPERIMENTAL=y
16# CONFIG_CLEAN_COMPILE is not set 16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN=y
18CONFIG_BROKEN_ON_SMP=y 17CONFIG_BROKEN_ON_SMP=y
19CONFIG_INIT_ENV_ARG_LIMIT=32 18CONFIG_INIT_ENV_ARG_LIMIT=32
20 19
@@ -473,7 +472,6 @@ CONFIG_BLK_DEV_IDE_BAST=y
473# 472#
474# IEEE 1394 (FireWire) support 473# IEEE 1394 (FireWire) support
475# 474#
476# CONFIG_IEEE1394 is not set
477 475
478# 476#
479# I2O device support 477# I2O device support
@@ -896,7 +894,6 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
896CONFIG_PROC_FS=y 894CONFIG_PROC_FS=y
897CONFIG_SYSFS=y 895CONFIG_SYSFS=y
898# CONFIG_TMPFS is not set 896# CONFIG_TMPFS is not set
899# CONFIG_HUGETLBFS is not set
900# CONFIG_HUGETLB_PAGE is not set 897# CONFIG_HUGETLB_PAGE is not set
901CONFIG_RAMFS=y 898CONFIG_RAMFS=y
902# CONFIG_RELAYFS_FS is not set 899# CONFIG_RELAYFS_FS is not set
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index 75e6f9a94713..d058e7c12568 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -7,337 +7,334 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 * This file is included twice in entry-common.S 10 * This file is included thrice in entry-common.S
11 */ 11 */
12#ifndef NR_syscalls 12/* 0 */ CALL(sys_restart_syscall)
13#define NR_syscalls 328 13 CALL(sys_exit)
14#else 14 CALL(sys_fork_wrapper)
15 15 CALL(sys_read)
16100: 16 CALL(sys_write)
17/* 0 */ .long sys_restart_syscall 17/* 5 */ CALL(sys_open)
18 .long sys_exit 18 CALL(sys_close)
19 .long sys_fork_wrapper 19 CALL(sys_ni_syscall) /* was sys_waitpid */
20 .long sys_read 20 CALL(sys_creat)
21 .long sys_write 21 CALL(sys_link)
22/* 5 */ .long sys_open 22/* 10 */ CALL(sys_unlink)
23 .long sys_close 23 CALL(sys_execve_wrapper)
24 .long sys_ni_syscall /* was sys_waitpid */ 24 CALL(sys_chdir)
25 .long sys_creat 25 CALL(OBSOLETE(sys_time)) /* used by libc4 */
26 .long sys_link 26 CALL(sys_mknod)
27/* 10 */ .long sys_unlink 27/* 15 */ CALL(sys_chmod)
28 .long sys_execve_wrapper 28 CALL(sys_lchown16)
29 .long sys_chdir 29 CALL(sys_ni_syscall) /* was sys_break */
30 .long OBSOLETE(sys_time) /* used by libc4 */ 30 CALL(sys_ni_syscall) /* was sys_stat */
31 .long sys_mknod 31 CALL(sys_lseek)
32/* 15 */ .long sys_chmod 32/* 20 */ CALL(sys_getpid)
33 .long sys_lchown16 33 CALL(sys_mount)
34 .long sys_ni_syscall /* was sys_break */ 34 CALL(OBSOLETE(sys_oldumount)) /* used by libc4 */
35 .long sys_ni_syscall /* was sys_stat */ 35 CALL(sys_setuid16)
36 .long sys_lseek 36 CALL(sys_getuid16)
37/* 20 */ .long sys_getpid 37/* 25 */ CALL(OBSOLETE(sys_stime))
38 .long sys_mount 38 CALL(sys_ptrace)
39 .long OBSOLETE(sys_oldumount) /* used by libc4 */ 39 CALL(OBSOLETE(sys_alarm)) /* used by libc4 */
40 .long sys_setuid16 40 CALL(sys_ni_syscall) /* was sys_fstat */
41 .long sys_getuid16 41 CALL(sys_pause)
42/* 25 */ .long OBSOLETE(sys_stime) 42/* 30 */ CALL(OBSOLETE(sys_utime)) /* used by libc4 */
43 .long sys_ptrace 43 CALL(sys_ni_syscall) /* was sys_stty */
44 .long OBSOLETE(sys_alarm) /* used by libc4 */ 44 CALL(sys_ni_syscall) /* was sys_getty */
45 .long sys_ni_syscall /* was sys_fstat */ 45 CALL(sys_access)
46 .long sys_pause 46 CALL(sys_nice)
47/* 30 */ .long OBSOLETE(sys_utime) /* used by libc4 */ 47/* 35 */ CALL(sys_ni_syscall) /* was sys_ftime */
48 .long sys_ni_syscall /* was sys_stty */ 48 CALL(sys_sync)
49 .long sys_ni_syscall /* was sys_getty */ 49 CALL(sys_kill)
50 .long sys_access 50 CALL(sys_rename)
51 .long sys_nice 51 CALL(sys_mkdir)
52/* 35 */ .long sys_ni_syscall /* was sys_ftime */ 52/* 40 */ CALL(sys_rmdir)
53 .long sys_sync 53 CALL(sys_dup)
54 .long sys_kill 54 CALL(sys_pipe)
55 .long sys_rename 55 CALL(sys_times)
56 .long sys_mkdir 56 CALL(sys_ni_syscall) /* was sys_prof */
57/* 40 */ .long sys_rmdir 57/* 45 */ CALL(sys_brk)
58 .long sys_dup 58 CALL(sys_setgid16)
59 .long sys_pipe 59 CALL(sys_getgid16)
60 .long sys_times 60 CALL(sys_ni_syscall) /* was sys_signal */
61 .long sys_ni_syscall /* was sys_prof */ 61 CALL(sys_geteuid16)
62/* 45 */ .long sys_brk 62/* 50 */ CALL(sys_getegid16)
63 .long sys_setgid16 63 CALL(sys_acct)
64 .long sys_getgid16 64 CALL(sys_umount)
65 .long sys_ni_syscall /* was sys_signal */ 65 CALL(sys_ni_syscall) /* was sys_lock */
66 .long sys_geteuid16 66 CALL(sys_ioctl)
67/* 50 */ .long sys_getegid16 67/* 55 */ CALL(sys_fcntl)
68 .long sys_acct 68 CALL(sys_ni_syscall) /* was sys_mpx */
69 .long sys_umount 69 CALL(sys_setpgid)
70 .long sys_ni_syscall /* was sys_lock */ 70 CALL(sys_ni_syscall) /* was sys_ulimit */
71 .long sys_ioctl 71 CALL(sys_ni_syscall) /* was sys_olduname */
72/* 55 */ .long sys_fcntl 72/* 60 */ CALL(sys_umask)
73 .long sys_ni_syscall /* was sys_mpx */ 73 CALL(sys_chroot)
74 .long sys_setpgid 74 CALL(sys_ustat)
75 .long sys_ni_syscall /* was sys_ulimit */ 75 CALL(sys_dup2)
76 .long sys_ni_syscall /* was sys_olduname */ 76 CALL(sys_getppid)
77/* 60 */ .long sys_umask 77/* 65 */ CALL(sys_getpgrp)
78 .long sys_chroot 78 CALL(sys_setsid)
79 .long sys_ustat 79 CALL(sys_sigaction)
80 .long sys_dup2 80 CALL(sys_ni_syscall) /* was sys_sgetmask */
81 .long sys_getppid 81 CALL(sys_ni_syscall) /* was sys_ssetmask */
82/* 65 */ .long sys_getpgrp 82/* 70 */ CALL(sys_setreuid16)
83 .long sys_setsid 83 CALL(sys_setregid16)
84 .long sys_sigaction 84 CALL(sys_sigsuspend_wrapper)
85 .long sys_ni_syscall /* was sys_sgetmask */ 85 CALL(sys_sigpending)
86 .long sys_ni_syscall /* was sys_ssetmask */ 86 CALL(sys_sethostname)
87/* 70 */ .long sys_setreuid16 87/* 75 */ CALL(sys_setrlimit)
88 .long sys_setregid16 88 CALL(OBSOLETE(sys_old_getrlimit)) /* used by libc4 */
89 .long sys_sigsuspend_wrapper 89 CALL(sys_getrusage)
90 .long sys_sigpending 90 CALL(sys_gettimeofday)
91 .long sys_sethostname 91 CALL(sys_settimeofday)
92/* 75 */ .long sys_setrlimit 92/* 80 */ CALL(sys_getgroups16)
93 .long OBSOLETE(sys_old_getrlimit) /* used by libc4 */ 93 CALL(sys_setgroups16)
94 .long sys_getrusage 94 CALL(OBSOLETE(old_select)) /* used by libc4 */
95 .long sys_gettimeofday 95 CALL(sys_symlink)
96 .long sys_settimeofday 96 CALL(sys_ni_syscall) /* was sys_lstat */
97/* 80 */ .long sys_getgroups16 97/* 85 */ CALL(sys_readlink)
98 .long sys_setgroups16 98 CALL(sys_uselib)
99 .long OBSOLETE(old_select) /* used by libc4 */ 99 CALL(sys_swapon)
100 .long sys_symlink 100 CALL(sys_reboot)
101 .long sys_ni_syscall /* was sys_lstat */ 101 CALL(OBSOLETE(old_readdir)) /* used by libc4 */
102/* 85 */ .long sys_readlink 102/* 90 */ CALL(OBSOLETE(old_mmap)) /* used by libc4 */
103 .long sys_uselib 103 CALL(sys_munmap)
104 .long sys_swapon 104 CALL(sys_truncate)
105 .long sys_reboot 105 CALL(sys_ftruncate)
106 .long OBSOLETE(old_readdir) /* used by libc4 */ 106 CALL(sys_fchmod)
107/* 90 */ .long OBSOLETE(old_mmap) /* used by libc4 */ 107/* 95 */ CALL(sys_fchown16)
108 .long sys_munmap 108 CALL(sys_getpriority)
109 .long sys_truncate 109 CALL(sys_setpriority)
110 .long sys_ftruncate 110 CALL(sys_ni_syscall) /* was sys_profil */
111 .long sys_fchmod 111 CALL(sys_statfs)
112/* 95 */ .long sys_fchown16 112/* 100 */ CALL(sys_fstatfs)
113 .long sys_getpriority 113 CALL(sys_ni_syscall)
114 .long sys_setpriority 114 CALL(OBSOLETE(sys_socketcall))
115 .long sys_ni_syscall /* was sys_profil */ 115 CALL(sys_syslog)
116 .long sys_statfs 116 CALL(sys_setitimer)
117/* 100 */ .long sys_fstatfs 117/* 105 */ CALL(sys_getitimer)
118 .long sys_ni_syscall 118 CALL(sys_newstat)
119 .long OBSOLETE(sys_socketcall) 119 CALL(sys_newlstat)
120 .long sys_syslog 120 CALL(sys_newfstat)
121 .long sys_setitimer 121 CALL(sys_ni_syscall) /* was sys_uname */
122/* 105 */ .long sys_getitimer 122/* 110 */ CALL(sys_ni_syscall) /* was sys_iopl */
123 .long sys_newstat 123 CALL(sys_vhangup)
124 .long sys_newlstat 124 CALL(sys_ni_syscall)
125 .long sys_newfstat 125 CALL(OBSOLETE(sys_syscall)) /* call a syscall */
126 .long sys_ni_syscall /* was sys_uname */ 126 CALL(sys_wait4)
127/* 110 */ .long sys_ni_syscall /* was sys_iopl */ 127/* 115 */ CALL(sys_swapoff)
128 .long sys_vhangup 128 CALL(sys_sysinfo)
129 .long sys_ni_syscall 129 CALL(OBSOLETE(ABI(sys_ipc, sys_oabi_ipc)))
130 .long OBSOLETE(sys_syscall) /* call a syscall */ 130 CALL(sys_fsync)
131 .long sys_wait4 131 CALL(sys_sigreturn_wrapper)
132/* 115 */ .long sys_swapoff 132/* 120 */ CALL(sys_clone_wrapper)
133 .long sys_sysinfo 133 CALL(sys_setdomainname)
134 .long OBSOLETE(ABI(sys_ipc, sys_oabi_ipc)) 134 CALL(sys_newuname)
135 .long sys_fsync 135 CALL(sys_ni_syscall)
136 .long sys_sigreturn_wrapper 136 CALL(sys_adjtimex)
137/* 120 */ .long sys_clone_wrapper 137/* 125 */ CALL(sys_mprotect)
138 .long sys_setdomainname 138 CALL(sys_sigprocmask)
139 .long sys_newuname 139 CALL(sys_ni_syscall) /* was sys_create_module */
140 .long sys_ni_syscall 140 CALL(sys_init_module)
141 .long sys_adjtimex 141 CALL(sys_delete_module)
142/* 125 */ .long sys_mprotect 142/* 130 */ CALL(sys_ni_syscall) /* was sys_get_kernel_syms */
143 .long sys_sigprocmask 143 CALL(sys_quotactl)
144 .long sys_ni_syscall /* was sys_create_module */ 144 CALL(sys_getpgid)
145 .long sys_init_module 145 CALL(sys_fchdir)
146 .long sys_delete_module 146 CALL(sys_bdflush)
147/* 130 */ .long sys_ni_syscall /* was sys_get_kernel_syms */ 147/* 135 */ CALL(sys_sysfs)
148 .long sys_quotactl 148 CALL(sys_personality)
149 .long sys_getpgid 149 CALL(sys_ni_syscall) /* CALL(_sys_afs_syscall) */
150 .long sys_fchdir 150 CALL(sys_setfsuid16)
151 .long sys_bdflush 151 CALL(sys_setfsgid16)
152/* 135 */ .long sys_sysfs 152/* 140 */ CALL(sys_llseek)
153 .long sys_personality 153 CALL(sys_getdents)
154 .long sys_ni_syscall /* .long _sys_afs_syscall */ 154 CALL(sys_select)
155 .long sys_setfsuid16 155 CALL(sys_flock)
156 .long sys_setfsgid16 156 CALL(sys_msync)
157/* 140 */ .long sys_llseek 157/* 145 */ CALL(sys_readv)
158 .long sys_getdents 158 CALL(sys_writev)
159 .long sys_select 159 CALL(sys_getsid)
160 .long sys_flock 160 CALL(sys_fdatasync)
161 .long sys_msync 161 CALL(sys_sysctl)
162/* 145 */ .long sys_readv 162/* 150 */ CALL(sys_mlock)
163 .long sys_writev 163 CALL(sys_munlock)
164 .long sys_getsid 164 CALL(sys_mlockall)
165 .long sys_fdatasync 165 CALL(sys_munlockall)
166 .long sys_sysctl 166 CALL(sys_sched_setparam)
167/* 150 */ .long sys_mlock 167/* 155 */ CALL(sys_sched_getparam)
168 .long sys_munlock 168 CALL(sys_sched_setscheduler)
169 .long sys_mlockall 169 CALL(sys_sched_getscheduler)
170 .long sys_munlockall 170 CALL(sys_sched_yield)
171 .long sys_sched_setparam 171 CALL(sys_sched_get_priority_max)
172/* 155 */ .long sys_sched_getparam 172/* 160 */ CALL(sys_sched_get_priority_min)
173 .long sys_sched_setscheduler 173 CALL(sys_sched_rr_get_interval)
174 .long sys_sched_getscheduler 174 CALL(sys_nanosleep)
175 .long sys_sched_yield 175 CALL(sys_arm_mremap)
176 .long sys_sched_get_priority_max 176 CALL(sys_setresuid16)
177/* 160 */ .long sys_sched_get_priority_min 177/* 165 */ CALL(sys_getresuid16)
178 .long sys_sched_rr_get_interval 178 CALL(sys_ni_syscall)
179 .long sys_nanosleep 179 CALL(sys_ni_syscall) /* was sys_query_module */
180 .long sys_arm_mremap 180 CALL(sys_poll)
181 .long sys_setresuid16 181 CALL(sys_nfsservctl)
182/* 165 */ .long sys_getresuid16 182/* 170 */ CALL(sys_setresgid16)
183 .long sys_ni_syscall 183 CALL(sys_getresgid16)
184 .long sys_ni_syscall /* was sys_query_module */ 184 CALL(sys_prctl)
185 .long sys_poll 185 CALL(sys_rt_sigreturn_wrapper)
186 .long sys_nfsservctl 186 CALL(sys_rt_sigaction)
187/* 170 */ .long sys_setresgid16 187/* 175 */ CALL(sys_rt_sigprocmask)
188 .long sys_getresgid16 188 CALL(sys_rt_sigpending)
189 .long sys_prctl 189 CALL(sys_rt_sigtimedwait)
190 .long sys_rt_sigreturn_wrapper 190 CALL(sys_rt_sigqueueinfo)
191 .long sys_rt_sigaction 191 CALL(sys_rt_sigsuspend_wrapper)
192/* 175 */ .long sys_rt_sigprocmask 192/* 180 */ CALL(ABI(sys_pread64, sys_oabi_pread64))
193 .long sys_rt_sigpending 193 CALL(ABI(sys_pwrite64, sys_oabi_pwrite64))
194 .long sys_rt_sigtimedwait 194 CALL(sys_chown16)
195 .long sys_rt_sigqueueinfo 195 CALL(sys_getcwd)
196 .long sys_rt_sigsuspend_wrapper 196 CALL(sys_capget)
197/* 180 */ .long ABI(sys_pread64, sys_oabi_pread64) 197/* 185 */ CALL(sys_capset)
198 .long ABI(sys_pwrite64, sys_oabi_pwrite64) 198 CALL(sys_sigaltstack_wrapper)
199 .long sys_chown16 199 CALL(sys_sendfile)
200 .long sys_getcwd 200 CALL(sys_ni_syscall)
201 .long sys_capget 201 CALL(sys_ni_syscall)
202/* 185 */ .long sys_capset 202/* 190 */ CALL(sys_vfork_wrapper)
203 .long sys_sigaltstack_wrapper 203 CALL(sys_getrlimit)
204 .long sys_sendfile 204 CALL(sys_mmap2)
205 .long sys_ni_syscall 205 CALL(ABI(sys_truncate64, sys_oabi_truncate64))
206 .long sys_ni_syscall 206 CALL(ABI(sys_ftruncate64, sys_oabi_ftruncate64))
207/* 190 */ .long sys_vfork_wrapper 207/* 195 */ CALL(ABI(sys_stat64, sys_oabi_stat64))
208 .long sys_getrlimit 208 CALL(ABI(sys_lstat64, sys_oabi_lstat64))
209 .long sys_mmap2 209 CALL(ABI(sys_fstat64, sys_oabi_fstat64))
210 .long ABI(sys_truncate64, sys_oabi_truncate64) 210 CALL(sys_lchown)
211 .long ABI(sys_ftruncate64, sys_oabi_ftruncate64) 211 CALL(sys_getuid)
212/* 195 */ .long ABI(sys_stat64, sys_oabi_stat64) 212/* 200 */ CALL(sys_getgid)
213 .long ABI(sys_lstat64, sys_oabi_lstat64) 213 CALL(sys_geteuid)
214 .long ABI(sys_fstat64, sys_oabi_fstat64) 214 CALL(sys_getegid)
215 .long sys_lchown 215 CALL(sys_setreuid)
216 .long sys_getuid 216 CALL(sys_setregid)
217/* 200 */ .long sys_getgid 217/* 205 */ CALL(sys_getgroups)
218 .long sys_geteuid 218 CALL(sys_setgroups)
219 .long sys_getegid 219 CALL(sys_fchown)
220 .long sys_setreuid 220 CALL(sys_setresuid)
221 .long sys_setregid 221 CALL(sys_getresuid)
222/* 205 */ .long sys_getgroups 222/* 210 */ CALL(sys_setresgid)
223 .long sys_setgroups 223 CALL(sys_getresgid)
224 .long sys_fchown 224 CALL(sys_chown)
225 .long sys_setresuid 225 CALL(sys_setuid)
226 .long sys_getresuid 226 CALL(sys_setgid)
227/* 210 */ .long sys_setresgid 227/* 215 */ CALL(sys_setfsuid)
228 .long sys_getresgid 228 CALL(sys_setfsgid)
229 .long sys_chown 229 CALL(sys_getdents64)
230 .long sys_setuid 230 CALL(sys_pivot_root)
231 .long sys_setgid 231 CALL(sys_mincore)
232/* 215 */ .long sys_setfsuid 232/* 220 */ CALL(sys_madvise)
233 .long sys_setfsgid 233 CALL(ABI(sys_fcntl64, sys_oabi_fcntl64))
234 .long sys_getdents64 234 CALL(sys_ni_syscall) /* TUX */
235 .long sys_pivot_root 235 CALL(sys_ni_syscall)
236 .long sys_mincore 236 CALL(sys_gettid)
237/* 220 */ .long sys_madvise 237/* 225 */ CALL(ABI(sys_readahead, sys_oabi_readahead))
238 .long ABI(sys_fcntl64, sys_oabi_fcntl64) 238 CALL(sys_setxattr)
239 .long sys_ni_syscall /* TUX */ 239 CALL(sys_lsetxattr)
240 .long sys_ni_syscall 240 CALL(sys_fsetxattr)
241 .long sys_gettid 241 CALL(sys_getxattr)
242/* 225 */ .long ABI(sys_readahead, sys_oabi_readahead) 242/* 230 */ CALL(sys_lgetxattr)
243 .long sys_setxattr 243 CALL(sys_fgetxattr)
244 .long sys_lsetxattr 244 CALL(sys_listxattr)
245 .long sys_fsetxattr 245 CALL(sys_llistxattr)
246 .long sys_getxattr 246 CALL(sys_flistxattr)
247/* 230 */ .long sys_lgetxattr 247/* 235 */ CALL(sys_removexattr)
248 .long sys_fgetxattr 248 CALL(sys_lremovexattr)
249 .long sys_listxattr 249 CALL(sys_fremovexattr)
250 .long sys_llistxattr 250 CALL(sys_tkill)
251 .long sys_flistxattr 251 CALL(sys_sendfile64)
252/* 235 */ .long sys_removexattr 252/* 240 */ CALL(sys_futex)
253 .long sys_lremovexattr 253 CALL(sys_sched_setaffinity)
254 .long sys_fremovexattr 254 CALL(sys_sched_getaffinity)
255 .long sys_tkill 255 CALL(sys_io_setup)
256 .long sys_sendfile64 256 CALL(sys_io_destroy)
257/* 240 */ .long sys_futex 257/* 245 */ CALL(sys_io_getevents)
258 .long sys_sched_setaffinity 258 CALL(sys_io_submit)
259 .long sys_sched_getaffinity 259 CALL(sys_io_cancel)
260 .long sys_io_setup 260 CALL(sys_exit_group)
261 .long sys_io_destroy 261 CALL(sys_lookup_dcookie)
262/* 245 */ .long sys_io_getevents 262/* 250 */ CALL(sys_epoll_create)
263 .long sys_io_submit 263 CALL(ABI(sys_epoll_ctl, sys_oabi_epoll_ctl))
264 .long sys_io_cancel 264 CALL(ABI(sys_epoll_wait, sys_oabi_epoll_wait))
265 .long sys_exit_group 265 CALL(sys_remap_file_pages)
266 .long sys_lookup_dcookie 266 CALL(sys_ni_syscall) /* sys_set_thread_area */
267/* 250 */ .long sys_epoll_create 267/* 255 */ CALL(sys_ni_syscall) /* sys_get_thread_area */
268 .long ABI(sys_epoll_ctl, sys_oabi_epoll_ctl) 268 CALL(sys_set_tid_address)
269 .long ABI(sys_epoll_wait, sys_oabi_epoll_wait) 269 CALL(sys_timer_create)
270 .long sys_remap_file_pages 270 CALL(sys_timer_settime)
271 .long sys_ni_syscall /* sys_set_thread_area */ 271 CALL(sys_timer_gettime)
272/* 255 */ .long sys_ni_syscall /* sys_get_thread_area */ 272/* 260 */ CALL(sys_timer_getoverrun)
273 .long sys_set_tid_address 273 CALL(sys_timer_delete)
274 .long sys_timer_create 274 CALL(sys_clock_settime)
275 .long sys_timer_settime 275 CALL(sys_clock_gettime)
276 .long sys_timer_gettime 276 CALL(sys_clock_getres)
277/* 260 */ .long sys_timer_getoverrun 277/* 265 */ CALL(sys_clock_nanosleep)
278 .long sys_timer_delete 278 CALL(sys_statfs64_wrapper)
279 .long sys_clock_settime 279 CALL(sys_fstatfs64_wrapper)
280 .long sys_clock_gettime 280 CALL(sys_tgkill)
281 .long sys_clock_getres 281 CALL(sys_utimes)
282/* 265 */ .long sys_clock_nanosleep 282/* 270 */ CALL(sys_arm_fadvise64_64)
283 .long sys_statfs64_wrapper 283 CALL(sys_pciconfig_iobase)
284 .long sys_fstatfs64_wrapper 284 CALL(sys_pciconfig_read)
285 .long sys_tgkill 285 CALL(sys_pciconfig_write)
286 .long sys_utimes 286 CALL(sys_mq_open)
287/* 270 */ .long sys_arm_fadvise64_64 287/* 275 */ CALL(sys_mq_unlink)
288 .long sys_pciconfig_iobase 288 CALL(sys_mq_timedsend)
289 .long sys_pciconfig_read 289 CALL(sys_mq_timedreceive)
290 .long sys_pciconfig_write 290 CALL(sys_mq_notify)
291 .long sys_mq_open 291 CALL(sys_mq_getsetattr)
292/* 275 */ .long sys_mq_unlink 292/* 280 */ CALL(sys_waitid)
293 .long sys_mq_timedsend 293 CALL(sys_socket)
294 .long sys_mq_timedreceive 294 CALL(sys_bind)
295 .long sys_mq_notify 295 CALL(sys_connect)
296 .long sys_mq_getsetattr 296 CALL(sys_listen)
297/* 280 */ .long sys_waitid 297/* 285 */ CALL(sys_accept)
298 .long sys_socket 298 CALL(sys_getsockname)
299 .long sys_bind 299 CALL(sys_getpeername)
300 .long sys_connect 300 CALL(sys_socketpair)
301 .long sys_listen 301 CALL(sys_send)
302/* 285 */ .long sys_accept 302/* 290 */ CALL(sys_sendto)
303 .long sys_getsockname 303 CALL(sys_recv)
304 .long sys_getpeername 304 CALL(sys_recvfrom)
305 .long sys_socketpair 305 CALL(sys_shutdown)
306 .long sys_send 306 CALL(sys_setsockopt)
307/* 290 */ .long sys_sendto 307/* 295 */ CALL(sys_getsockopt)
308 .long sys_recv 308 CALL(sys_sendmsg)
309 .long sys_recvfrom 309 CALL(sys_recvmsg)
310 .long sys_shutdown 310 CALL(ABI(sys_semop, sys_oabi_semop))
311 .long sys_setsockopt 311 CALL(sys_semget)
312/* 295 */ .long sys_getsockopt 312/* 300 */ CALL(sys_semctl)
313 .long sys_sendmsg 313 CALL(sys_msgsnd)
314 .long sys_recvmsg 314 CALL(sys_msgrcv)
315 .long ABI(sys_semop, sys_oabi_semop) 315 CALL(sys_msgget)
316 .long sys_semget 316 CALL(sys_msgctl)
317/* 300 */ .long sys_semctl 317/* 305 */ CALL(sys_shmat)
318 .long sys_msgsnd 318 CALL(sys_shmdt)
319 .long sys_msgrcv 319 CALL(sys_shmget)
320 .long sys_msgget 320 CALL(sys_shmctl)
321 .long sys_msgctl 321 CALL(sys_add_key)
322/* 305 */ .long sys_shmat 322/* 310 */ CALL(sys_request_key)
323 .long sys_shmdt 323 CALL(sys_keyctl)
324 .long sys_shmget 324 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
325 .long sys_shmctl 325/* vserver */ CALL(sys_ni_syscall)
326 .long sys_add_key 326 CALL(sys_ioprio_set)
327/* 310 */ .long sys_request_key 327/* 315 */ CALL(sys_ioprio_get)
328 .long sys_keyctl 328 CALL(sys_inotify_init)
329 .long ABI(sys_semtimedop, sys_oabi_semtimedop) 329 CALL(sys_inotify_add_watch)
330/* vserver */ .long sys_ni_syscall 330 CALL(sys_inotify_rm_watch)
331 .long sys_ioprio_set 331 CALL(sys_mbind)
332/* 315 */ .long sys_ioprio_get 332/* 320 */ CALL(sys_get_mempolicy)
333 .long sys_inotify_init 333 CALL(sys_set_mempolicy)
334 .long sys_inotify_add_watch 334#ifndef syscalls_counted
335 .long sys_inotify_rm_watch 335.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
336 .long sys_mbind 336#define syscalls_counted
337/* 320 */ .long sys_get_mempolicy
338 .long sys_set_mempolicy
339
340 .rept NR_syscalls - (. - 100b) / 4
341 .long sys_ni_syscall
342 .endr
343#endif 337#endif
338.rept syscalls_padding
339 CALL(sys_ni_syscall)
340.endr
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 2b92ce85f97f..dbcb11a31f78 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -87,7 +87,11 @@ ENTRY(ret_from_fork)
87 b ret_slow_syscall 87 b ret_slow_syscall
88 88
89 89
90 .equ NR_syscalls,0
91#define CALL(x) .equ NR_syscalls,NR_syscalls+1
90#include "calls.S" 92#include "calls.S"
93#undef CALL
94#define CALL(x) .long x
91 95
92/*============================================================================= 96/*=============================================================================
93 * SWI handler 97 * SWI handler
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 31820170f306..a0724f2b24ce 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -469,7 +469,9 @@ static void cp_clcd_enable(struct clcd_fb *fb)
469 if (fb->fb.var.bits_per_pixel <= 8) 469 if (fb->fb.var.bits_per_pixel <= 8)
470 val = CM_CTRL_LCDMUXSEL_VGA_8421BPP; 470 val = CM_CTRL_LCDMUXSEL_VGA_8421BPP;
471 else if (fb->fb.var.bits_per_pixel <= 16) 471 else if (fb->fb.var.bits_per_pixel <= 16)
472 val = CM_CTRL_LCDMUXSEL_VGA_16BPP; 472 val = CM_CTRL_LCDMUXSEL_VGA_16BPP
473 | CM_CTRL_LCDEN0 | CM_CTRL_LCDEN1
474 | CM_CTRL_STATIC1 | CM_CTRL_STATIC2;
473 else 475 else
474 val = 0; /* no idea for this, don't trust the docs */ 476 val = 0; /* no idea for this, don't trust the docs */
475 477
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index b41b1efaa2cf..3baa70819f24 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -44,7 +44,7 @@ unsigned int get_clk_frequency_khz( int info)
44 44
45 /* Read clkcfg register: it has turbo, b, half-turbo (and f) */ 45 /* Read clkcfg register: it has turbo, b, half-turbo (and f) */
46 asm( "mrc\tp14, 0, %0, c6, c0, 0" : "=r" (clkcfg) ); 46 asm( "mrc\tp14, 0, %0, c6, c0, 0" : "=r" (clkcfg) );
47 t = clkcfg & (1 << 1); 47 t = clkcfg & (1 << 0);
48 ht = clkcfg & (1 << 2); 48 ht = clkcfg & (1 << 2);
49 b = clkcfg & (1 << 3); 49 b = clkcfg & (1 << 3);
50 50
diff --git a/arch/arm/mach-s3c2410/Makefile b/arch/arm/mach-s3c2410/Makefile
index b4f1e051c768..1217bf00309c 100644
--- a/arch/arm/mach-s3c2410/Makefile
+++ b/arch/arm/mach-s3c2410/Makefile
@@ -10,9 +10,13 @@ obj-m :=
10obj-n := 10obj-n :=
11obj- := 11obj- :=
12 12
13# S3C2400 support files
14obj-$(CONFIG_CPU_S3C2400) += s3c2400-gpio.o
15
13# S3C2410 support files 16# S3C2410 support files
14 17
15obj-$(CONFIG_CPU_S3C2410) += s3c2410.o 18obj-$(CONFIG_CPU_S3C2410) += s3c2410.o
19obj-$(CONFIG_CPU_S3C2410) += s3c2410-gpio.o
16obj-$(CONFIG_S3C2410_DMA) += dma.o 20obj-$(CONFIG_S3C2410_DMA) += dma.o
17 21
18# Power Management support 22# Power Management support
@@ -25,6 +29,7 @@ obj-$(CONFIG_PM_SIMTEC) += pm-simtec.o
25obj-$(CONFIG_CPU_S3C2440) += s3c2440.o s3c2440-dsc.o 29obj-$(CONFIG_CPU_S3C2440) += s3c2440.o s3c2440-dsc.o
26obj-$(CONFIG_CPU_S3C2440) += s3c2440-irq.o 30obj-$(CONFIG_CPU_S3C2440) += s3c2440-irq.o
27obj-$(CONFIG_CPU_S3C2440) += s3c2440-clock.o 31obj-$(CONFIG_CPU_S3C2440) += s3c2440-clock.o
32obj-$(CONFIG_CPU_S3C2440) += s3c2410-gpio.o
28 33
29# bast extras 34# bast extras
30 35
diff --git a/arch/arm/mach-s3c2410/cpu.c b/arch/arm/mach-s3c2410/cpu.c
index 687fe371369d..00a379334b60 100644
--- a/arch/arm/mach-s3c2410/cpu.c
+++ b/arch/arm/mach-s3c2410/cpu.c
@@ -40,6 +40,7 @@
40 40
41#include "cpu.h" 41#include "cpu.h"
42#include "clock.h" 42#include "clock.h"
43#include "s3c2400.h"
43#include "s3c2410.h" 44#include "s3c2410.h"
44#include "s3c2440.h" 45#include "s3c2440.h"
45 46
@@ -55,6 +56,7 @@ struct cpu_table {
55 56
56/* table of supported CPUs */ 57/* table of supported CPUs */
57 58
59static const char name_s3c2400[] = "S3C2400";
58static const char name_s3c2410[] = "S3C2410"; 60static const char name_s3c2410[] = "S3C2410";
59static const char name_s3c2440[] = "S3C2440"; 61static const char name_s3c2440[] = "S3C2440";
60static const char name_s3c2410a[] = "S3C2410A"; 62static const char name_s3c2410a[] = "S3C2410A";
@@ -96,7 +98,16 @@ static struct cpu_table cpu_ids[] __initdata = {
96 .init_uarts = s3c2440_init_uarts, 98 .init_uarts = s3c2440_init_uarts,
97 .init = s3c2440_init, 99 .init = s3c2440_init,
98 .name = name_s3c2440a 100 .name = name_s3c2440a
99 } 101 },
102 {
103 .idcode = 0x0, /* S3C2400 doesn't have an idcode */
104 .idmask = 0xffffffff,
105 .map_io = s3c2400_map_io,
106 .init_clocks = s3c2400_init_clocks,
107 .init_uarts = s3c2400_init_uarts,
108 .init = s3c2400_init,
109 .name = name_s3c2400
110 },
100}; 111};
101 112
102/* minimal IO mapping */ 113/* minimal IO mapping */
@@ -148,12 +159,15 @@ static struct cpu_table *cpu;
148 159
149void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) 160void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
150{ 161{
151 unsigned long idcode; 162 unsigned long idcode = 0x0;
152 163
153 /* initialise the io descriptors we need for initialisation */ 164 /* initialise the io descriptors we need for initialisation */
154 iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); 165 iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
155 166
167#ifndef CONFIG_CPU_S3C2400
156 idcode = __raw_readl(S3C2410_GSTATUS1); 168 idcode = __raw_readl(S3C2410_GSTATUS1);
169#endif
170
157 cpu = s3c_lookup_cpu(idcode); 171 cpu = s3c_lookup_cpu(idcode);
158 172
159 if (cpu == NULL) { 173 if (cpu == NULL) {
diff --git a/arch/arm/mach-s3c2410/cpu.h b/arch/arm/mach-s3c2410/cpu.h
index 9cbe5eef492b..fc1067783f6d 100644
--- a/arch/arm/mach-s3c2410/cpu.h
+++ b/arch/arm/mach-s3c2410/cpu.h
@@ -17,11 +17,12 @@
17 * 14-Jan-2005 BJD Added s3c24xx_init_clocks() call 17 * 14-Jan-2005 BJD Added s3c24xx_init_clocks() call
18 * 10-Mar-2005 LCVR Changed S3C2410_{VA,SZ} to S3C24XX_{VA,SZ} & IODESC_ENT 18 * 10-Mar-2005 LCVR Changed S3C2410_{VA,SZ} to S3C24XX_{VA,SZ} & IODESC_ENT
19 * 14-Mar-2005 BJD Updated for __iomem 19 * 14-Mar-2005 BJD Updated for __iomem
20 * 15-Jan-2006 LCVR Updated S3C2410_PA_##x to new S3C24XX_PA_##x macro
20*/ 21*/
21 22
22/* todo - fix when rmk changes iodescs to use `void __iomem *` */ 23/* todo - fix when rmk changes iodescs to use `void __iomem *` */
23 24
24#define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C2410_PA_##x), S3C24XX_SZ_##x, MT_DEVICE } 25#define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE }
25 26
26#ifndef MHZ 27#ifndef MHZ
27#define MHZ (1000*1000) 28#define MHZ (1000*1000)
diff --git a/arch/arm/mach-s3c2410/devs.c b/arch/arm/mach-s3c2410/devs.c
index f58406e6ef5a..b8d994a24d1c 100644
--- a/arch/arm/mach-s3c2410/devs.c
+++ b/arch/arm/mach-s3c2410/devs.c
@@ -10,6 +10,7 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 * 11 *
12 * Modifications: 12 * Modifications:
13 * 15-Jan-2006 LCVR Using S3C24XX_PA_##x macro for common S3C24XX devices
13 * 10-Mar-2005 LCVR Changed S3C2410_{VA,SZ} to S3C24XX_{VA,SZ} 14 * 10-Mar-2005 LCVR Changed S3C2410_{VA,SZ} to S3C24XX_{VA,SZ}
14 * 10-Feb-2005 BJD Added camera from guillaume.gourat@nexvision.tv 15 * 10-Feb-2005 BJD Added camera from guillaume.gourat@nexvision.tv
15 * 29-Aug-2004 BJD Added timers 0 through 3 16 * 29-Aug-2004 BJD Added timers 0 through 3
@@ -46,8 +47,8 @@ struct platform_device *s3c24xx_uart_devs[3];
46 47
47static struct resource s3c_usb_resource[] = { 48static struct resource s3c_usb_resource[] = {
48 [0] = { 49 [0] = {
49 .start = S3C2410_PA_USBHOST, 50 .start = S3C24XX_PA_USBHOST,
50 .end = S3C2410_PA_USBHOST + S3C24XX_SZ_USBHOST - 1, 51 .end = S3C24XX_PA_USBHOST + S3C24XX_SZ_USBHOST - 1,
51 .flags = IORESOURCE_MEM, 52 .flags = IORESOURCE_MEM,
52 }, 53 },
53 [1] = { 54 [1] = {
@@ -76,8 +77,8 @@ EXPORT_SYMBOL(s3c_device_usb);
76 77
77static struct resource s3c_lcd_resource[] = { 78static struct resource s3c_lcd_resource[] = {
78 [0] = { 79 [0] = {
79 .start = S3C2410_PA_LCD, 80 .start = S3C24XX_PA_LCD,
80 .end = S3C2410_PA_LCD + S3C24XX_SZ_LCD - 1, 81 .end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1,
81 .flags = IORESOURCE_MEM, 82 .flags = IORESOURCE_MEM,
82 }, 83 },
83 [1] = { 84 [1] = {
@@ -139,8 +140,8 @@ EXPORT_SYMBOL(s3c_device_nand);
139 140
140static struct resource s3c_usbgadget_resource[] = { 141static struct resource s3c_usbgadget_resource[] = {
141 [0] = { 142 [0] = {
142 .start = S3C2410_PA_USBDEV, 143 .start = S3C24XX_PA_USBDEV,
143 .end = S3C2410_PA_USBDEV + S3C24XX_SZ_USBDEV - 1, 144 .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
144 .flags = IORESOURCE_MEM, 145 .flags = IORESOURCE_MEM,
145 }, 146 },
146 [1] = { 147 [1] = {
@@ -164,8 +165,8 @@ EXPORT_SYMBOL(s3c_device_usbgadget);
164 165
165static struct resource s3c_wdt_resource[] = { 166static struct resource s3c_wdt_resource[] = {
166 [0] = { 167 [0] = {
167 .start = S3C2410_PA_WATCHDOG, 168 .start = S3C24XX_PA_WATCHDOG,
168 .end = S3C2410_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG - 1, 169 .end = S3C24XX_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG - 1,
169 .flags = IORESOURCE_MEM, 170 .flags = IORESOURCE_MEM,
170 }, 171 },
171 [1] = { 172 [1] = {
@@ -189,8 +190,8 @@ EXPORT_SYMBOL(s3c_device_wdt);
189 190
190static struct resource s3c_i2c_resource[] = { 191static struct resource s3c_i2c_resource[] = {
191 [0] = { 192 [0] = {
192 .start = S3C2410_PA_IIC, 193 .start = S3C24XX_PA_IIC,
193 .end = S3C2410_PA_IIC + S3C24XX_SZ_IIC - 1, 194 .end = S3C24XX_PA_IIC + S3C24XX_SZ_IIC - 1,
194 .flags = IORESOURCE_MEM, 195 .flags = IORESOURCE_MEM,
195 }, 196 },
196 [1] = { 197 [1] = {
@@ -214,8 +215,8 @@ EXPORT_SYMBOL(s3c_device_i2c);
214 215
215static struct resource s3c_iis_resource[] = { 216static struct resource s3c_iis_resource[] = {
216 [0] = { 217 [0] = {
217 .start = S3C2410_PA_IIS, 218 .start = S3C24XX_PA_IIS,
218 .end = S3C2410_PA_IIS + S3C24XX_SZ_IIS -1, 219 .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1,
219 .flags = IORESOURCE_MEM, 220 .flags = IORESOURCE_MEM,
220 } 221 }
221}; 222};
@@ -239,8 +240,8 @@ EXPORT_SYMBOL(s3c_device_iis);
239 240
240static struct resource s3c_rtc_resource[] = { 241static struct resource s3c_rtc_resource[] = {
241 [0] = { 242 [0] = {
242 .start = S3C2410_PA_RTC, 243 .start = S3C24XX_PA_RTC,
243 .end = S3C2410_PA_RTC + 0xff, 244 .end = S3C24XX_PA_RTC + 0xff,
244 .flags = IORESOURCE_MEM, 245 .flags = IORESOURCE_MEM,
245 }, 246 },
246 [1] = { 247 [1] = {
@@ -268,8 +269,8 @@ EXPORT_SYMBOL(s3c_device_rtc);
268 269
269static struct resource s3c_adc_resource[] = { 270static struct resource s3c_adc_resource[] = {
270 [0] = { 271 [0] = {
271 .start = S3C2410_PA_ADC, 272 .start = S3C24XX_PA_ADC,
272 .end = S3C2410_PA_ADC + S3C24XX_SZ_ADC - 1, 273 .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
273 .flags = IORESOURCE_MEM, 274 .flags = IORESOURCE_MEM,
274 }, 275 },
275 [1] = { 276 [1] = {
@@ -316,8 +317,8 @@ EXPORT_SYMBOL(s3c_device_sdi);
316 317
317static struct resource s3c_spi0_resource[] = { 318static struct resource s3c_spi0_resource[] = {
318 [0] = { 319 [0] = {
319 .start = S3C2410_PA_SPI, 320 .start = S3C24XX_PA_SPI,
320 .end = S3C2410_PA_SPI + 0x1f, 321 .end = S3C24XX_PA_SPI + 0x1f,
321 .flags = IORESOURCE_MEM, 322 .flags = IORESOURCE_MEM,
322 }, 323 },
323 [1] = { 324 [1] = {
@@ -341,8 +342,8 @@ EXPORT_SYMBOL(s3c_device_spi0);
341 342
342static struct resource s3c_spi1_resource[] = { 343static struct resource s3c_spi1_resource[] = {
343 [0] = { 344 [0] = {
344 .start = S3C2410_PA_SPI + 0x20, 345 .start = S3C24XX_PA_SPI + 0x20,
345 .end = S3C2410_PA_SPI + 0x20 + 0x1f, 346 .end = S3C24XX_PA_SPI + 0x20 + 0x1f,
346 .flags = IORESOURCE_MEM, 347 .flags = IORESOURCE_MEM,
347 }, 348 },
348 [1] = { 349 [1] = {
@@ -366,8 +367,8 @@ EXPORT_SYMBOL(s3c_device_spi1);
366 367
367static struct resource s3c_timer0_resource[] = { 368static struct resource s3c_timer0_resource[] = {
368 [0] = { 369 [0] = {
369 .start = S3C2410_PA_TIMER + 0x0C, 370 .start = S3C24XX_PA_TIMER + 0x0C,
370 .end = S3C2410_PA_TIMER + 0x0C + 0xB, 371 .end = S3C24XX_PA_TIMER + 0x0C + 0xB,
371 .flags = IORESOURCE_MEM, 372 .flags = IORESOURCE_MEM,
372 }, 373 },
373 [1] = { 374 [1] = {
@@ -391,8 +392,8 @@ EXPORT_SYMBOL(s3c_device_timer0);
391 392
392static struct resource s3c_timer1_resource[] = { 393static struct resource s3c_timer1_resource[] = {
393 [0] = { 394 [0] = {
394 .start = S3C2410_PA_TIMER + 0x18, 395 .start = S3C24XX_PA_TIMER + 0x18,
395 .end = S3C2410_PA_TIMER + 0x23, 396 .end = S3C24XX_PA_TIMER + 0x23,
396 .flags = IORESOURCE_MEM, 397 .flags = IORESOURCE_MEM,
397 }, 398 },
398 [1] = { 399 [1] = {
@@ -416,8 +417,8 @@ EXPORT_SYMBOL(s3c_device_timer1);
416 417
417static struct resource s3c_timer2_resource[] = { 418static struct resource s3c_timer2_resource[] = {
418 [0] = { 419 [0] = {
419 .start = S3C2410_PA_TIMER + 0x24, 420 .start = S3C24XX_PA_TIMER + 0x24,
420 .end = S3C2410_PA_TIMER + 0x2F, 421 .end = S3C24XX_PA_TIMER + 0x2F,
421 .flags = IORESOURCE_MEM, 422 .flags = IORESOURCE_MEM,
422 }, 423 },
423 [1] = { 424 [1] = {
@@ -441,8 +442,8 @@ EXPORT_SYMBOL(s3c_device_timer2);
441 442
442static struct resource s3c_timer3_resource[] = { 443static struct resource s3c_timer3_resource[] = {
443 [0] = { 444 [0] = {
444 .start = S3C2410_PA_TIMER + 0x30, 445 .start = S3C24XX_PA_TIMER + 0x30,
445 .end = S3C2410_PA_TIMER + 0x3B, 446 .end = S3C24XX_PA_TIMER + 0x3B,
446 .flags = IORESOURCE_MEM, 447 .flags = IORESOURCE_MEM,
447 }, 448 },
448 [1] = { 449 [1] = {
diff --git a/arch/arm/mach-s3c2410/dma.c b/arch/arm/mach-s3c2410/dma.c
index 65feaf20d23e..4dbd8e758ea6 100644
--- a/arch/arm/mach-s3c2410/dma.c
+++ b/arch/arm/mach-s3c2410/dma.c
@@ -1152,7 +1152,7 @@ static int __init s3c2410_init_dma(void)
1152 1152
1153 printk("S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics\n"); 1153 printk("S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics\n");
1154 1154
1155 dma_base = ioremap(S3C2410_PA_DMA, 0x200); 1155 dma_base = ioremap(S3C24XX_PA_DMA, 0x200);
1156 if (dma_base == NULL) { 1156 if (dma_base == NULL) {
1157 printk(KERN_ERR "dma failed to remap register block\n"); 1157 printk(KERN_ERR "dma failed to remap register block\n");
1158 return -ENOMEM; 1158 return -ENOMEM;
diff --git a/arch/arm/mach-s3c2410/gpio.c b/arch/arm/mach-s3c2410/gpio.c
index 23ea3d5fa09c..cd39e8684584 100644
--- a/arch/arm/mach-s3c2410/gpio.c
+++ b/arch/arm/mach-s3c2410/gpio.c
@@ -31,6 +31,7 @@
31 * 05-Nov-2004 BJD EXPORT_SYMBOL() added for all code 31 * 05-Nov-2004 BJD EXPORT_SYMBOL() added for all code
32 * 13-Mar-2005 BJD Updates for __iomem 32 * 13-Mar-2005 BJD Updates for __iomem
33 * 26-Oct-2005 BJD Added generic configuration types 33 * 26-Oct-2005 BJD Added generic configuration types
34 * 15-Jan-2006 LCVR Added support for the S3C2400
34 */ 35 */
35 36
36 37
@@ -48,7 +49,7 @@
48 49
49void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function) 50void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function)
50{ 51{
51 void __iomem *base = S3C2410_GPIO_BASE(pin); 52 void __iomem *base = S3C24XX_GPIO_BASE(pin);
52 unsigned long mask; 53 unsigned long mask;
53 unsigned long con; 54 unsigned long con;
54 unsigned long flags; 55 unsigned long flags;
@@ -95,7 +96,7 @@ EXPORT_SYMBOL(s3c2410_gpio_cfgpin);
95 96
96unsigned int s3c2410_gpio_getcfg(unsigned int pin) 97unsigned int s3c2410_gpio_getcfg(unsigned int pin)
97{ 98{
98 void __iomem *base = S3C2410_GPIO_BASE(pin); 99 void __iomem *base = S3C24XX_GPIO_BASE(pin);
99 unsigned long mask; 100 unsigned long mask;
100 101
101 if (pin < S3C2410_GPIO_BANKB) { 102 if (pin < S3C2410_GPIO_BANKB) {
@@ -111,7 +112,7 @@ EXPORT_SYMBOL(s3c2410_gpio_getcfg);
111 112
112void s3c2410_gpio_pullup(unsigned int pin, unsigned int to) 113void s3c2410_gpio_pullup(unsigned int pin, unsigned int to)
113{ 114{
114 void __iomem *base = S3C2410_GPIO_BASE(pin); 115 void __iomem *base = S3C24XX_GPIO_BASE(pin);
115 unsigned long offs = S3C2410_GPIO_OFFSET(pin); 116 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
116 unsigned long flags; 117 unsigned long flags;
117 unsigned long up; 118 unsigned long up;
@@ -133,7 +134,7 @@ EXPORT_SYMBOL(s3c2410_gpio_pullup);
133 134
134void s3c2410_gpio_setpin(unsigned int pin, unsigned int to) 135void s3c2410_gpio_setpin(unsigned int pin, unsigned int to)
135{ 136{
136 void __iomem *base = S3C2410_GPIO_BASE(pin); 137 void __iomem *base = S3C24XX_GPIO_BASE(pin);
137 unsigned long offs = S3C2410_GPIO_OFFSET(pin); 138 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
138 unsigned long flags; 139 unsigned long flags;
139 unsigned long dat; 140 unsigned long dat;
@@ -152,7 +153,7 @@ EXPORT_SYMBOL(s3c2410_gpio_setpin);
152 153
153unsigned int s3c2410_gpio_getpin(unsigned int pin) 154unsigned int s3c2410_gpio_getpin(unsigned int pin)
154{ 155{
155 void __iomem *base = S3C2410_GPIO_BASE(pin); 156 void __iomem *base = S3C24XX_GPIO_BASE(pin);
156 unsigned long offs = S3C2410_GPIO_OFFSET(pin); 157 unsigned long offs = S3C2410_GPIO_OFFSET(pin);
157 158
158 return __raw_readl(base + 0x04) & (1<< offs); 159 return __raw_readl(base + 0x04) & (1<< offs);
@@ -166,70 +167,13 @@ unsigned int s3c2410_modify_misccr(unsigned int clear, unsigned int change)
166 unsigned long misccr; 167 unsigned long misccr;
167 168
168 local_irq_save(flags); 169 local_irq_save(flags);
169 misccr = __raw_readl(S3C2410_MISCCR); 170 misccr = __raw_readl(S3C24XX_MISCCR);
170 misccr &= ~clear; 171 misccr &= ~clear;
171 misccr ^= change; 172 misccr ^= change;
172 __raw_writel(misccr, S3C2410_MISCCR); 173 __raw_writel(misccr, S3C24XX_MISCCR);
173 local_irq_restore(flags); 174 local_irq_restore(flags);
174 175
175 return misccr; 176 return misccr;
176} 177}
177 178
178EXPORT_SYMBOL(s3c2410_modify_misccr); 179EXPORT_SYMBOL(s3c2410_modify_misccr);
179
180int s3c2410_gpio_getirq(unsigned int pin)
181{
182 if (pin < S3C2410_GPF0 || pin > S3C2410_GPG15_EINT23)
183 return -1; /* not valid interrupts */
184
185 if (pin < S3C2410_GPG0 && pin > S3C2410_GPF7)
186 return -1; /* not valid pin */
187
188 if (pin < S3C2410_GPF4)
189 return (pin - S3C2410_GPF0) + IRQ_EINT0;
190
191 if (pin < S3C2410_GPG0)
192 return (pin - S3C2410_GPF4) + IRQ_EINT4;
193
194 return (pin - S3C2410_GPG0) + IRQ_EINT8;
195}
196
197EXPORT_SYMBOL(s3c2410_gpio_getirq);
198
199int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on,
200 unsigned int config)
201{
202 void __iomem *reg = S3C2410_EINFLT0;
203 unsigned long flags;
204 unsigned long val;
205
206 if (pin < S3C2410_GPG8 || pin > S3C2410_GPG15)
207 return -1;
208
209 config &= 0xff;
210
211 pin -= S3C2410_GPG8_EINT16;
212 reg += pin & ~3;
213
214 local_irq_save(flags);
215
216 /* update filter width and clock source */
217
218 val = __raw_readl(reg);
219 val &= ~(0xff << ((pin & 3) * 8));
220 val |= config << ((pin & 3) * 8);
221 __raw_writel(val, reg);
222
223 /* update filter enable */
224
225 val = __raw_readl(S3C2410_EXTINT2);
226 val &= ~(1 << ((pin * 4) + 3));
227 val |= on << ((pin * 4) + 3);
228 __raw_writel(val, S3C2410_EXTINT2);
229
230 local_irq_restore(flags);
231
232 return 0;
233}
234
235EXPORT_SYMBOL(s3c2410_gpio_irqfilter);
diff --git a/arch/arm/mach-s3c2410/s3c2400-gpio.c b/arch/arm/mach-s3c2410/s3c2400-gpio.c
new file mode 100644
index 000000000000..5127f39fa9bf
--- /dev/null
+++ b/arch/arm/mach-s3c2410/s3c2400-gpio.c
@@ -0,0 +1,45 @@
1/* linux/arch/arm/mach-s3c2410/gpio.c
2 *
3 * Copyright (c) 2006 Lucas Correia Villa Real <lucasvr@gobolinux.org>
4 *
5 * S3C2400 GPIO support
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 as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * Changelog
22 * 15-Jan-2006 LCVR Splitted from gpio.c, adding support for the S3C2400
23 */
24
25#include <linux/kernel.h>
26#include <linux/init.h>
27#include <linux/module.h>
28#include <linux/interrupt.h>
29#include <linux/ioport.h>
30
31#include <asm/hardware.h>
32#include <asm/irq.h>
33#include <asm/io.h>
34
35#include <asm/arch/regs-gpio.h>
36
37int s3c2400_gpio_getirq(unsigned int pin)
38{
39 if (pin < S3C2410_GPE0 || pin > S3C2400_GPE7_EINT7)
40 return -1; /* not valid interrupts */
41
42 return (pin - S3C2410_GPE0) + IRQ_EINT0;
43}
44
45EXPORT_SYMBOL(s3c2400_gpio_getirq);
diff --git a/arch/arm/mach-s3c2410/s3c2410-gpio.c b/arch/arm/mach-s3c2410/s3c2410-gpio.c
new file mode 100644
index 000000000000..d5e1caea1d23
--- /dev/null
+++ b/arch/arm/mach-s3c2410/s3c2410-gpio.c
@@ -0,0 +1,93 @@
1/* linux/arch/arm/mach-s3c2410/gpio.c
2 *
3 * Copyright (c) 2004-2006 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 GPIO support
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 * Changelog
23 * 15-Jan-2006 LCVR Splitted from gpio.c
24 */
25
26#include <linux/kernel.h>
27#include <linux/init.h>
28#include <linux/module.h>
29#include <linux/interrupt.h>
30#include <linux/ioport.h>
31
32#include <asm/hardware.h>
33#include <asm/irq.h>
34#include <asm/io.h>
35
36#include <asm/arch/regs-gpio.h>
37
38int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on,
39 unsigned int config)
40{
41 void __iomem *reg = S3C2410_EINFLT0;
42 unsigned long flags;
43 unsigned long val;
44
45 if (pin < S3C2410_GPG8 || pin > S3C2410_GPG15)
46 return -1;
47
48 config &= 0xff;
49
50 pin -= S3C2410_GPG8_EINT16;
51 reg += pin & ~3;
52
53 local_irq_save(flags);
54
55 /* update filter width and clock source */
56
57 val = __raw_readl(reg);
58 val &= ~(0xff << ((pin & 3) * 8));
59 val |= config << ((pin & 3) * 8);
60 __raw_writel(val, reg);
61
62 /* update filter enable */
63
64 val = __raw_readl(S3C2410_EXTINT2);
65 val &= ~(1 << ((pin * 4) + 3));
66 val |= on << ((pin * 4) + 3);
67 __raw_writel(val, S3C2410_EXTINT2);
68
69 local_irq_restore(flags);
70
71 return 0;
72}
73
74EXPORT_SYMBOL(s3c2410_gpio_irqfilter);
75
76int s3c2410_gpio_getirq(unsigned int pin)
77{
78 if (pin < S3C2410_GPF0 || pin > S3C2410_GPG15_EINT23)
79 return -1; /* not valid interrupts */
80
81 if (pin < S3C2410_GPG0 && pin > S3C2410_GPF7)
82 return -1; /* not valid pin */
83
84 if (pin < S3C2410_GPF4)
85 return (pin - S3C2410_GPF0) + IRQ_EINT0;
86
87 if (pin < S3C2410_GPG0)
88 return (pin - S3C2410_GPF4) + IRQ_EINT4;
89
90 return (pin - S3C2410_GPG0) + IRQ_EINT8;
91}
92
93EXPORT_SYMBOL(s3c2410_gpio_getirq);
diff --git a/arch/arm/mach-s3c2410/sleep.S b/arch/arm/mach-s3c2410/sleep.S
index 61768dac7fee..832fb86a03b4 100644
--- a/arch/arm/mach-s3c2410/sleep.S
+++ b/arch/arm/mach-s3c2410/sleep.S
@@ -72,7 +72,7 @@ ENTRY(s3c2410_cpu_suspend)
72 @@ prepare cpu to sleep 72 @@ prepare cpu to sleep
73 73
74 ldr r4, =S3C2410_REFRESH 74 ldr r4, =S3C2410_REFRESH
75 ldr r5, =S3C2410_MISCCR 75 ldr r5, =S3C24XX_MISCCR
76 ldr r6, =S3C2410_CLKCON 76 ldr r6, =S3C2410_CLKCON
77 ldr r7, [ r4 ] @ get REFRESH (and ensure in TLB) 77 ldr r7, [ r4 ] @ get REFRESH (and ensure in TLB)
78 ldr r8, [ r5 ] @ get MISCCR (and ensure in TLB) 78 ldr r8, [ r5 ] @ get MISCCR (and ensure in TLB)
@@ -133,12 +133,12 @@ ENTRY(s3c2410_cpu_resume)
133 @@ load UART to allow us to print the two characters for 133 @@ load UART to allow us to print the two characters for
134 @@ resume debug 134 @@ resume debug
135 135
136 mov r2, #S3C2410_PA_UART & 0xff000000 136 mov r2, #S3C24XX_PA_UART & 0xff000000
137 orr r2, r2, #S3C2410_PA_UART & 0xff000 137 orr r2, r2, #S3C24XX_PA_UART & 0xff000
138 138
139#if 0 139#if 0
140 /* SMDK2440 LED set */ 140 /* SMDK2440 LED set */
141 mov r14, #S3C2410_PA_GPIO 141 mov r14, #S3C24XX_PA_GPIO
142 ldr r12, [ r14, #0x54 ] 142 ldr r12, [ r14, #0x54 ]
143 bic r12, r12, #3<<4 143 bic r12, r12, #3<<4
144 orr r12, r12, #1<<7 144 orr r12, r12, #1<<7
diff --git a/arch/arm/mm/cache-v6.S b/arch/arm/mm/cache-v6.S
index 72966d90e956..d921c1024ae0 100644
--- a/arch/arm/mm/cache-v6.S
+++ b/arch/arm/mm/cache-v6.S
@@ -92,22 +92,16 @@ ENTRY(v6_coherent_kern_range)
92 * - the Icache does not read data from the write buffer 92 * - the Icache does not read data from the write buffer
93 */ 93 */
94ENTRY(v6_coherent_user_range) 94ENTRY(v6_coherent_user_range)
95 bic r0, r0, #CACHE_LINE_SIZE - 1 95
961:
97#ifdef HARVARD_CACHE 96#ifdef HARVARD_CACHE
98 mcr p15, 0, r0, c7, c10, 1 @ clean D line 97 bic r0, r0, #CACHE_LINE_SIZE - 1
981: mcr p15, 0, r0, c7, c10, 1 @ clean D line
99 mcr p15, 0, r0, c7, c5, 1 @ invalidate I line 99 mcr p15, 0, r0, c7, c5, 1 @ invalidate I line
100#endif 100 add r0, r0, #CACHE_LINE_SIZE
101 mcr p15, 0, r0, c7, c5, 7 @ invalidate BTB entry
102 add r0, r0, #BTB_FLUSH_SIZE
103 mcr p15, 0, r0, c7, c5, 7 @ invalidate BTB entry
104 add r0, r0, #BTB_FLUSH_SIZE
105 mcr p15, 0, r0, c7, c5, 7 @ invalidate BTB entry
106 add r0, r0, #BTB_FLUSH_SIZE
107 mcr p15, 0, r0, c7, c5, 7 @ invalidate BTB entry
108 add r0, r0, #BTB_FLUSH_SIZE
109 cmp r0, r1 101 cmp r0, r1
110 blo 1b 102 blo 1b
103#endif
104 mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB
111#ifdef HARVARD_CACHE 105#ifdef HARVARD_CACHE
112 mov r0, #0 106 mov r0, #0
113 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer 107 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index de3ce1eec2ec..da9b35974118 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -142,7 +142,7 @@ __ioremap_pfn(unsigned long pfn, unsigned long offset, size_t size,
142 return NULL; 142 return NULL;
143 addr = (unsigned long)area->addr; 143 addr = (unsigned long)area->addr;
144 if (remap_area_pages(addr, pfn, size, flags)) { 144 if (remap_area_pages(addr, pfn, size, flags)) {
145 vfree(addr); 145 vfree((void *)addr);
146 return NULL; 146 return NULL;
147 } 147 }
148 return (void __iomem *) (offset + (char *)addr); 148 return (void __iomem *) (offset + (char *)addr);
diff --git a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
index d0245a31d4dd..ef8d30a185a9 100644
--- a/arch/arm/mm/mm-armv.c
+++ b/arch/arm/mm/mm-armv.c
@@ -343,6 +343,12 @@ static struct mem_types mem_types[] __initdata = {
343 PMD_SECT_AP_WRITE | PMD_SECT_BUFFERABLE | 343 PMD_SECT_AP_WRITE | PMD_SECT_BUFFERABLE |
344 PMD_SECT_TEX(1), 344 PMD_SECT_TEX(1),
345 .domain = DOMAIN_IO, 345 .domain = DOMAIN_IO,
346 },
347 [MT_NONSHARED_DEVICE] = {
348 .prot_l1 = PMD_TYPE_TABLE,
349 .prot_sect = PMD_TYPE_SECT | PMD_SECT_NONSHARED_DEV |
350 PMD_SECT_AP_WRITE,
351 .domain = DOMAIN_IO,
346 } 352 }
347}; 353};
348 354
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index 861b35947280..2d3823ec3153 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -241,7 +241,15 @@ ENTRY(xscale_flush_user_cache_range)
241 * it also trashes the mini I-cache used by JTAG debuggers. 241 * it also trashes the mini I-cache used by JTAG debuggers.
242 */ 242 */
243ENTRY(xscale_coherent_kern_range) 243ENTRY(xscale_coherent_kern_range)
244 /* FALLTHROUGH */ 244 bic r0, r0, #CACHELINESIZE - 1
2451: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
246 add r0, r0, #CACHELINESIZE
247 cmp r0, r1
248 blo 1b
249 mov r0, #0
250 mcr p15, 0, r0, c7, c5, 0 @ Invalidate I cache & BTB
251 mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
252 mov pc, lr
245 253
246/* 254/*
247 * coherent_user_range(start, end) 255 * coherent_user_range(start, end)
@@ -252,18 +260,16 @@ ENTRY(xscale_coherent_kern_range)
252 * 260 *
253 * - start - virtual start address 261 * - start - virtual start address
254 * - end - virtual end address 262 * - end - virtual end address
255 *
256 * Note: single I-cache line invalidation isn't used here since
257 * it also trashes the mini I-cache used by JTAG debuggers.
258 */ 263 */
259ENTRY(xscale_coherent_user_range) 264ENTRY(xscale_coherent_user_range)
260 bic r0, r0, #CACHELINESIZE - 1 265 bic r0, r0, #CACHELINESIZE - 1
2611: mcr p15, 0, r0, c7, c10, 1 @ clean D entry 2661: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
267 mcr p15, 0, r0, c7, c5, 1 @ Invalidate I cache entry
262 add r0, r0, #CACHELINESIZE 268 add r0, r0, #CACHELINESIZE
263 cmp r0, r1 269 cmp r0, r1
264 blo 1b 270 blo 1b
265 mov r0, #0 271 mov r0, #0
266 mcr p15, 0, r0, c7, c5, 0 @ Invalidate I cache & BTB 272 mcr p15, 0, r0, c7, c5, 6 @ Invalidate BTB
267 mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer 273 mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
268 mov pc, lr 274 mov pc, lr
269 275
diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c
index 1415930ceee1..6f8bc1f0e6a1 100644
--- a/arch/arm/oprofile/common.c
+++ b/arch/arm/oprofile/common.c
@@ -137,8 +137,9 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
137 if (spec) { 137 if (spec) {
138 init_MUTEX(&op_arm_sem); 138 init_MUTEX(&op_arm_sem);
139 139
140 if (spec->init() < 0) 140 ret = spec->init();
141 return -ENODEV; 141 if (ret < 0)
142 return ret;
142 143
143 op_arm_model = spec; 144 op_arm_model = spec;
144 init_driverfs(); 145 init_driverfs();
diff --git a/arch/arm26/Kconfig b/arch/arm26/Kconfig
index 274e07019b46..dee23d87fc5a 100644
--- a/arch/arm26/Kconfig
+++ b/arch/arm26/Kconfig
@@ -53,14 +53,14 @@ config GENERIC_ISA_DMA
53 53
54config ARCH_MAY_HAVE_PC_FDC 54config ARCH_MAY_HAVE_PC_FDC
55 bool 55 bool
56 default y
57 56
58source "init/Kconfig" 57source "init/Kconfig"
59 58
60 59
61menu "System Type" 60menu "System Type"
62 61
63comment "Archimedes/A5000 Implementations (select only ONE)" 62choice
63 prompt "Archimedes/A5000 Implementations"
64 64
65config ARCH_ARC 65config ARCH_ARC
66 bool "Archimedes" 66 bool "Archimedes"
@@ -73,6 +73,7 @@ config ARCH_ARC
73 73
74config ARCH_A5K 74config ARCH_A5K
75 bool "A5000" 75 bool "A5000"
76 select ARCH_MAY_HAVE_PC_FDC
76 help 77 help
77 Say Y here to to support the Acorn A5000. 78 Say Y here to to support the Acorn A5000.
78 79
@@ -87,6 +88,7 @@ config PAGESIZE_16
87 Say Y here if your Archimedes or A5000 system has only 2MB of 88 Say Y here if your Archimedes or A5000 system has only 2MB of
88 memory, otherwise say N. The resulting kernel will not run on a 89 memory, otherwise say N. The resulting kernel will not run on a
89 machine with 4MB of memory. 90 machine with 4MB of memory.
91endchoice
90endmenu 92endmenu
91 93
92config ISA_DMA_API 94config ISA_DMA_API
diff --git a/arch/arm26/kernel/fiq.c b/arch/arm26/kernel/fiq.c
index 08a97c9498ff..a24272b61f30 100644
--- a/arch/arm26/kernel/fiq.c
+++ b/arch/arm26/kernel/fiq.c
@@ -104,14 +104,14 @@ void set_fiq_regs(struct pt_regs *regs)
104{ 104{
105 register unsigned long tmp, tmp2; 105 register unsigned long tmp, tmp2;
106 __asm__ volatile ( 106 __asm__ volatile (
107 "mov %0, pc 107 "mov %0, pc \n"
108 bic %1, %0, #0x3 108 "bic %1, %0, #0x3 \n"
109 orr %1, %1, %3 109 "orr %1, %1, %3 \n"
110 teqp %1, #0 @ select FIQ mode 110 "teqp %1, #0 @ select FIQ mode \n"
111 mov r0, r0 111 "mov r0, r0 \n"
112 ldmia %2, {r8 - r14} 112 "ldmia %2, {r8 - r14} \n"
113 teqp %0, #0 @ return to SVC mode 113 "teqp %0, #0 @ return to SVC mode \n"
114 mov r0, r0" 114 "mov r0, r0 "
115 : "=&r" (tmp), "=&r" (tmp2) 115 : "=&r" (tmp), "=&r" (tmp2)
116 : "r" (&regs->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | MODE_FIQ26) 116 : "r" (&regs->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | MODE_FIQ26)
117 /* These registers aren't modified by the above code in a way 117 /* These registers aren't modified by the above code in a way
@@ -125,14 +125,14 @@ void get_fiq_regs(struct pt_regs *regs)
125{ 125{
126 register unsigned long tmp, tmp2; 126 register unsigned long tmp, tmp2;
127 __asm__ volatile ( 127 __asm__ volatile (
128 "mov %0, pc 128 "mov %0, pc \n"
129 bic %1, %0, #0x3 129 "bic %1, %0, #0x3 \n"
130 orr %1, %1, %3 130 "orr %1, %1, %3 \n"
131 teqp %1, #0 @ select FIQ mode 131 "teqp %1, #0 @ select FIQ mode \n"
132 mov r0, r0 132 "mov r0, r0 \n"
133 stmia %2, {r8 - r14} 133 "stmia %2, {r8 - r14} \n"
134 teqp %0, #0 @ return to SVC mode 134 "teqp %0, #0 @ return to SVC mode \n"
135 mov r0, r0" 135 "mov r0, r0 "
136 : "=&r" (tmp), "=&r" (tmp2) 136 : "=&r" (tmp), "=&r" (tmp2)
137 : "r" (&regs->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | MODE_FIQ26) 137 : "r" (&regs->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | MODE_FIQ26)
138 /* These registers aren't modified by the above code in a way 138 /* These registers aren't modified by the above code in a way
diff --git a/arch/arm26/kernel/signal.c b/arch/arm26/kernel/signal.c
index ce2055bdc9ee..2a48c12100c0 100644
--- a/arch/arm26/kernel/signal.c
+++ b/arch/arm26/kernel/signal.c
@@ -480,6 +480,7 @@ static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall)
480{ 480{
481 siginfo_t info; 481 siginfo_t info;
482 int signr; 482 int signr;
483 struct k_sigaction ka;
483 484
484 /* 485 /*
485 * We want the common case to go fast, which 486 * We want the common case to go fast, which
@@ -493,7 +494,7 @@ static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall)
493 if (current->ptrace & PT_SINGLESTEP) 494 if (current->ptrace & PT_SINGLESTEP)
494 ptrace_cancel_bpt(current); 495 ptrace_cancel_bpt(current);
495 496
496 signr = get_signal_to_deliver(&info, regs, NULL); 497 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
497 if (signr > 0) { 498 if (signr > 0) {
498 handle_signal(signr, &info, oldset, regs, syscall); 499 handle_signal(signr, &info, oldset, regs, syscall);
499 if (current->ptrace & PT_SINGLESTEP) 500 if (current->ptrace & PT_SINGLESTEP)
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index cbde675bc95c..0afec8566e7b 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -47,15 +47,6 @@ config DMI
47 47
48source "init/Kconfig" 48source "init/Kconfig"
49 49
50config DOUBLEFAULT
51 default y
52 bool "Enable doublefault exception handler" if EMBEDDED
53 help
54 This option allows trapping of rare doublefault exceptions that
55 would otherwise cause a system to silently reboot. Disabling this
56 option saves about 4k and might cause you much additional grey
57 hair.
58
59menu "Processor type and features" 50menu "Processor type and features"
60 51
61choice 52choice
@@ -451,12 +442,50 @@ config HIGHMEM4G
451 442
452config HIGHMEM64G 443config HIGHMEM64G
453 bool "64GB" 444 bool "64GB"
445 depends on X86_CMPXCHG64
454 help 446 help
455 Select this if you have a 32-bit processor and more than 4 447 Select this if you have a 32-bit processor and more than 4
456 gigabytes of physical RAM. 448 gigabytes of physical RAM.
457 449
458endchoice 450endchoice
459 451
452choice
453 depends on EXPERIMENTAL && !X86_PAE
454 prompt "Memory split"
455 default VMSPLIT_3G
456 help
457 Select the desired split between kernel and user memory.
458
459 If the address range available to the kernel is less than the
460 physical memory installed, the remaining memory will be available
461 as "high memory". Accessing high memory is a little more costly
462 than low memory, as it needs to be mapped into the kernel first.
463 Note that increasing the kernel address space limits the range
464 available to user programs, making the address space there
465 tighter. Selecting anything other than the default 3G/1G split
466 will also likely make your kernel incompatible with binary-only
467 kernel modules.
468
469 If you are not absolutely sure what you are doing, leave this
470 option alone!
471
472 config VMSPLIT_3G
473 bool "3G/1G user/kernel split"
474 config VMSPLIT_3G_OPT
475 bool "3G/1G user/kernel split (for full 1G low memory)"
476 config VMSPLIT_2G
477 bool "2G/2G user/kernel split"
478 config VMSPLIT_1G
479 bool "1G/3G user/kernel split"
480endchoice
481
482config PAGE_OFFSET
483 hex
484 default 0xB0000000 if VMSPLIT_3G_OPT
485 default 0x78000000 if VMSPLIT_2G
486 default 0x40000000 if VMSPLIT_1G
487 default 0xC0000000
488
460config HIGHMEM 489config HIGHMEM
461 bool 490 bool
462 depends on HIGHMEM64G || HIGHMEM4G 491 depends on HIGHMEM64G || HIGHMEM4G
@@ -711,6 +740,15 @@ config HOTPLUG_CPU
711 740
712 Say N. 741 Say N.
713 742
743config DOUBLEFAULT
744 default y
745 bool "Enable doublefault exception handler" if EMBEDDED
746 help
747 This option allows trapping of rare doublefault exceptions that
748 would otherwise cause a system to silently reboot. Disabling this
749 option saves about 4k and might cause you much additional grey
750 hair.
751
714endmenu 752endmenu
715 753
716 754
diff --git a/arch/i386/kernel/acpi/Makefile b/arch/i386/kernel/acpi/Makefile
index 267ca48e1b6c..d51c7313cae8 100644
--- a/arch/i386/kernel/acpi/Makefile
+++ b/arch/i386/kernel/acpi/Makefile
@@ -3,6 +3,6 @@ obj-$(CONFIG_X86_IO_APIC) += earlyquirk.o
3obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o 3obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o
4 4
5ifneq ($(CONFIG_ACPI_PROCESSOR),) 5ifneq ($(CONFIG_ACPI_PROCESSOR),)
6obj-y += cstate.o 6obj-y += cstate.o processor.o
7endif 7endif
8 8
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 2111529dea77..79577f0ace98 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -248,10 +248,17 @@ acpi_parse_lapic(acpi_table_entry_header * header, const unsigned long end)
248 248
249 acpi_table_print_madt_entry(header); 249 acpi_table_print_madt_entry(header);
250 250
251 /* Register even disabled CPUs for cpu hotplug */ 251 /* Record local apic id only when enabled */
252 252 if (processor->flags.enabled)
253 x86_acpiid_to_apicid[processor->acpi_id] = processor->id; 253 x86_acpiid_to_apicid[processor->acpi_id] = processor->id;
254 254
255 /*
256 * We need to register disabled CPU as well to permit
257 * counting disabled CPUs. This allows us to size
258 * cpus_possible_map more accurately, to permit
259 * to not preallocating memory for all NR_CPUS
260 * when we use CPU hotplug.
261 */
255 mp_register_lapic(processor->id, /* APIC ID */ 262 mp_register_lapic(processor->id, /* APIC ID */
256 processor->flags.enabled); /* Enabled? */ 263 processor->flags.enabled); /* Enabled? */
257 264
@@ -464,7 +471,7 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
464 * success: return IRQ number (>=0) 471 * success: return IRQ number (>=0)
465 * failure: return < 0 472 * failure: return < 0
466 */ 473 */
467int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) 474int acpi_register_gsi(u32 gsi, int triggering, int polarity)
468{ 475{
469 unsigned int irq; 476 unsigned int irq;
470 unsigned int plat_gsi = gsi; 477 unsigned int plat_gsi = gsi;
@@ -476,14 +483,14 @@ int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low)
476 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { 483 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
477 extern void eisa_set_level_irq(unsigned int irq); 484 extern void eisa_set_level_irq(unsigned int irq);
478 485
479 if (edge_level == ACPI_LEVEL_SENSITIVE) 486 if (triggering == ACPI_LEVEL_SENSITIVE)
480 eisa_set_level_irq(gsi); 487 eisa_set_level_irq(gsi);
481 } 488 }
482#endif 489#endif
483 490
484#ifdef CONFIG_X86_IO_APIC 491#ifdef CONFIG_X86_IO_APIC
485 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) { 492 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
486 plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low); 493 plat_gsi = mp_register_gsi(gsi, triggering, polarity);
487 } 494 }
488#endif 495#endif
489 acpi_gsi_to_irq(plat_gsi, &irq); 496 acpi_gsi_to_irq(plat_gsi, &irq);
diff --git a/arch/i386/kernel/acpi/cstate.c b/arch/i386/kernel/acpi/cstate.c
index 4c3036ba65df..25db49ef1770 100644
--- a/arch/i386/kernel/acpi/cstate.c
+++ b/arch/i386/kernel/acpi/cstate.c
@@ -14,64 +14,6 @@
14#include <acpi/processor.h> 14#include <acpi/processor.h>
15#include <asm/acpi.h> 15#include <asm/acpi.h>
16 16
17static void acpi_processor_power_init_intel_pdc(struct acpi_processor_power
18 *pow)
19{
20 struct acpi_object_list *obj_list;
21 union acpi_object *obj;
22 u32 *buf;
23
24 /* allocate and initialize pdc. It will be used later. */
25 obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
26 if (!obj_list) {
27 printk(KERN_ERR "Memory allocation error\n");
28 return;
29 }
30
31 obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
32 if (!obj) {
33 printk(KERN_ERR "Memory allocation error\n");
34 kfree(obj_list);
35 return;
36 }
37
38 buf = kmalloc(12, GFP_KERNEL);
39 if (!buf) {
40 printk(KERN_ERR "Memory allocation error\n");
41 kfree(obj);
42 kfree(obj_list);
43 return;
44 }
45
46 buf[0] = ACPI_PDC_REVISION_ID;
47 buf[1] = 1;
48 buf[2] = ACPI_PDC_C_CAPABILITY_SMP;
49
50 obj->type = ACPI_TYPE_BUFFER;
51 obj->buffer.length = 12;
52 obj->buffer.pointer = (u8 *) buf;
53 obj_list->count = 1;
54 obj_list->pointer = obj;
55 pow->pdc = obj_list;
56
57 return;
58}
59
60/* Initialize _PDC data based on the CPU vendor */
61void acpi_processor_power_init_pdc(struct acpi_processor_power *pow,
62 unsigned int cpu)
63{
64 struct cpuinfo_x86 *c = cpu_data + cpu;
65
66 pow->pdc = NULL;
67 if (c->x86_vendor == X86_VENDOR_INTEL)
68 acpi_processor_power_init_intel_pdc(pow);
69
70 return;
71}
72
73EXPORT_SYMBOL(acpi_processor_power_init_pdc);
74
75/* 17/*
76 * Initialize bm_flags based on the CPU cache properties 18 * Initialize bm_flags based on the CPU cache properties
77 * On SMP it depends on cache configuration 19 * On SMP it depends on cache configuration
diff --git a/arch/i386/kernel/acpi/processor.c b/arch/i386/kernel/acpi/processor.c
new file mode 100644
index 000000000000..9f4cc02717ec
--- /dev/null
+++ b/arch/i386/kernel/acpi/processor.c
@@ -0,0 +1,75 @@
1/*
2 * arch/i386/kernel/acpi/processor.c
3 *
4 * Copyright (C) 2005 Intel Corporation
5 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
6 * - Added _PDC for platforms with Intel CPUs
7 */
8
9#include <linux/kernel.h>
10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/acpi.h>
13
14#include <acpi/processor.h>
15#include <asm/acpi.h>
16
17static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c)
18{
19 struct acpi_object_list *obj_list;
20 union acpi_object *obj;
21 u32 *buf;
22
23 /* allocate and initialize pdc. It will be used later. */
24 obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
25 if (!obj_list) {
26 printk(KERN_ERR "Memory allocation error\n");
27 return;
28 }
29
30 obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
31 if (!obj) {
32 printk(KERN_ERR "Memory allocation error\n");
33 kfree(obj_list);
34 return;
35 }
36
37 buf = kmalloc(12, GFP_KERNEL);
38 if (!buf) {
39 printk(KERN_ERR "Memory allocation error\n");
40 kfree(obj);
41 kfree(obj_list);
42 return;
43 }
44
45 buf[0] = ACPI_PDC_REVISION_ID;
46 buf[1] = 1;
47 buf[2] = ACPI_PDC_C_CAPABILITY_SMP;
48
49 if (cpu_has(c, X86_FEATURE_EST))
50 buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
51
52 obj->type = ACPI_TYPE_BUFFER;
53 obj->buffer.length = 12;
54 obj->buffer.pointer = (u8 *) buf;
55 obj_list->count = 1;
56 obj_list->pointer = obj;
57 pr->pdc = obj_list;
58
59 return;
60}
61
62/* Initialize _PDC data based on the CPU vendor */
63void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
64{
65 unsigned int cpu = pr->id;
66 struct cpuinfo_x86 *c = cpu_data + cpu;
67
68 pr->pdc = NULL;
69 if (c->x86_vendor == X86_VENDOR_INTEL)
70 init_intel_pdc(pr, c);
71
72 return;
73}
74
75EXPORT_SYMBOL(arch_acpi_processor_init_pdc);
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index acd3f1e34ca6..98a5c23cf3df 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -75,8 +75,10 @@ void ack_bad_irq(unsigned int irq)
75 * holds up an irq slot - in excessive cases (when multiple 75 * holds up an irq slot - in excessive cases (when multiple
76 * unexpected vectors occur) that might lock up the APIC 76 * unexpected vectors occur) that might lock up the APIC
77 * completely. 77 * completely.
78 * But only ack when the APIC is enabled -AK
78 */ 79 */
79 ack_APIC_irq(); 80 if (!cpu_has_apic)
81 ack_APIC_irq();
80} 82}
81 83
82void __init apic_intr_init(void) 84void __init apic_intr_init(void)
@@ -1303,6 +1305,7 @@ int __init APIC_init_uniprocessor (void)
1303 if (!cpu_has_apic && APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) { 1305 if (!cpu_has_apic && APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) {
1304 printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n", 1306 printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
1305 boot_cpu_physical_apicid); 1307 boot_cpu_physical_apicid);
1308 clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
1306 return -1; 1309 return -1;
1307 } 1310 }
1308 1311
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index 333578a4e91a..0810f81f2a05 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -282,3 +282,11 @@ int __init amd_init_cpu(void)
282} 282}
283 283
284//early_arch_initcall(amd_init_cpu); 284//early_arch_initcall(amd_init_cpu);
285
286static int __init amd_exit_cpu(void)
287{
288 cpu_devs[X86_VENDOR_AMD] = NULL;
289 return 0;
290}
291
292late_initcall(amd_exit_cpu);
diff --git a/arch/i386/kernel/cpu/centaur.c b/arch/i386/kernel/cpu/centaur.c
index 394814e57672..f52669ecb93f 100644
--- a/arch/i386/kernel/cpu/centaur.c
+++ b/arch/i386/kernel/cpu/centaur.c
@@ -405,10 +405,6 @@ static void __init init_centaur(struct cpuinfo_x86 *c)
405 winchip2_protect_mcr(); 405 winchip2_protect_mcr();
406#endif 406#endif
407 break; 407 break;
408 case 10:
409 name="4";
410 /* no info on the WC4 yet */
411 break;
412 default: 408 default:
413 name="??"; 409 name="??";
414 } 410 }
@@ -474,3 +470,11 @@ int __init centaur_init_cpu(void)
474} 470}
475 471
476//early_arch_initcall(centaur_init_cpu); 472//early_arch_initcall(centaur_init_cpu);
473
474static int __init centaur_exit_cpu(void)
475{
476 cpu_devs[X86_VENDOR_CENTAUR] = NULL;
477 return 0;
478}
479
480late_initcall(centaur_exit_cpu);
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index 15aee26ec2b6..7eb9213734a3 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -44,6 +44,7 @@ static void default_init(struct cpuinfo_x86 * c)
44 44
45static struct cpu_dev default_cpu = { 45static struct cpu_dev default_cpu = {
46 .c_init = default_init, 46 .c_init = default_init,
47 .c_vendor = "Unknown",
47}; 48};
48static struct cpu_dev * this_cpu = &default_cpu; 49static struct cpu_dev * this_cpu = &default_cpu;
49 50
@@ -150,6 +151,7 @@ static void __devinit get_cpu_vendor(struct cpuinfo_x86 *c, int early)
150{ 151{
151 char *v = c->x86_vendor_id; 152 char *v = c->x86_vendor_id;
152 int i; 153 int i;
154 static int printed;
153 155
154 for (i = 0; i < X86_VENDOR_NUM; i++) { 156 for (i = 0; i < X86_VENDOR_NUM; i++) {
155 if (cpu_devs[i]) { 157 if (cpu_devs[i]) {
@@ -159,10 +161,17 @@ static void __devinit get_cpu_vendor(struct cpuinfo_x86 *c, int early)
159 c->x86_vendor = i; 161 c->x86_vendor = i;
160 if (!early) 162 if (!early)
161 this_cpu = cpu_devs[i]; 163 this_cpu = cpu_devs[i];
162 break; 164 return;
163 } 165 }
164 } 166 }
165 } 167 }
168 if (!printed) {
169 printed++;
170 printk(KERN_ERR "CPU: Vendor unknown, using generic init.\n");
171 printk(KERN_ERR "CPU: Your system may be unstable.\n");
172 }
173 c->x86_vendor = X86_VENDOR_UNKNOWN;
174 this_cpu = &default_cpu;
166} 175}
167 176
168 177
diff --git a/arch/i386/kernel/cpu/cpufreq/Kconfig b/arch/i386/kernel/cpu/cpufreq/Kconfig
index 0f1eb507233b..26892d2099b0 100644
--- a/arch/i386/kernel/cpu/cpufreq/Kconfig
+++ b/arch/i386/kernel/cpu/cpufreq/Kconfig
@@ -96,6 +96,7 @@ config X86_POWERNOW_K8_ACPI
96 96
97config X86_GX_SUSPMOD 97config X86_GX_SUSPMOD
98 tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation" 98 tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation"
99 depends on PCI
99 help 100 help
100 This add the CPUFreq driver for NatSemi Geode processors which 101 This add the CPUFreq driver for NatSemi Geode processors which
101 support suspend modulation. 102 support suspend modulation.
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 7975e79d5fa4..3852d0a4c1b5 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -295,68 +295,6 @@ acpi_cpufreq_guess_freq (
295} 295}
296 296
297 297
298/*
299 * acpi_processor_cpu_init_pdc_est - let BIOS know about the SMP capabilities
300 * of this driver
301 * @perf: processor-specific acpi_io_data struct
302 * @cpu: CPU being initialized
303 *
304 * To avoid issues with legacy OSes, some BIOSes require to be informed of
305 * the SMP capabilities of OS P-state driver. Here we set the bits in _PDC
306 * accordingly, for Enhanced Speedstep. Actual call to _PDC is done in
307 * driver/acpi/processor.c
308 */
309static void
310acpi_processor_cpu_init_pdc_est(
311 struct acpi_processor_performance *perf,
312 unsigned int cpu,
313 struct acpi_object_list *obj_list
314 )
315{
316 union acpi_object *obj;
317 u32 *buf;
318 struct cpuinfo_x86 *c = cpu_data + cpu;
319 dprintk("acpi_processor_cpu_init_pdc_est\n");
320
321 if (!cpu_has(c, X86_FEATURE_EST))
322 return;
323
324 /* Initialize pdc. It will be used later. */
325 if (!obj_list)
326 return;
327
328 if (!(obj_list->count && obj_list->pointer))
329 return;
330
331 obj = obj_list->pointer;
332 if ((obj->buffer.length == 12) && obj->buffer.pointer) {
333 buf = (u32 *)obj->buffer.pointer;
334 buf[0] = ACPI_PDC_REVISION_ID;
335 buf[1] = 1;
336 buf[2] = ACPI_PDC_EST_CAPABILITY_SMP;
337 perf->pdc = obj_list;
338 }
339 return;
340}
341
342
343/* CPU specific PDC initialization */
344static void
345acpi_processor_cpu_init_pdc(
346 struct acpi_processor_performance *perf,
347 unsigned int cpu,
348 struct acpi_object_list *obj_list
349 )
350{
351 struct cpuinfo_x86 *c = cpu_data + cpu;
352 dprintk("acpi_processor_cpu_init_pdc\n");
353 perf->pdc = NULL;
354 if (cpu_has(c, X86_FEATURE_EST))
355 acpi_processor_cpu_init_pdc_est(perf, cpu, obj_list);
356 return;
357}
358
359
360static int 298static int
361acpi_cpufreq_cpu_init ( 299acpi_cpufreq_cpu_init (
362 struct cpufreq_policy *policy) 300 struct cpufreq_policy *policy)
@@ -367,14 +305,7 @@ acpi_cpufreq_cpu_init (
367 unsigned int result = 0; 305 unsigned int result = 0;
368 struct cpuinfo_x86 *c = &cpu_data[policy->cpu]; 306 struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
369 307
370 union acpi_object arg0 = {ACPI_TYPE_BUFFER};
371 u32 arg0_buf[3];
372 struct acpi_object_list arg_list = {1, &arg0};
373
374 dprintk("acpi_cpufreq_cpu_init\n"); 308 dprintk("acpi_cpufreq_cpu_init\n");
375 /* setup arg_list for _PDC settings */
376 arg0.buffer.length = 12;
377 arg0.buffer.pointer = (u8 *) arg0_buf;
378 309
379 data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); 310 data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
380 if (!data) 311 if (!data)
@@ -382,9 +313,7 @@ acpi_cpufreq_cpu_init (
382 313
383 acpi_io_data[cpu] = data; 314 acpi_io_data[cpu] = data;
384 315
385 acpi_processor_cpu_init_pdc(&data->acpi_data, cpu, &arg_list);
386 result = acpi_processor_register_performance(&data->acpi_data, cpu); 316 result = acpi_processor_register_performance(&data->acpi_data, cpu);
387 data->acpi_data.pdc = NULL;
388 317
389 if (result) 318 if (result)
390 goto err_free; 319 goto err_free;
diff --git a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
index 270f2188d68b..cc73a7ae34bc 100644
--- a/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
+++ b/arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
@@ -52,6 +52,7 @@ enum {
52 52
53 53
54static int has_N44_O17_errata[NR_CPUS]; 54static int has_N44_O17_errata[NR_CPUS];
55static int has_N60_errata[NR_CPUS];
55static unsigned int stock_freq; 56static unsigned int stock_freq;
56static struct cpufreq_driver p4clockmod_driver; 57static struct cpufreq_driver p4clockmod_driver;
57static unsigned int cpufreq_p4_get(unsigned int cpu); 58static unsigned int cpufreq_p4_get(unsigned int cpu);
@@ -226,6 +227,12 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
226 case 0x0f12: 227 case 0x0f12:
227 has_N44_O17_errata[policy->cpu] = 1; 228 has_N44_O17_errata[policy->cpu] = 1;
228 dprintk("has errata -- disabling low frequencies\n"); 229 dprintk("has errata -- disabling low frequencies\n");
230 break;
231
232 case 0x0f29:
233 has_N60_errata[policy->cpu] = 1;
234 dprintk("has errata -- disabling frequencies lower than 2ghz\n");
235 break;
229 } 236 }
230 237
231 /* get max frequency */ 238 /* get max frequency */
@@ -237,6 +244,8 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
237 for (i=1; (p4clockmod_table[i].frequency != CPUFREQ_TABLE_END); i++) { 244 for (i=1; (p4clockmod_table[i].frequency != CPUFREQ_TABLE_END); i++) {
238 if ((i<2) && (has_N44_O17_errata[policy->cpu])) 245 if ((i<2) && (has_N44_O17_errata[policy->cpu]))
239 p4clockmod_table[i].frequency = CPUFREQ_ENTRY_INVALID; 246 p4clockmod_table[i].frequency = CPUFREQ_ENTRY_INVALID;
247 else if (has_N60_errata[policy->cpu] && p4clockmod_table[i].frequency < 2000000)
248 p4clockmod_table[i].frequency = CPUFREQ_ENTRY_INVALID;
240 else 249 else
241 p4clockmod_table[i].frequency = (stock_freq * i)/8; 250 p4clockmod_table[i].frequency = (stock_freq * i)/8;
242 } 251 }
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index 9a826cde4fd1..c173c0fa117a 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -362,22 +362,10 @@ static struct acpi_processor_performance p;
362 */ 362 */
363static int centrino_cpu_init_acpi(struct cpufreq_policy *policy) 363static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
364{ 364{
365 union acpi_object arg0 = {ACPI_TYPE_BUFFER};
366 u32 arg0_buf[3];
367 struct acpi_object_list arg_list = {1, &arg0};
368 unsigned long cur_freq; 365 unsigned long cur_freq;
369 int result = 0, i; 366 int result = 0, i;
370 unsigned int cpu = policy->cpu; 367 unsigned int cpu = policy->cpu;
371 368
372 /* _PDC settings */
373 arg0.buffer.length = 12;
374 arg0.buffer.pointer = (u8 *) arg0_buf;
375 arg0_buf[0] = ACPI_PDC_REVISION_ID;
376 arg0_buf[1] = 1;
377 arg0_buf[2] = ACPI_PDC_EST_CAPABILITY_SMP_MSR;
378
379 p.pdc = &arg_list;
380
381 /* register with ACPI core */ 369 /* register with ACPI core */
382 if (acpi_processor_register_performance(&p, cpu)) { 370 if (acpi_processor_register_performance(&p, cpu)) {
383 dprintk(KERN_INFO PFX "obtaining ACPI data failed\n"); 371 dprintk(KERN_INFO PFX "obtaining ACPI data failed\n");
diff --git a/arch/i386/kernel/cpu/cyrix.c b/arch/i386/kernel/cpu/cyrix.c
index 75015975d038..00f2e058797c 100644
--- a/arch/i386/kernel/cpu/cyrix.c
+++ b/arch/i386/kernel/cpu/cyrix.c
@@ -345,7 +345,7 @@ static void __init init_cyrix(struct cpuinfo_x86 *c)
345/* 345/*
346 * Handle National Semiconductor branded processors 346 * Handle National Semiconductor branded processors
347 */ 347 */
348static void __devinit init_nsc(struct cpuinfo_x86 *c) 348static void __init init_nsc(struct cpuinfo_x86 *c)
349{ 349{
350 /* There may be GX1 processors in the wild that are branded 350 /* There may be GX1 processors in the wild that are branded
351 * NSC and not Cyrix. 351 * NSC and not Cyrix.
@@ -444,6 +444,14 @@ int __init cyrix_init_cpu(void)
444 444
445//early_arch_initcall(cyrix_init_cpu); 445//early_arch_initcall(cyrix_init_cpu);
446 446
447static int __init cyrix_exit_cpu(void)
448{
449 cpu_devs[X86_VENDOR_CYRIX] = NULL;
450 return 0;
451}
452
453late_initcall(cyrix_exit_cpu);
454
447static struct cpu_dev nsc_cpu_dev __initdata = { 455static struct cpu_dev nsc_cpu_dev __initdata = {
448 .c_vendor = "NSC", 456 .c_vendor = "NSC",
449 .c_ident = { "Geode by NSC" }, 457 .c_ident = { "Geode by NSC" },
@@ -458,3 +466,11 @@ int __init nsc_init_cpu(void)
458} 466}
459 467
460//early_arch_initcall(nsc_init_cpu); 468//early_arch_initcall(nsc_init_cpu);
469
470static int __init nsc_exit_cpu(void)
471{
472 cpu_devs[X86_VENDOR_NSC] = NULL;
473 return 0;
474}
475
476late_initcall(nsc_exit_cpu);
diff --git a/arch/i386/kernel/cpu/intel_cacheinfo.c b/arch/i386/kernel/cpu/intel_cacheinfo.c
index fbfd374aa336..ffe58cee0c48 100644
--- a/arch/i386/kernel/cpu/intel_cacheinfo.c
+++ b/arch/i386/kernel/cpu/intel_cacheinfo.c
@@ -43,13 +43,23 @@ static struct _cache_table cache_table[] __cpuinitdata =
43 { 0x2c, LVL_1_DATA, 32 }, /* 8-way set assoc, 64 byte line size */ 43 { 0x2c, LVL_1_DATA, 32 }, /* 8-way set assoc, 64 byte line size */
44 { 0x30, LVL_1_INST, 32 }, /* 8-way set assoc, 64 byte line size */ 44 { 0x30, LVL_1_INST, 32 }, /* 8-way set assoc, 64 byte line size */
45 { 0x39, LVL_2, 128 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 45 { 0x39, LVL_2, 128 }, /* 4-way set assoc, sectored cache, 64 byte line size */
46 { 0x3a, LVL_2, 192 }, /* 6-way set assoc, sectored cache, 64 byte line size */
46 { 0x3b, LVL_2, 128 }, /* 2-way set assoc, sectored cache, 64 byte line size */ 47 { 0x3b, LVL_2, 128 }, /* 2-way set assoc, sectored cache, 64 byte line size */
47 { 0x3c, LVL_2, 256 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 48 { 0x3c, LVL_2, 256 }, /* 4-way set assoc, sectored cache, 64 byte line size */
49 { 0x3d, LVL_2, 384 }, /* 6-way set assoc, sectored cache, 64 byte line size */
50 { 0x3e, LVL_2, 512 }, /* 4-way set assoc, sectored cache, 64 byte line size */
48 { 0x41, LVL_2, 128 }, /* 4-way set assoc, 32 byte line size */ 51 { 0x41, LVL_2, 128 }, /* 4-way set assoc, 32 byte line size */
49 { 0x42, LVL_2, 256 }, /* 4-way set assoc, 32 byte line size */ 52 { 0x42, LVL_2, 256 }, /* 4-way set assoc, 32 byte line size */
50 { 0x43, LVL_2, 512 }, /* 4-way set assoc, 32 byte line size */ 53 { 0x43, LVL_2, 512 }, /* 4-way set assoc, 32 byte line size */
51 { 0x44, LVL_2, 1024 }, /* 4-way set assoc, 32 byte line size */ 54 { 0x44, LVL_2, 1024 }, /* 4-way set assoc, 32 byte line size */
52 { 0x45, LVL_2, 2048 }, /* 4-way set assoc, 32 byte line size */ 55 { 0x45, LVL_2, 2048 }, /* 4-way set assoc, 32 byte line size */
56 { 0x46, LVL_3, 4096 }, /* 4-way set assoc, 64 byte line size */
57 { 0x47, LVL_3, 8192 }, /* 8-way set assoc, 64 byte line size */
58 { 0x49, LVL_3, 4096 }, /* 16-way set assoc, 64 byte line size */
59 { 0x4a, LVL_3, 6144 }, /* 12-way set assoc, 64 byte line size */
60 { 0x4b, LVL_3, 8192 }, /* 16-way set assoc, 64 byte line size */
61 { 0x4c, LVL_3, 12288 }, /* 12-way set assoc, 64 byte line size */
62 { 0x4d, LVL_3, 16384 }, /* 16-way set assoc, 64 byte line size */
53 { 0x60, LVL_1_DATA, 16 }, /* 8-way set assoc, sectored cache, 64 byte line size */ 63 { 0x60, LVL_1_DATA, 16 }, /* 8-way set assoc, sectored cache, 64 byte line size */
54 { 0x66, LVL_1_DATA, 8 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 64 { 0x66, LVL_1_DATA, 8 }, /* 4-way set assoc, sectored cache, 64 byte line size */
55 { 0x67, LVL_1_DATA, 16 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 65 { 0x67, LVL_1_DATA, 16 }, /* 4-way set assoc, sectored cache, 64 byte line size */
@@ -57,6 +67,7 @@ static struct _cache_table cache_table[] __cpuinitdata =
57 { 0x70, LVL_TRACE, 12 }, /* 8-way set assoc */ 67 { 0x70, LVL_TRACE, 12 }, /* 8-way set assoc */
58 { 0x71, LVL_TRACE, 16 }, /* 8-way set assoc */ 68 { 0x71, LVL_TRACE, 16 }, /* 8-way set assoc */
59 { 0x72, LVL_TRACE, 32 }, /* 8-way set assoc */ 69 { 0x72, LVL_TRACE, 32 }, /* 8-way set assoc */
70 { 0x73, LVL_TRACE, 64 }, /* 8-way set assoc */
60 { 0x78, LVL_2, 1024 }, /* 4-way set assoc, 64 byte line size */ 71 { 0x78, LVL_2, 1024 }, /* 4-way set assoc, 64 byte line size */
61 { 0x79, LVL_2, 128 }, /* 8-way set assoc, sectored cache, 64 byte line size */ 72 { 0x79, LVL_2, 128 }, /* 8-way set assoc, sectored cache, 64 byte line size */
62 { 0x7a, LVL_2, 256 }, /* 8-way set assoc, sectored cache, 64 byte line size */ 73 { 0x7a, LVL_2, 256 }, /* 8-way set assoc, sectored cache, 64 byte line size */
@@ -141,6 +152,7 @@ static int __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_le
141 return 0; 152 return 0;
142} 153}
143 154
155/* will only be called once; __init is safe here */
144static int __init find_num_cache_leaves(void) 156static int __init find_num_cache_leaves(void)
145{ 157{
146 unsigned int eax, ebx, ecx, edx; 158 unsigned int eax, ebx, ecx, edx;
diff --git a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
index 1e9db198c440..3b4618bed70d 100644
--- a/arch/i386/kernel/cpu/mtrr/main.c
+++ b/arch/i386/kernel/cpu/mtrr/main.c
@@ -44,12 +44,10 @@
44#include <asm/msr.h> 44#include <asm/msr.h>
45#include "mtrr.h" 45#include "mtrr.h"
46 46
47#define MTRR_VERSION "2.0 (20020519)"
48
49u32 num_var_ranges = 0; 47u32 num_var_ranges = 0;
50 48
51unsigned int *usage_table; 49unsigned int *usage_table;
52static DECLARE_MUTEX(main_lock); 50static DECLARE_MUTEX(mtrr_sem);
53 51
54u32 size_or_mask, size_and_mask; 52u32 size_or_mask, size_and_mask;
55 53
@@ -335,7 +333,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
335 /* No CPU hotplug when we change MTRR entries */ 333 /* No CPU hotplug when we change MTRR entries */
336 lock_cpu_hotplug(); 334 lock_cpu_hotplug();
337 /* Search for existing MTRR */ 335 /* Search for existing MTRR */
338 down(&main_lock); 336 down(&mtrr_sem);
339 for (i = 0; i < num_var_ranges; ++i) { 337 for (i = 0; i < num_var_ranges; ++i) {
340 mtrr_if->get(i, &lbase, &lsize, &ltype); 338 mtrr_if->get(i, &lbase, &lsize, &ltype);
341 if (base >= lbase + lsize) 339 if (base >= lbase + lsize)
@@ -373,7 +371,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
373 printk(KERN_INFO "mtrr: no more MTRRs available\n"); 371 printk(KERN_INFO "mtrr: no more MTRRs available\n");
374 error = i; 372 error = i;
375 out: 373 out:
376 up(&main_lock); 374 up(&mtrr_sem);
377 unlock_cpu_hotplug(); 375 unlock_cpu_hotplug();
378 return error; 376 return error;
379} 377}
@@ -466,7 +464,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
466 max = num_var_ranges; 464 max = num_var_ranges;
467 /* No CPU hotplug when we change MTRR entries */ 465 /* No CPU hotplug when we change MTRR entries */
468 lock_cpu_hotplug(); 466 lock_cpu_hotplug();
469 down(&main_lock); 467 down(&mtrr_sem);
470 if (reg < 0) { 468 if (reg < 0) {
471 /* Search for existing MTRR */ 469 /* Search for existing MTRR */
472 for (i = 0; i < max; ++i) { 470 for (i = 0; i < max; ++i) {
@@ -505,7 +503,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
505 set_mtrr(reg, 0, 0, 0); 503 set_mtrr(reg, 0, 0, 0);
506 error = reg; 504 error = reg;
507 out: 505 out:
508 up(&main_lock); 506 up(&mtrr_sem);
509 unlock_cpu_hotplug(); 507 unlock_cpu_hotplug();
510 return error; 508 return error;
511} 509}
@@ -671,7 +669,6 @@ void __init mtrr_bp_init(void)
671 break; 669 break;
672 } 670 }
673 } 671 }
674 printk(KERN_INFO "mtrr: v%s\n",MTRR_VERSION);
675 672
676 if (mtrr_if) { 673 if (mtrr_if) {
677 set_num_var_ranges(); 674 set_num_var_ranges();
@@ -688,7 +685,7 @@ void mtrr_ap_init(void)
688 if (!mtrr_if || !use_intel()) 685 if (!mtrr_if || !use_intel())
689 return; 686 return;
690 /* 687 /*
691 * Ideally we should hold main_lock here to avoid mtrr entries changed, 688 * Ideally we should hold mtrr_sem here to avoid mtrr entries changed,
692 * but this routine will be called in cpu boot time, holding the lock 689 * but this routine will be called in cpu boot time, holding the lock
693 * breaks it. This routine is called in two cases: 1.very earily time 690 * breaks it. This routine is called in two cases: 1.very earily time
694 * of software resume, when there absolutely isn't mtrr entry changes; 691 * of software resume, when there absolutely isn't mtrr entry changes;
diff --git a/arch/i386/kernel/cpu/nexgen.c b/arch/i386/kernel/cpu/nexgen.c
index 30898a260a5c..ad87fa58058d 100644
--- a/arch/i386/kernel/cpu/nexgen.c
+++ b/arch/i386/kernel/cpu/nexgen.c
@@ -61,3 +61,11 @@ int __init nexgen_init_cpu(void)
61} 61}
62 62
63//early_arch_initcall(nexgen_init_cpu); 63//early_arch_initcall(nexgen_init_cpu);
64
65static int __init nexgen_exit_cpu(void)
66{
67 cpu_devs[X86_VENDOR_NEXGEN] = NULL;
68 return 0;
69}
70
71late_initcall(nexgen_exit_cpu);
diff --git a/arch/i386/kernel/cpu/rise.c b/arch/i386/kernel/cpu/rise.c
index 8602425628ca..d08d5a2811c8 100644
--- a/arch/i386/kernel/cpu/rise.c
+++ b/arch/i386/kernel/cpu/rise.c
@@ -51,3 +51,11 @@ int __init rise_init_cpu(void)
51} 51}
52 52
53//early_arch_initcall(rise_init_cpu); 53//early_arch_initcall(rise_init_cpu);
54
55static int __init rise_exit_cpu(void)
56{
57 cpu_devs[X86_VENDOR_RISE] = NULL;
58 return 0;
59}
60
61late_initcall(rise_exit_cpu);
diff --git a/arch/i386/kernel/cpu/transmeta.c b/arch/i386/kernel/cpu/transmeta.c
index fc426380366b..bdbeb77f4e22 100644
--- a/arch/i386/kernel/cpu/transmeta.c
+++ b/arch/i386/kernel/cpu/transmeta.c
@@ -84,7 +84,7 @@ static void __init init_transmeta(struct cpuinfo_x86 *c)
84#endif 84#endif
85} 85}
86 86
87static void transmeta_identify(struct cpuinfo_x86 * c) 87static void __init transmeta_identify(struct cpuinfo_x86 * c)
88{ 88{
89 u32 xlvl; 89 u32 xlvl;
90 generic_identify(c); 90 generic_identify(c);
@@ -111,3 +111,11 @@ int __init transmeta_init_cpu(void)
111} 111}
112 112
113//early_arch_initcall(transmeta_init_cpu); 113//early_arch_initcall(transmeta_init_cpu);
114
115static int __init transmeta_exit_cpu(void)
116{
117 cpu_devs[X86_VENDOR_TRANSMETA] = NULL;
118 return 0;
119}
120
121late_initcall(transmeta_exit_cpu);
diff --git a/arch/i386/kernel/cpu/umc.c b/arch/i386/kernel/cpu/umc.c
index 264fcad559d5..2cd988f6dc55 100644
--- a/arch/i386/kernel/cpu/umc.c
+++ b/arch/i386/kernel/cpu/umc.c
@@ -31,3 +31,11 @@ int __init umc_init_cpu(void)
31} 31}
32 32
33//early_arch_initcall(umc_init_cpu); 33//early_arch_initcall(umc_init_cpu);
34
35static int __init umc_exit_cpu(void)
36{
37 cpu_devs[X86_VENDOR_UMC] = NULL;
38 return 0;
39}
40
41late_initcall(umc_exit_cpu);
diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
index 91a64016956e..0102f3d50e57 100644
--- a/arch/i386/kernel/mpparse.c
+++ b/arch/i386/kernel/mpparse.c
@@ -1080,7 +1080,7 @@ void __init mp_config_acpi_legacy_irqs (void)
1080 1080
1081#define MAX_GSI_NUM 4096 1081#define MAX_GSI_NUM 4096
1082 1082
1083int mp_register_gsi (u32 gsi, int edge_level, int active_high_low) 1083int mp_register_gsi (u32 gsi, int triggering, int polarity)
1084{ 1084{
1085 int ioapic = -1; 1085 int ioapic = -1;
1086 int ioapic_pin = 0; 1086 int ioapic_pin = 0;
@@ -1129,7 +1129,7 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
1129 1129
1130 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit); 1130 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
1131 1131
1132 if (edge_level) { 1132 if (triggering == ACPI_LEVEL_SENSITIVE) {
1133 /* 1133 /*
1134 * For PCI devices assign IRQs in order, avoiding gaps 1134 * For PCI devices assign IRQs in order, avoiding gaps
1135 * due to unused I/O APIC pins. 1135 * due to unused I/O APIC pins.
@@ -1151,8 +1151,8 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
1151 } 1151 }
1152 1152
1153 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi, 1153 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
1154 edge_level == ACPI_EDGE_SENSITIVE ? 0 : 1, 1154 triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
1155 active_high_low == ACPI_ACTIVE_HIGH ? 0 : 1); 1155 polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
1156 return gsi; 1156 return gsi;
1157} 1157}
1158 1158
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index d661703ac1cb..63f39a7e2c96 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -138,7 +138,7 @@ static int __init check_nmi_watchdog(void)
138 if (nmi_watchdog == NMI_LOCAL_APIC) 138 if (nmi_watchdog == NMI_LOCAL_APIC)
139 smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0); 139 smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);
140 140
141 for (cpu = 0; cpu < NR_CPUS; cpu++) 141 for_each_cpu(cpu)
142 prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count; 142 prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count;
143 local_irq_enable(); 143 local_irq_enable();
144 mdelay((10*1000)/nmi_hz); // wait 10 ticks 144 mdelay((10*1000)/nmi_hz); // wait 10 ticks
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index 2185377fdde1..0480454ebffa 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -297,8 +297,10 @@ void show_regs(struct pt_regs * regs)
297 297
298 if (user_mode(regs)) 298 if (user_mode(regs))
299 printk(" ESP: %04x:%08lx",0xffff & regs->xss,regs->esp); 299 printk(" ESP: %04x:%08lx",0xffff & regs->xss,regs->esp);
300 printk(" EFLAGS: %08lx %s (%s)\n", 300 printk(" EFLAGS: %08lx %s (%s %.*s)\n",
301 regs->eflags, print_tainted(), system_utsname.release); 301 regs->eflags, print_tainted(), system_utsname.release,
302 (int)strcspn(system_utsname.version, " "),
303 system_utsname.version);
302 printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n", 304 printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
303 regs->eax,regs->ebx,regs->ecx,regs->edx); 305 regs->eax,regs->ebx,regs->ecx,regs->edx);
304 printk("ESI: %08lx EDI: %08lx EBP: %08lx", 306 printk("ESI: %08lx EDI: %08lx EBP: %08lx",
diff --git a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
index 47675bbbb316..7c86e3c5f1c1 100644
--- a/arch/i386/kernel/timers/timer_tsc.c
+++ b/arch/i386/kernel/timers/timer_tsc.c
@@ -45,6 +45,15 @@ static unsigned long last_tsc_high; /* msb 32 bits of Time Stamp Counter */
45static unsigned long long monotonic_base; 45static unsigned long long monotonic_base;
46static seqlock_t monotonic_lock = SEQLOCK_UNLOCKED; 46static seqlock_t monotonic_lock = SEQLOCK_UNLOCKED;
47 47
48/* Avoid compensating for lost ticks before TSCs are synched */
49static int detect_lost_ticks;
50static int __init start_lost_tick_compensation(void)
51{
52 detect_lost_ticks = 1;
53 return 0;
54}
55late_initcall(start_lost_tick_compensation);
56
48/* convert from cycles(64bits) => nanoseconds (64bits) 57/* convert from cycles(64bits) => nanoseconds (64bits)
49 * basic equation: 58 * basic equation:
50 * ns = cycles / (freq / ns_per_sec) 59 * ns = cycles / (freq / ns_per_sec)
@@ -196,7 +205,8 @@ static void mark_offset_tsc_hpet(void)
196 205
197 /* lost tick compensation */ 206 /* lost tick compensation */
198 offset = hpet_readl(HPET_T0_CMP) - hpet_tick; 207 offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
199 if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) { 208 if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))
209 && detect_lost_ticks) {
200 int lost_ticks = (offset - hpet_last) / hpet_tick; 210 int lost_ticks = (offset - hpet_last) / hpet_tick;
201 jiffies_64 += lost_ticks; 211 jiffies_64 += lost_ticks;
202 } 212 }
@@ -421,7 +431,7 @@ static void mark_offset_tsc(void)
421 delta += delay_at_last_interrupt; 431 delta += delay_at_last_interrupt;
422 lost = delta/(1000000/HZ); 432 lost = delta/(1000000/HZ);
423 delay = delta%(1000000/HZ); 433 delay = delta%(1000000/HZ);
424 if (lost >= 2) { 434 if (lost >= 2 && detect_lost_ticks) {
425 jiffies_64 += lost-1; 435 jiffies_64 += lost-1;
426 436
427 /* sanity check to ensure we're not always losing ticks */ 437 /* sanity check to ensure we're not always losing ticks */
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 0aaebf3e1cfa..b814dbdcc91e 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -166,7 +166,8 @@ static void show_trace_log_lvl(struct task_struct *task,
166 stack = (unsigned long*)context->previous_esp; 166 stack = (unsigned long*)context->previous_esp;
167 if (!stack) 167 if (!stack)
168 break; 168 break;
169 printk(KERN_EMERG " =======================\n"); 169 printk(log_lvl);
170 printk(" =======================\n");
170 } 171 }
171} 172}
172 173
@@ -239,9 +240,11 @@ void show_registers(struct pt_regs *regs)
239 } 240 }
240 print_modules(); 241 print_modules();
241 printk(KERN_EMERG "CPU: %d\nEIP: %04x:[<%08lx>] %s VLI\n" 242 printk(KERN_EMERG "CPU: %d\nEIP: %04x:[<%08lx>] %s VLI\n"
242 "EFLAGS: %08lx (%s) \n", 243 "EFLAGS: %08lx (%s %.*s) \n",
243 smp_processor_id(), 0xffff & regs->xcs, regs->eip, 244 smp_processor_id(), 0xffff & regs->xcs, regs->eip,
244 print_tainted(), regs->eflags, system_utsname.release); 245 print_tainted(), regs->eflags, system_utsname.release,
246 (int)strcspn(system_utsname.version, " "),
247 system_utsname.version);
245 print_symbol(KERN_EMERG "EIP is at %s\n", regs->eip); 248 print_symbol(KERN_EMERG "EIP is at %s\n", regs->eip);
246 printk(KERN_EMERG "eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", 249 printk(KERN_EMERG "eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n",
247 regs->eax, regs->ebx, regs->ecx, regs->edx); 250 regs->eax, regs->ebx, regs->ecx, regs->edx);
diff --git a/arch/i386/oprofile/backtrace.c b/arch/i386/oprofile/backtrace.c
index 21654be3f73f..acc18138fb22 100644
--- a/arch/i386/oprofile/backtrace.c
+++ b/arch/i386/oprofile/backtrace.c
@@ -49,7 +49,9 @@ dump_backtrace(struct frame_head * head)
49 * | stack | 49 * | stack |
50 * --------------- saved regs->ebp value if valid (frame_head address) 50 * --------------- saved regs->ebp value if valid (frame_head address)
51 * . . 51 * . .
52 * --------------- struct pt_regs stored on stack (struct pt_regs *) 52 * --------------- saved regs->rsp value if x86_64
53 * | |
54 * --------------- struct pt_regs * stored on stack if 32-bit
53 * | | 55 * | |
54 * . . 56 * . .
55 * | | 57 * | |
@@ -57,13 +59,26 @@ dump_backtrace(struct frame_head * head)
57 * | | 59 * | |
58 * | | \/ Lower addresses 60 * | | \/ Lower addresses
59 * 61 *
60 * Thus, &pt_regs <-> stack base restricts the valid(ish) ebp values 62 * Thus, regs (or regs->rsp for x86_64) <-> stack base restricts the
63 * valid(ish) ebp values. Note: (1) for x86_64, NMI and several other
64 * exceptions use special stacks, maintained by the interrupt stack table
65 * (IST). These stacks are set up in trap_init() in
66 * arch/x86_64/kernel/traps.c. Thus, for x86_64, regs now does not point
67 * to the kernel stack; instead, it points to some location on the NMI
68 * stack. On the other hand, regs->rsp is the stack pointer saved when the
69 * NMI occurred. (2) For 32-bit, regs->esp is not valid because the
70 * processor does not save %esp on the kernel stack when interrupts occur
71 * in the kernel mode.
61 */ 72 */
62#ifdef CONFIG_FRAME_POINTER 73#ifdef CONFIG_FRAME_POINTER
63static int valid_kernel_stack(struct frame_head * head, struct pt_regs * regs) 74static int valid_kernel_stack(struct frame_head * head, struct pt_regs * regs)
64{ 75{
65 unsigned long headaddr = (unsigned long)head; 76 unsigned long headaddr = (unsigned long)head;
77#ifdef CONFIG_X86_64
78 unsigned long stack = (unsigned long)regs->rsp;
79#else
66 unsigned long stack = (unsigned long)regs; 80 unsigned long stack = (unsigned long)regs;
81#endif
67 unsigned long stack_base = (stack & ~(THREAD_SIZE - 1)) + THREAD_SIZE; 82 unsigned long stack_base = (stack & ~(THREAD_SIZE - 1)) + THREAD_SIZE;
68 83
69 return headaddr > stack && headaddr < stack_base; 84 return headaddr > stack && headaddr < stack_base;
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index e715aa930036..3ca59cad05f3 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -539,6 +539,11 @@ static __init int intel_router_probe(struct irq_router *r, struct pci_dev *route
539 case PCI_DEVICE_ID_INTEL_ICH7_30: 539 case PCI_DEVICE_ID_INTEL_ICH7_30:
540 case PCI_DEVICE_ID_INTEL_ICH7_31: 540 case PCI_DEVICE_ID_INTEL_ICH7_31:
541 case PCI_DEVICE_ID_INTEL_ESB2_0: 541 case PCI_DEVICE_ID_INTEL_ESB2_0:
542 case PCI_DEVICE_ID_INTEL_ICH8_0:
543 case PCI_DEVICE_ID_INTEL_ICH8_1:
544 case PCI_DEVICE_ID_INTEL_ICH8_2:
545 case PCI_DEVICE_ID_INTEL_ICH8_3:
546 case PCI_DEVICE_ID_INTEL_ICH8_4:
542 r->name = "PIIX/ICH"; 547 r->name = "PIIX/ICH";
543 r->get = pirq_piix_get; 548 r->get = pirq_piix_get;
544 r->set = pirq_piix_set; 549 r->set = pirq_piix_set;
diff --git a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c
index 4bb4d4b0f73a..0ee8a983708c 100644
--- a/arch/i386/pci/mmconfig.c
+++ b/arch/i386/pci/mmconfig.c
@@ -36,8 +36,7 @@ static u32 get_base_addr(unsigned int seg, int bus, unsigned devfn)
36 while (1) { 36 while (1) {
37 ++cfg_num; 37 ++cfg_num;
38 if (cfg_num >= pci_mmcfg_config_num) { 38 if (cfg_num >= pci_mmcfg_config_num) {
39 /* Not found - fallback to type 1 */ 39 break;
40 return 0;
41 } 40 }
42 cfg = &pci_mmcfg_config[cfg_num]; 41 cfg = &pci_mmcfg_config[cfg_num];
43 if (cfg->pci_segment_group_number != seg) 42 if (cfg->pci_segment_group_number != seg)
@@ -46,6 +45,18 @@ static u32 get_base_addr(unsigned int seg, int bus, unsigned devfn)
46 (cfg->end_bus_number >= bus)) 45 (cfg->end_bus_number >= bus))
47 return cfg->base_address; 46 return cfg->base_address;
48 } 47 }
48
49 /* Handle more broken MCFG tables on Asus etc.
50 They only contain a single entry for bus 0-0. Assume
51 this applies to all busses. */
52 cfg = &pci_mmcfg_config[0];
53 if (pci_mmcfg_config_num == 1 &&
54 cfg->pci_segment_group_number == 0 &&
55 (cfg->start_bus_number | cfg->end_bus_number) == 0)
56 return cfg->base_address;
57
58 /* Fall back to type 0 */
59 return 0;
49} 60}
50 61
51static inline void pci_exp_set_dev_base(unsigned int base, int bus, int devfn) 62static inline void pci_exp_set_dev_base(unsigned int base, int bus, int devfn)
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 199eeaf0f4e3..845cd0902a50 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -194,7 +194,6 @@ config IA64_L1_CACHE_SHIFT
194 default "7" if MCKINLEY 194 default "7" if MCKINLEY
195 default "6" if ITANIUM 195 default "6" if ITANIUM
196 196
197# align cache-sensitive data to 64 bytes
198config IA64_CYCLONE 197config IA64_CYCLONE
199 bool "Cyclone (EXA) Time Source support" 198 bool "Cyclone (EXA) Time Source support"
200 help 199 help
@@ -374,6 +373,9 @@ config IA64_PALINFO
374 To use this option, you have to ensure that the "/proc file system 373 To use this option, you have to ensure that the "/proc file system
375 support" (CONFIG_PROC_FS) is enabled, too. 374 support" (CONFIG_PROC_FS) is enabled, too.
376 375
376config SGI_SN
377 def_bool y if (IA64_SGI_SN2 || IA64_GENERIC)
378
377source "drivers/firmware/Kconfig" 379source "drivers/firmware/Kconfig"
378 380
379source "fs/Kconfig.binfmt" 381source "fs/Kconfig.binfmt"
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index 307514f7a282..09a0dbc17fb6 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -13,6 +13,11 @@ obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o
13obj-$(CONFIG_IA64_GENERIC) += acpi-ext.o 13obj-$(CONFIG_IA64_GENERIC) += acpi-ext.o
14obj-$(CONFIG_IA64_HP_ZX1) += acpi-ext.o 14obj-$(CONFIG_IA64_HP_ZX1) += acpi-ext.o
15obj-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += acpi-ext.o 15obj-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += acpi-ext.o
16
17ifneq ($(CONFIG_ACPI_PROCESSOR),)
18obj-y += acpi-processor.o
19endif
20
16obj-$(CONFIG_IA64_PALINFO) += palinfo.o 21obj-$(CONFIG_IA64_PALINFO) += palinfo.o
17obj-$(CONFIG_IOSAPIC) += iosapic.o 22obj-$(CONFIG_IOSAPIC) += iosapic.o
18obj-$(CONFIG_MODULES) += module.o 23obj-$(CONFIG_MODULES) += module.o
diff --git a/arch/ia64/kernel/acpi-ext.c b/arch/ia64/kernel/acpi-ext.c
index 13a5b3b49bf8..4a5574ff007b 100644
--- a/arch/ia64/kernel/acpi-ext.c
+++ b/arch/ia64/kernel/acpi-ext.c
@@ -33,33 +33,33 @@ acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
33 struct acpi_vendor_info *info = (struct acpi_vendor_info *)context; 33 struct acpi_vendor_info *info = (struct acpi_vendor_info *)context;
34 struct acpi_resource_vendor *vendor; 34 struct acpi_resource_vendor *vendor;
35 struct acpi_vendor_descriptor *descriptor; 35 struct acpi_vendor_descriptor *descriptor;
36 u32 length; 36 u32 byte_length;
37 37
38 if (resource->id != ACPI_RSTYPE_VENDOR) 38 if (resource->type != ACPI_RESOURCE_TYPE_VENDOR)
39 return AE_OK; 39 return AE_OK;
40 40
41 vendor = (struct acpi_resource_vendor *)&resource->data; 41 vendor = (struct acpi_resource_vendor *)&resource->data;
42 descriptor = (struct acpi_vendor_descriptor *)vendor->reserved; 42 descriptor = (struct acpi_vendor_descriptor *)vendor->byte_data;
43 if (vendor->length <= sizeof(*info->descriptor) || 43 if (vendor->byte_length <= sizeof(*info->descriptor) ||
44 descriptor->guid_id != info->descriptor->guid_id || 44 descriptor->guid_id != info->descriptor->guid_id ||
45 efi_guidcmp(descriptor->guid, info->descriptor->guid)) 45 efi_guidcmp(descriptor->guid, info->descriptor->guid))
46 return AE_OK; 46 return AE_OK;
47 47
48 length = vendor->length - sizeof(struct acpi_vendor_descriptor); 48 byte_length = vendor->byte_length - sizeof(struct acpi_vendor_descriptor);
49 info->data = acpi_os_allocate(length); 49 info->data = acpi_os_allocate(byte_length);
50 if (!info->data) 50 if (!info->data)
51 return AE_NO_MEMORY; 51 return AE_NO_MEMORY;
52 52
53 memcpy(info->data, 53 memcpy(info->data,
54 vendor->reserved + sizeof(struct acpi_vendor_descriptor), 54 vendor->byte_data + sizeof(struct acpi_vendor_descriptor),
55 length); 55 byte_length);
56 info->length = length; 56 info->length = byte_length;
57 return AE_CTRL_TERMINATE; 57 return AE_CTRL_TERMINATE;
58} 58}
59 59
60acpi_status 60acpi_status
61acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id, 61acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id,
62 u8 ** data, u32 * length) 62 u8 ** data, u32 * byte_length)
63{ 63{
64 struct acpi_vendor_info info; 64 struct acpi_vendor_info info;
65 65
@@ -72,7 +72,7 @@ acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id,
72 return AE_NOT_FOUND; 72 return AE_NOT_FOUND;
73 73
74 *data = info.data; 74 *data = info.data;
75 *length = info.length; 75 *byte_length = info.length;
76 return AE_OK; 76 return AE_OK;
77} 77}
78 78
diff --git a/arch/ia64/kernel/acpi-processor.c b/arch/ia64/kernel/acpi-processor.c
new file mode 100644
index 000000000000..e683630c8ce2
--- /dev/null
+++ b/arch/ia64/kernel/acpi-processor.c
@@ -0,0 +1,67 @@
1/*
2 * arch/ia64/kernel/cpufreq/processor.c
3 *
4 * Copyright (C) 2005 Intel Corporation
5 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
6 * - Added _PDC for platforms with Intel CPUs
7 */
8
9#include <linux/kernel.h>
10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/acpi.h>
13
14#include <acpi/processor.h>
15#include <asm/acpi.h>
16
17static void init_intel_pdc(struct acpi_processor *pr)
18{
19 struct acpi_object_list *obj_list;
20 union acpi_object *obj;
21 u32 *buf;
22
23 /* allocate and initialize pdc. It will be used later. */
24 obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
25 if (!obj_list) {
26 printk(KERN_ERR "Memory allocation error\n");
27 return;
28 }
29
30 obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
31 if (!obj) {
32 printk(KERN_ERR "Memory allocation error\n");
33 kfree(obj_list);
34 return;
35 }
36
37 buf = kmalloc(12, GFP_KERNEL);
38 if (!buf) {
39 printk(KERN_ERR "Memory allocation error\n");
40 kfree(obj);
41 kfree(obj_list);
42 return;
43 }
44
45 buf[0] = ACPI_PDC_REVISION_ID;
46 buf[1] = 1;
47 buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
48
49 obj->type = ACPI_TYPE_BUFFER;
50 obj->buffer.length = 12;
51 obj->buffer.pointer = (u8 *) buf;
52 obj_list->count = 1;
53 obj_list->pointer = obj;
54 pr->pdc = obj_list;
55
56 return;
57}
58
59/* Initialize _PDC data based on the CPU vendor */
60void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
61{
62 pr->pdc = NULL;
63 init_intel_pdc(pr);
64 return;
65}
66
67EXPORT_SYMBOL(arch_acpi_processor_init_pdc);
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 9ad94ddf6687..d2702c419cf8 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -567,16 +567,16 @@ void __init acpi_numa_arch_fixup(void)
567 * success: return IRQ number (>=0) 567 * success: return IRQ number (>=0)
568 * failure: return < 0 568 * failure: return < 0
569 */ 569 */
570int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low) 570int acpi_register_gsi(u32 gsi, int triggering, int polarity)
571{ 571{
572 if (has_8259 && gsi < 16) 572 if (has_8259 && gsi < 16)
573 return isa_irq_to_vector(gsi); 573 return isa_irq_to_vector(gsi);
574 574
575 return iosapic_register_intr(gsi, 575 return iosapic_register_intr(gsi,
576 (active_high_low == 576 (polarity ==
577 ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH : 577 ACPI_ACTIVE_HIGH) ? IOSAPIC_POL_HIGH :
578 IOSAPIC_POL_LOW, 578 IOSAPIC_POL_LOW,
579 (edge_level == 579 (triggering ==
580 ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE : 580 ACPI_EDGE_SENSITIVE) ? IOSAPIC_EDGE :
581 IOSAPIC_LEVEL); 581 IOSAPIC_LEVEL);
582} 582}
diff --git a/arch/ia64/kernel/cpufreq/Makefile b/arch/ia64/kernel/cpufreq/Makefile
index f748d34c02f0..4838f2a57c7a 100644
--- a/arch/ia64/kernel/cpufreq/Makefile
+++ b/arch/ia64/kernel/cpufreq/Makefile
@@ -1 +1,2 @@
1obj-$(CONFIG_IA64_ACPI_CPUFREQ) += acpi-cpufreq.o 1obj-$(CONFIG_IA64_ACPI_CPUFREQ) += acpi-cpufreq.o
2
diff --git a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c b/arch/ia64/kernel/cpufreq/acpi-cpufreq.c
index da4d5cf80a48..5a1bf815282d 100644
--- a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c
+++ b/arch/ia64/kernel/cpufreq/acpi-cpufreq.c
@@ -269,48 +269,6 @@ acpi_cpufreq_verify (
269} 269}
270 270
271 271
272/*
273 * processor_init_pdc - let BIOS know about the SMP capabilities
274 * of this driver
275 * @perf: processor-specific acpi_io_data struct
276 * @cpu: CPU being initialized
277 *
278 * To avoid issues with legacy OSes, some BIOSes require to be informed of
279 * the SMP capabilities of OS P-state driver. Here we set the bits in _PDC
280 * accordingly. Actual call to _PDC is done in driver/acpi/processor.c
281 */
282static void
283processor_init_pdc (
284 struct acpi_processor_performance *perf,
285 unsigned int cpu,
286 struct acpi_object_list *obj_list
287 )
288{
289 union acpi_object *obj;
290 u32 *buf;
291
292 dprintk("processor_init_pdc\n");
293
294 perf->pdc = NULL;
295 /* Initialize pdc. It will be used later. */
296 if (!obj_list)
297 return;
298
299 if (!(obj_list->count && obj_list->pointer))
300 return;
301
302 obj = obj_list->pointer;
303 if ((obj->buffer.length == 12) && obj->buffer.pointer) {
304 buf = (u32 *)obj->buffer.pointer;
305 buf[0] = ACPI_PDC_REVISION_ID;
306 buf[1] = 1;
307 buf[2] = ACPI_PDC_EST_CAPABILITY_SMP;
308 perf->pdc = obj_list;
309 }
310 return;
311}
312
313
314static int 272static int
315acpi_cpufreq_cpu_init ( 273acpi_cpufreq_cpu_init (
316 struct cpufreq_policy *policy) 274 struct cpufreq_policy *policy)
@@ -320,14 +278,7 @@ acpi_cpufreq_cpu_init (
320 struct cpufreq_acpi_io *data; 278 struct cpufreq_acpi_io *data;
321 unsigned int result = 0; 279 unsigned int result = 0;
322 280
323 union acpi_object arg0 = {ACPI_TYPE_BUFFER};
324 u32 arg0_buf[3];
325 struct acpi_object_list arg_list = {1, &arg0};
326
327 dprintk("acpi_cpufreq_cpu_init\n"); 281 dprintk("acpi_cpufreq_cpu_init\n");
328 /* setup arg_list for _PDC settings */
329 arg0.buffer.length = 12;
330 arg0.buffer.pointer = (u8 *) arg0_buf;
331 282
332 data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); 283 data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL);
333 if (!data) 284 if (!data)
@@ -337,9 +288,7 @@ acpi_cpufreq_cpu_init (
337 288
338 acpi_io_data[cpu] = data; 289 acpi_io_data[cpu] = data;
339 290
340 processor_init_pdc(&data->acpi_data, cpu, &arg_list);
341 result = acpi_processor_register_performance(&data->acpi_data, cpu); 291 result = acpi_processor_register_performance(&data->acpi_data, cpu);
342 data->acpi_data.pdc = NULL;
343 292
344 if (result) 293 if (result)
345 goto err_free; 294 goto err_free;
diff --git a/arch/ia64/kernel/mca_asm.S b/arch/ia64/kernel/mca_asm.S
index 403a80a58c13..60a464bfd9e2 100644
--- a/arch/ia64/kernel/mca_asm.S
+++ b/arch/ia64/kernel/mca_asm.S
@@ -512,7 +512,7 @@ ia64_state_save:
512 st8 [temp1]=r12 // os_status, default is cold boot 512 st8 [temp1]=r12 // os_status, default is cold boot
513 mov r6=IA64_MCA_SAME_CONTEXT 513 mov r6=IA64_MCA_SAME_CONTEXT
514 ;; 514 ;;
515 st8 [temp1]=r6 // context, default is same context 515 st8 [temp2]=r6 // context, default is same context
516 516
517 // Save the pt_regs data that is not in minstate. The previous code 517 // Save the pt_regs data that is not in minstate. The previous code
518 // left regs at sos. 518 // left regs at sos.
diff --git a/arch/ia64/kernel/sal.c b/arch/ia64/kernel/sal.c
index acc0f132f86c..056f7a6eedc7 100644
--- a/arch/ia64/kernel/sal.c
+++ b/arch/ia64/kernel/sal.c
@@ -14,6 +14,7 @@
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/string.h> 15#include <linux/string.h>
16 16
17#include <asm/delay.h>
17#include <asm/page.h> 18#include <asm/page.h>
18#include <asm/sal.h> 19#include <asm/sal.h>
19#include <asm/pal.h> 20#include <asm/pal.h>
@@ -214,6 +215,78 @@ chk_nointroute_opt(void)
214static void __init sal_desc_ap_wakeup(void *p) { } 215static void __init sal_desc_ap_wakeup(void *p) { }
215#endif 216#endif
216 217
218/*
219 * HP rx5670 firmware polls for interrupts during SAL_CACHE_FLUSH by reading
220 * cr.ivr, but it never writes cr.eoi. This leaves any interrupt marked as
221 * "in-service" and masks other interrupts of equal or lower priority.
222 *
223 * HP internal defect reports: F1859, F2775, F3031.
224 */
225static int sal_cache_flush_drops_interrupts;
226
227static void __init
228check_sal_cache_flush (void)
229{
230 unsigned long flags, itv;
231 int cpu;
232 u64 vector;
233
234 cpu = get_cpu();
235 local_irq_save(flags);
236
237 /*
238 * Schedule a timer interrupt, wait until it's reported, and see if
239 * SAL_CACHE_FLUSH drops it.
240 */
241 itv = ia64_get_itv();
242 BUG_ON((itv & (1 << 16)) == 0);
243
244 ia64_set_itv(IA64_TIMER_VECTOR);
245 ia64_set_itm(ia64_get_itc() + 1000);
246
247 while (!ia64_get_irr(IA64_TIMER_VECTOR))
248 cpu_relax();
249
250 ia64_sal_cache_flush(3);
251
252 if (ia64_get_irr(IA64_TIMER_VECTOR)) {
253 vector = ia64_get_ivr();
254 ia64_eoi();
255 WARN_ON(vector != IA64_TIMER_VECTOR);
256 } else {
257 sal_cache_flush_drops_interrupts = 1;
258 printk(KERN_ERR "SAL: SAL_CACHE_FLUSH drops interrupts; "
259 "PAL_CACHE_FLUSH will be used instead\n");
260 ia64_eoi();
261 }
262
263 ia64_set_itv(itv);
264 local_irq_restore(flags);
265 put_cpu();
266}
267
268s64
269ia64_sal_cache_flush (u64 cache_type)
270{
271 struct ia64_sal_retval isrv;
272
273 if (sal_cache_flush_drops_interrupts) {
274 unsigned long flags;
275 u64 progress;
276 s64 rc;
277
278 progress = 0;
279 local_irq_save(flags);
280 rc = ia64_pal_cache_flush(cache_type,
281 PAL_CACHE_FLUSH_INVALIDATE, &progress, NULL);
282 local_irq_restore(flags);
283 return rc;
284 }
285
286 SAL_CALL(isrv, SAL_CACHE_FLUSH, cache_type, 0, 0, 0, 0, 0, 0);
287 return isrv.status;
288}
289
217void __init 290void __init
218ia64_sal_init (struct ia64_sal_systab *systab) 291ia64_sal_init (struct ia64_sal_systab *systab)
219{ 292{
@@ -262,6 +335,8 @@ ia64_sal_init (struct ia64_sal_systab *systab)
262 } 335 }
263 p += SAL_DESC_SIZE(*p); 336 p += SAL_DESC_SIZE(*p);
264 } 337 }
338
339 check_sal_cache_flush();
265} 340}
266 341
267int 342int
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 706b7734e191..6e5eea19fa67 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -71,31 +71,33 @@ static int __init topology_init(void)
71 int i, err = 0; 71 int i, err = 0;
72 72
73#ifdef CONFIG_NUMA 73#ifdef CONFIG_NUMA
74 sysfs_nodes = kmalloc(sizeof(struct node) * MAX_NUMNODES, GFP_KERNEL); 74 sysfs_nodes = kzalloc(sizeof(struct node) * MAX_NUMNODES, GFP_KERNEL);
75 if (!sysfs_nodes) { 75 if (!sysfs_nodes) {
76 err = -ENOMEM; 76 err = -ENOMEM;
77 goto out; 77 goto out;
78 } 78 }
79 memset(sysfs_nodes, 0, sizeof(struct node) * MAX_NUMNODES);
80 79
81 /* MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes? */ 80 /*
82 for_each_online_node(i) 81 * MCD - Do we want to register all ONLINE nodes, or all POSSIBLE nodes?
82 */
83 for_each_online_node(i) {
83 if ((err = register_node(&sysfs_nodes[i], i, 0))) 84 if ((err = register_node(&sysfs_nodes[i], i, 0)))
84 goto out; 85 goto out;
86 }
85#endif 87#endif
86 88
87 sysfs_cpus = kmalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL); 89 sysfs_cpus = kzalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL);
88 if (!sysfs_cpus) { 90 if (!sysfs_cpus) {
89 err = -ENOMEM; 91 err = -ENOMEM;
90 goto out; 92 goto out;
91 } 93 }
92 memset(sysfs_cpus, 0, sizeof(struct ia64_cpu) * NR_CPUS);
93 94
94 for_each_present_cpu(i) 95 for_each_present_cpu(i) {
95 if((err = arch_register_cpu(i))) 96 if((err = arch_register_cpu(i)))
96 goto out; 97 goto out;
98 }
97out: 99out:
98 return err; 100 return err;
99} 101}
100 102
101__initcall(topology_init); 103subsys_initcall(topology_init);
diff --git a/arch/ia64/kernel/unaligned.c b/arch/ia64/kernel/unaligned.c
index 43b45b65ee5a..f9e0ae936d1a 100644
--- a/arch/ia64/kernel/unaligned.c
+++ b/arch/ia64/kernel/unaligned.c
@@ -1283,8 +1283,9 @@ within_logging_rate_limit (void)
1283 1283
1284 if (jiffies - last_time > 5*HZ) 1284 if (jiffies - last_time > 5*HZ)
1285 count = 0; 1285 count = 0;
1286 if (++count < 5) { 1286 if (count < 5) {
1287 last_time = jiffies; 1287 last_time = jiffies;
1288 count++;
1288 return 1; 1289 return 1;
1289 } 1290 }
1290 return 0; 1291 return 0;
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index d27ecdcb6fca..0b30ca006286 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -193,12 +193,12 @@ add_io_space (struct pci_root_info *info, struct acpi_resource_address64 *addr)
193 goto free_resource; 193 goto free_resource;
194 } 194 }
195 195
196 min = addr->min_address_range; 196 min = addr->minimum;
197 max = min + addr->address_length - 1; 197 max = min + addr->address_length - 1;
198 if (addr->attribute.io.translation_attribute == ACPI_SPARSE_TRANSLATION) 198 if (addr->info.io.translation_type == ACPI_SPARSE_TRANSLATION)
199 sparse = 1; 199 sparse = 1;
200 200
201 space_nr = new_space(addr->address_translation_offset, sparse); 201 space_nr = new_space(addr->translation_offset, sparse);
202 if (space_nr == ~0) 202 if (space_nr == ~0)
203 goto free_name; 203 goto free_name;
204 204
@@ -285,7 +285,7 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
285 if (addr.resource_type == ACPI_MEMORY_RANGE) { 285 if (addr.resource_type == ACPI_MEMORY_RANGE) {
286 flags = IORESOURCE_MEM; 286 flags = IORESOURCE_MEM;
287 root = &iomem_resource; 287 root = &iomem_resource;
288 offset = addr.address_translation_offset; 288 offset = addr.translation_offset;
289 } else if (addr.resource_type == ACPI_IO_RANGE) { 289 } else if (addr.resource_type == ACPI_IO_RANGE) {
290 flags = IORESOURCE_IO; 290 flags = IORESOURCE_IO;
291 root = &ioport_resource; 291 root = &ioport_resource;
@@ -298,7 +298,7 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
298 window = &info->controller->window[info->controller->windows++]; 298 window = &info->controller->window[info->controller->windows++];
299 window->resource.name = info->name; 299 window->resource.name = info->name;
300 window->resource.flags = flags; 300 window->resource.flags = flags;
301 window->resource.start = addr.min_address_range + offset; 301 window->resource.start = addr.minimum + offset;
302 window->resource.end = window->resource.start + addr.address_length - 1; 302 window->resource.end = window->resource.start + addr.address_length - 1;
303 window->resource.child = NULL; 303 window->resource.child = NULL;
304 window->offset = offset; 304 window->offset = offset;
diff --git a/arch/ia64/sn/Makefile b/arch/ia64/sn/Makefile
index a269f6d84c29..79a7df02e812 100644
--- a/arch/ia64/sn/Makefile
+++ b/arch/ia64/sn/Makefile
@@ -9,6 +9,4 @@
9# Makefile for the sn ia64 subplatform 9# Makefile for the sn ia64 subplatform
10# 10#
11 11
12CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
13
14obj-y += kernel/ pci/ 12obj-y += kernel/ pci/
diff --git a/arch/ia64/sn/kernel/Makefile b/arch/ia64/sn/kernel/Makefile
index 4351c4ff9845..3e9b4eea7418 100644
--- a/arch/ia64/sn/kernel/Makefile
+++ b/arch/ia64/sn/kernel/Makefile
@@ -7,6 +7,8 @@
7# Copyright (C) 1999,2001-2005 Silicon Graphics, Inc. All Rights Reserved. 7# Copyright (C) 1999,2001-2005 Silicon Graphics, Inc. All Rights Reserved.
8# 8#
9 9
10CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
11
10obj-y += setup.o bte.o bte_error.o irq.o mca.o idle.o \ 12obj-y += setup.o bte.o bte_error.o irq.o mca.o idle.o \
11 huberror.o io_init.o iomv.o klconflib.o sn2/ 13 huberror.o io_init.o iomv.o klconflib.o sn2/
12obj-$(CONFIG_IA64_GENERIC) += machvec.o 14obj-$(CONFIG_IA64_GENERIC) += machvec.o
diff --git a/arch/ia64/sn/kernel/bte.c b/arch/ia64/sn/kernel/bte.c
index dd73c0cb754b..1f11db470d90 100644
--- a/arch/ia64/sn/kernel/bte.c
+++ b/arch/ia64/sn/kernel/bte.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9#include <linux/config.h> 9#include <linux/config.h>
@@ -186,18 +186,13 @@ retry_bteop:
186 186
187 /* Initialize the notification to a known value. */ 187 /* Initialize the notification to a known value. */
188 *bte->most_rcnt_na = BTE_WORD_BUSY; 188 *bte->most_rcnt_na = BTE_WORD_BUSY;
189 notif_phys_addr = TO_PHYS(ia64_tpa((unsigned long)bte->most_rcnt_na)); 189 notif_phys_addr = (u64)bte->most_rcnt_na;
190 190
191 if (is_shub2()) {
192 src = SH2_TIO_PHYS_TO_DMA(src);
193 dest = SH2_TIO_PHYS_TO_DMA(dest);
194 notif_phys_addr = SH2_TIO_PHYS_TO_DMA(notif_phys_addr);
195 }
196 /* Set the source and destination registers */ 191 /* Set the source and destination registers */
197 BTE_PRINTKV(("IBSA = 0x%lx)\n", (TO_PHYS(src)))); 192 BTE_PRINTKV(("IBSA = 0x%lx)\n", src));
198 BTE_SRC_STORE(bte, TO_PHYS(src)); 193 BTE_SRC_STORE(bte, src);
199 BTE_PRINTKV(("IBDA = 0x%lx)\n", (TO_PHYS(dest)))); 194 BTE_PRINTKV(("IBDA = 0x%lx)\n", dest));
200 BTE_DEST_STORE(bte, TO_PHYS(dest)); 195 BTE_DEST_STORE(bte, dest);
201 196
202 /* Set the notification register */ 197 /* Set the notification register */
203 BTE_PRINTKV(("IBNA = 0x%lx)\n", notif_phys_addr)); 198 BTE_PRINTKV(("IBNA = 0x%lx)\n", notif_phys_addr));
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 00700f7e6837..d7e4d79e16a8 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -10,6 +10,7 @@
10#include <linux/nodemask.h> 10#include <linux/nodemask.h>
11#include <asm/sn/types.h> 11#include <asm/sn/types.h>
12#include <asm/sn/addrs.h> 12#include <asm/sn/addrs.h>
13#include <asm/sn/sn_feature_sets.h>
13#include <asm/sn/geo.h> 14#include <asm/sn/geo.h>
14#include <asm/sn/io.h> 15#include <asm/sn/io.h>
15#include <asm/sn/pcibr_provider.h> 16#include <asm/sn/pcibr_provider.h>
@@ -173,8 +174,8 @@ sn_pcidev_info_get(struct pci_dev *dev)
173 */ 174 */
174static u8 war_implemented = 0; 175static u8 war_implemented = 0;
175 176
176static void sn_device_fixup_war(u64 nasid, u64 widget, int device, 177static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
177 struct sn_flush_device_common *common) 178 struct sn_flush_device_common *common)
178{ 179{
179 struct sn_flush_device_war *war_list; 180 struct sn_flush_device_war *war_list;
180 struct sn_flush_device_war *dev_entry; 181 struct sn_flush_device_war *dev_entry;
@@ -198,15 +199,16 @@ static void sn_device_fixup_war(u64 nasid, u64 widget, int device,
198 199
199 dev_entry = war_list + device; 200 dev_entry = war_list + device;
200 memcpy(common,dev_entry, sizeof(*common)); 201 memcpy(common,dev_entry, sizeof(*common));
201
202 kfree(war_list); 202 kfree(war_list);
203
204 return isrv.status;
203} 205}
204 206
205/* 207/*
206 * sn_fixup_ionodes() - This routine initializes the HUB data strcuture for 208 * sn_fixup_ionodes() - This routine initializes the HUB data strcuture for
207 * each node in the system. 209 * each node in the system.
208 */ 210 */
209static void sn_fixup_ionodes(void) 211static void __init sn_fixup_ionodes(void)
210{ 212{
211 struct sn_flush_device_kernel *sn_flush_device_kernel; 213 struct sn_flush_device_kernel *sn_flush_device_kernel;
212 struct sn_flush_device_kernel *dev_entry; 214 struct sn_flush_device_kernel *dev_entry;
@@ -279,23 +281,21 @@ static void sn_fixup_ionodes(void)
279 memset(dev_entry->common, 0x0, sizeof(struct 281 memset(dev_entry->common, 0x0, sizeof(struct
280 sn_flush_device_common)); 282 sn_flush_device_common));
281 283
282 status = sal_get_device_dmaflush_list(nasid, 284 if (sn_prom_feature_available(
283 widget, 285 PRF_DEVICE_FLUSH_LIST))
284 device, 286 status = sal_get_device_dmaflush_list(
287 nasid,
288 widget,
289 device,
285 (u64)(dev_entry->common)); 290 (u64)(dev_entry->common));
286 if (status) { 291 else
287 if (sn_sal_rev() < 0x0450) { 292 status = sn_device_fixup_war(nasid,
288 /* shortlived WAR for older 293 widget,
289 * PROM images 294 device,
290 */
291 sn_device_fixup_war(nasid,
292 widget,
293 device,
294 dev_entry->common); 295 dev_entry->common);
295 } 296 if (status != SALRET_OK)
296 else 297 panic("SAL call failed: %s\n",
297 BUG(); 298 ia64_sal_strerror(status));
298 }
299 299
300 spin_lock_init(&dev_entry->sfdl_flush_lock); 300 spin_lock_init(&dev_entry->sfdl_flush_lock);
301 } 301 }
@@ -467,6 +467,13 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
467 pcidev_info->pdi_sn_irq_info = NULL; 467 pcidev_info->pdi_sn_irq_info = NULL;
468 kfree(sn_irq_info); 468 kfree(sn_irq_info);
469 } 469 }
470
471 /*
472 * MSI currently not supported on altix. Remove this when
473 * the MSI abstraction patches are integrated into the kernel
474 * (sometime after 2.6.16 releases)
475 */
476 dev->no_msi = 1;
470} 477}
471 478
472/* 479/*
diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c
index ec37084bdc17..74d87d903d5d 100644
--- a/arch/ia64/sn/kernel/irq.c
+++ b/arch/ia64/sn/kernel/irq.c
@@ -5,11 +5,12 @@
5 * License. See the file "COPYING" in the main directory of this archive 5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details. 6 * for more details.
7 * 7 *
8 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 8 * Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
9 */ 9 */
10 10
11#include <linux/irq.h> 11#include <linux/irq.h>
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/init.h>
13#include <asm/sn/addrs.h> 14#include <asm/sn/addrs.h>
14#include <asm/sn/arch.h> 15#include <asm/sn/arch.h>
15#include <asm/sn/intr.h> 16#include <asm/sn/intr.h>
@@ -76,17 +77,15 @@ static void sn_enable_irq(unsigned int irq)
76 77
77static void sn_ack_irq(unsigned int irq) 78static void sn_ack_irq(unsigned int irq)
78{ 79{
79 u64 event_occurred, mask = 0; 80 u64 event_occurred, mask;
80 81
81 irq = irq & 0xff; 82 irq = irq & 0xff;
82 event_occurred = 83 event_occurred = HUB_L((u64*)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED));
83 HUB_L((u64*)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED));
84 mask = event_occurred & SH_ALL_INT_MASK; 84 mask = event_occurred & SH_ALL_INT_MASK;
85 HUB_S((u64*)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED_ALIAS), 85 HUB_S((u64*)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED_ALIAS), mask);
86 mask);
87 __set_bit(irq, (volatile void *)pda->sn_in_service_ivecs); 86 __set_bit(irq, (volatile void *)pda->sn_in_service_ivecs);
88 87
89 move_irq(irq); 88 move_native_irq(irq);
90} 89}
91 90
92static void sn_end_irq(unsigned int irq) 91static void sn_end_irq(unsigned int irq)
@@ -219,9 +218,8 @@ static void register_intr_pda(struct sn_irq_info *sn_irq_info)
219 pdacpu(cpu)->sn_last_irq = irq; 218 pdacpu(cpu)->sn_last_irq = irq;
220 } 219 }
221 220
222 if (pdacpu(cpu)->sn_first_irq == 0 || pdacpu(cpu)->sn_first_irq > irq) { 221 if (pdacpu(cpu)->sn_first_irq == 0 || pdacpu(cpu)->sn_first_irq > irq)
223 pdacpu(cpu)->sn_first_irq = irq; 222 pdacpu(cpu)->sn_first_irq = irq;
224 }
225} 223}
226 224
227static void unregister_intr_pda(struct sn_irq_info *sn_irq_info) 225static void unregister_intr_pda(struct sn_irq_info *sn_irq_info)
@@ -289,7 +287,7 @@ void sn_irq_fixup(struct pci_dev *pci_dev, struct sn_irq_info *sn_irq_info)
289 list_add_rcu(&sn_irq_info->list, sn_irq_lh[sn_irq_info->irq_irq]); 287 list_add_rcu(&sn_irq_info->list, sn_irq_lh[sn_irq_info->irq_irq]);
290 spin_unlock(&sn_irq_info_lock); 288 spin_unlock(&sn_irq_info_lock);
291 289
292 (void)register_intr_pda(sn_irq_info); 290 register_intr_pda(sn_irq_info);
293} 291}
294 292
295void sn_irq_unfixup(struct pci_dev *pci_dev) 293void sn_irq_unfixup(struct pci_dev *pci_dev)
@@ -419,7 +417,7 @@ void sn_lb_int_war_check(void)
419 rcu_read_unlock(); 417 rcu_read_unlock();
420} 418}
421 419
422void sn_irq_lh_init(void) 420void __init sn_irq_lh_init(void)
423{ 421{
424 int i; 422 int i;
425 423
@@ -434,5 +432,4 @@ void sn_irq_lh_init(void)
434 432
435 INIT_LIST_HEAD(sn_irq_lh[i]); 433 INIT_LIST_HEAD(sn_irq_lh[i]);
436 } 434 }
437
438} 435}
diff --git a/arch/ia64/sn/kernel/klconflib.c b/arch/ia64/sn/kernel/klconflib.c
index 0f11a3299cd2..87682b48ef83 100644
--- a/arch/ia64/sn/kernel/klconflib.c
+++ b/arch/ia64/sn/kernel/klconflib.c
@@ -78,31 +78,30 @@ format_module_id(char *buffer, moduleid_t m, int fmt)
78 position = MODULE_GET_BPOS(m); 78 position = MODULE_GET_BPOS(m);
79 79
80 if ((fmt == MODULE_FORMAT_BRIEF) || (fmt == MODULE_FORMAT_LCD)) { 80 if ((fmt == MODULE_FORMAT_BRIEF) || (fmt == MODULE_FORMAT_LCD)) {
81 /* Brief module number format, eg. 002c15 */ 81 /* Brief module number format, eg. 002c15 */
82 82
83 /* Decompress the rack number */ 83 /* Decompress the rack number */
84 *buffer++ = '0' + RACK_GET_CLASS(rack); 84 *buffer++ = '0' + RACK_GET_CLASS(rack);
85 *buffer++ = '0' + RACK_GET_GROUP(rack); 85 *buffer++ = '0' + RACK_GET_GROUP(rack);
86 *buffer++ = '0' + RACK_GET_NUM(rack); 86 *buffer++ = '0' + RACK_GET_NUM(rack);
87 87
88 /* Add the brick type */ 88 /* Add the brick type */
89 *buffer++ = brickchar; 89 *buffer++ = brickchar;
90 } 90 }
91 else if (fmt == MODULE_FORMAT_LONG) { 91 else if (fmt == MODULE_FORMAT_LONG) {
92 /* Fuller hwgraph format, eg. rack/002/bay/15 */ 92 /* Fuller hwgraph format, eg. rack/002/bay/15 */
93 93
94 strcpy(buffer, "rack" "/"); buffer += strlen(buffer); 94 strcpy(buffer, "rack" "/"); buffer += strlen(buffer);
95 95
96 *buffer++ = '0' + RACK_GET_CLASS(rack); 96 *buffer++ = '0' + RACK_GET_CLASS(rack);
97 *buffer++ = '0' + RACK_GET_GROUP(rack); 97 *buffer++ = '0' + RACK_GET_GROUP(rack);
98 *buffer++ = '0' + RACK_GET_NUM(rack); 98 *buffer++ = '0' + RACK_GET_NUM(rack);
99 99
100 strcpy(buffer, "/" "bay" "/"); buffer += strlen(buffer); 100 strcpy(buffer, "/" "bay" "/"); buffer += strlen(buffer);
101 } 101 }
102 102
103 /* Add the bay position, using at least two digits */ 103 /* Add the bay position, using at least two digits */
104 if (position < 10) 104 if (position < 10)
105 *buffer++ = '0'; 105 *buffer++ = '0';
106 sprintf(buffer, "%d", position); 106 sprintf(buffer, "%d", position);
107
108} 107}
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
index e510dce9971f..ee36bff93c30 100644
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -209,7 +209,7 @@ void __init early_sn_setup(void)
209} 209}
210 210
211extern int platform_intr_list[]; 211extern int platform_intr_list[];
212static int __initdata shub_1_1_found = 0; 212static int __initdata shub_1_1_found;
213 213
214/* 214/*
215 * sn_check_for_wars 215 * sn_check_for_wars
@@ -578,13 +578,17 @@ void __init sn_cpu_init(void)
578 sn_prom_type = 2; 578 sn_prom_type = 2;
579 else 579 else
580 sn_prom_type = 1; 580 sn_prom_type = 1;
581 printk("Running on medusa with %s PROM\n", (sn_prom_type == 1) ? "real" : "fake"); 581 printk(KERN_INFO "Running on medusa with %s PROM\n",
582 (sn_prom_type == 1) ? "real" : "fake");
582 } 583 }
583 584
584 memset(pda, 0, sizeof(pda)); 585 memset(pda, 0, sizeof(pda));
585 if (ia64_sn_get_sn_info(0, &sn_hub_info->shub2, &sn_hub_info->nasid_bitmask, &sn_hub_info->nasid_shift, 586 if (ia64_sn_get_sn_info(0, &sn_hub_info->shub2,
586 &sn_system_size, &sn_sharing_domain_size, &sn_partition_id, 587 &sn_hub_info->nasid_bitmask,
587 &sn_coherency_id, &sn_region_size)) 588 &sn_hub_info->nasid_shift,
589 &sn_system_size, &sn_sharing_domain_size,
590 &sn_partition_id, &sn_coherency_id,
591 &sn_region_size))
588 BUG(); 592 BUG();
589 sn_hub_info->as_shift = sn_hub_info->nasid_shift - 2; 593 sn_hub_info->as_shift = sn_hub_info->nasid_shift - 2;
590 594
@@ -716,7 +720,8 @@ void __init build_cnode_tables(void)
716 for_each_online_node(node) { 720 for_each_online_node(node) {
717 kl_config_hdr_t *klgraph_header; 721 kl_config_hdr_t *klgraph_header;
718 nasid = cnodeid_to_nasid(node); 722 nasid = cnodeid_to_nasid(node);
719 if ((klgraph_header = ia64_sn_get_klconfig_addr(nasid)) == NULL) 723 klgraph_header = ia64_sn_get_klconfig_addr(nasid);
724 if (klgraph_header == NULL)
720 BUG(); 725 BUG();
721 brd = NODE_OFFSET_TO_LBOARD(nasid, klgraph_header->ch_board_info); 726 brd = NODE_OFFSET_TO_LBOARD(nasid, klgraph_header->ch_board_info);
722 while (brd) { 727 while (brd) {
@@ -734,7 +739,7 @@ nasid_slice_to_cpuid(int nasid, int slice)
734{ 739{
735 long cpu; 740 long cpu;
736 741
737 for (cpu=0; cpu < NR_CPUS; cpu++) 742 for (cpu = 0; cpu < NR_CPUS; cpu++)
738 if (cpuid_to_nasid(cpu) == nasid && 743 if (cpuid_to_nasid(cpu) == nasid &&
739 cpuid_to_slice(cpu) == slice) 744 cpuid_to_slice(cpu) == slice)
740 return cpu; 745 return cpu;
diff --git a/arch/ia64/sn/kernel/sn2/Makefile b/arch/ia64/sn/kernel/sn2/Makefile
index 170bde4549da..99e177693234 100644
--- a/arch/ia64/sn/kernel/sn2/Makefile
+++ b/arch/ia64/sn/kernel/sn2/Makefile
@@ -9,5 +9,7 @@
9# sn2 specific kernel files 9# sn2 specific kernel files
10# 10#
11 11
12CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
13
12obj-y += cache.o io.o ptc_deadlock.o sn2_smp.o sn_proc_fs.o \ 14obj-y += cache.o io.o ptc_deadlock.o sn2_smp.o sn_proc_fs.o \
13 prominfo_proc.o timer.o timer_interrupt.o sn_hwperf.o 15 prominfo_proc.o timer.o timer_interrupt.o sn_hwperf.o
diff --git a/arch/ia64/sn/kernel/sn2/sn2_smp.c b/arch/ia64/sn/kernel/sn2/sn2_smp.c
index 471bbaa65d1b..f153a4c35c70 100644
--- a/arch/ia64/sn/kernel/sn2/sn2_smp.c
+++ b/arch/ia64/sn/kernel/sn2/sn2_smp.c
@@ -5,7 +5,7 @@
5 * License. See the file "COPYING" in the main directory of this archive 5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details. 6 * for more details.
7 * 7 *
8 * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved. 8 * Copyright (C) 2000-2006 Silicon Graphics, Inc. All rights reserved.
9 */ 9 */
10 10
11#include <linux/init.h> 11#include <linux/init.h>
@@ -46,104 +46,28 @@ DECLARE_PER_CPU(struct ptc_stats, ptcstats);
46 46
47static __cacheline_aligned DEFINE_SPINLOCK(sn2_global_ptc_lock); 47static __cacheline_aligned DEFINE_SPINLOCK(sn2_global_ptc_lock);
48 48
49void sn2_ptc_deadlock_recovery(short *, short, int, volatile unsigned long *, unsigned long data0, 49void sn2_ptc_deadlock_recovery(short *, short, short, int, volatile unsigned long *, unsigned long,
50 volatile unsigned long *, unsigned long data1); 50 volatile unsigned long *, unsigned long);
51 51
52#ifdef DEBUG_PTC
53/* 52/*
54 * ptctest: 53 * Note: some is the following is captured here to make degugging easier
55 * 54 * (the macros make more sense if you see the debug patch - not posted)
56 * xyz - 3 digit hex number:
57 * x - Force PTC purges to use shub:
58 * 0 - no force
59 * 1 - force
60 * y - interupt enable
61 * 0 - disable interrupts
62 * 1 - leave interuupts enabled
63 * z - type of lock:
64 * 0 - global lock
65 * 1 - node local lock
66 * 2 - no lock
67 *
68 * Note: on shub1, only ptctest == 0 is supported. Don't try other values!
69 */ 55 */
70
71static unsigned int sn2_ptctest = 0;
72
73static int __init ptc_test(char *str)
74{
75 get_option(&str, &sn2_ptctest);
76 return 1;
77}
78__setup("ptctest=", ptc_test);
79
80static inline int ptc_lock(unsigned long *flagp)
81{
82 unsigned long opt = sn2_ptctest & 255;
83
84 switch (opt) {
85 case 0x00:
86 spin_lock_irqsave(&sn2_global_ptc_lock, *flagp);
87 break;
88 case 0x01:
89 spin_lock_irqsave(&sn_nodepda->ptc_lock, *flagp);
90 break;
91 case 0x02:
92 local_irq_save(*flagp);
93 break;
94 case 0x10:
95 spin_lock(&sn2_global_ptc_lock);
96 break;
97 case 0x11:
98 spin_lock(&sn_nodepda->ptc_lock);
99 break;
100 case 0x12:
101 break;
102 default:
103 BUG();
104 }
105 return opt;
106}
107
108static inline void ptc_unlock(unsigned long flags, int opt)
109{
110 switch (opt) {
111 case 0x00:
112 spin_unlock_irqrestore(&sn2_global_ptc_lock, flags);
113 break;
114 case 0x01:
115 spin_unlock_irqrestore(&sn_nodepda->ptc_lock, flags);
116 break;
117 case 0x02:
118 local_irq_restore(flags);
119 break;
120 case 0x10:
121 spin_unlock(&sn2_global_ptc_lock);
122 break;
123 case 0x11:
124 spin_unlock(&sn_nodepda->ptc_lock);
125 break;
126 case 0x12:
127 break;
128 default:
129 BUG();
130 }
131}
132#else
133
134#define sn2_ptctest 0 56#define sn2_ptctest 0
57#define local_node_uses_ptc_ga(sh1) ((sh1) ? 1 : 0)
58#define max_active_pio(sh1) ((sh1) ? 32 : 7)
59#define reset_max_active_on_deadlock() 1
60#define PTC_LOCK(sh1) ((sh1) ? &sn2_global_ptc_lock : &sn_nodepda->ptc_lock)
135 61
136static inline int ptc_lock(unsigned long *flagp) 62static inline void ptc_lock(int sh1, unsigned long *flagp)
137{ 63{
138 spin_lock_irqsave(&sn2_global_ptc_lock, *flagp); 64 spin_lock_irqsave(PTC_LOCK(sh1), *flagp);
139 return 0;
140} 65}
141 66
142static inline void ptc_unlock(unsigned long flags, int opt) 67static inline void ptc_unlock(int sh1, unsigned long flags)
143{ 68{
144 spin_unlock_irqrestore(&sn2_global_ptc_lock, flags); 69 spin_unlock_irqrestore(PTC_LOCK(sh1), flags);
145} 70}
146#endif
147 71
148struct ptc_stats { 72struct ptc_stats {
149 unsigned long ptc_l; 73 unsigned long ptc_l;
@@ -151,27 +75,30 @@ struct ptc_stats {
151 unsigned long shub_ptc_flushes; 75 unsigned long shub_ptc_flushes;
152 unsigned long nodes_flushed; 76 unsigned long nodes_flushed;
153 unsigned long deadlocks; 77 unsigned long deadlocks;
78 unsigned long deadlocks2;
154 unsigned long lock_itc_clocks; 79 unsigned long lock_itc_clocks;
155 unsigned long shub_itc_clocks; 80 unsigned long shub_itc_clocks;
156 unsigned long shub_itc_clocks_max; 81 unsigned long shub_itc_clocks_max;
82 unsigned long shub_ptc_flushes_not_my_mm;
157}; 83};
158 84
159static inline unsigned long wait_piowc(void) 85static inline unsigned long wait_piowc(void)
160{ 86{
161 volatile unsigned long *piows, zeroval; 87 volatile unsigned long *piows;
162 unsigned long ws; 88 unsigned long zeroval, ws;
163 89
164 piows = pda->pio_write_status_addr; 90 piows = pda->pio_write_status_addr;
165 zeroval = pda->pio_write_status_val; 91 zeroval = pda->pio_write_status_val;
166 do { 92 do {
167 cpu_relax(); 93 cpu_relax();
168 } while (((ws = *piows) & SH_PIO_WRITE_STATUS_PENDING_WRITE_COUNT_MASK) != zeroval); 94 } while (((ws = *piows) & SH_PIO_WRITE_STATUS_PENDING_WRITE_COUNT_MASK) != zeroval);
169 return ws; 95 return (ws & SH_PIO_WRITE_STATUS_WRITE_DEADLOCK_MASK) != 0;
170} 96}
171 97
172void sn_tlb_migrate_finish(struct mm_struct *mm) 98void sn_tlb_migrate_finish(struct mm_struct *mm)
173{ 99{
174 if (mm == current->mm) 100 /* flush_tlb_mm is inefficient if more than 1 users of mm */
101 if (mm == current->mm && mm && atomic_read(&mm->mm_users) == 1)
175 flush_tlb_mm(mm); 102 flush_tlb_mm(mm);
176} 103}
177 104
@@ -201,12 +128,14 @@ void
201sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start, 128sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start,
202 unsigned long end, unsigned long nbits) 129 unsigned long end, unsigned long nbits)
203{ 130{
204 int i, opt, shub1, cnode, mynasid, cpu, lcpu = 0, nasid, flushed = 0; 131 int i, ibegin, shub1, cnode, mynasid, cpu, lcpu = 0, nasid;
205 int mymm = (mm == current->active_mm && current->mm); 132 int mymm = (mm == current->active_mm && mm == current->mm);
133 int use_cpu_ptcga;
206 volatile unsigned long *ptc0, *ptc1; 134 volatile unsigned long *ptc0, *ptc1;
207 unsigned long itc, itc2, flags, data0 = 0, data1 = 0, rr_value; 135 unsigned long itc, itc2, flags, data0 = 0, data1 = 0, rr_value, old_rr = 0;
208 short nasids[MAX_NUMNODES], nix; 136 short nasids[MAX_NUMNODES], nix;
209 nodemask_t nodes_flushed; 137 nodemask_t nodes_flushed;
138 int active, max_active, deadlock;
210 139
211 nodes_clear(nodes_flushed); 140 nodes_clear(nodes_flushed);
212 i = 0; 141 i = 0;
@@ -267,41 +196,56 @@ sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start,
267 196
268 197
269 mynasid = get_nasid(); 198 mynasid = get_nasid();
199 use_cpu_ptcga = local_node_uses_ptc_ga(shub1);
200 max_active = max_active_pio(shub1);
270 201
271 itc = ia64_get_itc(); 202 itc = ia64_get_itc();
272 opt = ptc_lock(&flags); 203 ptc_lock(shub1, &flags);
273 itc2 = ia64_get_itc(); 204 itc2 = ia64_get_itc();
205
274 __get_cpu_var(ptcstats).lock_itc_clocks += itc2 - itc; 206 __get_cpu_var(ptcstats).lock_itc_clocks += itc2 - itc;
275 __get_cpu_var(ptcstats).shub_ptc_flushes++; 207 __get_cpu_var(ptcstats).shub_ptc_flushes++;
276 __get_cpu_var(ptcstats).nodes_flushed += nix; 208 __get_cpu_var(ptcstats).nodes_flushed += nix;
209 if (!mymm)
210 __get_cpu_var(ptcstats).shub_ptc_flushes_not_my_mm++;
277 211
212 if (use_cpu_ptcga && !mymm) {
213 old_rr = ia64_get_rr(start);
214 ia64_set_rr(start, (old_rr & 0xff) | (rr_value << 8));
215 ia64_srlz_d();
216 }
217
218 wait_piowc();
278 do { 219 do {
279 if (shub1) 220 if (shub1)
280 data1 = start | (1UL << SH1_PTC_1_START_SHFT); 221 data1 = start | (1UL << SH1_PTC_1_START_SHFT);
281 else 222 else
282 data0 = (data0 & ~SH2_PTC_ADDR_MASK) | (start & SH2_PTC_ADDR_MASK); 223 data0 = (data0 & ~SH2_PTC_ADDR_MASK) | (start & SH2_PTC_ADDR_MASK);
283 for (i = 0; i < nix; i++) { 224 deadlock = 0;
225 active = 0;
226 for (ibegin = 0, i = 0; i < nix; i++) {
284 nasid = nasids[i]; 227 nasid = nasids[i];
285 if ((!(sn2_ptctest & 3)) && unlikely(nasid == mynasid && mymm)) { 228 if (use_cpu_ptcga && unlikely(nasid == mynasid)) {
286 ia64_ptcga(start, nbits << 2); 229 ia64_ptcga(start, nbits << 2);
287 ia64_srlz_i(); 230 ia64_srlz_i();
288 } else { 231 } else {
289 ptc0 = CHANGE_NASID(nasid, ptc0); 232 ptc0 = CHANGE_NASID(nasid, ptc0);
290 if (ptc1) 233 if (ptc1)
291 ptc1 = CHANGE_NASID(nasid, ptc1); 234 ptc1 = CHANGE_NASID(nasid, ptc1);
292 pio_atomic_phys_write_mmrs(ptc0, data0, ptc1, 235 pio_atomic_phys_write_mmrs(ptc0, data0, ptc1, data1);
293 data1); 236 active++;
294 flushed = 1; 237 }
238 if (active >= max_active || i == (nix - 1)) {
239 if ((deadlock = wait_piowc())) {
240 sn2_ptc_deadlock_recovery(nasids, ibegin, i, mynasid, ptc0, data0, ptc1, data1);
241 if (reset_max_active_on_deadlock())
242 max_active = 1;
243 }
244 active = 0;
245 ibegin = i + 1;
295 } 246 }
296 } 247 }
297 if (flushed
298 && (wait_piowc() &
299 (SH_PIO_WRITE_STATUS_WRITE_DEADLOCK_MASK))) {
300 sn2_ptc_deadlock_recovery(nasids, nix, mynasid, ptc0, data0, ptc1, data1);
301 }
302
303 start += (1UL << nbits); 248 start += (1UL << nbits);
304
305 } while (start < end); 249 } while (start < end);
306 250
307 itc2 = ia64_get_itc() - itc2; 251 itc2 = ia64_get_itc() - itc2;
@@ -309,7 +253,12 @@ sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start,
309 if (itc2 > __get_cpu_var(ptcstats).shub_itc_clocks_max) 253 if (itc2 > __get_cpu_var(ptcstats).shub_itc_clocks_max)
310 __get_cpu_var(ptcstats).shub_itc_clocks_max = itc2; 254 __get_cpu_var(ptcstats).shub_itc_clocks_max = itc2;
311 255
312 ptc_unlock(flags, opt); 256 if (old_rr) {
257 ia64_set_rr(start, old_rr);
258 ia64_srlz_d();
259 }
260
261 ptc_unlock(shub1, flags);
313 262
314 preempt_enable(); 263 preempt_enable();
315} 264}
@@ -321,27 +270,30 @@ sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start,
321 * TLB flush transaction. The recovery sequence is somewhat tricky & is 270 * TLB flush transaction. The recovery sequence is somewhat tricky & is
322 * coded in assembly language. 271 * coded in assembly language.
323 */ 272 */
324void sn2_ptc_deadlock_recovery(short *nasids, short nix, int mynasid, volatile unsigned long *ptc0, unsigned long data0, 273void sn2_ptc_deadlock_recovery(short *nasids, short ib, short ie, int mynasid, volatile unsigned long *ptc0, unsigned long data0,
325 volatile unsigned long *ptc1, unsigned long data1) 274 volatile unsigned long *ptc1, unsigned long data1)
326{ 275{
327 extern void sn2_ptc_deadlock_recovery_core(volatile unsigned long *, unsigned long, 276 extern unsigned long sn2_ptc_deadlock_recovery_core(volatile unsigned long *, unsigned long,
328 volatile unsigned long *, unsigned long, volatile unsigned long *, unsigned long); 277 volatile unsigned long *, unsigned long, volatile unsigned long *, unsigned long);
329 short nasid, i; 278 short nasid, i;
330 unsigned long *piows, zeroval; 279 unsigned long *piows, zeroval, n;
331 280
332 __get_cpu_var(ptcstats).deadlocks++; 281 __get_cpu_var(ptcstats).deadlocks++;
333 282
334 piows = (unsigned long *) pda->pio_write_status_addr; 283 piows = (unsigned long *) pda->pio_write_status_addr;
335 zeroval = pda->pio_write_status_val; 284 zeroval = pda->pio_write_status_val;
336 285
337 for (i=0; i < nix; i++) { 286
287 for (i=ib; i <= ie; i++) {
338 nasid = nasids[i]; 288 nasid = nasids[i];
339 if (!(sn2_ptctest & 3) && nasid == mynasid) 289 if (local_node_uses_ptc_ga(is_shub1()) && nasid == mynasid)
340 continue; 290 continue;
341 ptc0 = CHANGE_NASID(nasid, ptc0); 291 ptc0 = CHANGE_NASID(nasid, ptc0);
342 if (ptc1) 292 if (ptc1)
343 ptc1 = CHANGE_NASID(nasid, ptc1); 293 ptc1 = CHANGE_NASID(nasid, ptc1);
344 sn2_ptc_deadlock_recovery_core(ptc0, data0, ptc1, data1, piows, zeroval); 294
295 n = sn2_ptc_deadlock_recovery_core(ptc0, data0, ptc1, data1, piows, zeroval);
296 __get_cpu_var(ptcstats).deadlocks2 += n;
345 } 297 }
346 298
347} 299}
@@ -452,20 +404,22 @@ static int sn2_ptc_seq_show(struct seq_file *file, void *data)
452 cpu = *(loff_t *) data; 404 cpu = *(loff_t *) data;
453 405
454 if (!cpu) { 406 if (!cpu) {
455 seq_printf(file, "# ptc_l change_rid shub_ptc_flushes shub_nodes_flushed deadlocks lock_nsec shub_nsec shub_nsec_max\n"); 407 seq_printf(file,
408 "# cpu ptc_l newrid ptc_flushes nodes_flushed deadlocks lock_nsec shub_nsec shub_nsec_max not_my_mm deadlock2\n");
456 seq_printf(file, "# ptctest %d\n", sn2_ptctest); 409 seq_printf(file, "# ptctest %d\n", sn2_ptctest);
457 } 410 }
458 411
459 if (cpu < NR_CPUS && cpu_online(cpu)) { 412 if (cpu < NR_CPUS && cpu_online(cpu)) {
460 stat = &per_cpu(ptcstats, cpu); 413 stat = &per_cpu(ptcstats, cpu);
461 seq_printf(file, "cpu %d %ld %ld %ld %ld %ld %ld %ld %ld\n", cpu, stat->ptc_l, 414 seq_printf(file, "cpu %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n", cpu, stat->ptc_l,
462 stat->change_rid, stat->shub_ptc_flushes, stat->nodes_flushed, 415 stat->change_rid, stat->shub_ptc_flushes, stat->nodes_flushed,
463 stat->deadlocks, 416 stat->deadlocks,
464 1000 * stat->lock_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec, 417 1000 * stat->lock_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec,
465 1000 * stat->shub_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec, 418 1000 * stat->shub_itc_clocks / per_cpu(cpu_info, cpu).cyc_per_usec,
466 1000 * stat->shub_itc_clocks_max / per_cpu(cpu_info, cpu).cyc_per_usec); 419 1000 * stat->shub_itc_clocks_max / per_cpu(cpu_info, cpu).cyc_per_usec,
420 stat->shub_ptc_flushes_not_my_mm,
421 stat->deadlocks2);
467 } 422 }
468
469 return 0; 423 return 0;
470} 424}
471 425
@@ -476,7 +430,7 @@ static struct seq_operations sn2_ptc_seq_ops = {
476 .show = sn2_ptc_seq_show 430 .show = sn2_ptc_seq_show
477}; 431};
478 432
479int sn2_ptc_proc_open(struct inode *inode, struct file *file) 433static int sn2_ptc_proc_open(struct inode *inode, struct file *file)
480{ 434{
481 return seq_open(file, &sn2_ptc_seq_ops); 435 return seq_open(file, &sn2_ptc_seq_ops);
482} 436}
diff --git a/arch/ia64/sn/kernel/xpc_channel.c b/arch/ia64/sn/kernel/xpc_channel.c
index 8d950c778bb6..36e5437a0fb6 100644
--- a/arch/ia64/sn/kernel/xpc_channel.c
+++ b/arch/ia64/sn/kernel/xpc_channel.c
@@ -447,7 +447,7 @@ xpc_allocate_local_msgqueue(struct xpc_channel *ch)
447 447
448 nbytes = nentries * ch->msg_size; 448 nbytes = nentries * ch->msg_size;
449 ch->local_msgqueue = xpc_kmalloc_cacheline_aligned(nbytes, 449 ch->local_msgqueue = xpc_kmalloc_cacheline_aligned(nbytes,
450 (GFP_KERNEL | GFP_DMA), 450 GFP_KERNEL,
451 &ch->local_msgqueue_base); 451 &ch->local_msgqueue_base);
452 if (ch->local_msgqueue == NULL) { 452 if (ch->local_msgqueue == NULL) {
453 continue; 453 continue;
@@ -455,7 +455,7 @@ xpc_allocate_local_msgqueue(struct xpc_channel *ch)
455 memset(ch->local_msgqueue, 0, nbytes); 455 memset(ch->local_msgqueue, 0, nbytes);
456 456
457 nbytes = nentries * sizeof(struct xpc_notify); 457 nbytes = nentries * sizeof(struct xpc_notify);
458 ch->notify_queue = kmalloc(nbytes, (GFP_KERNEL | GFP_DMA)); 458 ch->notify_queue = kmalloc(nbytes, GFP_KERNEL);
459 if (ch->notify_queue == NULL) { 459 if (ch->notify_queue == NULL) {
460 kfree(ch->local_msgqueue_base); 460 kfree(ch->local_msgqueue_base);
461 ch->local_msgqueue = NULL; 461 ch->local_msgqueue = NULL;
@@ -502,7 +502,7 @@ xpc_allocate_remote_msgqueue(struct xpc_channel *ch)
502 502
503 nbytes = nentries * ch->msg_size; 503 nbytes = nentries * ch->msg_size;
504 ch->remote_msgqueue = xpc_kmalloc_cacheline_aligned(nbytes, 504 ch->remote_msgqueue = xpc_kmalloc_cacheline_aligned(nbytes,
505 (GFP_KERNEL | GFP_DMA), 505 GFP_KERNEL,
506 &ch->remote_msgqueue_base); 506 &ch->remote_msgqueue_base);
507 if (ch->remote_msgqueue == NULL) { 507 if (ch->remote_msgqueue == NULL) {
508 continue; 508 continue;
diff --git a/arch/ia64/sn/kernel/xpc_main.c b/arch/ia64/sn/kernel/xpc_main.c
index c75f8aeefc2b..9cd460dfe27e 100644
--- a/arch/ia64/sn/kernel/xpc_main.c
+++ b/arch/ia64/sn/kernel/xpc_main.c
@@ -575,18 +575,21 @@ xpc_activate_partition(struct xpc_partition *part)
575 575
576 spin_lock_irqsave(&part->act_lock, irq_flags); 576 spin_lock_irqsave(&part->act_lock, irq_flags);
577 577
578 pid = kernel_thread(xpc_activating, (void *) ((u64) partid), 0);
579
580 DBUG_ON(part->act_state != XPC_P_INACTIVE); 578 DBUG_ON(part->act_state != XPC_P_INACTIVE);
581 579
582 if (pid > 0) { 580 part->act_state = XPC_P_ACTIVATION_REQ;
583 part->act_state = XPC_P_ACTIVATION_REQ; 581 XPC_SET_REASON(part, xpcCloneKThread, __LINE__);
584 XPC_SET_REASON(part, xpcCloneKThread, __LINE__);
585 } else {
586 XPC_SET_REASON(part, xpcCloneKThreadFailed, __LINE__);
587 }
588 582
589 spin_unlock_irqrestore(&part->act_lock, irq_flags); 583 spin_unlock_irqrestore(&part->act_lock, irq_flags);
584
585 pid = kernel_thread(xpc_activating, (void *) ((u64) partid), 0);
586
587 if (unlikely(pid <= 0)) {
588 spin_lock_irqsave(&part->act_lock, irq_flags);
589 part->act_state = XPC_P_INACTIVE;
590 XPC_SET_REASON(part, xpcCloneKThreadFailed, __LINE__);
591 spin_unlock_irqrestore(&part->act_lock, irq_flags);
592 }
590} 593}
591 594
592 595
diff --git a/arch/ia64/sn/pci/Makefile b/arch/ia64/sn/pci/Makefile
index 321576b1b425..c6946784a6a8 100644
--- a/arch/ia64/sn/pci/Makefile
+++ b/arch/ia64/sn/pci/Makefile
@@ -7,4 +7,6 @@
7# 7#
8# Makefile for the sn pci general routines. 8# Makefile for the sn pci general routines.
9 9
10CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
11
10obj-y := pci_dma.o tioca_provider.o tioce_provider.o pcibr/ 12obj-y := pci_dma.o tioca_provider.o tioce_provider.o pcibr/
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index 9bf9f23b9a1f..5a36292388eb 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -90,14 +90,14 @@ void *sn_dma_alloc_coherent(struct device *dev, size_t size,
90 */ 90 */
91 node = pcibus_to_node(pdev->bus); 91 node = pcibus_to_node(pdev->bus);
92 if (likely(node >=0)) { 92 if (likely(node >=0)) {
93 struct page *p = alloc_pages_node(node, GFP_ATOMIC, get_order(size)); 93 struct page *p = alloc_pages_node(node, flags, get_order(size));
94 94
95 if (likely(p)) 95 if (likely(p))
96 cpuaddr = page_address(p); 96 cpuaddr = page_address(p);
97 else 97 else
98 return NULL; 98 return NULL;
99 } else 99 } else
100 cpuaddr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size)); 100 cpuaddr = (void *)__get_free_pages(flags, get_order(size));
101 101
102 if (unlikely(!cpuaddr)) 102 if (unlikely(!cpuaddr))
103 return NULL; 103 return NULL;
diff --git a/arch/ia64/sn/pci/pcibr/Makefile b/arch/ia64/sn/pci/pcibr/Makefile
index 1850c4a94c41..3b403ea456f9 100644
--- a/arch/ia64/sn/pci/pcibr/Makefile
+++ b/arch/ia64/sn/pci/pcibr/Makefile
@@ -7,5 +7,7 @@
7# 7#
8# Makefile for the sn2 io routines. 8# Makefile for the sn2 io routines.
9 9
10CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
11
10obj-y += pcibr_dma.o pcibr_reg.o \ 12obj-y += pcibr_dma.o pcibr_reg.o \
11 pcibr_ate.o pcibr_provider.o 13 pcibr_ate.o pcibr_provider.o
diff --git a/arch/mips/kernel/gdb-stub.c b/arch/mips/kernel/gdb-stub.c
index 96d18c43dca0..d4f88e0af24c 100644
--- a/arch/mips/kernel/gdb-stub.c
+++ b/arch/mips/kernel/gdb-stub.c
@@ -178,7 +178,7 @@ int kgdb_enabled;
178 */ 178 */
179static DEFINE_SPINLOCK(kgdb_lock); 179static DEFINE_SPINLOCK(kgdb_lock);
180static raw_spinlock_t kgdb_cpulock[NR_CPUS] = { 180static raw_spinlock_t kgdb_cpulock[NR_CPUS] = {
181 [0 ... NR_CPUS-1] = __RAW_SPIN_LOCK_UNLOCKED; 181 [0 ... NR_CPUS-1] = __RAW_SPIN_LOCK_UNLOCKED,
182}; 182};
183 183
184/* 184/*
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index e77a06e9621e..7c914a4c67c3 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -149,14 +149,20 @@ config HOTPLUG_CPU
149 default y if SMP 149 default y if SMP
150 select HOTPLUG 150 select HOTPLUG
151 151
152config ARCH_SELECT_MEMORY_MODEL
153 def_bool y
154 depends on 64BIT
155
152config ARCH_DISCONTIGMEM_ENABLE 156config ARCH_DISCONTIGMEM_ENABLE
153 bool "Discontiguous memory support (EXPERIMENTAL)" 157 def_bool y
154 depends on 64BIT && EXPERIMENTAL 158 depends on 64BIT
155 help 159
156 Say Y to support efficient handling of discontiguous physical memory, 160config ARCH_FLATMEM_ENABLE
157 for architectures which are either NUMA (Non-Uniform Memory Access) 161 def_bool y
158 or have huge holes in the physical address space for other reasons. 162
159 See <file:Documentation/vm/numa> for more. 163config ARCH_DISCONTIGMEM_DEFAULT
164 def_bool y
165 depends on ARCH_DISCONTIGMEM_ENABLE
160 166
161source "kernel/Kconfig.hz" 167source "kernel/Kconfig.hz"
162source "mm/Kconfig" 168source "mm/Kconfig"
diff --git a/arch/parisc/Kconfig.debug b/arch/parisc/Kconfig.debug
index 8caaed187a1f..9166bd117267 100644
--- a/arch/parisc/Kconfig.debug
+++ b/arch/parisc/Kconfig.debug
@@ -11,4 +11,14 @@ config DEBUG_RWLOCK
11 too many attempts. If you suspect a rwlock problem or a kernel 11 too many attempts. If you suspect a rwlock problem or a kernel
12 hacker asks for this option then say Y. Otherwise say N. 12 hacker asks for this option then say Y. Otherwise say N.
13 13
14config DEBUG_RODATA
15 bool "Write protect kernel read-only data structures"
16 depends on DEBUG_KERNEL
17 help
18 Mark the kernel read-only data as write-protected in the pagetables,
19 in order to catch accidental (and incorrect) writes to such const
20 data. This option may have a slight performance impact because a
21 portion of the kernel code won't be covered by a TLB anymore.
22 If in doubt, say "N".
23
14endmenu 24endmenu
diff --git a/arch/parisc/configs/b180_defconfig b/arch/parisc/configs/b180_defconfig
index 8819e7e6ae3f..37e98241ce4b 100644
--- a/arch/parisc/configs/b180_defconfig
+++ b/arch/parisc/configs/b180_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.14-rc5-pa1 3# Linux kernel version: 2.6.16-rc1-pa0
4# Fri Oct 21 23:06:10 2005 4# Tue Jan 17 08:21:01 2006
5# 5#
6CONFIG_PARISC=y 6CONFIG_PARISC=y
7CONFIG_MMU=y 7CONFIG_MMU=y
@@ -29,8 +29,6 @@ CONFIG_SYSVIPC=y
29# CONFIG_BSD_PROCESS_ACCT is not set 29# CONFIG_BSD_PROCESS_ACCT is not set
30CONFIG_SYSCTL=y 30CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set 31# CONFIG_AUDIT is not set
32# CONFIG_HOTPLUG is not set
33CONFIG_KOBJECT_UEVENT=y
34CONFIG_IKCONFIG=y 32CONFIG_IKCONFIG=y
35CONFIG_IKCONFIG_PROC=y 33CONFIG_IKCONFIG_PROC=y
36CONFIG_INITRAMFS_SOURCE="" 34CONFIG_INITRAMFS_SOURCE=""
@@ -38,8 +36,10 @@ CONFIG_INITRAMFS_SOURCE=""
38CONFIG_KALLSYMS=y 36CONFIG_KALLSYMS=y
39# CONFIG_KALLSYMS_ALL is not set 37# CONFIG_KALLSYMS_ALL is not set
40# CONFIG_KALLSYMS_EXTRA_PASS is not set 38# CONFIG_KALLSYMS_EXTRA_PASS is not set
39CONFIG_HOTPLUG=y
41CONFIG_PRINTK=y 40CONFIG_PRINTK=y
42CONFIG_BUG=y 41CONFIG_BUG=y
42CONFIG_ELF_CORE=y
43CONFIG_BASE_FULL=y 43CONFIG_BASE_FULL=y
44CONFIG_FUTEX=y 44CONFIG_FUTEX=y
45CONFIG_EPOLL=y 45CONFIG_EPOLL=y
@@ -48,8 +48,10 @@ CONFIG_CC_ALIGN_FUNCTIONS=0
48CONFIG_CC_ALIGN_LABELS=0 48CONFIG_CC_ALIGN_LABELS=0
49CONFIG_CC_ALIGN_LOOPS=0 49CONFIG_CC_ALIGN_LOOPS=0
50CONFIG_CC_ALIGN_JUMPS=0 50CONFIG_CC_ALIGN_JUMPS=0
51CONFIG_SLAB=y
51# CONFIG_TINY_SHMEM is not set 52# CONFIG_TINY_SHMEM is not set
52CONFIG_BASE_SMALL=0 53CONFIG_BASE_SMALL=0
54# CONFIG_SLOB is not set
53 55
54# 56#
55# Loadable module support 57# Loadable module support
@@ -57,10 +59,28 @@ CONFIG_BASE_SMALL=0
57CONFIG_MODULES=y 59CONFIG_MODULES=y
58# CONFIG_MODULE_UNLOAD is not set 60# CONFIG_MODULE_UNLOAD is not set
59CONFIG_OBSOLETE_MODPARM=y 61CONFIG_OBSOLETE_MODPARM=y
62CONFIG_MODVERSIONS=y
60# CONFIG_MODULE_SRCVERSION_ALL is not set 63# CONFIG_MODULE_SRCVERSION_ALL is not set
61# CONFIG_KMOD is not set 64# CONFIG_KMOD is not set
62 65
63# 66#
67# Block layer
68#
69
70#
71# IO Schedulers
72#
73CONFIG_IOSCHED_NOOP=y
74CONFIG_IOSCHED_AS=y
75CONFIG_IOSCHED_DEADLINE=y
76CONFIG_IOSCHED_CFQ=y
77# CONFIG_DEFAULT_AS is not set
78# CONFIG_DEFAULT_DEADLINE is not set
79CONFIG_DEFAULT_CFQ=y
80# CONFIG_DEFAULT_NOOP is not set
81CONFIG_DEFAULT_IOSCHED="cfq"
82
83#
64# Processor type and features 84# Processor type and features
65# 85#
66# CONFIG_PA7000 is not set 86# CONFIG_PA7000 is not set
@@ -77,6 +97,7 @@ CONFIG_HZ=250
77CONFIG_FLATMEM=y 97CONFIG_FLATMEM=y
78CONFIG_FLAT_NODE_MEM_MAP=y 98CONFIG_FLAT_NODE_MEM_MAP=y
79# CONFIG_SPARSEMEM_STATIC is not set 99# CONFIG_SPARSEMEM_STATIC is not set
100CONFIG_SPLIT_PTLOCK_CPUS=4096
80# CONFIG_PREEMPT is not set 101# CONFIG_PREEMPT is not set
81# CONFIG_HPUX is not set 102# CONFIG_HPUX is not set
82 103
@@ -84,8 +105,8 @@ CONFIG_FLAT_NODE_MEM_MAP=y
84# Bus options (PCI, PCMCIA, EISA, GSC, ISA) 105# Bus options (PCI, PCMCIA, EISA, GSC, ISA)
85# 106#
86CONFIG_GSC=y 107CONFIG_GSC=y
87# CONFIG_HPPB is not set 108CONFIG_HPPB=y
88# CONFIG_IOMMU_CCIO is not set 109CONFIG_IOMMU_CCIO=y
89CONFIG_GSC_LASI=y 110CONFIG_GSC_LASI=y
90CONFIG_GSC_WAX=y 111CONFIG_GSC_WAX=y
91CONFIG_EISA=y 112CONFIG_EISA=y
@@ -165,8 +186,11 @@ CONFIG_IPV6=y
165# CONFIG_LLC2 is not set 186# CONFIG_LLC2 is not set
166# CONFIG_IPX is not set 187# CONFIG_IPX is not set
167# CONFIG_ATALK is not set 188# CONFIG_ATALK is not set
189
190#
191# QoS and/or fair queueing
192#
168# CONFIG_NET_SCHED is not set 193# CONFIG_NET_SCHED is not set
169# CONFIG_NET_CLS_ROUTE is not set
170 194
171# 195#
172# Network testing 196# Network testing
@@ -205,6 +229,7 @@ CONFIG_STANDALONE=y
205CONFIG_PARPORT=y 229CONFIG_PARPORT=y
206CONFIG_PARPORT_PC=y 230CONFIG_PARPORT_PC=y
207# CONFIG_PARPORT_SERIAL is not set 231# CONFIG_PARPORT_SERIAL is not set
232CONFIG_PARPORT_NOT_PC=y
208CONFIG_PARPORT_GSC=y 233CONFIG_PARPORT_GSC=y
209# CONFIG_PARPORT_1284 is not set 234# CONFIG_PARPORT_1284 is not set
210 235
@@ -230,14 +255,6 @@ CONFIG_BLK_DEV_RAM_COUNT=16
230CONFIG_CDROM_PKTCDVD=m 255CONFIG_CDROM_PKTCDVD=m
231CONFIG_CDROM_PKTCDVD_BUFFERS=8 256CONFIG_CDROM_PKTCDVD_BUFFERS=8
232# CONFIG_CDROM_PKTCDVD_WCACHE is not set 257# CONFIG_CDROM_PKTCDVD_WCACHE is not set
233
234#
235# IO Schedulers
236#
237CONFIG_IOSCHED_NOOP=y
238CONFIG_IOSCHED_AS=y
239CONFIG_IOSCHED_DEADLINE=y
240CONFIG_IOSCHED_CFQ=y
241CONFIG_ATA_OVER_ETH=y 258CONFIG_ATA_OVER_ETH=y
242 259
243# 260#
@@ -281,6 +298,7 @@ CONFIG_SCSI_SPI_ATTRS=y
281# 298#
282# SCSI low-level drivers 299# SCSI low-level drivers
283# 300#
301# CONFIG_ISCSI_TCP is not set
284# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 302# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
285# CONFIG_SCSI_3W_9XXX is not set 303# CONFIG_SCSI_3W_9XXX is not set
286# CONFIG_SCSI_ACARD is not set 304# CONFIG_SCSI_ACARD is not set
@@ -313,21 +331,19 @@ CONFIG_SCSI_SYM53C8XX_2=y
313CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0 331CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
314CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 332CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
315CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 333CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
316# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set 334CONFIG_SCSI_SYM53C8XX_MMIO=y
317# CONFIG_SCSI_IPR is not set 335# CONFIG_SCSI_IPR is not set
318# CONFIG_SCSI_ZALON is not set 336CONFIG_SCSI_ZALON=y
337CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8
338CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32
339CONFIG_SCSI_NCR53C8XX_SYNC=40
340# CONFIG_SCSI_NCR53C8XX_PROFILE is not set
319# CONFIG_SCSI_PAS16 is not set 341# CONFIG_SCSI_PAS16 is not set
320# CONFIG_SCSI_PSI240I is not set 342# CONFIG_SCSI_PSI240I is not set
321# CONFIG_SCSI_QLOGIC_FAS is not set 343# CONFIG_SCSI_QLOGIC_FAS is not set
322# CONFIG_SCSI_QLOGIC_FC is not set 344# CONFIG_SCSI_QLOGIC_FC is not set
323# CONFIG_SCSI_QLOGIC_1280 is not set 345# CONFIG_SCSI_QLOGIC_1280 is not set
324CONFIG_SCSI_QLA2XXX=y 346# CONFIG_SCSI_QLA_FC is not set
325# CONFIG_SCSI_QLA21XX is not set
326# CONFIG_SCSI_QLA22XX is not set
327# CONFIG_SCSI_QLA2300 is not set
328# CONFIG_SCSI_QLA2322 is not set
329# CONFIG_SCSI_QLA6312 is not set
330# CONFIG_SCSI_QLA24XX is not set
331# CONFIG_SCSI_LPFC is not set 347# CONFIG_SCSI_LPFC is not set
332# CONFIG_SCSI_SIM710 is not set 348# CONFIG_SCSI_SIM710 is not set
333# CONFIG_SCSI_SYM53C416 is not set 349# CONFIG_SCSI_SYM53C416 is not set
@@ -397,7 +413,7 @@ CONFIG_NETDEVICES=y
397# 413#
398CONFIG_NET_ETHERNET=y 414CONFIG_NET_ETHERNET=y
399# CONFIG_MII is not set 415# CONFIG_MII is not set
400# CONFIG_LASI_82596 is not set 416CONFIG_LASI_82596=y
401# CONFIG_HAPPYMEAL is not set 417# CONFIG_HAPPYMEAL is not set
402# CONFIG_SUNGEM is not set 418# CONFIG_SUNGEM is not set
403# CONFIG_CASSINI is not set 419# CONFIG_CASSINI is not set
@@ -464,6 +480,7 @@ CONFIG_NET_RADIO=y
464# Wireless 802.11b ISA/PCI cards support 480# Wireless 802.11b ISA/PCI cards support
465# 481#
466# CONFIG_HERMES is not set 482# CONFIG_HERMES is not set
483# CONFIG_ATMEL is not set
467 484
468# 485#
469# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support 486# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
@@ -527,7 +544,7 @@ CONFIG_KEYBOARD_ATKBD_HP_KEYCODES=y
527# CONFIG_KEYBOARD_XTKBD is not set 544# CONFIG_KEYBOARD_XTKBD is not set
528# CONFIG_KEYBOARD_NEWTON is not set 545# CONFIG_KEYBOARD_NEWTON is not set
529# CONFIG_KEYBOARD_HIL_OLD is not set 546# CONFIG_KEYBOARD_HIL_OLD is not set
530# CONFIG_KEYBOARD_HIL is not set 547CONFIG_KEYBOARD_HIL=y
531CONFIG_INPUT_MOUSE=y 548CONFIG_INPUT_MOUSE=y
532CONFIG_MOUSE_PS2=y 549CONFIG_MOUSE_PS2=y
533# CONFIG_MOUSE_SERIAL is not set 550# CONFIG_MOUSE_SERIAL is not set
@@ -535,7 +552,7 @@ CONFIG_MOUSE_PS2=y
535# CONFIG_MOUSE_LOGIBM is not set 552# CONFIG_MOUSE_LOGIBM is not set
536# CONFIG_MOUSE_PC110PAD is not set 553# CONFIG_MOUSE_PC110PAD is not set
537# CONFIG_MOUSE_VSXXXAA is not set 554# CONFIG_MOUSE_VSXXXAA is not set
538# CONFIG_MOUSE_HIL is not set 555CONFIG_MOUSE_HIL=y
539# CONFIG_INPUT_JOYSTICK is not set 556# CONFIG_INPUT_JOYSTICK is not set
540# CONFIG_INPUT_TOUCHSCREEN is not set 557# CONFIG_INPUT_TOUCHSCREEN is not set
541CONFIG_INPUT_MISC=y 558CONFIG_INPUT_MISC=y
@@ -549,7 +566,8 @@ CONFIG_SERIO=y
549# CONFIG_SERIO_SERPORT is not set 566# CONFIG_SERIO_SERPORT is not set
550# CONFIG_SERIO_PARKBD is not set 567# CONFIG_SERIO_PARKBD is not set
551CONFIG_SERIO_GSCPS2=y 568CONFIG_SERIO_GSCPS2=y
552# CONFIG_HP_SDC is not set 569CONFIG_HP_SDC=y
570CONFIG_HIL_MLC=y
553# CONFIG_SERIO_PCIPS2 is not set 571# CONFIG_SERIO_PCIPS2 is not set
554CONFIG_SERIO_LIBPS2=y 572CONFIG_SERIO_LIBPS2=y
555# CONFIG_SERIO_RAW is not set 573# CONFIG_SERIO_RAW is not set
@@ -569,6 +587,7 @@ CONFIG_HW_CONSOLE=y
569CONFIG_SERIAL_8250=y 587CONFIG_SERIAL_8250=y
570CONFIG_SERIAL_8250_CONSOLE=y 588CONFIG_SERIAL_8250_CONSOLE=y
571CONFIG_SERIAL_8250_NR_UARTS=13 589CONFIG_SERIAL_8250_NR_UARTS=13
590CONFIG_SERIAL_8250_RUNTIME_UARTS=4
572CONFIG_SERIAL_8250_EXTENDED=y 591CONFIG_SERIAL_8250_EXTENDED=y
573CONFIG_SERIAL_8250_MANY_PORTS=y 592CONFIG_SERIAL_8250_MANY_PORTS=y
574CONFIG_SERIAL_8250_SHARE_IRQ=y 593CONFIG_SERIAL_8250_SHARE_IRQ=y
@@ -582,11 +601,10 @@ CONFIG_SERIAL_8250_SHARE_IRQ=y
582# 601#
583# Non-8250 serial port support 602# Non-8250 serial port support
584# 603#
585# CONFIG_SERIAL_MUX is not set 604CONFIG_SERIAL_MUX=y
586# CONFIG_PDC_CONSOLE is not set 605CONFIG_SERIAL_MUX_CONSOLE=y
587CONFIG_SERIAL_CORE=y 606CONFIG_SERIAL_CORE=y
588CONFIG_SERIAL_CORE_CONSOLE=y 607CONFIG_SERIAL_CORE_CONSOLE=y
589# CONFIG_SERIAL_JSM is not set
590CONFIG_UNIX98_PTYS=y 608CONFIG_UNIX98_PTYS=y
591CONFIG_LEGACY_PTYS=y 609CONFIG_LEGACY_PTYS=y
592CONFIG_LEGACY_PTY_COUNT=256 610CONFIG_LEGACY_PTY_COUNT=256
@@ -626,6 +644,12 @@ CONFIG_GEN_RTC=y
626# CONFIG_I2C is not set 644# CONFIG_I2C is not set
627 645
628# 646#
647# SPI support
648#
649# CONFIG_SPI is not set
650# CONFIG_SPI_MASTER is not set
651
652#
629# Dallas's 1-wire bus 653# Dallas's 1-wire bus
630# 654#
631# CONFIG_W1 is not set 655# CONFIG_W1 is not set
@@ -661,7 +685,6 @@ CONFIG_FB=y
661CONFIG_FB_CFB_FILLRECT=y 685CONFIG_FB_CFB_FILLRECT=y
662CONFIG_FB_CFB_COPYAREA=y 686CONFIG_FB_CFB_COPYAREA=y
663CONFIG_FB_CFB_IMAGEBLIT=y 687CONFIG_FB_CFB_IMAGEBLIT=y
664CONFIG_FB_SOFT_CURSOR=y
665# CONFIG_FB_MACMODES is not set 688# CONFIG_FB_MACMODES is not set
666# CONFIG_FB_MODE_HELPERS is not set 689# CONFIG_FB_MODE_HELPERS is not set
667# CONFIG_FB_TILEBLITTING is not set 690# CONFIG_FB_TILEBLITTING is not set
@@ -671,6 +694,7 @@ CONFIG_FB_SOFT_CURSOR=y
671# CONFIG_FB_ASILIANT is not set 694# CONFIG_FB_ASILIANT is not set
672# CONFIG_FB_IMSTT is not set 695# CONFIG_FB_IMSTT is not set
673CONFIG_FB_STI=y 696CONFIG_FB_STI=y
697# CONFIG_FB_S1D13XXX is not set
674# CONFIG_FB_NVIDIA is not set 698# CONFIG_FB_NVIDIA is not set
675# CONFIG_FB_RIVA is not set 699# CONFIG_FB_RIVA is not set
676# CONFIG_FB_MATROX is not set 700# CONFIG_FB_MATROX is not set
@@ -683,9 +707,7 @@ CONFIG_FB_STI=y
683# CONFIG_FB_KYRO is not set 707# CONFIG_FB_KYRO is not set
684# CONFIG_FB_3DFX is not set 708# CONFIG_FB_3DFX is not set
685# CONFIG_FB_VOODOO1 is not set 709# CONFIG_FB_VOODOO1 is not set
686# CONFIG_FB_CYBLA is not set
687# CONFIG_FB_TRIDENT is not set 710# CONFIG_FB_TRIDENT is not set
688# CONFIG_FB_S1D13XXX is not set
689# CONFIG_FB_VIRTUAL is not set 711# CONFIG_FB_VIRTUAL is not set
690 712
691# 713#
@@ -695,6 +717,7 @@ CONFIG_DUMMY_CONSOLE=y
695CONFIG_DUMMY_CONSOLE_COLUMNS=160 717CONFIG_DUMMY_CONSOLE_COLUMNS=160
696CONFIG_DUMMY_CONSOLE_ROWS=64 718CONFIG_DUMMY_CONSOLE_ROWS=64
697CONFIG_FRAMEBUFFER_CONSOLE=y 719CONFIG_FRAMEBUFFER_CONSOLE=y
720# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
698CONFIG_STI_CONSOLE=y 721CONFIG_STI_CONSOLE=y
699# CONFIG_FONTS is not set 722# CONFIG_FONTS is not set
700CONFIG_FONT_8x8=y 723CONFIG_FONT_8x8=y
@@ -713,7 +736,85 @@ CONFIG_LOGO_PARISC_CLUT224=y
713# 736#
714# Sound 737# Sound
715# 738#
716# CONFIG_SOUND is not set 739CONFIG_SOUND=y
740
741#
742# Advanced Linux Sound Architecture
743#
744CONFIG_SND=y
745CONFIG_SND_TIMER=y
746CONFIG_SND_PCM=y
747CONFIG_SND_SEQUENCER=y
748# CONFIG_SND_SEQ_DUMMY is not set
749CONFIG_SND_OSSEMUL=y
750CONFIG_SND_MIXER_OSS=y
751CONFIG_SND_PCM_OSS=y
752CONFIG_SND_SEQUENCER_OSS=y
753CONFIG_SND_SUPPORT_OLD_API=y
754# CONFIG_SND_VERBOSE_PRINTK is not set
755# CONFIG_SND_DEBUG is not set
756
757#
758# Generic devices
759#
760# CONFIG_SND_DUMMY is not set
761# CONFIG_SND_VIRMIDI is not set
762# CONFIG_SND_MTPAV is not set
763# CONFIG_SND_SERIAL_U16550 is not set
764# CONFIG_SND_MPU401 is not set
765
766#
767# PCI devices
768#
769# CONFIG_SND_AD1889 is not set
770# CONFIG_SND_ALI5451 is not set
771# CONFIG_SND_ATIIXP is not set
772# CONFIG_SND_ATIIXP_MODEM is not set
773# CONFIG_SND_AU8810 is not set
774# CONFIG_SND_AU8820 is not set
775# CONFIG_SND_AU8830 is not set
776# CONFIG_SND_BT87X is not set
777# CONFIG_SND_CA0106 is not set
778# CONFIG_SND_CMIPCI is not set
779# CONFIG_SND_CS4281 is not set
780# CONFIG_SND_CS46XX is not set
781# CONFIG_SND_EMU10K1 is not set
782# CONFIG_SND_EMU10K1X is not set
783# CONFIG_SND_ENS1370 is not set
784# CONFIG_SND_ENS1371 is not set
785# CONFIG_SND_ES1938 is not set
786# CONFIG_SND_ES1968 is not set
787# CONFIG_SND_FM801 is not set
788# CONFIG_SND_HDA_INTEL is not set
789# CONFIG_SND_HDSP is not set
790# CONFIG_SND_HDSPM is not set
791# CONFIG_SND_ICE1712 is not set
792# CONFIG_SND_ICE1724 is not set
793# CONFIG_SND_INTEL8X0 is not set
794# CONFIG_SND_KORG1212 is not set
795# CONFIG_SND_MAESTRO3 is not set
796# CONFIG_SND_MIXART is not set
797# CONFIG_SND_NM256 is not set
798# CONFIG_SND_PCXHR is not set
799# CONFIG_SND_RME32 is not set
800# CONFIG_SND_RME96 is not set
801# CONFIG_SND_RME9652 is not set
802# CONFIG_SND_SONICVIBES is not set
803# CONFIG_SND_TRIDENT is not set
804# CONFIG_SND_VIA82XX is not set
805# CONFIG_SND_VIA82XX_MODEM is not set
806# CONFIG_SND_VX222 is not set
807# CONFIG_SND_YMFPCI is not set
808
809#
810# GSC devices
811#
812CONFIG_SND_HARMONY=y
813
814#
815# Open Sound System
816#
817# CONFIG_SOUND_PRIME is not set
717 818
718# 819#
719# USB support 820# USB support
@@ -723,6 +824,10 @@ CONFIG_USB_ARCH_HAS_OHCI=y
723# CONFIG_USB is not set 824# CONFIG_USB is not set
724 825
725# 826#
827# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
828#
829
830#
726# USB Gadget Support 831# USB Gadget Support
727# 832#
728# CONFIG_USB_GADGET is not set 833# CONFIG_USB_GADGET is not set
@@ -877,18 +982,23 @@ CONFIG_NLS_DEFAULT="iso8859-1"
877# Kernel hacking 982# Kernel hacking
878# 983#
879# CONFIG_PRINTK_TIME is not set 984# CONFIG_PRINTK_TIME is not set
880CONFIG_DEBUG_KERNEL=y
881CONFIG_MAGIC_SYSRQ=y 985CONFIG_MAGIC_SYSRQ=y
986CONFIG_DEBUG_KERNEL=y
882CONFIG_LOG_BUF_SHIFT=16 987CONFIG_LOG_BUF_SHIFT=16
883CONFIG_DETECT_SOFTLOCKUP=y 988CONFIG_DETECT_SOFTLOCKUP=y
884# CONFIG_SCHEDSTATS is not set 989# CONFIG_SCHEDSTATS is not set
885# CONFIG_DEBUG_SLAB is not set 990# CONFIG_DEBUG_SLAB is not set
991# CONFIG_DEBUG_MUTEXES is not set
886# CONFIG_DEBUG_SPINLOCK is not set 992# CONFIG_DEBUG_SPINLOCK is not set
887# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 993# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
888# CONFIG_DEBUG_KOBJECT is not set 994# CONFIG_DEBUG_KOBJECT is not set
889# CONFIG_DEBUG_INFO is not set 995# CONFIG_DEBUG_INFO is not set
890# CONFIG_DEBUG_IOREMAP is not set 996# CONFIG_DEBUG_IOREMAP is not set
891# CONFIG_DEBUG_FS is not set 997# CONFIG_DEBUG_FS is not set
998# CONFIG_DEBUG_VM is not set
999CONFIG_FORCED_INLINING=y
1000# CONFIG_RCU_TORTURE_TEST is not set
1001# CONFIG_DEBUG_RODATA is not set
892 1002
893# 1003#
894# Security options 1004# Security options
diff --git a/arch/parisc/hpux/entry_hpux.S b/arch/parisc/hpux/entry_hpux.S
index fa9bf38787e7..31c8cccfba31 100644
--- a/arch/parisc/hpux/entry_hpux.S
+++ b/arch/parisc/hpux/entry_hpux.S
@@ -22,10 +22,9 @@
22#include <linux/linkage.h> 22#include <linux/linkage.h>
23#include <asm/unistd.h> 23#include <asm/unistd.h>
24 24
25 .text
26
27#define ENTRY_NAME(_name_) .word _name_ 25#define ENTRY_NAME(_name_) .word _name_
28 26
27 .section .rodata,"a"
29 .align 4 28 .align 4
30 .export hpux_call_table 29 .export hpux_call_table
31 .import hpux_unimplemented_wrapper 30 .import hpux_unimplemented_wrapper
diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
index 2d804e2d16d1..3d569a485a1a 100644
--- a/arch/parisc/kernel/drivers.c
+++ b/arch/parisc/kernel/drivers.c
@@ -408,11 +408,10 @@ static void setup_bus_id(struct parisc_device *padev)
408 408
409struct parisc_device * create_tree_node(char id, struct device *parent) 409struct parisc_device * create_tree_node(char id, struct device *parent)
410{ 410{
411 struct parisc_device *dev = kmalloc(sizeof(*dev), GFP_KERNEL); 411 struct parisc_device *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
412 if (!dev) 412 if (!dev)
413 return NULL; 413 return NULL;
414 414
415 memset(dev, 0, sizeof(*dev));
416 dev->hw_path = id; 415 dev->hw_path = id;
417 dev->id.hw_type = HPHW_FAULTY; 416 dev->id.hw_type = HPHW_FAULTY;
418 417
diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c
index f40a777dd388..1d00c365f2b1 100644
--- a/arch/parisc/kernel/parisc_ksyms.c
+++ b/arch/parisc/kernel/parisc_ksyms.c
@@ -48,9 +48,6 @@ EXPORT_SYMBOL(strrchr);
48EXPORT_SYMBOL(strstr); 48EXPORT_SYMBOL(strstr);
49EXPORT_SYMBOL(strpbrk); 49EXPORT_SYMBOL(strpbrk);
50 50
51#include <linux/pm.h>
52EXPORT_SYMBOL(pm_power_off);
53
54#include <asm/atomic.h> 51#include <asm/atomic.h>
55EXPORT_SYMBOL(__xchg8); 52EXPORT_SYMBOL(__xchg8);
56EXPORT_SYMBOL(__xchg32); 53EXPORT_SYMBOL(__xchg32);
diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c
index 88cba49c5301..79c7db2705fd 100644
--- a/arch/parisc/kernel/pci.c
+++ b/arch/parisc/kernel/pci.c
@@ -47,18 +47,17 @@
47 * this makes the boot time much longer than necessary. 47 * this makes the boot time much longer than necessary.
48 * 20ms seems to work for all the HP PCI implementations to date. 48 * 20ms seems to work for all the HP PCI implementations to date.
49 * 49 *
50 * XXX: turn into a #defined constant in <asm/pci.h> ? 50 * #define pci_post_reset_delay 50
51 */ 51 */
52int pci_post_reset_delay = 50;
53 52
54struct pci_port_ops *pci_port; 53struct pci_port_ops *pci_port __read_mostly;
55struct pci_bios_ops *pci_bios; 54struct pci_bios_ops *pci_bios __read_mostly;
56 55
57int pci_hba_count = 0; 56static int pci_hba_count __read_mostly;
58 57
59/* parisc_pci_hba used by pci_port->in/out() ops to lookup bus data. */ 58/* parisc_pci_hba used by pci_port->in/out() ops to lookup bus data. */
60#define PCI_HBA_MAX 32 59#define PCI_HBA_MAX 32
61struct pci_hba_data *parisc_pci_hba[PCI_HBA_MAX]; 60static struct pci_hba_data *parisc_pci_hba[PCI_HBA_MAX] __read_mostly;
62 61
63 62
64/******************************************************************** 63/********************************************************************
@@ -259,8 +258,10 @@ void __devinit pcibios_resource_to_bus(struct pci_dev *dev,
259void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 258void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
260 struct pci_bus_region *region) 259 struct pci_bus_region *region)
261{ 260{
261#ifdef CONFIG_64BIT
262 struct pci_bus *bus = dev->bus; 262 struct pci_bus *bus = dev->bus;
263 struct pci_hba_data *hba = HBA_DATA(bus->bridge->platform_data); 263 struct pci_hba_data *hba = HBA_DATA(bus->bridge->platform_data);
264#endif
264 265
265 if (res->flags & IORESOURCE_MEM) { 266 if (res->flags & IORESOURCE_MEM) {
266 res->start = PCI_HOST_ADDR(hba, region->start); 267 res->start = PCI_HOST_ADDR(hba, region->start);
diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c
index 11d406cd0b3e..53f861c82f93 100644
--- a/arch/parisc/kernel/perf.c
+++ b/arch/parisc/kernel/perf.c
@@ -68,20 +68,20 @@ struct rdr_tbl_ent {
68}; 68};
69 69
70static int perf_processor_interface __read_mostly = UNKNOWN_INTF; 70static int perf_processor_interface __read_mostly = UNKNOWN_INTF;
71static int perf_enabled __read_mostly = 0; 71static int perf_enabled __read_mostly;
72static spinlock_t perf_lock; 72static spinlock_t perf_lock;
73struct parisc_device *cpu_device __read_mostly = NULL; 73struct parisc_device *cpu_device __read_mostly;
74 74
75/* RDRs to write for PCX-W */ 75/* RDRs to write for PCX-W */
76static int perf_rdrs_W[] = 76static const int perf_rdrs_W[] =
77 { 0, 1, 4, 5, 6, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 }; 77 { 0, 1, 4, 5, 6, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 };
78 78
79/* RDRs to write for PCX-U */ 79/* RDRs to write for PCX-U */
80static int perf_rdrs_U[] = 80static const int perf_rdrs_U[] =
81 { 0, 1, 4, 5, 6, 7, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 }; 81 { 0, 1, 4, 5, 6, 7, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 };
82 82
83/* RDR register descriptions for PCX-W */ 83/* RDR register descriptions for PCX-W */
84static struct rdr_tbl_ent perf_rdr_tbl_W[] = { 84static const struct rdr_tbl_ent perf_rdr_tbl_W[] = {
85 { 19, 1, 8 }, /* RDR 0 */ 85 { 19, 1, 8 }, /* RDR 0 */
86 { 16, 1, 16 }, /* RDR 1 */ 86 { 16, 1, 16 }, /* RDR 1 */
87 { 72, 2, 0 }, /* RDR 2 */ 87 { 72, 2, 0 }, /* RDR 2 */
@@ -117,7 +117,7 @@ static struct rdr_tbl_ent perf_rdr_tbl_W[] = {
117}; 117};
118 118
119/* RDR register descriptions for PCX-U */ 119/* RDR register descriptions for PCX-U */
120static struct rdr_tbl_ent perf_rdr_tbl_U[] = { 120static const struct rdr_tbl_ent perf_rdr_tbl_U[] = {
121 { 19, 1, 8 }, /* RDR 0 */ 121 { 19, 1, 8 }, /* RDR 0 */
122 { 32, 1, 16 }, /* RDR 1 */ 122 { 32, 1, 16 }, /* RDR 1 */
123 { 20, 1, 0 }, /* RDR 2 */ 123 { 20, 1, 0 }, /* RDR 2 */
@@ -156,7 +156,7 @@ static struct rdr_tbl_ent perf_rdr_tbl_U[] = {
156 * A non-zero write_control in the above tables is a byte offset into 156 * A non-zero write_control in the above tables is a byte offset into
157 * this array. 157 * this array.
158 */ 158 */
159static uint64_t perf_bitmasks[] = { 159static const uint64_t perf_bitmasks[] = {
160 0x0000000000000000ul, /* first dbl word must be zero */ 160 0x0000000000000000ul, /* first dbl word must be zero */
161 0xfdffe00000000000ul, /* RDR0 bitmask */ 161 0xfdffe00000000000ul, /* RDR0 bitmask */
162 0x003f000000000000ul, /* RDR1 bitmask */ 162 0x003f000000000000ul, /* RDR1 bitmask */
@@ -173,7 +173,7 @@ static uint64_t perf_bitmasks[] = {
173 * Write control bitmasks for Pa-8700 processor given 173 * Write control bitmasks for Pa-8700 processor given
174 * somethings have changed slightly. 174 * somethings have changed slightly.
175 */ 175 */
176static uint64_t perf_bitmasks_piranha[] = { 176static const uint64_t perf_bitmasks_piranha[] = {
177 0x0000000000000000ul, /* first dbl word must be zero */ 177 0x0000000000000000ul, /* first dbl word must be zero */
178 0xfdffe00000000000ul, /* RDR0 bitmask */ 178 0xfdffe00000000000ul, /* RDR0 bitmask */
179 0x003f000000000000ul, /* RDR1 bitmask */ 179 0x003f000000000000ul, /* RDR1 bitmask */
@@ -186,7 +186,7 @@ static uint64_t perf_bitmasks_piranha[] = {
186 0xfffc000000000000ul 186 0xfffc000000000000ul
187}; 187};
188 188
189static uint64_t *bitmask_array; /* array of bitmasks to use */ 189static const uint64_t *bitmask_array; /* array of bitmasks to use */
190 190
191/****************************************************************************** 191/******************************************************************************
192 * Function Prototypes 192 * Function Prototypes
@@ -200,7 +200,7 @@ static ssize_t perf_write(struct file *file, const char __user *buf, size_t coun
200static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 200static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
201static void perf_start_counters(void); 201static void perf_start_counters(void);
202static int perf_stop_counters(uint32_t *raddr); 202static int perf_stop_counters(uint32_t *raddr);
203static struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num); 203static const struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num);
204static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer); 204static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer);
205static int perf_rdr_clear(uint32_t rdr_num); 205static int perf_rdr_clear(uint32_t rdr_num);
206static int perf_write_image(uint64_t *memaddr); 206static int perf_write_image(uint64_t *memaddr);
@@ -444,7 +444,6 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
444 uint32_t raddr[4]; 444 uint32_t raddr[4];
445 int error = 0; 445 int error = 0;
446 446
447 lock_kernel();
448 switch (cmd) { 447 switch (cmd) {
449 448
450 case PA_PERF_ON: 449 case PA_PERF_ON:
@@ -477,8 +476,6 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
477 error = -ENOTTY; 476 error = -ENOTTY;
478 } 477 }
479 478
480 unlock_kernel();
481
482 return error; 479 return error;
483} 480}
484 481
@@ -655,7 +652,7 @@ static int perf_stop_counters(uint32_t *raddr)
655 * Retrieve a pointer to the description of what this 652 * Retrieve a pointer to the description of what this
656 * RDR contains. 653 * RDR contains.
657 */ 654 */
658static struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num) 655static const struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num)
659{ 656{
660 if (perf_processor_interface == ONYX_INTF) { 657 if (perf_processor_interface == ONYX_INTF) {
661 return &perf_rdr_tbl_U[rdr_num]; 658 return &perf_rdr_tbl_U[rdr_num];
@@ -673,7 +670,7 @@ static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer)
673{ 670{
674 uint64_t data, data_mask = 0; 671 uint64_t data, data_mask = 0;
675 uint32_t width, xbits, i; 672 uint32_t width, xbits, i;
676 struct rdr_tbl_ent *tentry; 673 const struct rdr_tbl_ent *tentry;
677 674
678 tentry = perf_rdr_get_entry(rdr_num); 675 tentry = perf_rdr_get_entry(rdr_num);
679 if ((width = tentry->width) == 0) 676 if ((width = tentry->width) == 0)
@@ -721,7 +718,7 @@ static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer)
721 */ 718 */
722static int perf_rdr_clear(uint32_t rdr_num) 719static int perf_rdr_clear(uint32_t rdr_num)
723{ 720{
724 struct rdr_tbl_ent *tentry; 721 const struct rdr_tbl_ent *tentry;
725 int32_t i; 722 int32_t i;
726 723
727 tentry = perf_rdr_get_entry(rdr_num); 724 tentry = perf_rdr_get_entry(rdr_num);
@@ -753,10 +750,11 @@ static int perf_write_image(uint64_t *memaddr)
753 uint64_t buffer[MAX_RDR_WORDS]; 750 uint64_t buffer[MAX_RDR_WORDS];
754 uint64_t *bptr; 751 uint64_t *bptr;
755 uint32_t dwords; 752 uint32_t dwords;
756 uint32_t *intrigue_rdr; 753 const uint32_t *intrigue_rdr;
757 uint64_t *intrigue_bitmask, tmp64; 754 const uint64_t *intrigue_bitmask;
755 uint64_t tmp64;
758 void __iomem *runway; 756 void __iomem *runway;
759 struct rdr_tbl_ent *tentry; 757 const struct rdr_tbl_ent *tentry;
760 int i; 758 int i;
761 759
762 /* Clear out counters */ 760 /* Clear out counters */
@@ -830,7 +828,7 @@ static int perf_write_image(uint64_t *memaddr)
830 */ 828 */
831static void perf_rdr_write(uint32_t rdr_num, uint64_t *buffer) 829static void perf_rdr_write(uint32_t rdr_num, uint64_t *buffer)
832{ 830{
833 struct rdr_tbl_ent *tentry; 831 const struct rdr_tbl_ent *tentry;
834 int32_t i; 832 int32_t i;
835 833
836printk("perf_rdr_write\n"); 834printk("perf_rdr_write\n");
diff --git a/arch/parisc/kernel/perf_images.h b/arch/parisc/kernel/perf_images.h
index d9562fe3f75c..7fef9644df47 100644
--- a/arch/parisc/kernel/perf_images.h
+++ b/arch/parisc/kernel/perf_images.h
@@ -25,7 +25,7 @@
25 25
26#define PCXU_IMAGE_SIZE 584 26#define PCXU_IMAGE_SIZE 584
27 27
28static uint32_t onyx_images[][PCXU_IMAGE_SIZE/sizeof(uint32_t)] = { 28static uint32_t onyx_images[][PCXU_IMAGE_SIZE/sizeof(uint32_t)] __read_mostly = {
29/* 29/*
30 * CPI: 30 * CPI:
31 * 31 *
@@ -2093,7 +2093,7 @@ static uint32_t onyx_images[][PCXU_IMAGE_SIZE/sizeof(uint32_t)] = {
2093}; 2093};
2094#define PCXW_IMAGE_SIZE 576 2094#define PCXW_IMAGE_SIZE 576
2095 2095
2096static uint32_t cuda_images[][PCXW_IMAGE_SIZE/sizeof(uint32_t)] = { 2096static uint32_t cuda_images[][PCXW_IMAGE_SIZE/sizeof(uint32_t)] __read_mostly = {
2097/* 2097/*
2098 * CPI: FROM CPI.IDF (Image 0) 2098 * CPI: FROM CPI.IDF (Image 0)
2099 * 2099 *
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index 5da41677e70b..e8dea4177113 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -54,27 +54,6 @@
54#include <asm/uaccess.h> 54#include <asm/uaccess.h>
55#include <asm/unwind.h> 55#include <asm/unwind.h>
56 56
57static int hlt_counter __read_mostly;
58
59/*
60 * Power off function, if any
61 */
62void (*pm_power_off)(void);
63
64void disable_hlt(void)
65{
66 hlt_counter++;
67}
68
69EXPORT_SYMBOL(disable_hlt);
70
71void enable_hlt(void)
72{
73 hlt_counter--;
74}
75
76EXPORT_SYMBOL(enable_hlt);
77
78void default_idle(void) 57void default_idle(void)
79{ 58{
80 barrier(); 59 barrier();
@@ -102,12 +81,7 @@ void cpu_idle(void)
102} 81}
103 82
104 83
105#ifdef __LP64__ 84#define COMMAND_GLOBAL F_EXTEND(0xfffe0030)
106#define COMMAND_GLOBAL 0xfffffffffffe0030UL
107#else
108#define COMMAND_GLOBAL 0xfffe0030
109#endif
110
111#define CMD_RESET 5 /* reset any module */ 85#define CMD_RESET 5 /* reset any module */
112 86
113/* 87/*
@@ -162,6 +136,7 @@ void machine_halt(void)
162 */ 136 */
163} 137}
164 138
139void (*chassis_power_off)(void);
165 140
166/* 141/*
167 * This routine is called from sys_reboot to actually turn off the 142 * This routine is called from sys_reboot to actually turn off the
@@ -170,8 +145,8 @@ void machine_halt(void)
170void machine_power_off(void) 145void machine_power_off(void)
171{ 146{
172 /* If there is a registered power off handler, call it. */ 147 /* If there is a registered power off handler, call it. */
173 if(pm_power_off) 148 if (chassis_power_off)
174 pm_power_off(); 149 chassis_power_off();
175 150
176 /* Put the soft power button back under hardware control. 151 /* Put the soft power button back under hardware control.
177 * If the user had already pressed the power button, the 152 * If the user had already pressed the power button, the
@@ -187,6 +162,8 @@ void machine_power_off(void)
187 KERN_EMERG "Please power this system off now."); 162 KERN_EMERG "Please power this system off now.");
188} 163}
189 164
165void (*pm_power_off)(void) = machine_power_off;
166EXPORT_SYMBOL(pm_power_off);
190 167
191/* 168/*
192 * Create a kernel thread 169 * Create a kernel thread
diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c
index 27160e8bf15b..413292f1a4a3 100644
--- a/arch/parisc/kernel/ptrace.c
+++ b/arch/parisc/kernel/ptrace.c
@@ -91,7 +91,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
91 int copied; 91 int copied;
92 92
93#ifdef __LP64__ 93#ifdef __LP64__
94 if (is_compat_task(child)) { 94 if (personality(child->personality) == PER_LINUX32) {
95 unsigned int tmp; 95 unsigned int tmp;
96 96
97 addr &= 0xffffffffL; 97 addr &= 0xffffffffL;
@@ -123,7 +123,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
123 case PTRACE_POKEDATA: 123 case PTRACE_POKEDATA:
124 ret = 0; 124 ret = 0;
125#ifdef __LP64__ 125#ifdef __LP64__
126 if (is_compat_task(child)) { 126 if (personality(child->personality) == PER_LINUX32) {
127 unsigned int tmp = (unsigned int)data; 127 unsigned int tmp = (unsigned int)data;
128 DBG("sys_ptrace(POKE%s, %d, %lx, %lx)\n", 128 DBG("sys_ptrace(POKE%s, %d, %lx, %lx)\n",
129 request == PTRACE_POKETEXT ? "TEXT" : "DATA", 129 request == PTRACE_POKETEXT ? "TEXT" : "DATA",
@@ -146,7 +146,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
146 case PTRACE_PEEKUSR: { 146 case PTRACE_PEEKUSR: {
147 ret = -EIO; 147 ret = -EIO;
148#ifdef __LP64__ 148#ifdef __LP64__
149 if (is_compat_task(child)) { 149 if (personality(child->personality) == PER_LINUX32) {
150 unsigned int tmp; 150 unsigned int tmp;
151 151
152 if (addr & (sizeof(int)-1)) 152 if (addr & (sizeof(int)-1))
@@ -205,7 +205,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
205 goto out_tsk; 205 goto out_tsk;
206 } 206 }
207#ifdef __LP64__ 207#ifdef __LP64__
208 if (is_compat_task(child)) { 208 if (personality(child->personality) == PER_LINUX32) {
209 if (addr & (sizeof(int)-1)) 209 if (addr & (sizeof(int)-1))
210 goto out_tsk; 210 goto out_tsk;
211 if ((addr = translate_usr_offset(addr)) < 0) 211 if ((addr = translate_usr_offset(addr)) < 0)
diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
index 3a25a7bd673e..05767e83cf2d 100644
--- a/arch/parisc/kernel/signal.c
+++ b/arch/parisc/kernel/signal.c
@@ -317,7 +317,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
317 317
318 if(personality(current->personality) == PER_LINUX32) { 318 if(personality(current->personality) == PER_LINUX32) {
319 DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &compat_frame->info); 319 DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &compat_frame->info);
320 err |= compat_copy_siginfo_to_user(&compat_frame->info, info); 320 err |= copy_siginfo_to_user32(&compat_frame->info, info);
321 DBG(1,"SETUP_RT_FRAME: 1\n"); 321 DBG(1,"SETUP_RT_FRAME: 1\n");
322 compat_val = (compat_int_t)current->sas_ss_sp; 322 compat_val = (compat_int_t)current->sas_ss_sp;
323 err |= __put_user(compat_val, &compat_frame->uc.uc_stack.ss_sp); 323 err |= __put_user(compat_val, &compat_frame->uc.uc_stack.ss_sp);
diff --git a/arch/parisc/kernel/signal32.c b/arch/parisc/kernel/signal32.c
index 0792e20efef3..a6b4231cafa1 100644
--- a/arch/parisc/kernel/signal32.c
+++ b/arch/parisc/kernel/signal32.c
@@ -31,7 +31,6 @@
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33 33
34#include <asm/compat_signal.h>
35#include <asm/uaccess.h> 34#include <asm/uaccess.h>
36 35
37#include "signal32.h" 36#include "signal32.h"
@@ -398,3 +397,104 @@ setup_sigcontext32(struct compat_sigcontext __user *sc, struct compat_regfile __
398 397
399 return err; 398 return err;
400} 399}
400
401int
402copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from)
403{
404 unsigned long tmp;
405 int err;
406
407 if (!access_ok(VERIFY_READ, from, sizeof(compat_siginfo_t)))
408 return -EFAULT;
409
410 err = __get_user(to->si_signo, &from->si_signo);
411 err |= __get_user(to->si_errno, &from->si_errno);
412 err |= __get_user(to->si_code, &from->si_code);
413
414 if (to->si_code < 0)
415 err |= __copy_from_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
416 else {
417 switch (to->si_code >> 16) {
418 case __SI_CHLD >> 16:
419 err |= __get_user(to->si_utime, &from->si_utime);
420 err |= __get_user(to->si_stime, &from->si_stime);
421 err |= __get_user(to->si_status, &from->si_status);
422 default:
423 err |= __get_user(to->si_pid, &from->si_pid);
424 err |= __get_user(to->si_uid, &from->si_uid);
425 break;
426 case __SI_FAULT >> 16:
427 err |= __get_user(tmp, &from->si_addr);
428 to->si_addr = (void __user *) tmp;
429 break;
430 case __SI_POLL >> 16:
431 err |= __get_user(to->si_band, &from->si_band);
432 err |= __get_user(to->si_fd, &from->si_fd);
433 break;
434 case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
435 case __SI_MESGQ >> 16:
436 err |= __get_user(to->si_pid, &from->si_pid);
437 err |= __get_user(to->si_uid, &from->si_uid);
438 err |= __get_user(to->si_int, &from->si_int);
439 break;
440 }
441 }
442 return err;
443}
444
445int
446copy_siginfo_to_user32 (compat_siginfo_t __user *to, siginfo_t *from)
447{
448 unsigned int addr;
449 int err;
450
451 if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
452 return -EFAULT;
453
454 /* If you change siginfo_t structure, please be sure
455 this code is fixed accordingly.
456 It should never copy any pad contained in the structure
457 to avoid security leaks, but must copy the generic
458 3 ints plus the relevant union member.
459 This routine must convert siginfo from 64bit to 32bit as well
460 at the same time. */
461 err = __put_user(from->si_signo, &to->si_signo);
462 err |= __put_user(from->si_errno, &to->si_errno);
463 err |= __put_user((short)from->si_code, &to->si_code);
464 if (from->si_code < 0)
465 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
466 else {
467 switch (from->si_code >> 16) {
468 case __SI_CHLD >> 16:
469 err |= __put_user(from->si_utime, &to->si_utime);
470 err |= __put_user(from->si_stime, &to->si_stime);
471 err |= __put_user(from->si_status, &to->si_status);
472 default:
473 err |= __put_user(from->si_pid, &to->si_pid);
474 err |= __put_user(from->si_uid, &to->si_uid);
475 break;
476 case __SI_FAULT >> 16:
477 /* avoid type-checking warnings by copying _pad[0] in lieu of si_addr... */
478 err |= __put_user(from->_sifields._pad[0], &to->si_addr);
479 break;
480 case __SI_POLL >> 16:
481 err |= __put_user(from->si_band, &to->si_band);
482 err |= __put_user(from->si_fd, &to->si_fd);
483 break;
484 case __SI_TIMER >> 16:
485 err |= __put_user(from->si_tid, &to->si_tid);
486 err |= __put_user(from->si_overrun, &to->si_overrun);
487 addr = (unsigned long) from->si_ptr;
488 err |= __put_user(addr, &to->si_ptr);
489 break;
490 case __SI_RT >> 16: /* Not generated by the kernel as of now. */
491 case __SI_MESGQ >> 16:
492 err |= __put_user(from->si_uid, &to->si_uid);
493 err |= __put_user(from->si_pid, &to->si_pid);
494 addr = (unsigned long) from->si_ptr;
495 err |= __put_user(addr, &to->si_ptr);
496 break;
497 }
498 }
499 return err;
500}
diff --git a/arch/parisc/kernel/signal32.h b/arch/parisc/kernel/signal32.h
index 4d1569e717cc..e39b38a67a87 100644
--- a/arch/parisc/kernel/signal32.h
+++ b/arch/parisc/kernel/signal32.h
@@ -20,8 +20,34 @@
20#define _PARISC64_KERNEL_SIGNAL32_H 20#define _PARISC64_KERNEL_SIGNAL32_H
21 21
22#include <linux/compat.h> 22#include <linux/compat.h>
23#include <asm/compat_signal.h> 23
24#include <asm/compat_rt_sigframe.h> 24typedef compat_uptr_t compat_sighandler_t;
25
26typedef struct compat_sigaltstack {
27 compat_uptr_t ss_sp;
28 compat_int_t ss_flags;
29 compat_size_t ss_size;
30} compat_stack_t;
31
32/* Most things should be clean enough to redefine this at will, if care
33 is taken to make libc match. */
34
35struct compat_sigaction {
36 compat_sighandler_t sa_handler;
37 compat_uint_t sa_flags;
38 compat_sigset_t sa_mask; /* mask last for extensibility */
39};
40
41/* 32-bit ucontext as seen from an 64-bit kernel */
42struct compat_ucontext {
43 compat_uint_t uc_flags;
44 compat_uptr_t uc_link;
45 compat_stack_t uc_stack; /* struct compat_sigaltstack (12 bytes)*/
46 /* FIXME: Pad out to get uc_mcontext to start at an 8-byte aligned boundary */
47 compat_uint_t pad[1];
48 struct compat_sigcontext uc_mcontext;
49 compat_sigset_t uc_sigmask; /* mask last for extensibility */
50};
25 51
26/* ELF32 signal handling */ 52/* ELF32 signal handling */
27 53
@@ -29,6 +55,103 @@ struct k_sigaction32 {
29 struct compat_sigaction sa; 55 struct compat_sigaction sa;
30}; 56};
31 57
58typedef struct compat_siginfo {
59 int si_signo;
60 int si_errno;
61 int si_code;
62
63 union {
64 int _pad[((128/sizeof(int)) - 3)];
65
66 /* kill() */
67 struct {
68 unsigned int _pid; /* sender's pid */
69 unsigned int _uid; /* sender's uid */
70 } _kill;
71
72 /* POSIX.1b timers */
73 struct {
74 compat_timer_t _tid; /* timer id */
75 int _overrun; /* overrun count */
76 char _pad[sizeof(unsigned int) - sizeof(int)];
77 compat_sigval_t _sigval; /* same as below */
78 int _sys_private; /* not to be passed to user */
79 } _timer;
80
81 /* POSIX.1b signals */
82 struct {
83 unsigned int _pid; /* sender's pid */
84 unsigned int _uid; /* sender's uid */
85 compat_sigval_t _sigval;
86 } _rt;
87
88 /* SIGCHLD */
89 struct {
90 unsigned int _pid; /* which child */
91 unsigned int _uid; /* sender's uid */
92 int _status; /* exit code */
93 compat_clock_t _utime;
94 compat_clock_t _stime;
95 } _sigchld;
96
97 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
98 struct {
99 unsigned int _addr; /* faulting insn/memory ref. */
100 } _sigfault;
101
102 /* SIGPOLL */
103 struct {
104 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
105 int _fd;
106 } _sigpoll;
107 } _sifields;
108} compat_siginfo_t;
109
110int copy_siginfo_to_user32 (compat_siginfo_t __user *to, siginfo_t *from);
111int copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from);
112
113/* In a deft move of uber-hackery, we decide to carry the top half of all
114 * 64-bit registers in a non-portable, non-ABI, hidden structure.
115 * Userspace can read the hidden structure if it *wants* but is never
116 * guaranteed to be in the same place. Infact the uc_sigmask from the
117 * ucontext_t structure may push the hidden register file downards
118 */
119struct compat_regfile {
120 /* Upper half of all the 64-bit registers that were truncated
121 on a copy to a 32-bit userspace */
122 compat_int_t rf_gr[32];
123 compat_int_t rf_iasq[2];
124 compat_int_t rf_iaoq[2];
125 compat_int_t rf_sar;
126};
127
128#define COMPAT_SIGRETURN_TRAMP 4
129#define COMPAT_SIGRESTARTBLOCK_TRAMP 5
130#define COMPAT_TRAMP_SIZE (COMPAT_SIGRETURN_TRAMP + \
131 COMPAT_SIGRESTARTBLOCK_TRAMP)
132
133struct compat_rt_sigframe {
134 /* XXX: Must match trampoline size in arch/parisc/kernel/signal.c
135 Secondary to that it must protect the ERESTART_RESTARTBLOCK
136 trampoline we left on the stack (we were bad and didn't
137 change sp so we could run really fast.) */
138 compat_uint_t tramp[COMPAT_TRAMP_SIZE];
139 compat_siginfo_t info;
140 struct compat_ucontext uc;
141 /* Hidden location of truncated registers, *must* be last. */
142 struct compat_regfile regs;
143};
144
145/*
146 * The 32-bit ABI wants at least 48 bytes for a function call frame:
147 * 16 bytes for arg0-arg3, and 32 bytes for magic (the only part of
148 * which Linux/parisc uses is sp-20 for the saved return pointer...)
149 * Then, the stack pointer must be rounded to a cache line (64 bytes).
150 */
151#define SIGFRAME32 64
152#define FUNCTIONCALLFRAME32 48
153#define PARISC_RT_SIGFRAME_SIZE32 (((sizeof(struct compat_rt_sigframe) + FUNCTIONCALLFRAME32) + SIGFRAME32) & -SIGFRAME32)
154
32void sigset_32to64(sigset_t *s64, compat_sigset_t *s32); 155void sigset_32to64(sigset_t *s64, compat_sigset_t *s32);
33void sigset_64to32(compat_sigset_t *s32, sigset_t *s64); 156void sigset_64to32(compat_sigset_t *s32, sigset_t *s64);
34int do_sigaltstack32 (const compat_stack_t __user *uss32, 157int do_sigaltstack32 (const compat_stack_t __user *uss32,
diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
index d66163492890..af88afef41bd 100644
--- a/arch/parisc/kernel/syscall.S
+++ b/arch/parisc/kernel/syscall.S
@@ -650,6 +650,8 @@ end_linux_gateway_page:
650#define LWS_ENTRY(_name_) .word (lws_##_name_ - linux_gateway_page) 650#define LWS_ENTRY(_name_) .word (lws_##_name_ - linux_gateway_page)
651#endif 651#endif
652 652
653 .section .rodata,"a"
654
653 .align 4096 655 .align 4096
654 /* Light-weight-syscall table */ 656 /* Light-weight-syscall table */
655 /* Start of lws table. */ 657 /* Start of lws table. */
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 32cbc0489324..51d2480627d1 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -374,5 +374,24 @@
374 ENTRY_SAME(keyctl) 374 ENTRY_SAME(keyctl)
375 ENTRY_SAME(ioprio_set) 375 ENTRY_SAME(ioprio_set)
376 ENTRY_SAME(ioprio_get) 376 ENTRY_SAME(ioprio_get)
377 ENTRY_SAME(inotify_init)
378 ENTRY_SAME(inotify_add_watch) /* 270 */
379 ENTRY_SAME(inotify_rm_watch)
380 ENTRY_COMP(pselect6)
381 ENTRY_COMP(ppoll)
382 ENTRY_SAME(migrate_pages)
383 ENTRY_COMP(openat) /* 275 */
384 ENTRY_SAME(mkdirat)
385 ENTRY_SAME(mknodat)
386 ENTRY_SAME(fchownat)
387 ENTRY_COMP(futimesat)
388 ENTRY_COMP(newfstatat) /* 280 */
389 ENTRY_SAME(unlinkat)
390 ENTRY_SAME(renameat)
391 ENTRY_SAME(linkat)
392 ENTRY_SAME(symlinkat)
393 ENTRY_SAME(readlinkat) /* 285 */
394 ENTRY_SAME(fchmodat)
395 ENTRY_SAME(faccessat)
377 /* Nothing yet */ 396 /* Nothing yet */
378 397
diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
index 15914f0235a0..ff200608c851 100644
--- a/arch/parisc/kernel/traps.c
+++ b/arch/parisc/kernel/traps.c
@@ -193,10 +193,9 @@ void show_stack(struct task_struct *task, unsigned long *s)
193 193
194HERE: 194HERE:
195 asm volatile ("copy %%r30, %0" : "=r"(sp)); 195 asm volatile ("copy %%r30, %0" : "=r"(sp));
196 r = (struct pt_regs *)kmalloc(sizeof(struct pt_regs), GFP_KERNEL); 196 r = kzalloc(sizeof(struct pt_regs), GFP_KERNEL);
197 if (!r) 197 if (!r)
198 return; 198 return;
199 memset(r, 0, sizeof(struct pt_regs));
200 r->iaoq[0] = (unsigned long)&&HERE; 199 r->iaoq[0] = (unsigned long)&&HERE;
201 r->gr[2] = (unsigned long)__builtin_return_address(0); 200 r->gr[2] = (unsigned long)__builtin_return_address(0);
202 r->gr[30] = sp; 201 r->gr[30] = sp;
diff --git a/arch/parisc/math-emu/decode_exc.c b/arch/parisc/math-emu/decode_exc.c
index f84f2586672b..66c8a9f6a27e 100644
--- a/arch/parisc/math-emu/decode_exc.c
+++ b/arch/parisc/math-emu/decode_exc.c
@@ -337,6 +337,7 @@ decode_fpu(unsigned int Fpu_register[], unsigned int trap_counts[])
337 } 337 }
338 break; 338 break;
339 case INVALIDEXCEPTION: 339 case INVALIDEXCEPTION:
340 case OPC_2E_INVALIDEXCEPTION:
340 update_trap_counts(Fpu_register, aflags, bflags, trap_counts); 341 update_trap_counts(Fpu_register, aflags, bflags, trap_counts);
341 return SIGNALCODE(SIGFPE, FPE_FLTINV); 342 return SIGNALCODE(SIGFPE, FPE_FLTINV);
342 case DIVISIONBYZEROEXCEPTION: 343 case DIVISIONBYZEROEXCEPTION:
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 720287d46e55..7847ca13d6c2 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -371,17 +371,11 @@ static void __init setup_bootmem(void)
371 371
372void free_initmem(void) 372void free_initmem(void)
373{ 373{
374 /* FIXME: */
375#if 0
376 printk(KERN_INFO "NOT FREEING INITMEM (%dk)\n",
377 (&__init_end - &__init_begin) >> 10);
378 return;
379#else
380 unsigned long addr; 374 unsigned long addr;
381 375
382 printk(KERN_INFO "Freeing unused kernel memory: "); 376 printk(KERN_INFO "Freeing unused kernel memory: ");
383 377
384#if 1 378#ifdef CONFIG_DEBUG_KERNEL
385 /* Attempt to catch anyone trying to execute code here 379 /* Attempt to catch anyone trying to execute code here
386 * by filling the page with BRK insns. 380 * by filling the page with BRK insns.
387 * 381 *
@@ -414,9 +408,21 @@ void free_initmem(void)
414 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BCOMPLETE); 408 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BCOMPLETE);
415 409
416 printk("%luk freed\n", (unsigned long)(&__init_end - &__init_begin) >> 10); 410 printk("%luk freed\n", (unsigned long)(&__init_end - &__init_begin) >> 10);
417#endif
418} 411}
419 412
413
414#ifdef CONFIG_DEBUG_RODATA
415void mark_rodata_ro(void)
416{
417 extern char __start_rodata, __end_rodata;
418 /* rodata memory was already mapped with KERNEL_RO access rights by
419 pagetable_init() and map_pages(). No need to do additional stuff here */
420 printk (KERN_INFO "Write protecting the kernel read-only data: %luk\n",
421 (unsigned long)(&__end_rodata - &__start_rodata) >> 10);
422}
423#endif
424
425
420/* 426/*
421 * Just an arbitrary offset to serve as a "hole" between mapping areas 427 * Just an arbitrary offset to serve as a "hole" between mapping areas
422 * (between top of physical memory and a potential pcxl dma mapping 428 * (between top of physical memory and a potential pcxl dma mapping
@@ -477,11 +483,6 @@ void __init mem_init(void)
477 483
478} 484}
479 485
480int do_check_pgt_cache(int low, int high)
481{
482 return 0;
483}
484
485unsigned long *empty_zero_page __read_mostly; 486unsigned long *empty_zero_page __read_mostly;
486 487
487void show_mem(void) 488void show_mem(void)
@@ -690,7 +691,7 @@ static void __init pagetable_init(void)
690 691
691#ifdef CONFIG_BLK_DEV_INITRD 692#ifdef CONFIG_BLK_DEV_INITRD
692 if (initrd_end && initrd_end > mem_limit) { 693 if (initrd_end && initrd_end > mem_limit) {
693 printk("initrd: mapping %08lx-%08lx\n", initrd_start, initrd_end); 694 printk(KERN_INFO "initrd: mapping %08lx-%08lx\n", initrd_start, initrd_end);
694 map_pages(initrd_start, __pa(initrd_start), 695 map_pages(initrd_start, __pa(initrd_start),
695 initrd_end - initrd_start, PAGE_KERNEL); 696 initrd_end - initrd_start, PAGE_KERNEL);
696 } 697 }
@@ -792,8 +793,6 @@ map_hpux_gateway_page(struct task_struct *tsk, struct mm_struct *mm)
792EXPORT_SYMBOL(map_hpux_gateway_page); 793EXPORT_SYMBOL(map_hpux_gateway_page);
793#endif 794#endif
794 795
795extern void flush_tlb_all_local(void);
796
797void __init paging_init(void) 796void __init paging_init(void)
798{ 797{
799 int i; 798 int i;
@@ -802,7 +801,7 @@ void __init paging_init(void)
802 pagetable_init(); 801 pagetable_init();
803 gateway_init(); 802 gateway_init();
804 flush_cache_all_local(); /* start with known state */ 803 flush_cache_all_local(); /* start with known state */
805 flush_tlb_all_local(); 804 flush_tlb_all_local(NULL);
806 805
807 for (i = 0; i < npmem_ranges; i++) { 806 for (i = 0; i < npmem_ranges; i++) {
808 unsigned long zones_size[MAX_NR_ZONES] = { 0, 0, 0 }; 807 unsigned long zones_size[MAX_NR_ZONES] = { 0, 0, 0 };
@@ -993,7 +992,7 @@ void flush_tlb_all(void)
993 do_recycle++; 992 do_recycle++;
994 } 993 }
995 spin_unlock(&sid_lock); 994 spin_unlock(&sid_lock);
996 on_each_cpu((void (*)(void *))flush_tlb_all_local, NULL, 1, 1); 995 on_each_cpu(flush_tlb_all_local, NULL, 1, 1);
997 if (do_recycle) { 996 if (do_recycle) {
998 spin_lock(&sid_lock); 997 spin_lock(&sid_lock);
999 recycle_sids(recycle_ndirty,recycle_dirty_array); 998 recycle_sids(recycle_ndirty,recycle_dirty_array);
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index f970ace208d3..c7a799a09516 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -134,7 +134,6 @@ static int __init add_legacy_soc_port(struct device_node *np,
134 return add_legacy_port(np, -1, UPIO_MEM, addr, addr, NO_IRQ, flags); 134 return add_legacy_port(np, -1, UPIO_MEM, addr, addr, NO_IRQ, flags);
135} 135}
136 136
137#ifdef CONFIG_ISA
138static int __init add_legacy_isa_port(struct device_node *np, 137static int __init add_legacy_isa_port(struct device_node *np,
139 struct device_node *isa_brg) 138 struct device_node *isa_brg)
140{ 139{
@@ -168,7 +167,6 @@ static int __init add_legacy_isa_port(struct device_node *np,
168 return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr, NO_IRQ, UPF_BOOT_AUTOCONF); 167 return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr, NO_IRQ, UPF_BOOT_AUTOCONF);
169 168
170} 169}
171#endif
172 170
173#ifdef CONFIG_PCI 171#ifdef CONFIG_PCI
174static int __init add_legacy_pci_port(struct device_node *np, 172static int __init add_legacy_pci_port(struct device_node *np,
@@ -276,7 +274,6 @@ void __init find_legacy_serial_ports(void)
276 of_node_put(soc); 274 of_node_put(soc);
277 } 275 }
278 276
279#ifdef CONFIG_ISA
280 /* First fill our array with ISA ports */ 277 /* First fill our array with ISA ports */
281 for (np = NULL; (np = of_find_node_by_type(np, "serial"));) { 278 for (np = NULL; (np = of_find_node_by_type(np, "serial"));) {
282 struct device_node *isa = of_get_parent(np); 279 struct device_node *isa = of_get_parent(np);
@@ -287,7 +284,6 @@ void __init find_legacy_serial_ports(void)
287 } 284 }
288 of_node_put(isa); 285 of_node_put(isa);
289 } 286 }
290#endif
291 287
292#ifdef CONFIG_PCI 288#ifdef CONFIG_PCI
293 /* Next, try to locate PCI ports */ 289 /* Next, try to locate PCI ports */
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 3747ab0dac3f..c6d0595da6b5 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -254,11 +254,9 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs);
254 */ 254 */
255long sys_sigsuspend(old_sigset_t mask) 255long sys_sigsuspend(old_sigset_t mask)
256{ 256{
257 sigset_t saveset;
258
259 mask &= _BLOCKABLE; 257 mask &= _BLOCKABLE;
260 spin_lock_irq(&current->sighand->siglock); 258 spin_lock_irq(&current->sighand->siglock);
261 saveset = current->blocked; 259 current->saved_sigmask = current->blocked;
262 siginitset(&current->blocked, mask); 260 siginitset(&current->blocked, mask);
263 recalc_sigpending(); 261 recalc_sigpending();
264 spin_unlock_irq(&current->sighand->siglock); 262 spin_unlock_irq(&current->sighand->siglock);
diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c
index c32c623001dc..356a739e52b2 100644
--- a/arch/powerpc/platforms/powermac/pfunc_core.c
+++ b/arch/powerpc/platforms/powermac/pfunc_core.c
@@ -862,21 +862,28 @@ int pmf_register_irq_client(struct device_node *target,
862 spin_unlock_irqrestore(&pmf_lock, flags); 862 spin_unlock_irqrestore(&pmf_lock, flags);
863 return -ENODEV; 863 return -ENODEV;
864 } 864 }
865 if (list_empty(&func->irq_clients))
866 func->dev->handlers->irq_enable(func);
865 list_add(&client->link, &func->irq_clients); 867 list_add(&client->link, &func->irq_clients);
868 client->func = func;
866 spin_unlock_irqrestore(&pmf_lock, flags); 869 spin_unlock_irqrestore(&pmf_lock, flags);
867 870
868 return 0; 871 return 0;
869} 872}
870EXPORT_SYMBOL_GPL(pmf_register_irq_client); 873EXPORT_SYMBOL_GPL(pmf_register_irq_client);
871 874
872void pmf_unregister_irq_client(struct device_node *np, 875void pmf_unregister_irq_client(struct pmf_irq_client *client)
873 const char *name,
874 struct pmf_irq_client *client)
875{ 876{
877 struct pmf_function *func = client->func;
876 unsigned long flags; 878 unsigned long flags;
877 879
880 BUG_ON(func == NULL);
881
878 spin_lock_irqsave(&pmf_lock, flags); 882 spin_lock_irqsave(&pmf_lock, flags);
883 client->func = NULL;
879 list_del(&client->link); 884 list_del(&client->link);
885 if (list_empty(&func->irq_clients))
886 func->dev->handlers->irq_disable(func);
880 spin_unlock_irqrestore(&pmf_lock, flags); 887 spin_unlock_irqrestore(&pmf_lock, flags);
881} 888}
882EXPORT_SYMBOL_GPL(pmf_unregister_irq_client); 889EXPORT_SYMBOL_GPL(pmf_unregister_irq_client);
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
index 21934784f936..bdaa8aabdaa6 100644
--- a/arch/powerpc/platforms/pseries/pci_dlpar.c
+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
@@ -58,6 +58,7 @@ pcibios_find_pci_bus(struct device_node *dn)
58 58
59 return find_bus_among_children(pdn->phb->bus, dn); 59 return find_bus_among_children(pdn->phb->bus, dn);
60} 60}
61EXPORT_SYMBOL_GPL(pcibios_find_pci_bus);
61 62
62/** 63/**
63 * pcibios_remove_pci_devices - remove all devices under this bus 64 * pcibios_remove_pci_devices - remove all devices under this bus
@@ -106,6 +107,7 @@ pcibios_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus)
106 } 107 }
107 } 108 }
108} 109}
110EXPORT_SYMBOL_GPL(pcibios_fixup_new_pci_devices);
109 111
110static int 112static int
111pcibios_pci_config_bridge(struct pci_dev *dev) 113pcibios_pci_config_bridge(struct pci_dev *dev)
@@ -172,3 +174,4 @@ pcibios_add_pci_devices(struct pci_bus * bus)
172 pcibios_pci_config_bridge(dev); 174 pcibios_pci_config_bridge(dev);
173 } 175 }
174} 176}
177EXPORT_SYMBOL_GPL(pcibios_add_pci_devices);
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index 7d23edc6facb..3525c91204d4 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -1,13 +1,12 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.15-rc2 3# Linux kernel version: 2.6.16-rc1
4# Mon Nov 21 13:51:30 2005 4# Thu Jan 19 10:58:53 2006
5# 5#
6CONFIG_MMU=y 6CONFIG_MMU=y
7CONFIG_RWSEM_XCHGADD_ALGORITHM=y 7CONFIG_RWSEM_XCHGADD_ALGORITHM=y
8CONFIG_GENERIC_CALIBRATE_DELAY=y 8CONFIG_GENERIC_CALIBRATE_DELAY=y
9CONFIG_S390=y 9CONFIG_S390=y
10CONFIG_UID16=y
11 10
12# 11#
13# Code maturity level options 12# Code maturity level options
@@ -29,18 +28,20 @@ CONFIG_POSIX_MQUEUE=y
29CONFIG_SYSCTL=y 28CONFIG_SYSCTL=y
30CONFIG_AUDIT=y 29CONFIG_AUDIT=y
31# CONFIG_AUDITSYSCALL is not set 30# CONFIG_AUDITSYSCALL is not set
32CONFIG_HOTPLUG=y
33CONFIG_KOBJECT_UEVENT=y
34CONFIG_IKCONFIG=y 31CONFIG_IKCONFIG=y
35CONFIG_IKCONFIG_PROC=y 32CONFIG_IKCONFIG_PROC=y
36# CONFIG_CPUSETS is not set 33# CONFIG_CPUSETS is not set
37CONFIG_INITRAMFS_SOURCE="" 34CONFIG_INITRAMFS_SOURCE=""
35CONFIG_UID16=y
36# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
38# CONFIG_EMBEDDED is not set 37# CONFIG_EMBEDDED is not set
39CONFIG_KALLSYMS=y 38CONFIG_KALLSYMS=y
40# CONFIG_KALLSYMS_ALL is not set 39# CONFIG_KALLSYMS_ALL is not set
41# CONFIG_KALLSYMS_EXTRA_PASS is not set 40# CONFIG_KALLSYMS_EXTRA_PASS is not set
41CONFIG_HOTPLUG=y
42CONFIG_PRINTK=y 42CONFIG_PRINTK=y
43CONFIG_BUG=y 43CONFIG_BUG=y
44CONFIG_ELF_CORE=y
44CONFIG_BASE_FULL=y 45CONFIG_BASE_FULL=y
45CONFIG_FUTEX=y 46CONFIG_FUTEX=y
46CONFIG_EPOLL=y 47CONFIG_EPOLL=y
@@ -49,8 +50,10 @@ CONFIG_CC_ALIGN_FUNCTIONS=0
49CONFIG_CC_ALIGN_LABELS=0 50CONFIG_CC_ALIGN_LABELS=0
50CONFIG_CC_ALIGN_LOOPS=0 51CONFIG_CC_ALIGN_LOOPS=0
51CONFIG_CC_ALIGN_JUMPS=0 52CONFIG_CC_ALIGN_JUMPS=0
53CONFIG_SLAB=y
52# CONFIG_TINY_SHMEM is not set 54# CONFIG_TINY_SHMEM is not set
53CONFIG_BASE_SMALL=0 55CONFIG_BASE_SMALL=0
56# CONFIG_SLOB is not set
54 57
55# 58#
56# Loadable module support 59# Loadable module support
@@ -76,11 +79,11 @@ CONFIG_IOSCHED_NOOP=y
76CONFIG_IOSCHED_AS=y 79CONFIG_IOSCHED_AS=y
77CONFIG_IOSCHED_DEADLINE=y 80CONFIG_IOSCHED_DEADLINE=y
78CONFIG_IOSCHED_CFQ=y 81CONFIG_IOSCHED_CFQ=y
79CONFIG_DEFAULT_AS=y 82# CONFIG_DEFAULT_AS is not set
80# CONFIG_DEFAULT_DEADLINE is not set 83CONFIG_DEFAULT_DEADLINE=y
81# CONFIG_DEFAULT_CFQ is not set 84# CONFIG_DEFAULT_CFQ is not set
82# CONFIG_DEFAULT_NOOP is not set 85# CONFIG_DEFAULT_NOOP is not set
83CONFIG_DEFAULT_IOSCHED="anticipatory" 86CONFIG_DEFAULT_IOSCHED="deadline"
84 87
85# 88#
86# Base setup 89# Base setup
@@ -193,6 +196,11 @@ CONFIG_IPV6=y
193# SCTP Configuration (EXPERIMENTAL) 196# SCTP Configuration (EXPERIMENTAL)
194# 197#
195# CONFIG_IP_SCTP is not set 198# CONFIG_IP_SCTP is not set
199
200#
201# TIPC Configuration (EXPERIMENTAL)
202#
203# CONFIG_TIPC is not set
196# CONFIG_ATM is not set 204# CONFIG_ATM is not set
197# CONFIG_BRIDGE is not set 205# CONFIG_BRIDGE is not set
198# CONFIG_VLAN_8021Q is not set 206# CONFIG_VLAN_8021Q is not set
@@ -362,6 +370,7 @@ CONFIG_DM_MULTIPATH=y
362# 370#
363CONFIG_UNIX98_PTYS=y 371CONFIG_UNIX98_PTYS=y
364CONFIG_UNIX98_PTY_COUNT=2048 372CONFIG_UNIX98_PTY_COUNT=2048
373# CONFIG_HANGCHECK_TIMER is not set
365 374
366# 375#
367# Watchdog Cards 376# Watchdog Cards
@@ -488,6 +497,7 @@ CONFIG_FS_MBCACHE=y
488# CONFIG_JFS_FS is not set 497# CONFIG_JFS_FS is not set
489# CONFIG_FS_POSIX_ACL is not set 498# CONFIG_FS_POSIX_ACL is not set
490# CONFIG_XFS_FS is not set 499# CONFIG_XFS_FS is not set
500# CONFIG_OCFS2_FS is not set
491# CONFIG_MINIX_FS is not set 501# CONFIG_MINIX_FS is not set
492# CONFIG_ROMFS_FS is not set 502# CONFIG_ROMFS_FS is not set
493CONFIG_INOTIFY=y 503CONFIG_INOTIFY=y
@@ -520,6 +530,7 @@ CONFIG_TMPFS=y
520# CONFIG_HUGETLB_PAGE is not set 530# CONFIG_HUGETLB_PAGE is not set
521CONFIG_RAMFS=y 531CONFIG_RAMFS=y
522# CONFIG_RELAYFS_FS is not set 532# CONFIG_RELAYFS_FS is not set
533# CONFIG_CONFIGFS_FS is not set
523 534
524# 535#
525# Miscellaneous filesystems 536# Miscellaneous filesystems
@@ -584,6 +595,7 @@ CONFIG_MSDOS_PARTITION=y
584# CONFIG_SGI_PARTITION is not set 595# CONFIG_SGI_PARTITION is not set
585# CONFIG_ULTRIX_PARTITION is not set 596# CONFIG_ULTRIX_PARTITION is not set
586# CONFIG_SUN_PARTITION is not set 597# CONFIG_SUN_PARTITION is not set
598# CONFIG_KARMA_PARTITION is not set
587# CONFIG_EFI_PARTITION is not set 599# CONFIG_EFI_PARTITION is not set
588 600
589# 601#
@@ -592,7 +604,7 @@ CONFIG_MSDOS_PARTITION=y
592# CONFIG_NLS is not set 604# CONFIG_NLS is not set
593 605
594# 606#
595# Profiling support 607# Instrumentation Support
596# 608#
597# CONFIG_PROFILING is not set 609# CONFIG_PROFILING is not set
598 610
@@ -600,19 +612,21 @@ CONFIG_MSDOS_PARTITION=y
600# Kernel hacking 612# Kernel hacking
601# 613#
602# CONFIG_PRINTK_TIME is not set 614# CONFIG_PRINTK_TIME is not set
603CONFIG_DEBUG_KERNEL=y
604CONFIG_MAGIC_SYSRQ=y 615CONFIG_MAGIC_SYSRQ=y
616CONFIG_DEBUG_KERNEL=y
605CONFIG_LOG_BUF_SHIFT=17 617CONFIG_LOG_BUF_SHIFT=17
606CONFIG_DETECT_SOFTLOCKUP=y 618# CONFIG_DETECT_SOFTLOCKUP is not set
607# CONFIG_SCHEDSTATS is not set 619# CONFIG_SCHEDSTATS is not set
608# CONFIG_DEBUG_SLAB is not set 620# CONFIG_DEBUG_SLAB is not set
609CONFIG_DEBUG_PREEMPT=y 621# CONFIG_DEBUG_PREEMPT is not set
622CONFIG_DEBUG_MUTEXES=y
610# CONFIG_DEBUG_SPINLOCK is not set 623# CONFIG_DEBUG_SPINLOCK is not set
611# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 624# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
612# CONFIG_DEBUG_KOBJECT is not set 625# CONFIG_DEBUG_KOBJECT is not set
613# CONFIG_DEBUG_INFO is not set 626# CONFIG_DEBUG_INFO is not set
614CONFIG_DEBUG_FS=y 627# CONFIG_DEBUG_FS is not set
615# CONFIG_DEBUG_VM is not set 628# CONFIG_DEBUG_VM is not set
629CONFIG_FORCED_INLINING=y
616# CONFIG_RCU_TORTURE_TEST is not set 630# CONFIG_RCU_TORTURE_TEST is not set
617 631
618# 632#
diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c
index fa2b3bc22f20..ef706694a0c1 100644
--- a/arch/s390/kernel/compat_signal.c
+++ b/arch/s390/kernel/compat_signal.c
@@ -1,8 +1,7 @@
1/* 1/*
2 * arch/s390/kernel/signal32.c 2 * arch/s390/kernel/compat_signal.c
3 * 3 *
4 * S390 version 4 * Copyright (C) IBM Corp. 2000,2006
5 * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) 5 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
7 * Gerhard Tonn (ton@de.ibm.com) 6 * Gerhard Tonn (ton@de.ibm.com)
8 * 7 *
@@ -52,8 +51,6 @@ typedef struct
52 struct ucontext32 uc; 51 struct ucontext32 uc;
53} rt_sigframe32; 52} rt_sigframe32;
54 53
55asmlinkage int FASTCALL(do_signal(struct pt_regs *regs, sigset_t *oldset));
56
57int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) 54int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
58{ 55{
59 int err; 56 int err;
@@ -161,66 +158,6 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
161 return err; 158 return err;
162} 159}
163 160
164/*
165 * Atomically swap in the new signal mask, and wait for a signal.
166 */
167asmlinkage int
168sys32_sigsuspend(struct pt_regs * regs,int history0, int history1, old_sigset_t mask)
169{
170 sigset_t saveset;
171
172 mask &= _BLOCKABLE;
173 spin_lock_irq(&current->sighand->siglock);
174 saveset = current->blocked;
175 siginitset(&current->blocked, mask);
176 recalc_sigpending();
177 spin_unlock_irq(&current->sighand->siglock);
178 regs->gprs[2] = -EINTR;
179
180 while (1) {
181 set_current_state(TASK_INTERRUPTIBLE);
182 schedule();
183 if (do_signal(regs, &saveset))
184 return -EINTR;
185 }
186}
187
188asmlinkage int
189sys32_rt_sigsuspend(struct pt_regs * regs, compat_sigset_t __user *unewset,
190 size_t sigsetsize)
191{
192 sigset_t saveset, newset;
193 compat_sigset_t set32;
194
195 /* XXX: Don't preclude handling different sized sigset_t's. */
196 if (sigsetsize != sizeof(sigset_t))
197 return -EINVAL;
198
199 if (copy_from_user(&set32, unewset, sizeof(set32)))
200 return -EFAULT;
201 switch (_NSIG_WORDS) {
202 case 4: newset.sig[3] = set32.sig[6] + (((long)set32.sig[7]) << 32);
203 case 3: newset.sig[2] = set32.sig[4] + (((long)set32.sig[5]) << 32);
204 case 2: newset.sig[1] = set32.sig[2] + (((long)set32.sig[3]) << 32);
205 case 1: newset.sig[0] = set32.sig[0] + (((long)set32.sig[1]) << 32);
206 }
207 sigdelsetmask(&newset, ~_BLOCKABLE);
208
209 spin_lock_irq(&current->sighand->siglock);
210 saveset = current->blocked;
211 current->blocked = newset;
212 recalc_sigpending();
213 spin_unlock_irq(&current->sighand->siglock);
214 regs->gprs[2] = -EINTR;
215
216 while (1) {
217 set_current_state(TASK_INTERRUPTIBLE);
218 schedule();
219 if (do_signal(regs, &saveset))
220 return -EINTR;
221 }
222}
223
224asmlinkage long 161asmlinkage long
225sys32_sigaction(int sig, const struct old_sigaction32 __user *act, 162sys32_sigaction(int sig, const struct old_sigaction32 __user *act,
226 struct old_sigaction32 __user *oact) 163 struct old_sigaction32 __user *oact)
@@ -520,7 +457,7 @@ static inline int map_signal(int sig)
520 return sig; 457 return sig;
521} 458}
522 459
523static void setup_frame32(int sig, struct k_sigaction *ka, 460static int setup_frame32(int sig, struct k_sigaction *ka,
524 sigset_t *set, struct pt_regs * regs) 461 sigset_t *set, struct pt_regs * regs)
525{ 462{
526 sigframe32 __user *frame = get_sigframe(ka, regs, sizeof(sigframe32)); 463 sigframe32 __user *frame = get_sigframe(ka, regs, sizeof(sigframe32));
@@ -565,13 +502,14 @@ static void setup_frame32(int sig, struct k_sigaction *ka,
565 /* Place signal number on stack to allow backtrace from handler. */ 502 /* Place signal number on stack to allow backtrace from handler. */
566 if (__put_user(regs->gprs[2], (int __user *) &frame->signo)) 503 if (__put_user(regs->gprs[2], (int __user *) &frame->signo))
567 goto give_sigsegv; 504 goto give_sigsegv;
568 return; 505 return 0;
569 506
570give_sigsegv: 507give_sigsegv:
571 force_sigsegv(sig, current); 508 force_sigsegv(sig, current);
509 return -EFAULT;
572} 510}
573 511
574static void setup_rt_frame32(int sig, struct k_sigaction *ka, siginfo_t *info, 512static int setup_rt_frame32(int sig, struct k_sigaction *ka, siginfo_t *info,
575 sigset_t *set, struct pt_regs * regs) 513 sigset_t *set, struct pt_regs * regs)
576{ 514{
577 int err = 0; 515 int err = 0;
@@ -615,31 +553,37 @@ static void setup_rt_frame32(int sig, struct k_sigaction *ka, siginfo_t *info,
615 regs->gprs[2] = map_signal(sig); 553 regs->gprs[2] = map_signal(sig);
616 regs->gprs[3] = (__u64) &frame->info; 554 regs->gprs[3] = (__u64) &frame->info;
617 regs->gprs[4] = (__u64) &frame->uc; 555 regs->gprs[4] = (__u64) &frame->uc;
618 return; 556 return 0;
619 557
620give_sigsegv: 558give_sigsegv:
621 force_sigsegv(sig, current); 559 force_sigsegv(sig, current);
560 return -EFAULT;
622} 561}
623 562
624/* 563/*
625 * OK, we're invoking a handler 564 * OK, we're invoking a handler
626 */ 565 */
627 566
628void 567int
629handle_signal32(unsigned long sig, struct k_sigaction *ka, 568handle_signal32(unsigned long sig, struct k_sigaction *ka,
630 siginfo_t *info, sigset_t *oldset, struct pt_regs * regs) 569 siginfo_t *info, sigset_t *oldset, struct pt_regs * regs)
631{ 570{
571 int ret;
572
632 /* Set up the stack frame */ 573 /* Set up the stack frame */
633 if (ka->sa.sa_flags & SA_SIGINFO) 574 if (ka->sa.sa_flags & SA_SIGINFO)
634 setup_rt_frame32(sig, ka, info, oldset, regs); 575 ret = setup_rt_frame32(sig, ka, info, oldset, regs);
635 else 576 else
636 setup_frame32(sig, ka, oldset, regs); 577 ret = setup_frame32(sig, ka, oldset, regs);
637 578
638 spin_lock_irq(&current->sighand->siglock); 579 if (ret == 0) {
639 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask); 580 spin_lock_irq(&current->sighand->siglock);
640 if (!(ka->sa.sa_flags & SA_NODEFER)) 581 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
641 sigaddset(&current->blocked,sig); 582 if (!(ka->sa.sa_flags & SA_NODEFER))
642 recalc_sigpending(); 583 sigaddset(&current->blocked,sig);
643 spin_unlock_irq(&current->sighand->siglock); 584 recalc_sigpending();
585 spin_unlock_irq(&current->sighand->siglock);
586 }
587 return ret;
644} 588}
645 589
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index cfde1905d07d..83b33fe1923c 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -1,9 +1,8 @@
1/* 1/*
2* arch/s390/kernel/sys_wrapper31.S 2* arch/s390/kernel/compat_wrapper.S
3* wrapper for 31 bit compatible system calls. 3* wrapper for 31 bit compatible system calls.
4* 4*
5* S390 version 5* Copyright (C) IBM Corp. 2000,2006
6* Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
7* Author(s): Gerhard Tonn (ton@de.ibm.com), 6* Author(s): Gerhard Tonn (ton@de.ibm.com),
8* Thomas Spatzier (tspat@de.ibm.com) 7* Thomas Spatzier (tspat@de.ibm.com)
9*/ 8*/
@@ -288,7 +287,12 @@ sys32_setregid16_wrapper:
288 llgfr %r3,%r3 # __kernel_old_gid_emu31_t 287 llgfr %r3,%r3 # __kernel_old_gid_emu31_t
289 jg sys32_setregid16 # branch to system call 288 jg sys32_setregid16 # branch to system call
290 289
291#sys32_sigsuspend_wrapper # done in sigsuspend_glue 290 .globl sys_sigsuspend_wrapper
291sys_sigsuspend_wrapper:
292 lgfr %r2,%r2 # int
293 lgfr %r3,%r3 # int
294 llgfr %r4,%r4 # old_sigset_t
295 jg sys_sigsuspend
292 296
293 .globl compat_sys_sigpending_wrapper 297 .globl compat_sys_sigpending_wrapper
294compat_sys_sigpending_wrapper: 298compat_sys_sigpending_wrapper:
@@ -855,7 +859,11 @@ sys32_rt_sigqueueinfo_wrapper:
855 llgtr %r4,%r4 # siginfo_emu31_t * 859 llgtr %r4,%r4 # siginfo_emu31_t *
856 jg sys32_rt_sigqueueinfo # branch to system call 860 jg sys32_rt_sigqueueinfo # branch to system call
857 861
858#sys32_rt_sigsuspend_wrapper # done in rt_sigsuspend_glue 862 .globl compat_sys_rt_sigsuspend_wrapper
863compat_sys_rt_sigsuspend_wrapper:
864 llgtr %r2,%r2 # compat_sigset_t *
865 llgfr %r3,%r3 # compat_size_t
866 jg compat_sys_rt_sigsuspend
859 867
860 .globl sys32_pread64_wrapper 868 .globl sys32_pread64_wrapper
861sys32_pread64_wrapper: 869sys32_pread64_wrapper:
@@ -1475,3 +1483,122 @@ sys_inotify_rm_watch_wrapper:
1475 lgfr %r2,%r2 # int 1483 lgfr %r2,%r2 # int
1476 llgfr %r3,%r3 # u32 1484 llgfr %r3,%r3 # u32
1477 jg sys_inotify_rm_watch 1485 jg sys_inotify_rm_watch
1486
1487 .globl compat_sys_openat_wrapper
1488compat_sys_openat_wrapper:
1489 llgfr %r2,%r2 # unsigned int
1490 llgtr %r3,%r3 # const char *
1491 lgfr %r4,%r4 # int
1492 lgfr %r5,%r5 # int
1493 jg compat_sys_openat
1494
1495 .globl sys_mkdirat_wrapper
1496sys_mkdirat_wrapper:
1497 lgfr %r2,%r2 # int
1498 llgtr %r3,%r3 # const char *
1499 lgfr %r4,%r4 # int
1500 jg sys_mkdirat
1501
1502 .globl sys_mknodat_wrapper
1503sys_mknodat_wrapper:
1504 lgfr %r2,%r2 # int
1505 llgtr %r3,%r3 # const char *
1506 lgfr %r4,%r4 # int
1507 llgfr %r5,%r5 # unsigned int
1508 jg sys_mknodat
1509
1510 .globl sys_fchownat_wrapper
1511sys_fchownat_wrapper:
1512 lgfr %r2,%r2 # int
1513 llgtr %r3,%r3 # const char *
1514 llgfr %r4,%r4 # uid_t
1515 llgfr %r5,%r5 # gid_t
1516 lgfr %r6,%r6 # int
1517 jg sys_fchownat
1518
1519 .globl compat_sys_futimesat_wrapper
1520compat_sys_futimesat_wrapper:
1521 llgfr %r2,%r2 # unsigned int
1522 llgtr %r3,%r3 # char *
1523 llgtr %r4,%r4 # struct timeval *
1524 jg compat_sys_futimesat
1525
1526 .globl compat_sys_newfstatat_wrapper
1527compat_sys_newfstatat_wrapper:
1528 llgfr %r2,%r2 # unsigned int
1529 llgtr %r3,%r3 # char *
1530 llgtr %r4,%r4 # struct stat *
1531 lgfr %r5,%r5 # int
1532 jg compat_sys_newfstatat
1533
1534 .globl sys_unlinkat_wrapper
1535sys_unlinkat_wrapper:
1536 lgfr %r2,%r2 # int
1537 llgtr %r3,%r3 # const char *
1538 lgfr %r4,%r4 # int
1539 jg sys_unlinkat
1540
1541 .globl sys_renameat_wrapper
1542sys_renameat_wrapper:
1543 lgfr %r2,%r2 # int
1544 llgtr %r3,%r3 # const char *
1545 lgfr %r4,%r4 # int
1546 llgtr %r5,%r5 # const char *
1547 jg sys_renameat
1548
1549 .globl sys_linkat_wrapper
1550sys_linkat_wrapper:
1551 lgfr %r2,%r2 # int
1552 llgtr %r3,%r3 # const char *
1553 lgfr %r4,%r4 # int
1554 llgtr %r5,%r5 # const char *
1555 jg sys_linkat
1556
1557 .globl sys_symlinkat_wrapper
1558sys_symlinkat_wrapper:
1559 llgtr %r2,%r2 # const char *
1560 lgfr %r3,%r3 # int
1561 llgtr %r4,%r4 # const char *
1562 jg sys_symlinkat
1563
1564 .globl sys_readlinkat_wrapper
1565sys_readlinkat_wrapper:
1566 lgfr %r2,%r2 # int
1567 llgtr %r3,%r3 # const char *
1568 llgtr %r4,%r4 # char *
1569 lgfr %r5,%r5 # int
1570 jg sys_readlinkat
1571
1572 .globl sys_fchmodat_wrapper
1573sys_fchmodat_wrapper:
1574 lgfr %r2,%r2 # int
1575 llgtr %r3,%r3 # const char *
1576 llgfr %r4,%r4 # mode_t
1577 jg sys_fchmodat
1578
1579 .globl sys_faccessat_wrapper
1580sys_faccessat_wrapper:
1581 lgfr %r2,%r2 # int
1582 llgtr %r3,%r3 # const char *
1583 lgfr %r4,%r4 # int
1584 jg sys_faccessat
1585
1586 .globl compat_sys_pselect6_wrapper
1587compat_sys_pselect6_wrapper:
1588 lgfr %r2,%r2 # int
1589 llgtr %r3,%r3 # fd_set *
1590 llgtr %r4,%r4 # fd_set *
1591 llgtr %r5,%r5 # fd_set *
1592 llgtr %r6,%r6 # struct timespec *
1593 llgt %r0,164(%r15) # void *
1594 stg %r0,160(%r15)
1595 jg compat_sys_pselect6
1596
1597 .globl compat_sys_ppoll_wrapper
1598compat_sys_ppoll_wrapper:
1599 llgtr %r2,%r2 # struct pollfd *
1600 llgfr %r3,%r3 # unsigned int
1601 llgtr %r4,%r4 # struct timespec *
1602 llgtr %r5,%r5 # const sigset_t *
1603 llgfr %r6,%r6 # size_t
1604 jg compat_sys_ppoll
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index 27b07730b7b8..b2448487854c 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -2,8 +2,7 @@
2 * arch/s390/kernel/entry.S 2 * arch/s390/kernel/entry.S
3 * S390 low-level entry points. 3 * S390 low-level entry points.
4 * 4 *
5 * S390 version 5 * Copyright (C) IBM Corp. 1999,2006
6 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
8 * Hartmut Penner (hp@de.ibm.com), 7 * Hartmut Penner (hp@de.ibm.com),
9 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), 8 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
@@ -50,9 +49,10 @@ SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
50SP_TRAP = STACK_FRAME_OVERHEAD + __PT_TRAP 49SP_TRAP = STACK_FRAME_OVERHEAD + __PT_TRAP
51SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE 50SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
52 51
53_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING | \ 52_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
54 _TIF_RESTART_SVC | _TIF_SINGLE_STEP ) 53 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
55_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING) 54_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
55 _TIF_MCCK_PENDING)
56 56
57STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER 57STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
58STACK_SIZE = 1 << STACK_SHIFT 58STACK_SIZE = 1 << STACK_SHIFT
@@ -251,8 +251,8 @@ sysc_work:
251 bo BASED(sysc_mcck_pending) 251 bo BASED(sysc_mcck_pending)
252 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED 252 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
253 bo BASED(sysc_reschedule) 253 bo BASED(sysc_reschedule)
254 tm __TI_flags+3(%r9),_TIF_SIGPENDING 254 tm __TI_flags+3(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
255 bo BASED(sysc_sigpending) 255 bnz BASED(sysc_sigpending)
256 tm __TI_flags+3(%r9),_TIF_RESTART_SVC 256 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
257 bo BASED(sysc_restart) 257 bo BASED(sysc_restart)
258 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP 258 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
@@ -276,12 +276,11 @@ sysc_mcck_pending:
276 br %r1 # TIF bit will be cleared by handler 276 br %r1 # TIF bit will be cleared by handler
277 277
278# 278#
279# _TIF_SIGPENDING is set, call do_signal 279# _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
280# 280#
281sysc_sigpending: 281sysc_sigpending:
282 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP 282 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
283 la %r2,SP_PTREGS(%r15) # load pt_regs 283 la %r2,SP_PTREGS(%r15) # load pt_regs
284 sr %r3,%r3 # clear *oldset
285 l %r1,BASED(.Ldo_signal) 284 l %r1,BASED(.Ldo_signal)
286 basr %r14,%r1 # call do_signal 285 basr %r14,%r1 # call do_signal
287 tm __TI_flags+3(%r9),_TIF_RESTART_SVC 286 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
@@ -397,30 +396,6 @@ sys_rt_sigreturn_glue:
397 l %r1,BASED(.Lrt_sigreturn) 396 l %r1,BASED(.Lrt_sigreturn)
398 br %r1 # branch to sys_sigreturn 397 br %r1 # branch to sys_sigreturn
399 398
400#
401# sigsuspend and rt_sigsuspend need pt_regs as an additional
402# parameter and they have to skip the store of %r2 into the
403# user register %r2 because the return value was set in
404# sigsuspend and rt_sigsuspend already and must not be overwritten!
405#
406
407sys_sigsuspend_glue:
408 lr %r5,%r4 # move mask back
409 lr %r4,%r3 # move history1 parameter
410 lr %r3,%r2 # move history0 parameter
411 la %r2,SP_PTREGS(%r15) # load pt_regs as first parameter
412 l %r1,BASED(.Lsigsuspend)
413 la %r14,4(%r14) # skip store of return value
414 br %r1 # branch to sys_sigsuspend
415
416sys_rt_sigsuspend_glue:
417 lr %r4,%r3 # move sigsetsize parameter
418 lr %r3,%r2 # move unewset parameter
419 la %r2,SP_PTREGS(%r15) # load pt_regs as first parameter
420 l %r1,BASED(.Lrt_sigsuspend)
421 la %r14,4(%r14) # skip store of return value
422 br %r1 # branch to sys_rt_sigsuspend
423
424sys_sigaltstack_glue: 399sys_sigaltstack_glue:
425 la %r4,SP_PTREGS(%r15) # load pt_regs as parameter 400 la %r4,SP_PTREGS(%r15) # load pt_regs as parameter
426 l %r1,BASED(.Lsigaltstack) 401 l %r1,BASED(.Lsigaltstack)
@@ -604,15 +579,16 @@ io_work:
604 lr %r15,%r1 579 lr %r15,%r1
605# 580#
606# One of the work bits is on. Find out which one. 581# One of the work bits is on. Find out which one.
607# Checked are: _TIF_SIGPENDING, _TIF_NEED_RESCHED and _TIF_MCCK_PENDING 582# Checked are: _TIF_SIGPENDING, _TIF_RESTORE_SIGMASK, _TIF_NEED_RESCHED
583# and _TIF_MCCK_PENDING
608# 584#
609io_work_loop: 585io_work_loop:
610 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING 586 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
611 bo BASED(io_mcck_pending) 587 bo BASED(io_mcck_pending)
612 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED 588 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
613 bo BASED(io_reschedule) 589 bo BASED(io_reschedule)
614 tm __TI_flags+3(%r9),_TIF_SIGPENDING 590 tm __TI_flags+3(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
615 bo BASED(io_sigpending) 591 bnz BASED(io_sigpending)
616 b BASED(io_leave) 592 b BASED(io_leave)
617 593
618# 594#
@@ -636,12 +612,11 @@ io_reschedule:
636 b BASED(io_work_loop) 612 b BASED(io_work_loop)
637 613
638# 614#
639# _TIF_SIGPENDING is set, call do_signal 615# _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
640# 616#
641io_sigpending: 617io_sigpending:
642 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts 618 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
643 la %r2,SP_PTREGS(%r15) # load pt_regs 619 la %r2,SP_PTREGS(%r15) # load pt_regs
644 sr %r3,%r3 # clear *oldset
645 l %r1,BASED(.Ldo_signal) 620 l %r1,BASED(.Ldo_signal)
646 basr %r14,%r1 # call do_signal 621 basr %r14,%r1 # call do_signal
647 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts 622 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index 369ab4413ec7..2ac095bc0e25 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -1,9 +1,8 @@
1/* 1/*
2 * arch/s390/kernel/entry.S 2 * arch/s390/kernel/entry64.S
3 * S390 low-level entry points. 3 * S390 low-level entry points.
4 * 4 *
5 * S390 version 5 * Copyright (C) IBM Corp. 1999,2006
6 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
8 * Hartmut Penner (hp@de.ibm.com), 7 * Hartmut Penner (hp@de.ibm.com),
9 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), 8 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
@@ -53,9 +52,10 @@ SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
53STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER 52STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
54STACK_SIZE = 1 << STACK_SHIFT 53STACK_SIZE = 1 << STACK_SHIFT
55 54
56_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING | \ 55_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
57 _TIF_RESTART_SVC | _TIF_SINGLE_STEP ) 56 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
58_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING) 57_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
58 _TIF_MCCK_PENDING)
59 59
60#define BASED(name) name-system_call(%r13) 60#define BASED(name) name-system_call(%r13)
61 61
@@ -249,8 +249,8 @@ sysc_work:
249 jo sysc_mcck_pending 249 jo sysc_mcck_pending
250 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED 250 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
251 jo sysc_reschedule 251 jo sysc_reschedule
252 tm __TI_flags+7(%r9),_TIF_SIGPENDING 252 tm __TI_flags+7(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
253 jo sysc_sigpending 253 jnz sysc_sigpending
254 tm __TI_flags+7(%r9),_TIF_RESTART_SVC 254 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
255 jo sysc_restart 255 jo sysc_restart
256 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP 256 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP
@@ -272,12 +272,11 @@ sysc_mcck_pending:
272 jg s390_handle_mcck # TIF bit will be cleared by handler 272 jg s390_handle_mcck # TIF bit will be cleared by handler
273 273
274# 274#
275# _TIF_SIGPENDING is set, call do_signal 275# _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
276# 276#
277sysc_sigpending: 277sysc_sigpending:
278 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP 278 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
279 la %r2,SP_PTREGS(%r15) # load pt_regs 279 la %r2,SP_PTREGS(%r15) # load pt_regs
280 sgr %r3,%r3 # clear *oldset
281 brasl %r14,do_signal # call do_signal 280 brasl %r14,do_signal # call do_signal
282 tm __TI_flags+7(%r9),_TIF_RESTART_SVC 281 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
283 jo sysc_restart 282 jo sysc_restart
@@ -414,52 +413,6 @@ sys32_rt_sigreturn_glue:
414 jg sys32_rt_sigreturn # branch to sys32_sigreturn 413 jg sys32_rt_sigreturn # branch to sys32_sigreturn
415#endif 414#endif
416 415
417#
418# sigsuspend and rt_sigsuspend need pt_regs as an additional
419# parameter and they have to skip the store of %r2 into the
420# user register %r2 because the return value was set in
421# sigsuspend and rt_sigsuspend already and must not be overwritten!
422#
423
424sys_sigsuspend_glue:
425 lgr %r5,%r4 # move mask back
426 lgr %r4,%r3 # move history1 parameter
427 lgr %r3,%r2 # move history0 parameter
428 la %r2,SP_PTREGS(%r15) # load pt_regs as first parameter
429 la %r14,6(%r14) # skip store of return value
430 jg sys_sigsuspend # branch to sys_sigsuspend
431
432#ifdef CONFIG_COMPAT
433sys32_sigsuspend_glue:
434 llgfr %r4,%r4 # unsigned long
435 lgr %r5,%r4 # move mask back
436 lgfr %r3,%r3 # int
437 lgr %r4,%r3 # move history1 parameter
438 lgfr %r2,%r2 # int
439 lgr %r3,%r2 # move history0 parameter
440 la %r2,SP_PTREGS(%r15) # load pt_regs as first parameter
441 la %r14,6(%r14) # skip store of return value
442 jg sys32_sigsuspend # branch to sys32_sigsuspend
443#endif
444
445sys_rt_sigsuspend_glue:
446 lgr %r4,%r3 # move sigsetsize parameter
447 lgr %r3,%r2 # move unewset parameter
448 la %r2,SP_PTREGS(%r15) # load pt_regs as first parameter
449 la %r14,6(%r14) # skip store of return value
450 jg sys_rt_sigsuspend # branch to sys_rt_sigsuspend
451
452#ifdef CONFIG_COMPAT
453sys32_rt_sigsuspend_glue:
454 llgfr %r3,%r3 # size_t
455 lgr %r4,%r3 # move sigsetsize parameter
456 llgtr %r2,%r2 # sigset_emu31_t *
457 lgr %r3,%r2 # move unewset parameter
458 la %r2,SP_PTREGS(%r15) # load pt_regs as first parameter
459 la %r14,6(%r14) # skip store of return value
460 jg sys32_rt_sigsuspend # branch to sys32_rt_sigsuspend
461#endif
462
463sys_sigaltstack_glue: 416sys_sigaltstack_glue:
464 la %r4,SP_PTREGS(%r15) # load pt_regs as parameter 417 la %r4,SP_PTREGS(%r15) # load pt_regs as parameter
465 jg sys_sigaltstack # branch to sys_sigreturn 418 jg sys_sigaltstack # branch to sys_sigreturn
@@ -646,15 +599,16 @@ io_work:
646 lgr %r15,%r1 599 lgr %r15,%r1
647# 600#
648# One of the work bits is on. Find out which one. 601# One of the work bits is on. Find out which one.
649# Checked are: _TIF_SIGPENDING, _TIF_NEED_RESCHED and _TIF_MCCK_PENDING 602# Checked are: _TIF_SIGPENDING, _TIF_RESTORE_SIGPENDING, _TIF_NEED_RESCHED
603# and _TIF_MCCK_PENDING
650# 604#
651io_work_loop: 605io_work_loop:
652 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING 606 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
653 jo io_mcck_pending 607 jo io_mcck_pending
654 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED 608 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
655 jo io_reschedule 609 jo io_reschedule
656 tm __TI_flags+7(%r9),_TIF_SIGPENDING 610 tm __TI_flags+7(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
657 jo io_sigpending 611 jnz io_sigpending
658 j io_leave 612 j io_leave
659 613
660# 614#
@@ -676,12 +630,11 @@ io_reschedule:
676 j io_work_loop 630 j io_work_loop
677 631
678# 632#
679# _TIF_SIGPENDING is set, call do_signal 633# _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
680# 634#
681io_sigpending: 635io_sigpending:
682 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts 636 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
683 la %r2,SP_PTREGS(%r15) # load pt_regs 637 la %r2,SP_PTREGS(%r15) # load pt_regs
684 slgr %r3,%r3 # clear *oldset
685 brasl %r14,do_signal # call do_signal 638 brasl %r14,do_signal # call do_signal
686 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts 639 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
687 j io_work_loop 640 j io_work_loop
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c
index 6ae4a77270b5..ae1927e48cfb 100644
--- a/arch/s390/kernel/signal.c
+++ b/arch/s390/kernel/signal.c
@@ -1,8 +1,7 @@
1/* 1/*
2 * arch/s390/kernel/signal.c 2 * arch/s390/kernel/signal.c
3 * 3 *
4 * S390 version 4 * Copyright (C) IBM Corp. 1999,2006
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) 5 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
7 * 6 *
8 * Based on Intel version 7 * Based on Intel version
@@ -51,60 +50,24 @@ typedef struct
51 struct ucontext uc; 50 struct ucontext uc;
52} rt_sigframe; 51} rt_sigframe;
53 52
54int do_signal(struct pt_regs *regs, sigset_t *oldset);
55
56/* 53/*
57 * Atomically swap in the new signal mask, and wait for a signal. 54 * Atomically swap in the new signal mask, and wait for a signal.
58 */ 55 */
59asmlinkage int 56asmlinkage int
60sys_sigsuspend(struct pt_regs * regs, int history0, int history1, 57sys_sigsuspend(int history0, int history1, old_sigset_t mask)
61 old_sigset_t mask)
62{ 58{
63 sigset_t saveset;
64
65 mask &= _BLOCKABLE; 59 mask &= _BLOCKABLE;
66 spin_lock_irq(&current->sighand->siglock); 60 spin_lock_irq(&current->sighand->siglock);
67 saveset = current->blocked; 61 current->saved_sigmask = current->blocked;
68 siginitset(&current->blocked, mask); 62 siginitset(&current->blocked, mask);
69 recalc_sigpending(); 63 recalc_sigpending();
70 spin_unlock_irq(&current->sighand->siglock); 64 spin_unlock_irq(&current->sighand->siglock);
71 regs->gprs[2] = -EINTR;
72
73 while (1) {
74 set_current_state(TASK_INTERRUPTIBLE);
75 schedule();
76 if (do_signal(regs, &saveset))
77 return -EINTR;
78 }
79}
80
81asmlinkage long
82sys_rt_sigsuspend(struct pt_regs *regs, sigset_t __user *unewset,
83 size_t sigsetsize)
84{
85 sigset_t saveset, newset;
86 65
87 /* XXX: Don't preclude handling different sized sigset_t's. */ 66 current->state = TASK_INTERRUPTIBLE;
88 if (sigsetsize != sizeof(sigset_t)) 67 schedule();
89 return -EINVAL; 68 set_thread_flag(TIF_RESTORE_SIGMASK);
90 69
91 if (copy_from_user(&newset, unewset, sizeof(newset))) 70 return -ERESTARTNOHAND;
92 return -EFAULT;
93 sigdelsetmask(&newset, ~_BLOCKABLE);
94
95 spin_lock_irq(&current->sighand->siglock);
96 saveset = current->blocked;
97 current->blocked = newset;
98 recalc_sigpending();
99 spin_unlock_irq(&current->sighand->siglock);
100 regs->gprs[2] = -EINTR;
101
102 while (1) {
103 set_current_state(TASK_INTERRUPTIBLE);
104 schedule();
105 if (do_signal(regs, &saveset))
106 return -EINTR;
107 }
108} 71}
109 72
110asmlinkage long 73asmlinkage long
@@ -306,8 +269,8 @@ static inline int map_signal(int sig)
306 return sig; 269 return sig;
307} 270}
308 271
309static void setup_frame(int sig, struct k_sigaction *ka, 272static int setup_frame(int sig, struct k_sigaction *ka,
310 sigset_t *set, struct pt_regs * regs) 273 sigset_t *set, struct pt_regs * regs)
311{ 274{
312 sigframe __user *frame; 275 sigframe __user *frame;
313 276
@@ -355,13 +318,14 @@ static void setup_frame(int sig, struct k_sigaction *ka,
355 /* Place signal number on stack to allow backtrace from handler. */ 318 /* Place signal number on stack to allow backtrace from handler. */
356 if (__put_user(regs->gprs[2], (int __user *) &frame->signo)) 319 if (__put_user(regs->gprs[2], (int __user *) &frame->signo))
357 goto give_sigsegv; 320 goto give_sigsegv;
358 return; 321 return 0;
359 322
360give_sigsegv: 323give_sigsegv:
361 force_sigsegv(sig, current); 324 force_sigsegv(sig, current);
325 return -EFAULT;
362} 326}
363 327
364static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 328static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
365 sigset_t *set, struct pt_regs * regs) 329 sigset_t *set, struct pt_regs * regs)
366{ 330{
367 int err = 0; 331 int err = 0;
@@ -409,32 +373,39 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
409 regs->gprs[2] = map_signal(sig); 373 regs->gprs[2] = map_signal(sig);
410 regs->gprs[3] = (unsigned long) &frame->info; 374 regs->gprs[3] = (unsigned long) &frame->info;
411 regs->gprs[4] = (unsigned long) &frame->uc; 375 regs->gprs[4] = (unsigned long) &frame->uc;
412 return; 376 return 0;
413 377
414give_sigsegv: 378give_sigsegv:
415 force_sigsegv(sig, current); 379 force_sigsegv(sig, current);
380 return -EFAULT;
416} 381}
417 382
418/* 383/*
419 * OK, we're invoking a handler 384 * OK, we're invoking a handler
420 */ 385 */
421 386
422static void 387static int
423handle_signal(unsigned long sig, struct k_sigaction *ka, 388handle_signal(unsigned long sig, struct k_sigaction *ka,
424 siginfo_t *info, sigset_t *oldset, struct pt_regs * regs) 389 siginfo_t *info, sigset_t *oldset, struct pt_regs * regs)
425{ 390{
391 int ret;
392
426 /* Set up the stack frame */ 393 /* Set up the stack frame */
427 if (ka->sa.sa_flags & SA_SIGINFO) 394 if (ka->sa.sa_flags & SA_SIGINFO)
428 setup_rt_frame(sig, ka, info, oldset, regs); 395 ret = setup_rt_frame(sig, ka, info, oldset, regs);
429 else 396 else
430 setup_frame(sig, ka, oldset, regs); 397 ret = setup_frame(sig, ka, oldset, regs);
398
399 if (ret == 0) {
400 spin_lock_irq(&current->sighand->siglock);
401 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
402 if (!(ka->sa.sa_flags & SA_NODEFER))
403 sigaddset(&current->blocked,sig);
404 recalc_sigpending();
405 spin_unlock_irq(&current->sighand->siglock);
406 }
431 407
432 spin_lock_irq(&current->sighand->siglock); 408 return ret;
433 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
434 if (!(ka->sa.sa_flags & SA_NODEFER))
435 sigaddset(&current->blocked,sig);
436 recalc_sigpending();
437 spin_unlock_irq(&current->sighand->siglock);
438} 409}
439 410
440/* 411/*
@@ -446,12 +417,13 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
446 * the kernel can handle, and then we build all the user-level signal handling 417 * the kernel can handle, and then we build all the user-level signal handling
447 * stack-frames in one go after that. 418 * stack-frames in one go after that.
448 */ 419 */
449int do_signal(struct pt_regs *regs, sigset_t *oldset) 420void do_signal(struct pt_regs *regs)
450{ 421{
451 unsigned long retval = 0, continue_addr = 0, restart_addr = 0; 422 unsigned long retval = 0, continue_addr = 0, restart_addr = 0;
452 siginfo_t info; 423 siginfo_t info;
453 int signr; 424 int signr;
454 struct k_sigaction ka; 425 struct k_sigaction ka;
426 sigset_t *oldset;
455 427
456 /* 428 /*
457 * We want the common case to go fast, which 429 * We want the common case to go fast, which
@@ -460,9 +432,11 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
460 * if so. 432 * if so.
461 */ 433 */
462 if (!user_mode(regs)) 434 if (!user_mode(regs))
463 return 1; 435 return;
464 436
465 if (!oldset) 437 if (test_thread_flag(TIF_RESTORE_SIGMASK))
438 oldset = &current->saved_sigmask;
439 else
466 oldset = &current->blocked; 440 oldset = &current->blocked;
467 441
468 /* Are we from a system call? */ 442 /* Are we from a system call? */
@@ -473,12 +447,14 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
473 447
474 /* Prepare for system call restart. We do this here so that a 448 /* Prepare for system call restart. We do this here so that a
475 debugger will see the already changed PSW. */ 449 debugger will see the already changed PSW. */
476 if (retval == -ERESTARTNOHAND || 450 switch (retval) {
477 retval == -ERESTARTSYS || 451 case -ERESTARTNOHAND:
478 retval == -ERESTARTNOINTR) { 452 case -ERESTARTSYS:
453 case -ERESTARTNOINTR:
479 regs->gprs[2] = regs->orig_gpr2; 454 regs->gprs[2] = regs->orig_gpr2;
480 regs->psw.addr = restart_addr; 455 regs->psw.addr = restart_addr;
481 } else if (retval == -ERESTART_RESTARTBLOCK) { 456 break;
457 case -ERESTART_RESTARTBLOCK:
482 regs->gprs[2] = -EINTR; 458 regs->gprs[2] = -EINTR;
483 } 459 }
484 } 460 }
@@ -503,17 +479,38 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
503 /* Whee! Actually deliver the signal. */ 479 /* Whee! Actually deliver the signal. */
504#ifdef CONFIG_COMPAT 480#ifdef CONFIG_COMPAT
505 if (test_thread_flag(TIF_31BIT)) { 481 if (test_thread_flag(TIF_31BIT)) {
506 extern void handle_signal32(unsigned long sig, 482 extern int handle_signal32(unsigned long sig,
507 struct k_sigaction *ka, 483 struct k_sigaction *ka,
508 siginfo_t *info, 484 siginfo_t *info,
509 sigset_t *oldset, 485 sigset_t *oldset,
510 struct pt_regs *regs); 486 struct pt_regs *regs);
511 handle_signal32(signr, &ka, &info, oldset, regs); 487 if (handle_signal32(
512 return 1; 488 signr, &ka, &info, oldset, regs) == 0) {
489 if (test_thread_flag(TIF_RESTORE_SIGMASK))
490 clear_thread_flag(TIF_RESTORE_SIGMASK);
491 }
492 return;
513 } 493 }
514#endif 494#endif
515 handle_signal(signr, &ka, &info, oldset, regs); 495 if (handle_signal(signr, &ka, &info, oldset, regs) == 0) {
516 return 1; 496 /*
497 * A signal was successfully delivered; the saved
498 * sigmask will have been stored in the signal frame,
499 * and will be restored by sigreturn, so we can simply
500 * clear the TIF_RESTORE_SIGMASK flag.
501 */
502 if (test_thread_flag(TIF_RESTORE_SIGMASK))
503 clear_thread_flag(TIF_RESTORE_SIGMASK);
504 }
505 return;
506 }
507
508 /*
509 * If there's no signal to deliver, we just put the saved sigmask back.
510 */
511 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
512 clear_thread_flag(TIF_RESTORE_SIGMASK);
513 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
517 } 514 }
518 515
519 /* Restart a different system call. */ 516 /* Restart a different system call. */
@@ -522,5 +519,4 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
522 regs->gprs[2] = __NR_restart_syscall; 519 regs->gprs[2] = __NR_restart_syscall;
523 set_thread_flag(TIF_RESTART_SVC); 520 set_thread_flag(TIF_RESTART_SVC);
524 } 521 }
525 return 0;
526} 522}
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S
index 426d7cafdab3..3280345efacd 100644
--- a/arch/s390/kernel/syscalls.S
+++ b/arch/s390/kernel/syscalls.S
@@ -80,7 +80,7 @@ NI_SYSCALL /* old sgetmask syscall*/
80NI_SYSCALL /* old ssetmask syscall*/ 80NI_SYSCALL /* old ssetmask syscall*/
81SYSCALL(sys_setreuid16,sys_ni_syscall,sys32_setreuid16_wrapper) /* old setreuid16 syscall */ 81SYSCALL(sys_setreuid16,sys_ni_syscall,sys32_setreuid16_wrapper) /* old setreuid16 syscall */
82SYSCALL(sys_setregid16,sys_ni_syscall,sys32_setregid16_wrapper) /* old setregid16 syscall */ 82SYSCALL(sys_setregid16,sys_ni_syscall,sys32_setregid16_wrapper) /* old setregid16 syscall */
83SYSCALL(sys_sigsuspend_glue,sys_sigsuspend_glue,sys32_sigsuspend_glue) 83SYSCALL(sys_sigsuspend,sys_sigsuspend,sys_sigsuspend_wrapper)
84SYSCALL(sys_sigpending,sys_sigpending,compat_sys_sigpending_wrapper) 84SYSCALL(sys_sigpending,sys_sigpending,compat_sys_sigpending_wrapper)
85SYSCALL(sys_sethostname,sys_sethostname,sys32_sethostname_wrapper) 85SYSCALL(sys_sethostname,sys_sethostname,sys32_sethostname_wrapper)
86SYSCALL(sys_setrlimit,sys_setrlimit,compat_sys_setrlimit_wrapper) /* 75 */ 86SYSCALL(sys_setrlimit,sys_setrlimit,compat_sys_setrlimit_wrapper) /* 75 */
@@ -187,7 +187,7 @@ SYSCALL(sys_rt_sigprocmask,sys_rt_sigprocmask,sys32_rt_sigprocmask_wrapper) /* 1
187SYSCALL(sys_rt_sigpending,sys_rt_sigpending,sys32_rt_sigpending_wrapper) 187SYSCALL(sys_rt_sigpending,sys_rt_sigpending,sys32_rt_sigpending_wrapper)
188SYSCALL(sys_rt_sigtimedwait,sys_rt_sigtimedwait,compat_sys_rt_sigtimedwait_wrapper) 188SYSCALL(sys_rt_sigtimedwait,sys_rt_sigtimedwait,compat_sys_rt_sigtimedwait_wrapper)
189SYSCALL(sys_rt_sigqueueinfo,sys_rt_sigqueueinfo,sys32_rt_sigqueueinfo_wrapper) 189SYSCALL(sys_rt_sigqueueinfo,sys_rt_sigqueueinfo,sys32_rt_sigqueueinfo_wrapper)
190SYSCALL(sys_rt_sigsuspend_glue,sys_rt_sigsuspend_glue,sys32_rt_sigsuspend_glue) 190SYSCALL(sys_rt_sigsuspend,sys_rt_sigsuspend,compat_sys_rt_sigsuspend_wrapper)
191SYSCALL(sys_pread64,sys_pread64,sys32_pread64_wrapper) /* 180 */ 191SYSCALL(sys_pread64,sys_pread64,sys32_pread64_wrapper) /* 180 */
192SYSCALL(sys_pwrite64,sys_pwrite64,sys32_pwrite64_wrapper) 192SYSCALL(sys_pwrite64,sys_pwrite64,sys32_pwrite64_wrapper)
193SYSCALL(sys_chown16,sys_ni_syscall,sys32_chown16_wrapper) /* old chown16 syscall */ 193SYSCALL(sys_chown16,sys_ni_syscall,sys32_chown16_wrapper) /* old chown16 syscall */
@@ -293,5 +293,21 @@ SYSCALL(sys_waitid,sys_waitid,compat_sys_waitid_wrapper)
293SYSCALL(sys_ioprio_set,sys_ioprio_set,sys_ioprio_set_wrapper) 293SYSCALL(sys_ioprio_set,sys_ioprio_set,sys_ioprio_set_wrapper)
294SYSCALL(sys_ioprio_get,sys_ioprio_get,sys_ioprio_get_wrapper) 294SYSCALL(sys_ioprio_get,sys_ioprio_get,sys_ioprio_get_wrapper)
295SYSCALL(sys_inotify_init,sys_inotify_init,sys_inotify_init) 295SYSCALL(sys_inotify_init,sys_inotify_init,sys_inotify_init)
296SYSCALL(sys_inotify_add_watch,sys_inotify_add_watch,sys_inotify_add_watch_wrapper) 296SYSCALL(sys_inotify_add_watch,sys_inotify_add_watch,sys_inotify_add_watch_wrapper) /* 285 */
297SYSCALL(sys_inotify_rm_watch,sys_inotify_rm_watch,sys_inotify_rm_watch_wrapper) 297SYSCALL(sys_inotify_rm_watch,sys_inotify_rm_watch,sys_inotify_rm_watch_wrapper)
298NI_SYSCALL /* 287 sys_migrate_pages */
299SYSCALL(sys_openat,sys_openat,compat_sys_openat_wrapper)
300SYSCALL(sys_mkdirat,sys_mkdirat,sys_mkdirat_wrapper)
301SYSCALL(sys_mknodat,sys_mknodat,sys_mknodat_wrapper) /* 290 */
302SYSCALL(sys_fchownat,sys_fchownat,sys_fchownat_wrapper)
303SYSCALL(sys_futimesat,sys_futimesat,compat_sys_futimesat_wrapper)
304SYSCALL(sys_newfstatat,sys_newfstatat,compat_sys_newfstatat_wrapper)
305SYSCALL(sys_unlinkat,sys_unlinkat,sys_unlinkat_wrapper)
306SYSCALL(sys_renameat,sys_renameat,sys_renameat_wrapper) /* 295 */
307SYSCALL(sys_linkat,sys_linkat,sys_linkat_wrapper)
308SYSCALL(sys_symlinkat,sys_symlinkat,sys_symlinkat_wrapper)
309SYSCALL(sys_readlinkat,sys_readlinkat,sys_readlinkat_wrapper)
310SYSCALL(sys_fchmodat,sys_fchmodat,sys_fchmodat_wrapper)
311SYSCALL(sys_faccessat,sys_faccessat,sys_faccessat_wrapper) /* 300 */
312SYSCALL(sys_pselect6,sys_pselect6,compat_sys_pselect6_wrapper)
313SYSCALL(sys_ppoll,sys_ppoll,compat_sys_ppoll_wrapper)
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index 7c0fe152a111..fea043b69b91 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -61,9 +61,18 @@ extern unsigned long wall_jiffies;
61 */ 61 */
62unsigned long long sched_clock(void) 62unsigned long long sched_clock(void)
63{ 63{
64 return ((get_clock() - jiffies_timer_cc) * 1000) >> 12; 64 return ((get_clock() - jiffies_timer_cc) * 125) >> 9;
65} 65}
66 66
67/*
68 * Monotonic_clock - returns # of nanoseconds passed since time_init()
69 */
70unsigned long long monotonic_clock(void)
71{
72 return sched_clock();
73}
74EXPORT_SYMBOL(monotonic_clock);
75
67void tod_to_timeval(__u64 todval, struct timespec *xtime) 76void tod_to_timeval(__u64 todval, struct timespec *xtime)
68{ 77{
69 unsigned long long sec; 78 unsigned long long sec;
diff --git a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile
index f20b51ff1d86..e05d087a6eae 100644
--- a/arch/s390/lib/Makefile
+++ b/arch/s390/lib/Makefile
@@ -6,4 +6,4 @@ EXTRA_AFLAGS := -traditional
6 6
7lib-y += delay.o string.o 7lib-y += delay.o string.o
8lib-y += $(if $(CONFIG_64BIT),uaccess64.o,uaccess.o) 8lib-y += $(if $(CONFIG_64BIT),uaccess64.o,uaccess.o)
9lib-$(CONFIG_SMP) += spinlock.o \ No newline at end of file 9lib-$(CONFIG_SMP) += spinlock.o
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 01bc7d589afe..504d56f8ca7f 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -396,14 +396,8 @@ source "arch/sh/boards/renesas/hs7751rvoip/Kconfig"
396 396
397source "arch/sh/boards/renesas/rts7751r2d/Kconfig" 397source "arch/sh/boards/renesas/rts7751r2d/Kconfig"
398 398
399config SH_PCLK_FREQ_BOOL
400 bool "Set default pclk frequency"
401 default y if !SH_RTC
402 default n
403
404config SH_PCLK_FREQ 399config SH_PCLK_FREQ
405 int "Peripheral clock frequency (in Hz)" 400 int "Peripheral clock frequency (in Hz)"
406 depends on SH_PCLK_FREQ_BOOL
407 default "50000000" if CPU_SUBTYPE_SH7750 || CPU_SUBTYPE_SH7780 401 default "50000000" if CPU_SUBTYPE_SH7750 || CPU_SUBTYPE_SH7780
408 default "60000000" if CPU_SUBTYPE_SH7751 402 default "60000000" if CPU_SUBTYPE_SH7751
409 default "33333333" if CPU_SUBTYPE_SH7300 || CPU_SUBTYPE_SH7770 || CPU_SUBTYPE_SH7760 403 default "33333333" if CPU_SUBTYPE_SH7300 || CPU_SUBTYPE_SH7770 || CPU_SUBTYPE_SH7760
diff --git a/arch/sh/boards/superh/microdev/io.c b/arch/sh/boards/superh/microdev/io.c
index fe83b2c03076..1ed7f880b8c7 100644
--- a/arch/sh/boards/superh/microdev/io.c
+++ b/arch/sh/boards/superh/microdev/io.c
@@ -16,7 +16,7 @@
16#include <linux/pci.h> 16#include <linux/pci.h>
17#include <linux/wait.h> 17#include <linux/wait.h>
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/mach/io.h> 19#include <asm/microdev.h>
20 20
21 /* 21 /*
22 * we need to have a 'safe' address to re-direct all I/O requests 22 * we need to have a 'safe' address to re-direct all I/O requests
@@ -52,8 +52,90 @@
52#define IO_ISP1161_PHYS 0xa7700000ul /* Physical address of Philips ISP1161x USB chip */ 52#define IO_ISP1161_PHYS 0xa7700000ul /* Physical address of Philips ISP1161x USB chip */
53#define IO_SUPERIO_PHYS 0xa7800000ul /* Physical address of SMSC FDC37C93xAPM SuperIO chip */ 53#define IO_SUPERIO_PHYS 0xa7800000ul /* Physical address of SMSC FDC37C93xAPM SuperIO chip */
54 54
55#define PORT2ADDR(x) (microdev_isa_port2addr(x)) 55/*
56 * map I/O ports to memory-mapped addresses
57 */
58static unsigned long microdev_isa_port2addr(unsigned long offset)
59{
60 unsigned long result;
61
62 if ((offset >= IO_LAN91C111_BASE) &&
63 (offset < IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) {
64 /*
65 * SMSC LAN91C111 Ethernet chip
66 */
67 result = IO_LAN91C111_PHYS + offset - IO_LAN91C111_BASE;
68 } else if ((offset >= IO_SUPERIO_BASE) &&
69 (offset < IO_SUPERIO_BASE + IO_SUPERIO_EXTENT)) {
70 /*
71 * SMSC FDC37C93xAPM SuperIO chip
72 *
73 * Configuration Registers
74 */
75 result = IO_SUPERIO_PHYS + (offset << 1);
76#if 0
77 } else if (offset == KBD_DATA_REG || offset == KBD_CNTL_REG ||
78 offset == KBD_STATUS_REG) {
79 /*
80 * SMSC FDC37C93xAPM SuperIO chip
81 *
82 * PS/2 Keyboard + Mouse (ports 0x60 and 0x64).
83 */
84 result = IO_SUPERIO_PHYS + (offset << 1);
85#endif
86 } else if (((offset >= IO_IDE1_BASE) &&
87 (offset < IO_IDE1_BASE + IO_IDE_EXTENT)) ||
88 (offset == IO_IDE1_MISC)) {
89 /*
90 * SMSC FDC37C93xAPM SuperIO chip
91 *
92 * IDE #1
93 */
94 result = IO_SUPERIO_PHYS + (offset << 1);
95 } else if (((offset >= IO_IDE2_BASE) &&
96 (offset < IO_IDE2_BASE + IO_IDE_EXTENT)) ||
97 (offset == IO_IDE2_MISC)) {
98 /*
99 * SMSC FDC37C93xAPM SuperIO chip
100 *
101 * IDE #2
102 */
103 result = IO_SUPERIO_PHYS + (offset << 1);
104 } else if ((offset >= IO_SERIAL1_BASE) &&
105 (offset < IO_SERIAL1_BASE + IO_SERIAL_EXTENT)) {
106 /*
107 * SMSC FDC37C93xAPM SuperIO chip
108 *
109 * Serial #1
110 */
111 result = IO_SUPERIO_PHYS + (offset << 1);
112 } else if ((offset >= IO_SERIAL2_BASE) &&
113 (offset < IO_SERIAL2_BASE + IO_SERIAL_EXTENT)) {
114 /*
115 * SMSC FDC37C93xAPM SuperIO chip
116 *
117 * Serial #2
118 */
119 result = IO_SUPERIO_PHYS + (offset << 1);
120 } else if ((offset >= IO_ISP1161_BASE) &&
121 (offset < IO_ISP1161_BASE + IO_ISP1161_EXTENT)) {
122 /*
123 * Philips USB ISP1161x chip
124 */
125 result = IO_ISP1161_PHYS + offset - IO_ISP1161_BASE;
126 } else {
127 /*
128 * safe default.
129 */
130 printk("Warning: unexpected port in %s( offset = 0x%lx )\n",
131 __FUNCTION__, offset);
132 result = PVR;
133 }
134
135 return result;
136}
56 137
138#define PORT2ADDR(x) (microdev_isa_port2addr(x))
57 139
58static inline void delay(void) 140static inline void delay(void)
59{ 141{
@@ -94,6 +176,17 @@ unsigned int microdev_inl(unsigned long port)
94 return *(volatile unsigned int*)PORT2ADDR(port); 176 return *(volatile unsigned int*)PORT2ADDR(port);
95} 177}
96 178
179void microdev_outw(unsigned short b, unsigned long port)
180{
181#ifdef CONFIG_PCI
182 if (port >= PCIBIOS_MIN_IO) {
183 microdev_pci_outw(b, port);
184 return;
185 }
186#endif
187 *(volatile unsigned short*)PORT2ADDR(port) = b;
188}
189
97void microdev_outb(unsigned char b, unsigned long port) 190void microdev_outb(unsigned char b, unsigned long port)
98{ 191{
99#ifdef CONFIG_PCI 192#ifdef CONFIG_PCI
@@ -158,17 +251,6 @@ void microdev_outb(unsigned char b, unsigned long port)
158 } 251 }
159} 252}
160 253
161void microdev_outw(unsigned short b, unsigned long port)
162{
163#ifdef CONFIG_PCI
164 if (port >= PCIBIOS_MIN_IO) {
165 microdev_pci_outw(b, port);
166 return;
167 }
168#endif
169 *(volatile unsigned short*)PORT2ADDR(port) = b;
170}
171
172void microdev_outl(unsigned int b, unsigned long port) 254void microdev_outl(unsigned int b, unsigned long port)
173{ 255{
174#ifdef CONFIG_PCI 256#ifdef CONFIG_PCI
@@ -284,87 +366,3 @@ void microdev_outsl(unsigned long port, const void *buffer, unsigned long count)
284 while (count--) 366 while (count--)
285 *port_addr = *buf++; 367 *port_addr = *buf++;
286} 368}
287
288/*
289 * map I/O ports to memory-mapped addresses
290 */
291unsigned long microdev_isa_port2addr(unsigned long offset)
292{
293 unsigned long result;
294
295 if ((offset >= IO_LAN91C111_BASE) &&
296 (offset < IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) {
297 /*
298 * SMSC LAN91C111 Ethernet chip
299 */
300 result = IO_LAN91C111_PHYS + offset - IO_LAN91C111_BASE;
301 } else if ((offset >= IO_SUPERIO_BASE) &&
302 (offset < IO_SUPERIO_BASE + IO_SUPERIO_EXTENT)) {
303 /*
304 * SMSC FDC37C93xAPM SuperIO chip
305 *
306 * Configuration Registers
307 */
308 result = IO_SUPERIO_PHYS + (offset << 1);
309#if 0
310 } else if (offset == KBD_DATA_REG || offset == KBD_CNTL_REG ||
311 offset == KBD_STATUS_REG) {
312 /*
313 * SMSC FDC37C93xAPM SuperIO chip
314 *
315 * PS/2 Keyboard + Mouse (ports 0x60 and 0x64).
316 */
317 result = IO_SUPERIO_PHYS + (offset << 1);
318#endif
319 } else if (((offset >= IO_IDE1_BASE) &&
320 (offset < IO_IDE1_BASE + IO_IDE_EXTENT)) ||
321 (offset == IO_IDE1_MISC)) {
322 /*
323 * SMSC FDC37C93xAPM SuperIO chip
324 *
325 * IDE #1
326 */
327 result = IO_SUPERIO_PHYS + (offset << 1);
328 } else if (((offset >= IO_IDE2_BASE) &&
329 (offset < IO_IDE2_BASE + IO_IDE_EXTENT)) ||
330 (offset == IO_IDE2_MISC)) {
331 /*
332 * SMSC FDC37C93xAPM SuperIO chip
333 *
334 * IDE #2
335 */
336 result = IO_SUPERIO_PHYS + (offset << 1);
337 } else if ((offset >= IO_SERIAL1_BASE) &&
338 (offset < IO_SERIAL1_BASE + IO_SERIAL_EXTENT)) {
339 /*
340 * SMSC FDC37C93xAPM SuperIO chip
341 *
342 * Serial #1
343 */
344 result = IO_SUPERIO_PHYS + (offset << 1);
345 } else if ((offset >= IO_SERIAL2_BASE) &&
346 (offset < IO_SERIAL2_BASE + IO_SERIAL_EXTENT)) {
347 /*
348 * SMSC FDC37C93xAPM SuperIO chip
349 *
350 * Serial #2
351 */
352 result = IO_SUPERIO_PHYS + (offset << 1);
353 } else if ((offset >= IO_ISP1161_BASE) &&
354 (offset < IO_ISP1161_BASE + IO_ISP1161_EXTENT)) {
355 /*
356 * Philips USB ISP1161x chip
357 */
358 result = IO_ISP1161_PHYS + offset - IO_ISP1161_BASE;
359 } else {
360 /*
361 * safe default.
362 */
363 printk("Warning: unexpected port in %s( offset = 0x%lx )\n",
364 __FUNCTION__, offset);
365 result = PVR;
366 }
367
368 return result;
369}
370
diff --git a/arch/sh/boards/superh/microdev/irq.c b/arch/sh/boards/superh/microdev/irq.c
index 1395c1e65da4..efcbd86b7cd2 100644
--- a/arch/sh/boards/superh/microdev/irq.c
+++ b/arch/sh/boards/superh/microdev/irq.c
@@ -15,7 +15,7 @@
15 15
16#include <asm/system.h> 16#include <asm/system.h>
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/mach/irq.h> 18#include <asm/microdev.h>
19 19
20#define NUM_EXTERNAL_IRQS 16 /* IRL0 .. IRL15 */ 20#define NUM_EXTERNAL_IRQS 16 /* IRL0 .. IRL15 */
21 21
diff --git a/arch/sh/boards/superh/microdev/setup.c b/arch/sh/boards/superh/microdev/setup.c
index 1c1d65fb12df..892b14d31405 100644
--- a/arch/sh/boards/superh/microdev/setup.c
+++ b/arch/sh/boards/superh/microdev/setup.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com) 4 * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
5 * Copyright (C) 2003, 2004 SuperH, Inc. 5 * Copyright (C) 2003, 2004 SuperH, Inc.
6 * Copyright (C) 2004 Paul Mundt 6 * Copyright (C) 2004, 2005 Paul Mundt
7 * 7 *
8 * SuperH SH4-202 MicroDev board support. 8 * SuperH SH4-202 MicroDev board support.
9 * 9 *
@@ -15,11 +15,10 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/ioport.h> 17#include <linux/ioport.h>
18#include <video/s1d13xxxfb.h>
19#include <asm/microdev.h>
18#include <asm/io.h> 20#include <asm/io.h>
19#include <asm/mach/irq.h>
20#include <asm/mach/io.h>
21#include <asm/machvec.h> 21#include <asm/machvec.h>
22#include <asm/machvec_init.h>
23 22
24extern void microdev_heartbeat(void); 23extern void microdev_heartbeat(void);
25 24
@@ -51,8 +50,6 @@ struct sh_machine_vector mv_sh4202_microdev __initmv = {
51 .mv_outsw = microdev_outsw, 50 .mv_outsw = microdev_outsw,
52 .mv_outsl = microdev_outsl, 51 .mv_outsl = microdev_outsl,
53 52
54 .mv_isa_port2addr = microdev_isa_port2addr,
55
56 .mv_init_irq = init_microdev_irq, 53 .mv_init_irq = init_microdev_irq,
57 54
58#ifdef CONFIG_HEARTBEAT 55#ifdef CONFIG_HEARTBEAT
@@ -142,16 +139,161 @@ static struct platform_device smc91x_device = {
142 .resource = smc91x_resources, 139 .resource = smc91x_resources,
143}; 140};
144 141
145static int __init smc91x_setup(void) 142#ifdef CONFIG_FB_S1D13XXX
143static struct s1d13xxxfb_regval s1d13806_initregs[] = {
144 { S1DREG_MISC, 0x00 },
145 { S1DREG_COM_DISP_MODE, 0x00 },
146 { S1DREG_GPIO_CNF0, 0x00 },
147 { S1DREG_GPIO_CNF1, 0x00 },
148 { S1DREG_GPIO_CTL0, 0x00 },
149 { S1DREG_GPIO_CTL1, 0x00 },
150 { S1DREG_CLK_CNF, 0x02 },
151 { S1DREG_LCD_CLK_CNF, 0x01 },
152 { S1DREG_CRT_CLK_CNF, 0x03 },
153 { S1DREG_MPLUG_CLK_CNF, 0x03 },
154 { S1DREG_CPU2MEM_WST_SEL, 0x02 },
155 { S1DREG_SDRAM_REF_RATE, 0x03 },
156 { S1DREG_SDRAM_TC0, 0x00 },
157 { S1DREG_SDRAM_TC1, 0x01 },
158 { S1DREG_MEM_CNF, 0x80 },
159 { S1DREG_PANEL_TYPE, 0x25 },
160 { S1DREG_MOD_RATE, 0x00 },
161 { S1DREG_LCD_DISP_HWIDTH, 0x63 },
162 { S1DREG_LCD_NDISP_HPER, 0x1e },
163 { S1DREG_TFT_FPLINE_START, 0x06 },
164 { S1DREG_TFT_FPLINE_PWIDTH, 0x03 },
165 { S1DREG_LCD_DISP_VHEIGHT0, 0x57 },
166 { S1DREG_LCD_DISP_VHEIGHT1, 0x02 },
167 { S1DREG_LCD_NDISP_VPER, 0x00 },
168 { S1DREG_TFT_FPFRAME_START, 0x0a },
169 { S1DREG_TFT_FPFRAME_PWIDTH, 0x81 },
170 { S1DREG_LCD_DISP_MODE, 0x03 },
171 { S1DREG_LCD_MISC, 0x00 },
172 { S1DREG_LCD_DISP_START0, 0x00 },
173 { S1DREG_LCD_DISP_START1, 0x00 },
174 { S1DREG_LCD_DISP_START2, 0x00 },
175 { S1DREG_LCD_MEM_OFF0, 0x90 },
176 { S1DREG_LCD_MEM_OFF1, 0x01 },
177 { S1DREG_LCD_PIX_PAN, 0x00 },
178 { S1DREG_LCD_DISP_FIFO_HTC, 0x00 },
179 { S1DREG_LCD_DISP_FIFO_LTC, 0x00 },
180 { S1DREG_CRT_DISP_HWIDTH, 0x63 },
181 { S1DREG_CRT_NDISP_HPER, 0x1f },
182 { S1DREG_CRT_HRTC_START, 0x04 },
183 { S1DREG_CRT_HRTC_PWIDTH, 0x8f },
184 { S1DREG_CRT_DISP_VHEIGHT0, 0x57 },
185 { S1DREG_CRT_DISP_VHEIGHT1, 0x02 },
186 { S1DREG_CRT_NDISP_VPER, 0x1b },
187 { S1DREG_CRT_VRTC_START, 0x00 },
188 { S1DREG_CRT_VRTC_PWIDTH, 0x83 },
189 { S1DREG_TV_OUT_CTL, 0x10 },
190 { S1DREG_CRT_DISP_MODE, 0x05 },
191 { S1DREG_CRT_DISP_START0, 0x00 },
192 { S1DREG_CRT_DISP_START1, 0x00 },
193 { S1DREG_CRT_DISP_START2, 0x00 },
194 { S1DREG_CRT_MEM_OFF0, 0x20 },
195 { S1DREG_CRT_MEM_OFF1, 0x03 },
196 { S1DREG_CRT_PIX_PAN, 0x00 },
197 { S1DREG_CRT_DISP_FIFO_HTC, 0x00 },
198 { S1DREG_CRT_DISP_FIFO_LTC, 0x00 },
199 { S1DREG_LCD_CUR_CTL, 0x00 },
200 { S1DREG_LCD_CUR_START, 0x01 },
201 { S1DREG_LCD_CUR_XPOS0, 0x00 },
202 { S1DREG_LCD_CUR_XPOS1, 0x00 },
203 { S1DREG_LCD_CUR_YPOS0, 0x00 },
204 { S1DREG_LCD_CUR_YPOS1, 0x00 },
205 { S1DREG_LCD_CUR_BCTL0, 0x00 },
206 { S1DREG_LCD_CUR_GCTL0, 0x00 },
207 { S1DREG_LCD_CUR_RCTL0, 0x00 },
208 { S1DREG_LCD_CUR_BCTL1, 0x1f },
209 { S1DREG_LCD_CUR_GCTL1, 0x3f },
210 { S1DREG_LCD_CUR_RCTL1, 0x1f },
211 { S1DREG_LCD_CUR_FIFO_HTC, 0x00 },
212 { S1DREG_CRT_CUR_CTL, 0x00 },
213 { S1DREG_CRT_CUR_START, 0x01 },
214 { S1DREG_CRT_CUR_XPOS0, 0x00 },
215 { S1DREG_CRT_CUR_XPOS1, 0x00 },
216 { S1DREG_CRT_CUR_YPOS0, 0x00 },
217 { S1DREG_CRT_CUR_YPOS1, 0x00 },
218 { S1DREG_CRT_CUR_BCTL0, 0x00 },
219 { S1DREG_CRT_CUR_GCTL0, 0x00 },
220 { S1DREG_CRT_CUR_RCTL0, 0x00 },
221 { S1DREG_CRT_CUR_BCTL1, 0x1f },
222 { S1DREG_CRT_CUR_GCTL1, 0x3f },
223 { S1DREG_CRT_CUR_RCTL1, 0x1f },
224 { S1DREG_CRT_CUR_FIFO_HTC, 0x00 },
225 { S1DREG_BBLT_CTL0, 0x00 },
226 { S1DREG_BBLT_CTL1, 0x00 },
227 { S1DREG_BBLT_CC_EXP, 0x00 },
228 { S1DREG_BBLT_OP, 0x00 },
229 { S1DREG_BBLT_SRC_START0, 0x00 },
230 { S1DREG_BBLT_SRC_START1, 0x00 },
231 { S1DREG_BBLT_SRC_START2, 0x00 },
232 { S1DREG_BBLT_DST_START0, 0x00 },
233 { S1DREG_BBLT_DST_START1, 0x00 },
234 { S1DREG_BBLT_DST_START2, 0x00 },
235 { S1DREG_BBLT_MEM_OFF0, 0x00 },
236 { S1DREG_BBLT_MEM_OFF1, 0x00 },
237 { S1DREG_BBLT_WIDTH0, 0x00 },
238 { S1DREG_BBLT_WIDTH1, 0x00 },
239 { S1DREG_BBLT_HEIGHT0, 0x00 },
240 { S1DREG_BBLT_HEIGHT1, 0x00 },
241 { S1DREG_BBLT_BGC0, 0x00 },
242 { S1DREG_BBLT_BGC1, 0x00 },
243 { S1DREG_BBLT_FGC0, 0x00 },
244 { S1DREG_BBLT_FGC1, 0x00 },
245 { S1DREG_LKUP_MODE, 0x00 },
246 { S1DREG_LKUP_ADDR, 0x00 },
247 { S1DREG_PS_CNF, 0x10 },
248 { S1DREG_PS_STATUS, 0x00 },
249 { S1DREG_CPU2MEM_WDOGT, 0x00 },
250 { S1DREG_COM_DISP_MODE, 0x02 },
251};
252
253static struct s1d13xxxfb_pdata s1d13806_platform_data = {
254 .initregs = s1d13806_initregs,
255 .initregssize = ARRAY_SIZE(s1d13806_initregs),
256};
257
258static struct resource s1d13806_resources[] = {
259 [0] = {
260 .start = 0x07200000,
261 .end = 0x07200000 + 0x00200000 - 1,
262 .flags = IORESOURCE_MEM,
263 },
264 [1] = {
265 .start = 0x07000000,
266 .end = 0x07000000 + 0x00200000 - 1,
267 .flags = IORESOURCE_MEM,
268 },
269};
270
271static struct platform_device s1d13806_device = {
272 .name = "s1d13806fb",
273 .id = -1,
274 .num_resources = ARRAY_SIZE(s1d13806_resources),
275 .resource = s1d13806_resources,
276
277 .dev = {
278 .platform_data = &s1d13806_platform_data,
279 },
280};
281#endif
282
283static struct platform_device *microdev_devices[] __initdata = {
284 &smc91x_device,
285#ifdef CONFIG_FB_S1D13XXX
286 &s1d13806_device,
287#endif
288};
289
290static int __init microdev_devices_setup(void)
146{ 291{
147 return platform_device_register(&smc91x_device); 292 return platform_add_devices(microdev_devices, ARRAY_SIZE(microdev_devices));
148} 293}
149 294
150__initcall(smc91x_setup); 295__initcall(microdev_devices_setup);
151 296
152 /*
153 * Initialize the board
154 */
155void __init platform_setup(void) 297void __init platform_setup(void)
156{ 298{
157 int * const fpgaRevisionRegister = (int*)(MICRODEV_FPGA_GP_BASE + 0x8ul); 299 int * const fpgaRevisionRegister = (int*)(MICRODEV_FPGA_GP_BASE + 0x8ul);
diff --git a/arch/sh/boards/unknown/Makefile b/arch/sh/boards/unknown/Makefile
index cffc21031e71..7d18f408b0c5 100644
--- a/arch/sh/boards/unknown/Makefile
+++ b/arch/sh/boards/unknown/Makefile
@@ -2,5 +2,5 @@
2# Makefile for unknown SH boards 2# Makefile for unknown SH boards
3# 3#
4 4
5obj-y := mach.o io.o setup.o 5obj-y := setup.o
6 6
diff --git a/arch/sh/boards/unknown/io.c b/arch/sh/boards/unknown/io.c
deleted file mode 100644
index 8f3f17267bd9..000000000000
--- a/arch/sh/boards/unknown/io.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * linux/arch/sh/kernel/io_unknown.c
3 *
4 * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * I/O routine for unknown hardware.
10 */
11
12static unsigned int unknown_handler(void)
13{
14 return 0;
15}
16
17#define UNKNOWN_ALIAS(fn) \
18 void unknown_##fn(void) __attribute__ ((alias ("unknown_handler")));
19
20UNKNOWN_ALIAS(inb)
21UNKNOWN_ALIAS(inw)
22UNKNOWN_ALIAS(inl)
23UNKNOWN_ALIAS(outb)
24UNKNOWN_ALIAS(outw)
25UNKNOWN_ALIAS(outl)
26UNKNOWN_ALIAS(inb_p)
27UNKNOWN_ALIAS(inw_p)
28UNKNOWN_ALIAS(inl_p)
29UNKNOWN_ALIAS(outb_p)
30UNKNOWN_ALIAS(outw_p)
31UNKNOWN_ALIAS(outl_p)
32UNKNOWN_ALIAS(insb)
33UNKNOWN_ALIAS(insw)
34UNKNOWN_ALIAS(insl)
35UNKNOWN_ALIAS(outsb)
36UNKNOWN_ALIAS(outsw)
37UNKNOWN_ALIAS(outsl)
38UNKNOWN_ALIAS(readb)
39UNKNOWN_ALIAS(readw)
40UNKNOWN_ALIAS(readl)
41UNKNOWN_ALIAS(writeb)
42UNKNOWN_ALIAS(writew)
43UNKNOWN_ALIAS(writel)
44UNKNOWN_ALIAS(isa_port2addr)
45UNKNOWN_ALIAS(ioremap)
46UNKNOWN_ALIAS(iounmap)
diff --git a/arch/sh/boards/unknown/mach.c b/arch/sh/boards/unknown/mach.c
deleted file mode 100644
index ad0bcc60a640..000000000000
--- a/arch/sh/boards/unknown/mach.c
+++ /dev/null
@@ -1,67 +0,0 @@
1/*
2 * linux/arch/sh/kernel/mach_unknown.c
3 *
4 * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Machine specific code for an unknown machine (internal peripherials only)
10 */
11
12#include <linux/config.h>
13#include <linux/init.h>
14
15#include <asm/machvec.h>
16#include <asm/machvec_init.h>
17
18#include <asm/io_unknown.h>
19
20#include <asm/rtc.h>
21/*
22 * The Machine Vector
23 */
24
25struct sh_machine_vector mv_unknown __initmv = {
26#if defined(CONFIG_CPU_SH4)
27 .mv_nr_irqs = 48,
28#elif defined(CONFIG_CPU_SUBTYPE_SH7708)
29 .mv_nr_irqs = 32,
30#elif defined(CONFIG_CPU_SUBTYPE_SH7709)
31 .mv_nr_irqs = 61,
32#endif
33
34 .mv_inb = unknown_inb,
35 .mv_inw = unknown_inw,
36 .mv_inl = unknown_inl,
37 .mv_outb = unknown_outb,
38 .mv_outw = unknown_outw,
39 .mv_outl = unknown_outl,
40
41 .mv_inb_p = unknown_inb_p,
42 .mv_inw_p = unknown_inw_p,
43 .mv_inl_p = unknown_inl_p,
44 .mv_outb_p = unknown_outb_p,
45 .mv_outw_p = unknown_outw_p,
46 .mv_outl_p = unknown_outl_p,
47
48 .mv_insb = unknown_insb,
49 .mv_insw = unknown_insw,
50 .mv_insl = unknown_insl,
51 .mv_outsb = unknown_outsb,
52 .mv_outsw = unknown_outsw,
53 .mv_outsl = unknown_outsl,
54
55 .mv_readb = unknown_readb,
56 .mv_readw = unknown_readw,
57 .mv_readl = unknown_readl,
58 .mv_writeb = unknown_writeb,
59 .mv_writew = unknown_writew,
60 .mv_writel = unknown_writel,
61
62 .mv_ioremap = unknown_ioremap,
63 .mv_iounmap = unknown_iounmap,
64
65 .mv_isa_port2addr = unknown_isa_port2addr,
66};
67ALIAS_MV(unknown)
diff --git a/arch/sh/boards/unknown/setup.c b/arch/sh/boards/unknown/setup.c
index 7d772a6f8865..02e84f03f45c 100644
--- a/arch/sh/boards/unknown/setup.c
+++ b/arch/sh/boards/unknown/setup.c
@@ -7,10 +7,20 @@
7 * License. See linux/COPYING for more information. 7 * License. See linux/COPYING for more information.
8 * 8 *
9 * Setup code for an unknown machine (internal peripherials only) 9 * Setup code for an unknown machine (internal peripherials only)
10 *
11 * This is the simplest of all boards, and serves only as a quick and dirty
12 * method to start debugging a new board during bring-up until proper board
13 * setup code is written.
10 */ 14 */
11
12#include <linux/config.h> 15#include <linux/config.h>
13#include <linux/init.h> 16#include <linux/init.h>
17#include <asm/machvec.h>
18#include <asm/irq.h>
19
20struct sh_machine_vector mv_unknown __initmv = {
21 .mv_nr_irqs = NR_IRQS,
22};
23ALIAS_MV(unknown)
14 24
15const char *get_system_type(void) 25const char *get_system_type(void)
16{ 26{
diff --git a/arch/sh/cchips/voyagergx/consistent.c b/arch/sh/cchips/voyagergx/consistent.c
index 3d9a02c093a3..07e8b9c5a531 100644
--- a/arch/sh/cchips/voyagergx/consistent.c
+++ b/arch/sh/cchips/voyagergx/consistent.c
@@ -15,7 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/bus-sh.h> 18
19 19
20struct voya_alloc_entry { 20struct voya_alloc_entry {
21 struct list_head list; 21 struct list_head list;
@@ -30,12 +30,13 @@ static LIST_HEAD(voya_alloc_list);
30#define OHCI_HCCA_SIZE 0x100 30#define OHCI_HCCA_SIZE 0x100
31#define OHCI_SRAM_SIZE 0x10000 31#define OHCI_SRAM_SIZE 0x10000
32 32
33#define VOYAGER_OHCI_NAME "voyager-ohci"
34
33void *voyagergx_consistent_alloc(struct device *dev, size_t size, 35void *voyagergx_consistent_alloc(struct device *dev, size_t size,
34 dma_addr_t *handle, gfp_t flag) 36 dma_addr_t *handle, gfp_t flag)
35{ 37{
36 struct list_head *list = &voya_alloc_list; 38 struct list_head *list = &voya_alloc_list;
37 struct voya_alloc_entry *entry; 39 struct voya_alloc_entry *entry;
38 struct sh_dev *shdev = to_sh_dev(dev);
39 unsigned long start, end; 40 unsigned long start, end;
40 unsigned long flags; 41 unsigned long flags;
41 42
@@ -46,9 +47,7 @@ void *voyagergx_consistent_alloc(struct device *dev, size_t size,
46 * 47 *
47 * Everything else goes through consistent_alloc(). 48 * Everything else goes through consistent_alloc().
48 */ 49 */
49 if (!dev || dev->bus != &sh_bus_types[SH_BUS_VIRT] || 50 if (!dev || strcmp(dev->driver->name, VOYAGER_OHCI_NAME))
50 (dev->bus == &sh_bus_types[SH_BUS_VIRT] &&
51 shdev->dev_id != SH_DEV_ID_USB_OHCI))
52 return NULL; 51 return NULL;
53 52
54 start = OHCI_SRAM_START + OHCI_HCCA_SIZE; 53 start = OHCI_SRAM_START + OHCI_HCCA_SIZE;
@@ -98,12 +97,9 @@ int voyagergx_consistent_free(struct device *dev, size_t size,
98 void *vaddr, dma_addr_t handle) 97 void *vaddr, dma_addr_t handle)
99{ 98{
100 struct voya_alloc_entry *entry; 99 struct voya_alloc_entry *entry;
101 struct sh_dev *shdev = to_sh_dev(dev);
102 unsigned long flags; 100 unsigned long flags;
103 101
104 if (!dev || dev->bus != &sh_bus_types[SH_BUS_VIRT] || 102 if (!dev || strcmp(dev->driver->name, VOYAGER_OHCI_NAME))
105 (dev->bus == &sh_bus_types[SH_BUS_VIRT] &&
106 shdev->dev_id != SH_DEV_ID_USB_OHCI))
107 return -EINVAL; 103 return -EINVAL;
108 104
109 spin_lock_irqsave(&voya_list_lock, flags); 105 spin_lock_irqsave(&voya_list_lock, flags);
@@ -123,4 +119,3 @@ int voyagergx_consistent_free(struct device *dev, size_t size,
123 119
124EXPORT_SYMBOL(voyagergx_consistent_alloc); 120EXPORT_SYMBOL(voyagergx_consistent_alloc);
125EXPORT_SYMBOL(voyagergx_consistent_free); 121EXPORT_SYMBOL(voyagergx_consistent_free);
126
diff --git a/arch/sh/cchips/voyagergx/irq.c b/arch/sh/cchips/voyagergx/irq.c
index 1b6ac523b458..2ee330b3c38f 100644
--- a/arch/sh/cchips/voyagergx/irq.c
+++ b/arch/sh/cchips/voyagergx/irq.c
@@ -163,7 +163,12 @@ int voyagergx_irq_demux(int irq)
163 return irq; 163 return irq;
164} 164}
165 165
166static struct irqaction irq0 = { voyagergx_interrupt, SA_INTERRUPT, 0, "VOYAGERGX", NULL, NULL}; 166static struct irqaction irq0 = {
167 .name = "voyagergx",
168 .handler = voyagergx_interrupt,
169 .flags = SA_INTERRUPT,
170 .mask = CPU_MASK_NONE,
171};
167 172
168void __init setup_voyagergx_irq(void) 173void __init setup_voyagergx_irq(void)
169{ 174{
diff --git a/arch/sh/configs/microdev_defconfig b/arch/sh/configs/microdev_defconfig
index a3bd280b53d6..ab3db76d1e51 100644
--- a/arch/sh/configs/microdev_defconfig
+++ b/arch/sh/configs/microdev_defconfig
@@ -1,10 +1,9 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.11-sh 3# Linux kernel version: 2.6.16-rc1
4# Wed Mar 2 15:09:41 2005 4# Fri Jan 27 19:43:20 2006
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_UID16=y
8CONFIG_RWSEM_GENERIC_SPINLOCK=y 7CONFIG_RWSEM_GENERIC_SPINLOCK=y
9CONFIG_GENERIC_HARDIRQS=y 8CONFIG_GENERIC_HARDIRQS=y
10CONFIG_GENERIC_IRQ_PROBE=y 9CONFIG_GENERIC_IRQ_PROBE=y
@@ -17,11 +16,13 @@ CONFIG_EXPERIMENTAL=y
17CONFIG_CLEAN_COMPILE=y 16CONFIG_CLEAN_COMPILE=y
18CONFIG_BROKEN_ON_SMP=y 17CONFIG_BROKEN_ON_SMP=y
19CONFIG_LOCK_KERNEL=y 18CONFIG_LOCK_KERNEL=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
20 20
21# 21#
22# General setup 22# General setup
23# 23#
24CONFIG_LOCALVERSION="" 24CONFIG_LOCALVERSION=""
25CONFIG_LOCALVERSION_AUTO=y
25CONFIG_SWAP=y 26CONFIG_SWAP=y
26# CONFIG_SYSVIPC is not set 27# CONFIG_SYSVIPC is not set
27# CONFIG_POSIX_MQUEUE is not set 28# CONFIG_POSIX_MQUEUE is not set
@@ -29,22 +30,29 @@ CONFIG_BSD_PROCESS_ACCT=y
29# CONFIG_BSD_PROCESS_ACCT_V3 is not set 30# CONFIG_BSD_PROCESS_ACCT_V3 is not set
30CONFIG_SYSCTL=y 31CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set 32# CONFIG_AUDIT is not set
32CONFIG_LOG_BUF_SHIFT=14
33CONFIG_HOTPLUG=y
34CONFIG_KOBJECT_UEVENT=y
35# CONFIG_IKCONFIG is not set 33# CONFIG_IKCONFIG is not set
34CONFIG_INITRAMFS_SOURCE=""
35CONFIG_UID16=y
36# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
36CONFIG_EMBEDDED=y 37CONFIG_EMBEDDED=y
37CONFIG_KALLSYMS=y 38CONFIG_KALLSYMS=y
38# CONFIG_KALLSYMS_EXTRA_PASS is not set 39# CONFIG_KALLSYMS_EXTRA_PASS is not set
40CONFIG_HOTPLUG=y
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_ELF_CORE=y
44CONFIG_BASE_FULL=y
39CONFIG_FUTEX=y 45CONFIG_FUTEX=y
40CONFIG_EPOLL=y 46CONFIG_EPOLL=y
41# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
42CONFIG_SHMEM=y 47CONFIG_SHMEM=y
43CONFIG_CC_ALIGN_FUNCTIONS=0 48CONFIG_CC_ALIGN_FUNCTIONS=0
44CONFIG_CC_ALIGN_LABELS=0 49CONFIG_CC_ALIGN_LABELS=0
45CONFIG_CC_ALIGN_LOOPS=0 50CONFIG_CC_ALIGN_LOOPS=0
46CONFIG_CC_ALIGN_JUMPS=0 51CONFIG_CC_ALIGN_JUMPS=0
52CONFIG_SLAB=y
47# CONFIG_TINY_SHMEM is not set 53# CONFIG_TINY_SHMEM is not set
54CONFIG_BASE_SMALL=0
55# CONFIG_SLOB is not set
48 56
49# 57#
50# Loadable module support 58# Loadable module support
@@ -52,6 +60,24 @@ CONFIG_CC_ALIGN_JUMPS=0
52# CONFIG_MODULES is not set 60# CONFIG_MODULES is not set
53 61
54# 62#
63# Block layer
64#
65# CONFIG_LBD is not set
66
67#
68# IO Schedulers
69#
70CONFIG_IOSCHED_NOOP=y
71CONFIG_IOSCHED_AS=y
72CONFIG_IOSCHED_DEADLINE=y
73CONFIG_IOSCHED_CFQ=y
74CONFIG_DEFAULT_AS=y
75# CONFIG_DEFAULT_DEADLINE is not set
76# CONFIG_DEFAULT_CFQ is not set
77# CONFIG_DEFAULT_NOOP is not set
78CONFIG_DEFAULT_IOSCHED="anticipatory"
79
80#
55# System type 81# System type
56# 82#
57# CONFIG_SH_SOLUTION_ENGINE is not set 83# CONFIG_SH_SOLUTION_ENGINE is not set
@@ -61,9 +87,7 @@ CONFIG_CC_ALIGN_JUMPS=0
61# CONFIG_SH_7751_SYSTEMH is not set 87# CONFIG_SH_7751_SYSTEMH is not set
62# CONFIG_SH_STB1_HARP is not set 88# CONFIG_SH_STB1_HARP is not set
63# CONFIG_SH_STB1_OVERDRIVE is not set 89# CONFIG_SH_STB1_OVERDRIVE is not set
64# CONFIG_SH_HP620 is not set 90# CONFIG_SH_HP6XX is not set
65# CONFIG_SH_HP680 is not set
66# CONFIG_SH_HP690 is not set
67# CONFIG_SH_CQREEK is not set 91# CONFIG_SH_CQREEK is not set
68# CONFIG_SH_DMIDA is not set 92# CONFIG_SH_DMIDA is not set
69# CONFIG_SH_EC3104 is not set 93# CONFIG_SH_EC3104 is not set
@@ -78,45 +102,94 @@ CONFIG_CC_ALIGN_JUMPS=0
78# CONFIG_SH_SECUREEDGE5410 is not set 102# CONFIG_SH_SECUREEDGE5410 is not set
79# CONFIG_SH_HS7751RVOIP is not set 103# CONFIG_SH_HS7751RVOIP is not set
80# CONFIG_SH_RTS7751R2D is not set 104# CONFIG_SH_RTS7751R2D is not set
105# CONFIG_SH_R7780RP is not set
81# CONFIG_SH_EDOSK7705 is not set 106# CONFIG_SH_EDOSK7705 is not set
82CONFIG_SH_SH4202_MICRODEV=y 107CONFIG_SH_SH4202_MICRODEV=y
108# CONFIG_SH_LANDISK is not set
109# CONFIG_SH_TITAN is not set
83# CONFIG_SH_UNKNOWN is not set 110# CONFIG_SH_UNKNOWN is not set
84# CONFIG_CPU_SH2 is not set 111
85# CONFIG_CPU_SH3 is not set 112#
113# Processor selection
114#
86CONFIG_CPU_SH4=y 115CONFIG_CPU_SH4=y
116
117#
118# SH-2 Processor Support
119#
87# CONFIG_CPU_SUBTYPE_SH7604 is not set 120# CONFIG_CPU_SUBTYPE_SH7604 is not set
121
122#
123# SH-3 Processor Support
124#
88# CONFIG_CPU_SUBTYPE_SH7300 is not set 125# CONFIG_CPU_SUBTYPE_SH7300 is not set
89# CONFIG_CPU_SUBTYPE_SH7705 is not set 126# CONFIG_CPU_SUBTYPE_SH7705 is not set
90# CONFIG_CPU_SUBTYPE_SH7707 is not set 127# CONFIG_CPU_SUBTYPE_SH7707 is not set
91# CONFIG_CPU_SUBTYPE_SH7708 is not set 128# CONFIG_CPU_SUBTYPE_SH7708 is not set
92# CONFIG_CPU_SUBTYPE_SH7709 is not set 129# CONFIG_CPU_SUBTYPE_SH7709 is not set
130
131#
132# SH-4 Processor Support
133#
93# CONFIG_CPU_SUBTYPE_SH7750 is not set 134# CONFIG_CPU_SUBTYPE_SH7750 is not set
135# CONFIG_CPU_SUBTYPE_SH7091 is not set
136# CONFIG_CPU_SUBTYPE_SH7750R is not set
137# CONFIG_CPU_SUBTYPE_SH7750S is not set
94# CONFIG_CPU_SUBTYPE_SH7751 is not set 138# CONFIG_CPU_SUBTYPE_SH7751 is not set
139# CONFIG_CPU_SUBTYPE_SH7751R is not set
95# CONFIG_CPU_SUBTYPE_SH7760 is not set 140# CONFIG_CPU_SUBTYPE_SH7760 is not set
96# CONFIG_CPU_SUBTYPE_SH73180 is not set 141CONFIG_CPU_SUBTYPE_SH4_202=y
142
143#
144# ST40 Processor Support
145#
97# CONFIG_CPU_SUBTYPE_ST40STB1 is not set 146# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
98# CONFIG_CPU_SUBTYPE_ST40GX1 is not set 147# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
99CONFIG_CPU_SUBTYPE_SH4_202=y 148
149#
150# SH-4A Processor Support
151#
152# CONFIG_CPU_SUBTYPE_SH73180 is not set
153# CONFIG_CPU_SUBTYPE_SH7770 is not set
154# CONFIG_CPU_SUBTYPE_SH7780 is not set
155
156#
157# Memory management options
158#
100CONFIG_MMU=y 159CONFIG_MMU=y
101CONFIG_CMDLINE_BOOL=y 160CONFIG_SELECT_MEMORY_MODEL=y
102CONFIG_CMDLINE="console=ttySC0,115200" 161CONFIG_FLATMEM_MANUAL=y
162# CONFIG_DISCONTIGMEM_MANUAL is not set
163# CONFIG_SPARSEMEM_MANUAL is not set
164CONFIG_FLATMEM=y
165CONFIG_FLAT_NODE_MEM_MAP=y
166# CONFIG_SPARSEMEM_STATIC is not set
167CONFIG_SPLIT_PTLOCK_CPUS=4
168
169#
170# Cache configuration
171#
172# CONFIG_SH_DIRECT_MAPPED is not set
173# CONFIG_SH_WRITETHROUGH is not set
174# CONFIG_SH_OCRAM is not set
103CONFIG_MEMORY_START=0x08000000 175CONFIG_MEMORY_START=0x08000000
104CONFIG_MEMORY_SIZE=0x04000000 176CONFIG_MEMORY_SIZE=0x04000000
105CONFIG_MEMORY_SET=y 177
106# CONFIG_MEMORY_OVERRIDE is not set 178#
179# Processor features
180#
181CONFIG_CPU_LITTLE_ENDIAN=y
107CONFIG_SH_RTC=y 182CONFIG_SH_RTC=y
108CONFIG_SH_FPU=y 183CONFIG_SH_FPU=y
109CONFIG_ZERO_PAGE_OFFSET=0x00001000
110CONFIG_BOOT_LINK_OFFSET=0x00800000
111CONFIG_CPU_LITTLE_ENDIAN=y
112CONFIG_PREEMPT=y
113# CONFIG_UBC_WAKEUP is not set
114# CONFIG_SH_WRITETHROUGH is not set
115# CONFIG_SH_OCRAM is not set
116# CONFIG_SH_STORE_QUEUES is not set 184# CONFIG_SH_STORE_QUEUES is not set
117# CONFIG_SMP is not set 185CONFIG_CPU_HAS_INTEVT=y
118CONFIG_SH_PCLK_CALC=y 186CONFIG_CPU_HAS_SR_RB=y
119CONFIG_SH_PCLK_FREQ=65986048 187
188#
189# Timer support
190#
191CONFIG_SH_TMU=y
192CONFIG_SH_PCLK_FREQ=66000000
120 193
121# 194#
122# CPU Frequency scaling 195# CPU Frequency scaling
@@ -137,20 +210,31 @@ CONFIG_NR_ONCHIP_DMA_CHANNELS=4
137CONFIG_HEARTBEAT=y 210CONFIG_HEARTBEAT=y
138 211
139# 212#
140# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 213# Kernel features
141# 214#
142CONFIG_ISA=y 215# CONFIG_KEXEC is not set
143# CONFIG_PCI is not set 216CONFIG_PREEMPT=y
217# CONFIG_SMP is not set
144 218
145# 219#
146# PCCARD (PCMCIA/CardBus) support 220# Boot options
147# 221#
148# CONFIG_PCCARD is not set 222CONFIG_ZERO_PAGE_OFFSET=0x00001000
223CONFIG_BOOT_LINK_OFFSET=0x00800000
224# CONFIG_UBC_WAKEUP is not set
225CONFIG_CMDLINE_BOOL=y
226CONFIG_CMDLINE="console=ttySC0,115200"
149 227
150# 228#
151# PC-card bridges 229# Bus options
152# 230#
153CONFIG_PCMCIA_PROBE=y 231# CONFIG_SUPERHYWAY is not set
232# CONFIG_PCI is not set
233
234#
235# PCCARD (PCMCIA/CardBus) support
236#
237# CONFIG_PCCARD is not set
154 238
155# 239#
156# PCI Hotplug Support 240# PCI Hotplug Support
@@ -164,9 +248,79 @@ CONFIG_BINFMT_ELF=y
164# CONFIG_BINFMT_MISC is not set 248# CONFIG_BINFMT_MISC is not set
165 249
166# 250#
167# SH initrd options 251# Networking
252#
253CONFIG_NET=y
254
255#
256# Networking options
257#
258# CONFIG_PACKET is not set
259# CONFIG_UNIX is not set
260# CONFIG_NET_KEY is not set
261CONFIG_INET=y
262# CONFIG_IP_MULTICAST is not set
263# CONFIG_IP_ADVANCED_ROUTER is not set
264CONFIG_IP_FIB_HASH=y
265CONFIG_IP_PNP=y
266CONFIG_IP_PNP_DHCP=y
267# CONFIG_IP_PNP_BOOTP is not set
268# CONFIG_IP_PNP_RARP is not set
269# CONFIG_NET_IPIP is not set
270# CONFIG_NET_IPGRE is not set
271# CONFIG_ARPD is not set
272# CONFIG_SYN_COOKIES is not set
273# CONFIG_INET_AH is not set
274# CONFIG_INET_ESP is not set
275# CONFIG_INET_IPCOMP is not set
276# CONFIG_INET_TUNNEL is not set
277CONFIG_INET_DIAG=y
278CONFIG_INET_TCP_DIAG=y
279# CONFIG_TCP_CONG_ADVANCED is not set
280CONFIG_TCP_CONG_BIC=y
281# CONFIG_IPV6 is not set
282# CONFIG_NETFILTER is not set
283
284#
285# DCCP Configuration (EXPERIMENTAL)
286#
287# CONFIG_IP_DCCP is not set
288
289#
290# SCTP Configuration (EXPERIMENTAL)
168# 291#
169# CONFIG_EMBEDDED_RAMDISK is not set 292# CONFIG_IP_SCTP is not set
293
294#
295# TIPC Configuration (EXPERIMENTAL)
296#
297# CONFIG_TIPC is not set
298# CONFIG_ATM is not set
299# CONFIG_BRIDGE is not set
300# CONFIG_VLAN_8021Q is not set
301# CONFIG_DECNET is not set
302# CONFIG_LLC2 is not set
303# CONFIG_IPX is not set
304# CONFIG_ATALK is not set
305# CONFIG_X25 is not set
306# CONFIG_LAPB is not set
307# CONFIG_NET_DIVERT is not set
308# CONFIG_ECONET is not set
309# CONFIG_WAN_ROUTER is not set
310
311#
312# QoS and/or fair queueing
313#
314# CONFIG_NET_SCHED is not set
315
316#
317# Network testing
318#
319# CONFIG_NET_PKTGEN is not set
320# CONFIG_HAMRADIO is not set
321# CONFIG_IRDA is not set
322# CONFIG_BT is not set
323# CONFIG_IEEE80211 is not set
170 324
171# 325#
172# Device Drivers 326# Device Drivers
@@ -180,6 +334,11 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
180# CONFIG_FW_LOADER is not set 334# CONFIG_FW_LOADER is not set
181 335
182# 336#
337# Connector - unified userspace <-> kernelspace linker
338#
339# CONFIG_CONNECTOR is not set
340
341#
183# Memory Technology Devices (MTD) 342# Memory Technology Devices (MTD)
184# 343#
185# CONFIG_MTD is not set 344# CONFIG_MTD is not set
@@ -192,13 +351,10 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
192# 351#
193# Plug and Play support 352# Plug and Play support
194# 353#
195# CONFIG_PNP is not set
196 354
197# 355#
198# Block devices 356# Block devices
199# 357#
200# CONFIG_BLK_DEV_FD is not set
201# CONFIG_BLK_DEV_XD is not set
202# CONFIG_BLK_DEV_COW_COMMON is not set 358# CONFIG_BLK_DEV_COW_COMMON is not set
203# CONFIG_BLK_DEV_LOOP is not set 359# CONFIG_BLK_DEV_LOOP is not set
204# CONFIG_BLK_DEV_NBD is not set 360# CONFIG_BLK_DEV_NBD is not set
@@ -206,17 +362,7 @@ CONFIG_BLK_DEV_RAM=y
206CONFIG_BLK_DEV_RAM_COUNT=16 362CONFIG_BLK_DEV_RAM_COUNT=16
207CONFIG_BLK_DEV_RAM_SIZE=4096 363CONFIG_BLK_DEV_RAM_SIZE=4096
208CONFIG_BLK_DEV_INITRD=y 364CONFIG_BLK_DEV_INITRD=y
209CONFIG_INITRAMFS_SOURCE=""
210# CONFIG_LBD is not set
211# CONFIG_CDROM_PKTCDVD is not set 365# CONFIG_CDROM_PKTCDVD is not set
212
213#
214# IO Schedulers
215#
216CONFIG_IOSCHED_NOOP=y
217CONFIG_IOSCHED_AS=y
218CONFIG_IOSCHED_DEADLINE=y
219CONFIG_IOSCHED_CFQ=y
220# CONFIG_ATA_OVER_ETH is not set 366# CONFIG_ATA_OVER_ETH is not set
221 367
222# 368#
@@ -241,9 +387,7 @@ CONFIG_BLK_DEV_IDECD=y
241# IDE chipset support/bugfixes 387# IDE chipset support/bugfixes
242# 388#
243CONFIG_IDE_GENERIC=y 389CONFIG_IDE_GENERIC=y
244CONFIG_IDE_SH=y
245# CONFIG_IDE_ARM is not set 390# CONFIG_IDE_ARM is not set
246# CONFIG_IDE_CHIPSETS is not set
247# CONFIG_BLK_DEV_IDEDMA is not set 391# CONFIG_BLK_DEV_IDEDMA is not set
248# CONFIG_IDEDMA_AUTO is not set 392# CONFIG_IDEDMA_AUTO is not set
249# CONFIG_BLK_DEV_HD is not set 393# CONFIG_BLK_DEV_HD is not set
@@ -251,14 +395,10 @@ CONFIG_IDE_SH=y
251# 395#
252# SCSI device support 396# SCSI device support
253# 397#
398# CONFIG_RAID_ATTRS is not set
254# CONFIG_SCSI is not set 399# CONFIG_SCSI is not set
255 400
256# 401#
257# Old CD-ROM drivers (not SCSI, not IDE)
258#
259# CONFIG_CD_NO_IDESCSI is not set
260
261#
262# Multi-device support (RAID and LVM) 402# Multi-device support (RAID and LVM)
263# 403#
264# CONFIG_MD is not set 404# CONFIG_MD is not set
@@ -266,6 +406,7 @@ CONFIG_IDE_SH=y
266# 406#
267# Fusion MPT device support 407# Fusion MPT device support
268# 408#
409# CONFIG_FUSION is not set
269 410
270# 411#
271# IEEE 1394 (FireWire) support 412# IEEE 1394 (FireWire) support
@@ -276,69 +417,8 @@ CONFIG_IDE_SH=y
276# 417#
277 418
278# 419#
279# Networking support 420# Network device support
280#
281CONFIG_NET=y
282
283#
284# Networking options
285#
286# CONFIG_PACKET is not set
287# CONFIG_NETLINK_DEV is not set
288# CONFIG_UNIX is not set
289# CONFIG_NET_KEY is not set
290CONFIG_INET=y
291# CONFIG_IP_MULTICAST is not set
292# CONFIG_IP_ADVANCED_ROUTER is not set
293CONFIG_IP_PNP=y
294CONFIG_IP_PNP_DHCP=y
295# CONFIG_IP_PNP_BOOTP is not set
296# CONFIG_IP_PNP_RARP is not set
297# CONFIG_NET_IPIP is not set
298# CONFIG_NET_IPGRE is not set
299# CONFIG_ARPD is not set
300# CONFIG_SYN_COOKIES is not set
301# CONFIG_INET_AH is not set
302# CONFIG_INET_ESP is not set
303# CONFIG_INET_IPCOMP is not set
304# CONFIG_INET_TUNNEL is not set
305CONFIG_IP_TCPDIAG=y
306# CONFIG_IP_TCPDIAG_IPV6 is not set
307# CONFIG_IPV6 is not set
308# CONFIG_NETFILTER is not set
309
310#
311# SCTP Configuration (EXPERIMENTAL)
312#
313# CONFIG_IP_SCTP is not set
314# CONFIG_ATM is not set
315# CONFIG_BRIDGE is not set
316# CONFIG_VLAN_8021Q is not set
317# CONFIG_DECNET is not set
318# CONFIG_LLC2 is not set
319# CONFIG_IPX is not set
320# CONFIG_ATALK is not set
321# CONFIG_X25 is not set
322# CONFIG_LAPB is not set
323# CONFIG_NET_DIVERT is not set
324# CONFIG_ECONET is not set
325# CONFIG_WAN_ROUTER is not set
326
327#
328# QoS and/or fair queueing
329#
330# CONFIG_NET_SCHED is not set
331# CONFIG_NET_CLS_ROUTE is not set
332
333#
334# Network testing
335# 421#
336# CONFIG_NET_PKTGEN is not set
337# CONFIG_NETPOLL is not set
338# CONFIG_NET_POLL_CONTROLLER is not set
339# CONFIG_HAMRADIO is not set
340# CONFIG_IRDA is not set
341# CONFIG_BT is not set
342CONFIG_NETDEVICES=y 422CONFIG_NETDEVICES=y
343# CONFIG_DUMMY is not set 423# CONFIG_DUMMY is not set
344# CONFIG_BONDING is not set 424# CONFIG_BONDING is not set
@@ -346,9 +426,9 @@ CONFIG_NETDEVICES=y
346# CONFIG_TUN is not set 426# CONFIG_TUN is not set
347 427
348# 428#
349# ARCnet devices 429# PHY device support
350# 430#
351# CONFIG_ARCNET is not set 431# CONFIG_PHYLIB is not set
352 432
353# 433#
354# Ethernet (10 or 100Mbit) 434# Ethernet (10 or 100Mbit)
@@ -356,17 +436,7 @@ CONFIG_NETDEVICES=y
356CONFIG_NET_ETHERNET=y 436CONFIG_NET_ETHERNET=y
357CONFIG_MII=y 437CONFIG_MII=y
358# CONFIG_STNIC is not set 438# CONFIG_STNIC is not set
359# CONFIG_NET_VENDOR_3COM is not set
360# CONFIG_LANCE is not set
361# CONFIG_NET_VENDOR_SMC is not set
362CONFIG_SMC91X=y 439CONFIG_SMC91X=y
363# CONFIG_NET_VENDOR_RACAL is not set
364# CONFIG_AT1700 is not set
365# CONFIG_DEPCA is not set
366# CONFIG_HP100 is not set
367# CONFIG_NET_ISA is not set
368# CONFIG_NET_PCI is not set
369# CONFIG_NET_POCKET is not set
370 440
371# 441#
372# Ethernet (1000 Mbit) 442# Ethernet (1000 Mbit)
@@ -379,7 +449,6 @@ CONFIG_SMC91X=y
379# 449#
380# Token Ring devices 450# Token Ring devices
381# 451#
382# CONFIG_TR is not set
383 452
384# 453#
385# Wireless LAN (non-hamradio) 454# Wireless LAN (non-hamradio)
@@ -394,6 +463,8 @@ CONFIG_SMC91X=y
394# CONFIG_SLIP is not set 463# CONFIG_SLIP is not set
395# CONFIG_SHAPER is not set 464# CONFIG_SHAPER is not set
396# CONFIG_NETCONSOLE is not set 465# CONFIG_NETCONSOLE is not set
466# CONFIG_NETPOLL is not set
467# CONFIG_NET_POLL_CONTROLLER is not set
397 468
398# 469#
399# ISDN subsystem 470# ISDN subsystem
@@ -411,20 +482,10 @@ CONFIG_SMC91X=y
411# CONFIG_INPUT is not set 482# CONFIG_INPUT is not set
412 483
413# 484#
414# Userland interfaces 485# Hardware I/O ports
415#
416
417#
418# Input I/O drivers
419# 486#
420# CONFIG_GAMEPORT is not set
421CONFIG_SOUND_GAMEPORT=y
422# CONFIG_SERIO is not set 487# CONFIG_SERIO is not set
423# CONFIG_SERIO_I8042 is not set 488# CONFIG_GAMEPORT is not set
424
425#
426# Input Device Drivers
427#
428 489
429# 490#
430# Character devices 491# Character devices
@@ -464,24 +525,46 @@ CONFIG_RTC=y
464# 525#
465# Ftape, the floppy tape device driver 526# Ftape, the floppy tape device driver
466# 527#
467# CONFIG_DRM is not set
468# CONFIG_RAW_DRIVER is not set 528# CONFIG_RAW_DRIVER is not set
469 529
470# 530#
531# TPM devices
532#
533# CONFIG_TCG_TPM is not set
534# CONFIG_TELCLOCK is not set
535
536#
471# I2C support 537# I2C support
472# 538#
473# CONFIG_I2C is not set 539# CONFIG_I2C is not set
474 540
475# 541#
542# SPI support
543#
544# CONFIG_SPI is not set
545# CONFIG_SPI_MASTER is not set
546
547#
476# Dallas's 1-wire bus 548# Dallas's 1-wire bus
477# 549#
478# CONFIG_W1 is not set 550# CONFIG_W1 is not set
479 551
480# 552#
553# Hardware Monitoring support
554#
555CONFIG_HWMON=y
556# CONFIG_HWMON_VID is not set
557# CONFIG_HWMON_DEBUG_CHIP is not set
558
559#
481# Misc devices 560# Misc devices
482# 561#
483 562
484# 563#
564# Multimedia Capabilities Port drivers
565#
566
567#
485# Multimedia devices 568# Multimedia devices
486# 569#
487# CONFIG_VIDEO_DEV is not set 570# CONFIG_VIDEO_DEV is not set
@@ -508,7 +591,7 @@ CONFIG_RTC=y
508# CONFIG_USB_ARCH_HAS_OHCI is not set 591# CONFIG_USB_ARCH_HAS_OHCI is not set
509 592
510# 593#
511# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information 594# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
512# 595#
513 596
514# 597#
@@ -524,13 +607,21 @@ CONFIG_RTC=y
524# 607#
525# InfiniBand support 608# InfiniBand support
526# 609#
527# CONFIG_INFINIBAND is not set 610
611#
612# SN Devices
613#
614
615#
616# EDAC - error detection and reporting (RAS)
617#
528 618
529# 619#
530# File systems 620# File systems
531# 621#
532CONFIG_EXT2_FS=y 622CONFIG_EXT2_FS=y
533# CONFIG_EXT2_FS_XATTR is not set 623# CONFIG_EXT2_FS_XATTR is not set
624# CONFIG_EXT2_FS_XIP is not set
534CONFIG_EXT3_FS=y 625CONFIG_EXT3_FS=y
535CONFIG_EXT3_FS_XATTR=y 626CONFIG_EXT3_FS_XATTR=y
536# CONFIG_EXT3_FS_POSIX_ACL is not set 627# CONFIG_EXT3_FS_POSIX_ACL is not set
@@ -540,17 +631,17 @@ CONFIG_JBD=y
540CONFIG_FS_MBCACHE=y 631CONFIG_FS_MBCACHE=y
541# CONFIG_REISERFS_FS is not set 632# CONFIG_REISERFS_FS is not set
542# CONFIG_JFS_FS is not set 633# CONFIG_JFS_FS is not set
543 634# CONFIG_FS_POSIX_ACL is not set
544#
545# XFS support
546#
547# CONFIG_XFS_FS is not set 635# CONFIG_XFS_FS is not set
636# CONFIG_OCFS2_FS is not set
548# CONFIG_MINIX_FS is not set 637# CONFIG_MINIX_FS is not set
549# CONFIG_ROMFS_FS is not set 638# CONFIG_ROMFS_FS is not set
639CONFIG_INOTIFY=y
550# CONFIG_QUOTA is not set 640# CONFIG_QUOTA is not set
551CONFIG_DNOTIFY=y 641CONFIG_DNOTIFY=y
552# CONFIG_AUTOFS_FS is not set 642# CONFIG_AUTOFS_FS is not set
553# CONFIG_AUTOFS4_FS is not set 643# CONFIG_AUTOFS4_FS is not set
644# CONFIG_FUSE_FS is not set
554 645
555# 646#
556# CD-ROM/DVD Filesystems 647# CD-ROM/DVD Filesystems
@@ -574,16 +665,12 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
574CONFIG_PROC_FS=y 665CONFIG_PROC_FS=y
575CONFIG_PROC_KCORE=y 666CONFIG_PROC_KCORE=y
576CONFIG_SYSFS=y 667CONFIG_SYSFS=y
577CONFIG_DEVFS_FS=y
578CONFIG_DEVFS_MOUNT=y
579# CONFIG_DEVFS_DEBUG is not set
580CONFIG_DEVPTS_FS_XATTR=y
581# CONFIG_DEVPTS_FS_SECURITY is not set
582CONFIG_TMPFS=y 668CONFIG_TMPFS=y
583# CONFIG_TMPFS_XATTR is not set
584# CONFIG_HUGETLBFS is not set 669# CONFIG_HUGETLBFS is not set
585# CONFIG_HUGETLB_PAGE is not set 670# CONFIG_HUGETLB_PAGE is not set
586CONFIG_RAMFS=y 671CONFIG_RAMFS=y
672# CONFIG_RELAYFS_FS is not set
673# CONFIG_CONFIGFS_FS is not set
587 674
588# 675#
589# Miscellaneous filesystems 676# Miscellaneous filesystems
@@ -607,12 +694,14 @@ CONFIG_RAMFS=y
607# 694#
608CONFIG_NFS_FS=y 695CONFIG_NFS_FS=y
609CONFIG_NFS_V3=y 696CONFIG_NFS_V3=y
697# CONFIG_NFS_V3_ACL is not set
610CONFIG_NFS_V4=y 698CONFIG_NFS_V4=y
611# CONFIG_NFS_DIRECTIO is not set 699# CONFIG_NFS_DIRECTIO is not set
612# CONFIG_NFSD is not set 700# CONFIG_NFSD is not set
613CONFIG_ROOT_NFS=y 701CONFIG_ROOT_NFS=y
614CONFIG_LOCKD=y 702CONFIG_LOCKD=y
615CONFIG_LOCKD_V4=y 703CONFIG_LOCKD_V4=y
704CONFIG_NFS_COMMON=y
616CONFIG_SUNRPC=y 705CONFIG_SUNRPC=y
617CONFIG_SUNRPC_GSS=y 706CONFIG_SUNRPC_GSS=y
618CONFIG_RPCSEC_GSS_KRB5=y 707CONFIG_RPCSEC_GSS_KRB5=y
@@ -622,6 +711,7 @@ CONFIG_RPCSEC_GSS_KRB5=y
622# CONFIG_NCP_FS is not set 711# CONFIG_NCP_FS is not set
623# CONFIG_CODA_FS is not set 712# CONFIG_CODA_FS is not set
624# CONFIG_AFS_FS is not set 713# CONFIG_AFS_FS is not set
714# CONFIG_9P_FS is not set
625 715
626# 716#
627# Partition Types 717# Partition Types
@@ -681,8 +771,10 @@ CONFIG_NLS_DEFAULT="iso8859-1"
681# 771#
682# Kernel hacking 772# Kernel hacking
683# 773#
774# CONFIG_PRINTK_TIME is not set
775# CONFIG_MAGIC_SYSRQ is not set
684# CONFIG_DEBUG_KERNEL is not set 776# CONFIG_DEBUG_KERNEL is not set
685CONFIG_DEBUG_PREEMPT=y 777CONFIG_LOG_BUF_SHIFT=14
686# CONFIG_FRAME_POINTER is not set 778# CONFIG_FRAME_POINTER is not set
687# CONFIG_SH_STANDARD_BIOS is not set 779# CONFIG_SH_STANDARD_BIOS is not set
688# CONFIG_EARLY_SCIF_CONSOLE is not set 780# CONFIG_EARLY_SCIF_CONSOLE is not set
@@ -706,6 +798,7 @@ CONFIG_CRYPTO_MD5=y
706# CONFIG_CRYPTO_SHA256 is not set 798# CONFIG_CRYPTO_SHA256 is not set
707# CONFIG_CRYPTO_SHA512 is not set 799# CONFIG_CRYPTO_SHA512 is not set
708# CONFIG_CRYPTO_WP512 is not set 800# CONFIG_CRYPTO_WP512 is not set
801# CONFIG_CRYPTO_TGR192 is not set
709CONFIG_CRYPTO_DES=y 802CONFIG_CRYPTO_DES=y
710# CONFIG_CRYPTO_BLOWFISH is not set 803# CONFIG_CRYPTO_BLOWFISH is not set
711# CONFIG_CRYPTO_TWOFISH is not set 804# CONFIG_CRYPTO_TWOFISH is not set
@@ -730,5 +823,6 @@ CONFIG_CRYPTO_DES=y
730# Library routines 823# Library routines
731# 824#
732# CONFIG_CRC_CCITT is not set 825# CONFIG_CRC_CCITT is not set
826# CONFIG_CRC16 is not set
733CONFIG_CRC32=y 827CONFIG_CRC32=y
734# CONFIG_LIBCRC32C is not set 828# CONFIG_LIBCRC32C is not set
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index 7a86eeb22655..f05cd96f8867 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -8,7 +8,7 @@ obj-y := process.o signal.o entry.o traps.o irq.o \
8 ptrace.o setup.o time.o sys_sh.o semaphore.o \ 8 ptrace.o setup.o time.o sys_sh.o semaphore.o \
9 io.o io_generic.o sh_ksyms.o 9 io.o io_generic.o sh_ksyms.o
10 10
11obj-y += cpu/ 11obj-y += cpu/ timers/
12 12
13obj-$(CONFIG_SMP) += smp.o 13obj-$(CONFIG_SMP) += smp.o
14obj-$(CONFIG_CF_ENABLER) += cf-enabler.o 14obj-$(CONFIG_CF_ENABLER) += cf-enabler.o
diff --git a/arch/sh/kernel/cpu/Makefile b/arch/sh/kernel/cpu/Makefile
index 5bfc33bec5d0..59d5b748752f 100644
--- a/arch/sh/kernel/cpu/Makefile
+++ b/arch/sh/kernel/cpu/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Linux/SuperH CPU-specifc backends. 2# Makefile for the Linux/SuperH CPU-specifc backends.
3# 3#
4 4
5obj-y += irq/ init.o bus.o clock.o 5obj-y += irq/ init.o clock.o
6 6
7obj-$(CONFIG_CPU_SH2) += sh2/ 7obj-$(CONFIG_CPU_SH2) += sh2/
8obj-$(CONFIG_CPU_SH3) += sh3/ 8obj-$(CONFIG_CPU_SH3) += sh3/
diff --git a/arch/sh/kernel/cpu/bus.c b/arch/sh/kernel/cpu/bus.c
deleted file mode 100644
index fc6c4bd40c65..000000000000
--- a/arch/sh/kernel/cpu/bus.c
+++ /dev/null
@@ -1,197 +0,0 @@
1/*
2 * arch/sh/kernel/cpu/bus.c
3 *
4 * Virtual bus for SuperH.
5 *
6 * Copyright (C) 2004 Paul Mundt
7 *
8 * Shamelessly cloned from arch/arm/mach-omap/bus.c, which was written
9 * by:
10 *
11 * Copyright (C) 2003 - 2004 Nokia Corporation
12 * Written by Tony Lindgren <tony@atomide.com>
13 * Portions of code based on sa1111.c.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 */
20#include <linux/kernel.h>
21#include <linux/device.h>
22#include <linux/init.h>
23#include <linux/module.h>
24#include <asm/bus-sh.h>
25
26static int sh_bus_match(struct device *dev, struct device_driver *drv)
27{
28 struct sh_driver *shdrv = to_sh_driver(drv);
29 struct sh_dev *shdev = to_sh_dev(dev);
30
31 return shdev->dev_id == shdrv->dev_id;
32}
33
34static int sh_bus_suspend(struct device *dev, pm_message_t state)
35{
36 struct sh_dev *shdev = to_sh_dev(dev);
37 struct sh_driver *shdrv = to_sh_driver(dev->driver);
38
39 if (shdrv && shdrv->suspend)
40 return shdrv->suspend(shdev, state);
41
42 return 0;
43}
44
45static int sh_bus_resume(struct device *dev)
46{
47 struct sh_dev *shdev = to_sh_dev(dev);
48 struct sh_driver *shdrv = to_sh_driver(dev->driver);
49
50 if (shdrv && shdrv->resume)
51 return shdrv->resume(shdev);
52
53 return 0;
54}
55
56static int sh_device_probe(struct device *dev)
57{
58 struct sh_dev *shdev = to_sh_dev(dev);
59 struct sh_driver *shdrv = to_sh_driver(dev->driver);
60
61 if (shdrv && shdrv->probe)
62 return shdrv->probe(shdev);
63
64 return -ENODEV;
65}
66
67static int sh_device_remove(struct device *dev)
68{
69 struct sh_dev *shdev = to_sh_dev(dev);
70 struct sh_driver *shdrv = to_sh_driver(dev->driver);
71
72 if (shdrv && shdrv->remove)
73 return shdrv->remove(shdev);
74
75 return 0;
76}
77
78static struct device sh_bus_devices[SH_NR_BUSES] = {
79 {
80 .bus_id = SH_BUS_NAME_VIRT,
81 },
82};
83
84struct bus_type sh_bus_types[SH_NR_BUSES] = {
85 {
86 .name = SH_BUS_NAME_VIRT,
87 .match = sh_bus_match,
88 .probe = sh_bus_probe,
89 .remove = sh_bus_remove,
90 .suspend = sh_bus_suspend,
91 .resume = sh_bus_resume,
92 },
93};
94
95int sh_device_register(struct sh_dev *dev)
96{
97 if (!dev)
98 return -EINVAL;
99
100 if (dev->bus_id < 0 || dev->bus_id >= SH_NR_BUSES) {
101 printk(KERN_ERR "%s: bus_id invalid: %s bus: %d\n",
102 __FUNCTION__, dev->name, dev->bus_id);
103 return -EINVAL;
104 }
105
106 dev->dev.parent = &sh_bus_devices[dev->bus_id];
107 dev->dev.bus = &sh_bus_types[dev->bus_id];
108
109 /* This is needed for USB OHCI to work */
110 if (dev->dma_mask)
111 dev->dev.dma_mask = dev->dma_mask;
112 if (dev->coherent_dma_mask)
113 dev->dev.coherent_dma_mask = dev->coherent_dma_mask;
114
115 snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%s%u",
116 dev->name, dev->dev_id);
117
118 printk(KERN_INFO "Registering SH device '%s'. Parent at %s\n",
119 dev->dev.bus_id, dev->dev.parent->bus_id);
120
121 return device_register(&dev->dev);
122}
123
124void sh_device_unregister(struct sh_dev *dev)
125{
126 device_unregister(&dev->dev);
127}
128
129int sh_driver_register(struct sh_driver *drv)
130{
131 if (!drv)
132 return -EINVAL;
133
134 if (drv->bus_id < 0 || drv->bus_id >= SH_NR_BUSES) {
135 printk(KERN_ERR "%s: bus_id invalid: bus: %d device %d\n",
136 __FUNCTION__, drv->bus_id, drv->dev_id);
137 return -EINVAL;
138 }
139
140 drv->drv.bus = &sh_bus_types[drv->bus_id];
141
142 return driver_register(&drv->drv);
143}
144
145void sh_driver_unregister(struct sh_driver *drv)
146{
147 driver_unregister(&drv->drv);
148}
149
150static int __init sh_bus_init(void)
151{
152 int i, ret = 0;
153
154 for (i = 0; i < SH_NR_BUSES; i++) {
155 ret = device_register(&sh_bus_devices[i]);
156 if (ret != 0) {
157 printk(KERN_ERR "Unable to register bus device %s\n",
158 sh_bus_devices[i].bus_id);
159 continue;
160 }
161
162 ret = bus_register(&sh_bus_types[i]);
163 if (ret != 0) {
164 printk(KERN_ERR "Unable to register bus %s\n",
165 sh_bus_types[i].name);
166 device_unregister(&sh_bus_devices[i]);
167 }
168 }
169
170 printk(KERN_INFO "SH Virtual Bus initialized\n");
171
172 return ret;
173}
174
175static void __exit sh_bus_exit(void)
176{
177 int i;
178
179 for (i = 0; i < SH_NR_BUSES; i++) {
180 bus_unregister(&sh_bus_types[i]);
181 device_unregister(&sh_bus_devices[i]);
182 }
183}
184
185module_init(sh_bus_init);
186module_exit(sh_bus_exit);
187
188MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
189MODULE_DESCRIPTION("SH Virtual Bus");
190MODULE_LICENSE("GPL");
191
192EXPORT_SYMBOL(sh_bus_types);
193EXPORT_SYMBOL(sh_device_register);
194EXPORT_SYMBOL(sh_device_unregister);
195EXPORT_SYMBOL(sh_driver_register);
196EXPORT_SYMBOL(sh_driver_unregister);
197
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 989e7fdd524d..97fa37f42b84 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -38,9 +38,7 @@ static DECLARE_MUTEX(clock_list_sem);
38static struct clk master_clk = { 38static struct clk master_clk = {
39 .name = "master_clk", 39 .name = "master_clk",
40 .flags = CLK_ALWAYS_ENABLED | CLK_RATE_PROPAGATES, 40 .flags = CLK_ALWAYS_ENABLED | CLK_RATE_PROPAGATES,
41#ifdef CONFIG_SH_PCLK_FREQ_BOOL
42 .rate = CONFIG_SH_PCLK_FREQ, 41 .rate = CONFIG_SH_PCLK_FREQ,
43#endif
44}; 42};
45 43
46static struct clk module_clk = { 44static struct clk module_clk = {
@@ -227,16 +225,7 @@ int __init clk_init(void)
227{ 225{
228 int i, ret = 0; 226 int i, ret = 0;
229 227
230 if (unlikely(!master_clk.rate)) 228 BUG_ON(unlikely(!master_clk.rate));
231 /*
232 * NOTE: This will break if the default divisor has been
233 * changed.
234 *
235 * No one should be changing the default on us however,
236 * expect that a sane value for CONFIG_SH_PCLK_FREQ will
237 * be defined in the event of a different divisor.
238 */
239 master_clk.rate = get_timer_frequency() * 4;
240 229
241 for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) { 230 for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) {
242 struct clk *clk = onchip_clocks[i]; 231 struct clk *clk = onchip_clocks[i];
diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c
index fdbd718ae5c6..e55150ed0856 100644
--- a/arch/sh/kernel/cpu/irq/ipr.c
+++ b/arch/sh/kernel/cpu/irq/ipr.c
@@ -108,8 +108,7 @@ static void end_ipr_irq(unsigned int irq)
108 enable_ipr_irq(irq); 108 enable_ipr_irq(irq);
109} 109}
110 110
111void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, 111void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, int priority)
112 int priority, int maskpos)
113{ 112{
114 disable_irq_nosync(irq); 113 disable_irq_nosync(irq);
115 ipr_data[irq].addr = addr; 114 ipr_data[irq].addr = addr;
@@ -123,44 +122,44 @@ void make_ipr_irq(unsigned int irq, unsigned int addr, int pos,
123void __init init_IRQ(void) 122void __init init_IRQ(void)
124{ 123{
125#ifndef CONFIG_CPU_SUBTYPE_SH7780 124#ifndef CONFIG_CPU_SUBTYPE_SH7780
126 make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY, 0); 125 make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY);
127 make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY, 0); 126 make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY);
128#if defined(CONFIG_SH_RTC) 127#if defined(CONFIG_SH_RTC)
129 make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY, 0); 128 make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY);
130#endif 129#endif
131 130
132#ifdef SCI_ERI_IRQ 131#ifdef SCI_ERI_IRQ
133 make_ipr_irq(SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY, 0); 132 make_ipr_irq(SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY);
134 make_ipr_irq(SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY, 0); 133 make_ipr_irq(SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY);
135 make_ipr_irq(SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY, 0); 134 make_ipr_irq(SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY);
136#endif 135#endif
137 136
138#ifdef SCIF1_ERI_IRQ 137#ifdef SCIF1_ERI_IRQ
139 make_ipr_irq(SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY, 0); 138 make_ipr_irq(SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY);
140 make_ipr_irq(SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY, 0); 139 make_ipr_irq(SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY);
141 make_ipr_irq(SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY, 0); 140 make_ipr_irq(SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY);
142 make_ipr_irq(SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY, 0); 141 make_ipr_irq(SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY);
143#endif 142#endif
144 143
145#if defined(CONFIG_CPU_SUBTYPE_SH7300) 144#if defined(CONFIG_CPU_SUBTYPE_SH7300)
146 make_ipr_irq(SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY, 0); 145 make_ipr_irq(SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY);
147 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY, 0); 146 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
148 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY, 0); 147 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
149 make_ipr_irq(VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY, 0); 148 make_ipr_irq(VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
150#endif 149#endif
151 150
152#ifdef SCIF_ERI_IRQ 151#ifdef SCIF_ERI_IRQ
153 make_ipr_irq(SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY, 0); 152 make_ipr_irq(SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY);
154 make_ipr_irq(SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY, 0); 153 make_ipr_irq(SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY);
155 make_ipr_irq(SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY, 0); 154 make_ipr_irq(SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY);
156 make_ipr_irq(SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY, 0); 155 make_ipr_irq(SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY);
157#endif 156#endif
158 157
159#ifdef IRDA_ERI_IRQ 158#ifdef IRDA_ERI_IRQ
160 make_ipr_irq(IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY, 0); 159 make_ipr_irq(IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY);
161 make_ipr_irq(IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY, 0); 160 make_ipr_irq(IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY);
162 make_ipr_irq(IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY, 0); 161 make_ipr_irq(IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY);
163 make_ipr_irq(IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY, 0); 162 make_ipr_irq(IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY);
164#endif 163#endif
165 164
166#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 165#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
@@ -175,12 +174,12 @@ void __init init_IRQ(void)
175 * You should set corresponding bits of PFC to "00" 174 * You should set corresponding bits of PFC to "00"
176 * to enable these interrupts. 175 * to enable these interrupts.
177 */ 176 */
178 make_ipr_irq(IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY, 0); 177 make_ipr_irq(IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY);
179 make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY, 0); 178 make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY);
180 make_ipr_irq(IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY, 0); 179 make_ipr_irq(IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY);
181 make_ipr_irq(IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY, 0); 180 make_ipr_irq(IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY);
182 make_ipr_irq(IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY, 0); 181 make_ipr_irq(IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY);
183 make_ipr_irq(IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY, 0); 182 make_ipr_irq(IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY);
184#endif 183#endif
185#endif 184#endif
186 185
diff --git a/arch/sh/kernel/entry.S b/arch/sh/kernel/entry.S
index fb6368159dd0..a440d36ee618 100644
--- a/arch/sh/kernel/entry.S
+++ b/arch/sh/kernel/entry.S
@@ -16,6 +16,7 @@
16#include <linux/config.h> 16#include <linux/config.h>
17#include <asm/asm-offsets.h> 17#include <asm/asm-offsets.h>
18#include <asm/thread_info.h> 18#include <asm/thread_info.h>
19#include <asm/cpu/mmu_context.h>
19#include <asm/unistd.h> 20#include <asm/unistd.h>
20 21
21#if !defined(CONFIG_NFSD) && !defined(CONFIG_NFSD_MODULE) 22#if !defined(CONFIG_NFSD) && !defined(CONFIG_NFSD_MODULE)
@@ -75,23 +76,6 @@
75ENOSYS = 38 76ENOSYS = 38
76EINVAL = 22 77EINVAL = 22
77 78
78#if defined(CONFIG_CPU_SH3)
79TRA = 0xffffffd0
80EXPEVT = 0xffffffd4
81#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
82 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
83INTEVT = 0xa4000000 ! INTEVTE2(0xa4000000)
84#else
85INTEVT = 0xffffffd8
86#endif
87MMU_TEA = 0xfffffffc ! TLB Exception Address Register
88#elif defined(CONFIG_CPU_SH4)
89TRA = 0xff000020
90EXPEVT = 0xff000024
91INTEVT = 0xff000028
92MMU_TEA = 0xff00000c ! TLB Exception Address Register
93#endif
94
95#if defined(CONFIG_KGDB_NMI) 79#if defined(CONFIG_KGDB_NMI)
96NMI_VEC = 0x1c0 ! Must catch early for debounce 80NMI_VEC = 0x1c0 ! Must catch early for debounce
97#endif 81#endif
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index a4dc2b532e10..9fd1723e6219 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -15,21 +15,18 @@
15#include <linux/unistd.h> 15#include <linux/unistd.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/elfcore.h> 17#include <linux/elfcore.h>
18#include <linux/slab.h>
19#include <linux/a.out.h> 18#include <linux/a.out.h>
19#include <linux/slab.h>
20#include <linux/pm.h>
20#include <linux/ptrace.h> 21#include <linux/ptrace.h>
21#include <linux/platform.h> 22#include <linux/platform.h>
22#include <linux/kallsyms.h> 23#include <linux/kallsyms.h>
24#include <linux/kexec.h>
23 25
24#include <asm/io.h> 26#include <asm/io.h>
25#include <asm/uaccess.h> 27#include <asm/uaccess.h>
26#include <asm/mmu_context.h> 28#include <asm/mmu_context.h>
27#include <asm/elf.h> 29#include <asm/elf.h>
28#if defined(CONFIG_SH_HS7751RVOIP)
29#include <asm/hs7751rvoip/hs7751rvoip.h>
30#elif defined(CONFIG_SH_RTS7751R2D)
31#include <asm/rts7751r2d/rts7751r2d.h>
32#endif
33 30
34static int hlt_counter=0; 31static int hlt_counter=0;
35 32
@@ -37,6 +34,11 @@ int ubc_usercnt = 0;
37 34
38#define HARD_IDLE_TIMEOUT (HZ / 3) 35#define HARD_IDLE_TIMEOUT (HZ / 3)
39 36
37void (*pm_idle)(void);
38
39void (*pm_power_off)(void);
40EXPORT_SYMBOL(pm_power_off);
41
40void disable_hlt(void) 42void disable_hlt(void)
41{ 43{
42 hlt_counter++; 44 hlt_counter++;
@@ -51,17 +53,25 @@ void enable_hlt(void)
51 53
52EXPORT_SYMBOL(enable_hlt); 54EXPORT_SYMBOL(enable_hlt);
53 55
56void default_idle(void)
57{
58 if (!hlt_counter)
59 cpu_sleep();
60 else
61 cpu_relax();
62}
63
54void cpu_idle(void) 64void cpu_idle(void)
55{ 65{
56 /* endless idle loop with no priority at all */ 66 /* endless idle loop with no priority at all */
57 while (1) { 67 while (1) {
58 if (hlt_counter) { 68 void (*idle)(void) = pm_idle;
59 while (!need_resched()) 69
60 cpu_relax(); 70 if (!idle)
61 } else { 71 idle = default_idle;
62 while (!need_resched()) 72
63 cpu_sleep(); 73 while (!need_resched())
64 } 74 idle();
65 75
66 preempt_enable_no_resched(); 76 preempt_enable_no_resched();
67 schedule(); 77 schedule();
@@ -88,28 +98,16 @@ void machine_restart(char * __unused)
88 98
89void machine_halt(void) 99void machine_halt(void)
90{ 100{
91#if defined(CONFIG_SH_HS7751RVOIP) 101 local_irq_disable();
92 unsigned short value;
93 102
94 value = ctrl_inw(PA_OUTPORTR);
95 ctrl_outw((value & 0xffdf), PA_OUTPORTR);
96#elif defined(CONFIG_SH_RTS7751R2D)
97 ctrl_outw(0x0001, PA_POWOFF);
98#endif
99 while (1) 103 while (1)
100 cpu_sleep(); 104 cpu_sleep();
101} 105}
102 106
103void machine_power_off(void) 107void machine_power_off(void)
104{ 108{
105#if defined(CONFIG_SH_HS7751RVOIP) 109 if (pm_power_off)
106 unsigned short value; 110 pm_power_off();
107
108 value = ctrl_inw(PA_OUTPORTR);
109 ctrl_outw((value & 0xffdf), PA_OUTPORTR);
110#elif defined(CONFIG_SH_RTS7751R2D)
111 ctrl_outw(0x0001, PA_POWOFF);
112#endif
113} 111}
114 112
115void show_regs(struct pt_regs * regs) 113void show_regs(struct pt_regs * regs)
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 036050b377cd..a067a34e0b64 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -22,10 +22,10 @@
22#include <linux/cpu.h> 22#include <linux/cpu.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/io_generic.h>
26#include <asm/sections.h> 25#include <asm/sections.h>
27#include <asm/irq.h> 26#include <asm/irq.h>
28#include <asm/setup.h> 27#include <asm/setup.h>
28#include <asm/clock.h>
29 29
30#ifdef CONFIG_SH_KGDB 30#ifdef CONFIG_SH_KGDB
31#include <asm/kgdb.h> 31#include <asm/kgdb.h>
@@ -41,7 +41,7 @@ extern void * __rd_start, * __rd_end;
41 * This value will be used at the very early stage of serial setup. 41 * This value will be used at the very early stage of serial setup.
42 * The bigger value means no problem. 42 * The bigger value means no problem.
43 */ 43 */
44struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 0, 10000000, }; 44struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 10000000, };
45struct screen_info screen_info; 45struct screen_info screen_info;
46 46
47#if defined(CONFIG_SH_UNKNOWN) 47#if defined(CONFIG_SH_UNKNOWN)
@@ -186,7 +186,7 @@ static inline void parse_cmdline (char ** cmdline_p, char mv_name[MV_NAME_SIZE],
186 186
187static int __init sh_mv_setup(char **cmdline_p) 187static int __init sh_mv_setup(char **cmdline_p)
188{ 188{
189#if defined(CONFIG_SH_UNKNOWN) 189#ifdef CONFIG_SH_UNKNOWN
190 extern struct sh_machine_vector mv_unknown; 190 extern struct sh_machine_vector mv_unknown;
191#endif 191#endif
192 struct sh_machine_vector *mv = NULL; 192 struct sh_machine_vector *mv = NULL;
@@ -196,7 +196,7 @@ static int __init sh_mv_setup(char **cmdline_p)
196 196
197 parse_cmdline(cmdline_p, mv_name, &mv, &mv_io_base, &mv_mmio_enable); 197 parse_cmdline(cmdline_p, mv_name, &mv, &mv_io_base, &mv_mmio_enable);
198 198
199#ifdef CONFIG_SH_GENERIC 199#ifdef CONFIG_SH_UNKNOWN
200 if (mv == NULL) { 200 if (mv == NULL) {
201 mv = &mv_unknown; 201 mv = &mv_unknown;
202 if (*mv_name != '\0') { 202 if (*mv_name != '\0') {
@@ -206,9 +206,6 @@ static int __init sh_mv_setup(char **cmdline_p)
206 } 206 }
207 sh_mv = *mv; 207 sh_mv = *mv;
208#endif 208#endif
209#ifdef CONFIG_SH_UNKNOWN
210 sh_mv = mv_unknown;
211#endif
212 209
213 /* 210 /*
214 * Manually walk the vec, fill in anything that the board hasn't yet 211 * Manually walk the vec, fill in anything that the board hasn't yet
@@ -231,10 +228,8 @@ static int __init sh_mv_setup(char **cmdline_p)
231 mv_set(readb); mv_set(readw); mv_set(readl); 228 mv_set(readb); mv_set(readw); mv_set(readl);
232 mv_set(writeb); mv_set(writew); mv_set(writel); 229 mv_set(writeb); mv_set(writew); mv_set(writel);
233 230
234 mv_set(ioremap); 231 mv_set(ioport_map);
235 mv_set(iounmap); 232 mv_set(ioport_unmap);
236
237 mv_set(isa_port2addr);
238 mv_set(irq_demux); 233 mv_set(irq_demux);
239 234
240#ifdef CONFIG_SH_UNKNOWN 235#ifdef CONFIG_SH_UNKNOWN
@@ -273,10 +268,10 @@ void __init setup_arch(char **cmdline_p)
273 init_mm.end_data = (unsigned long) _edata; 268 init_mm.end_data = (unsigned long) _edata;
274 init_mm.brk = (unsigned long) _end; 269 init_mm.brk = (unsigned long) _end;
275 270
276 code_resource.start = virt_to_bus(_text); 271 code_resource.start = (unsigned long)virt_to_phys(_text);
277 code_resource.end = virt_to_bus(_etext)-1; 272 code_resource.end = (unsigned long)virt_to_phys(_etext)-1;
278 data_resource.start = virt_to_bus(_etext); 273 data_resource.start = (unsigned long)virt_to_phys(_etext);
279 data_resource.end = virt_to_bus(_edata)-1; 274 data_resource.end = (unsigned long)virt_to_phys(_edata)-1;
280 275
281 sh_mv_setup(cmdline_p); 276 sh_mv_setup(cmdline_p);
282 277
@@ -435,6 +430,9 @@ static const char *cpu_name[] = {
435 [CPU_ST40GX1] = "ST40GX1", 430 [CPU_ST40GX1] = "ST40GX1",
436 [CPU_SH4_202] = "SH4-202", 431 [CPU_SH4_202] = "SH4-202",
437 [CPU_SH4_501] = "SH4-501", 432 [CPU_SH4_501] = "SH4-501",
433 [CPU_SH7770] = "SH7770",
434 [CPU_SH7780] = "SH7780",
435 [CPU_SH7781] = "SH7781",
438 [CPU_SH_NONE] = "Unknown" 436 [CPU_SH_NONE] = "Unknown"
439}; 437};
440 438
@@ -445,7 +443,7 @@ const char *get_cpu_subtype(void)
445 443
446#ifdef CONFIG_PROC_FS 444#ifdef CONFIG_PROC_FS
447static const char *cpu_flags[] = { 445static const char *cpu_flags[] = {
448 "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr", 446 "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr", "ptea", NULL
449}; 447};
450 448
451static void show_cpuflags(struct seq_file *m) 449static void show_cpuflags(struct seq_file *m)
@@ -459,7 +457,7 @@ static void show_cpuflags(struct seq_file *m)
459 return; 457 return;
460 } 458 }
461 459
462 for (i = 0; i < cpu_data->flags; i++) 460 for (i = 0; cpu_flags[i]; i++)
463 if ((cpu_data->flags & (1 << i))) 461 if ((cpu_data->flags & (1 << i)))
464 seq_printf(m, " %s", cpu_flags[i+1]); 462 seq_printf(m, " %s", cpu_flags[i+1]);
465 463
@@ -472,7 +470,8 @@ static void show_cacheinfo(struct seq_file *m, const char *type, struct cache_in
472 470
473 cache_size = info.ways * info.sets * info.linesz; 471 cache_size = info.ways * info.sets * info.linesz;
474 472
475 seq_printf(m, "%s size\t: %dKiB\n", type, cache_size >> 10); 473 seq_printf(m, "%s size\t: %2dKiB (%d-way)\n",
474 type, cache_size >> 10, info.ways);
476} 475}
477 476
478/* 477/*
@@ -511,21 +510,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)
511 boot_cpu_data.loops_per_jiffy/(500000/HZ), 510 boot_cpu_data.loops_per_jiffy/(500000/HZ),
512 (boot_cpu_data.loops_per_jiffy/(5000/HZ)) % 100); 511 (boot_cpu_data.loops_per_jiffy/(5000/HZ)) % 100);
513 512
514#define PRINT_CLOCK(name, value) \ 513 return show_clocks(m);
515 seq_printf(m, name " clock\t: %d.%02dMHz\n", \
516 ((value) / 1000000), ((value) % 1000000)/10000)
517
518 PRINT_CLOCK("cpu", boot_cpu_data.cpu_clock);
519 PRINT_CLOCK("bus", boot_cpu_data.bus_clock);
520#ifdef CONFIG_CPU_SUBTYPE_ST40STB1
521 PRINT_CLOCK("memory", boot_cpu_data.memory_clock);
522#endif
523 PRINT_CLOCK("module", boot_cpu_data.module_clock);
524
525 return 0;
526} 514}
527 515
528
529static void *c_start(struct seq_file *m, loff_t *pos) 516static void *c_start(struct seq_file *m, loff_t *pos)
530{ 517{
531 return *pos < NR_CPUS ? cpu_data + *pos : NULL; 518 return *pos < NR_CPUS ? cpu_data + *pos : NULL;
@@ -596,7 +583,7 @@ static int __init kgdb_parse_options(char *options)
596 options += map->namelen + 1; 583 options += map->namelen + 1;
597 584
598 options = (*options == ',') ? options+1 : options; 585 options = (*options == ',') ? options+1 : options;
599 586
600 /* Read optional parameters (baud/parity/bits) */ 587 /* Read optional parameters (baud/parity/bits) */
601 baud = simple_strtoul(options, &options, 10); 588 baud = simple_strtoul(options, &options, 10);
602 if (baud != 0) { 589 if (baud != 0) {
diff --git a/arch/sh64/kernel/time.c b/arch/sh64/kernel/time.c
index 1195af37ee5a..0773c9f389f3 100644
--- a/arch/sh64/kernel/time.c
+++ b/arch/sh64/kernel/time.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/profile.h> 30#include <linux/profile.h>
31#include <linux/smp.h> 31#include <linux/smp.h>
32#include <linux/module.h>
32 33
33#include <asm/registers.h> /* required by inline __asm__ stmt. */ 34#include <asm/registers.h> /* required by inline __asm__ stmt. */
34 35
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index c51d08d218ef..267ec8f6fb58 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -38,7 +38,7 @@
38 38
39#define curptr g6 39#define curptr g6
40 40
41#define NR_SYSCALLS 284 /* Each OS is different... */ 41#define NR_SYSCALLS 299 /* Each OS is different... */
42 42
43/* These are just handy. */ 43/* These are just handy. */
44#define _SV save %sp, -STACKFRAME_SZ, %sp 44#define _SV save %sp, -STACKFRAME_SZ, %sp
diff --git a/arch/sparc/math-emu/math.c b/arch/sparc/math-emu/math.c
index be2c80932e26..8613b3eb877c 100644
--- a/arch/sparc/math-emu/math.c
+++ b/arch/sparc/math-emu/math.c
@@ -323,11 +323,6 @@ static int do_one_mathemu(u32 insn, unsigned long *pfsr, unsigned long *fregs)
323 case FMOVS: 323 case FMOVS:
324 case FABSS: 324 case FABSS:
325 case FNEGS: TYPE(2,1,0,1,0,0,0); break; 325 case FNEGS: TYPE(2,1,0,1,0,0,0); break;
326 default:
327#ifdef DEBUG_MATHEMU
328 printk("unknown FPop1: %03lx\n",(insn>>5)&0x1ff);
329#endif
330 break;
331 } 326 }
332 } else if ((insn & 0xc1f80000) == 0x81a80000) /* FPOP2 */ { 327 } else if ((insn & 0xc1f80000) == 0x81a80000) /* FPOP2 */ {
333 switch ((insn >> 5) & 0x1ff) { 328 switch ((insn >> 5) & 0x1ff) {
@@ -337,11 +332,6 @@ static int do_one_mathemu(u32 insn, unsigned long *pfsr, unsigned long *fregs)
337 case FCMPED: TYPE(3,0,0,2,1,2,1); break; 332 case FCMPED: TYPE(3,0,0,2,1,2,1); break;
338 case FCMPQ: TYPE(3,0,0,3,1,3,1); break; 333 case FCMPQ: TYPE(3,0,0,3,1,3,1); break;
339 case FCMPEQ: TYPE(3,0,0,3,1,3,1); break; 334 case FCMPEQ: TYPE(3,0,0,3,1,3,1); break;
340 default:
341#ifdef DEBUG_MATHEMU
342 printk("unknown FPop2: %03lx\n",(insn>>5)&0x1ff);
343#endif
344 break;
345 } 335 }
346 } 336 }
347 337
diff --git a/arch/sparc64/boot/.gitignore b/arch/sparc64/boot/.gitignore
new file mode 100644
index 000000000000..36356f9d498e
--- /dev/null
+++ b/arch/sparc64/boot/.gitignore
@@ -0,0 +1,4 @@
1image
2tftpboot.img
3vmlinux.aout
4piggyback
diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig
index 9ceddad0fb49..bc56a7d88308 100644
--- a/arch/sparc64/defconfig
+++ b/arch/sparc64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.16-rc1 3# Linux kernel version: 2.6.16-rc2
4# Wed Jan 18 13:41:02 2006 4# Sat Feb 4 02:31:38 2006
5# 5#
6CONFIG_SPARC=y 6CONFIG_SPARC=y
7CONFIG_SPARC64=y 7CONFIG_SPARC64=y
@@ -23,7 +23,6 @@ CONFIG_HZ=250
23# Code maturity level options 23# Code maturity level options
24# 24#
25CONFIG_EXPERIMENTAL=y 25CONFIG_EXPERIMENTAL=y
26CONFIG_CLEAN_COMPILE=y
27CONFIG_BROKEN_ON_SMP=y 26CONFIG_BROKEN_ON_SMP=y
28CONFIG_INIT_ENV_ARG_LIMIT=32 27CONFIG_INIT_ENV_ARG_LIMIT=32
29 28
@@ -155,6 +154,7 @@ CONFIG_NET=y
155# 154#
156# Networking options 155# Networking options
157# 156#
157# CONFIG_NETDEBUG is not set
158CONFIG_PACKET=y 158CONFIG_PACKET=y
159CONFIG_PACKET_MMAP=y 159CONFIG_PACKET_MMAP=y
160CONFIG_UNIX=y 160CONFIG_UNIX=y
@@ -224,6 +224,11 @@ CONFIG_IP_DCCP_TFRC_LIB=m
224# SCTP Configuration (EXPERIMENTAL) 224# SCTP Configuration (EXPERIMENTAL)
225# 225#
226# CONFIG_IP_SCTP is not set 226# CONFIG_IP_SCTP is not set
227
228#
229# TIPC Configuration (EXPERIMENTAL)
230#
231# CONFIG_TIPC is not set
227# CONFIG_ATM is not set 232# CONFIG_ATM is not set
228# CONFIG_BRIDGE is not set 233# CONFIG_BRIDGE is not set
229CONFIG_VLAN_8021Q=m 234CONFIG_VLAN_8021Q=m
@@ -233,11 +238,6 @@ CONFIG_VLAN_8021Q=m
233# CONFIG_ATALK is not set 238# CONFIG_ATALK is not set
234# CONFIG_X25 is not set 239# CONFIG_X25 is not set
235# CONFIG_LAPB is not set 240# CONFIG_LAPB is not set
236
237#
238# TIPC Configuration (EXPERIMENTAL)
239#
240# CONFIG_TIPC is not set
241# CONFIG_NET_DIVERT is not set 241# CONFIG_NET_DIVERT is not set
242# CONFIG_ECONET is not set 242# CONFIG_ECONET is not set
243# CONFIG_WAN_ROUTER is not set 243# CONFIG_WAN_ROUTER is not set
@@ -657,6 +657,7 @@ CONFIG_SERIAL_SUNSU_CONSOLE=y
657CONFIG_SERIAL_SUNSAB=m 657CONFIG_SERIAL_SUNSAB=m
658CONFIG_SERIAL_CORE=y 658CONFIG_SERIAL_CORE=y
659CONFIG_SERIAL_CORE_CONSOLE=y 659CONFIG_SERIAL_CORE_CONSOLE=y
660# CONFIG_SERIAL_JSM is not set
660CONFIG_UNIX98_PTYS=y 661CONFIG_UNIX98_PTYS=y
661# CONFIG_LEGACY_PTYS is not set 662# CONFIG_LEGACY_PTYS is not set
662 663
@@ -1118,6 +1119,10 @@ CONFIG_USB_HIDDEV=y
1118# 1119#
1119 1120
1120# 1121#
1122# EDAC - error detection and reporting (RAS)
1123#
1124
1125#
1121# Misc Linux/SPARC drivers 1126# Misc Linux/SPARC drivers
1122# 1127#
1123CONFIG_SUN_OPENPROMIO=m 1128CONFIG_SUN_OPENPROMIO=m
diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
index e50e56e4ab61..12911e7463f2 100644
--- a/arch/sparc64/kernel/entry.S
+++ b/arch/sparc64/kernel/entry.S
@@ -25,7 +25,7 @@
25 25
26#define curptr g6 26#define curptr g6
27 27
28#define NR_SYSCALLS 284 /* Each OS is different... */ 28#define NR_SYSCALLS 299 /* Each OS is different... */
29 29
30 .text 30 .text
31 .align 32 31 .align 32
diff --git a/arch/sparc64/kernel/sys32.S b/arch/sparc64/kernel/sys32.S
index 9cd272ac3ac1..60b59375aa78 100644
--- a/arch/sparc64/kernel/sys32.S
+++ b/arch/sparc64/kernel/sys32.S
@@ -84,7 +84,6 @@ SIGN2(sys32_fadvise64_64, compat_sys_fadvise64_64, %o0, %o5)
84SIGN2(sys32_bdflush, sys_bdflush, %o0, %o1) 84SIGN2(sys32_bdflush, sys_bdflush, %o0, %o1)
85SIGN1(sys32_mlockall, sys_mlockall, %o0) 85SIGN1(sys32_mlockall, sys_mlockall, %o0)
86SIGN1(sys32_nfsservctl, compat_sys_nfsservctl, %o0) 86SIGN1(sys32_nfsservctl, compat_sys_nfsservctl, %o0)
87SIGN1(sys32_clock_settime, compat_sys_clock_settime, %o1)
88SIGN1(sys32_clock_nanosleep, compat_sys_clock_nanosleep, %o1) 87SIGN1(sys32_clock_nanosleep, compat_sys_clock_nanosleep, %o1)
89SIGN1(sys32_timer_settime, compat_sys_timer_settime, %o1) 88SIGN1(sys32_timer_settime, compat_sys_timer_settime, %o1)
90SIGN1(sys32_io_submit, compat_sys_io_submit, %o1) 89SIGN1(sys32_io_submit, compat_sys_io_submit, %o1)
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index bf0fc5bfbfbe..2881faf36635 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -71,7 +71,7 @@ sys_call_table32:
71/*240*/ .word sys_munlockall, sys32_sched_setparam, sys32_sched_getparam, sys32_sched_setscheduler, sys32_sched_getscheduler 71/*240*/ .word sys_munlockall, sys32_sched_setparam, sys32_sched_getparam, sys32_sched_setscheduler, sys32_sched_getscheduler
72 .word sys_sched_yield, sys32_sched_get_priority_max, sys32_sched_get_priority_min, sys32_sched_rr_get_interval, compat_sys_nanosleep 72 .word sys_sched_yield, sys32_sched_get_priority_max, sys32_sched_get_priority_min, sys32_sched_rr_get_interval, compat_sys_nanosleep
73/*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl 73/*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
74 .word sys_ni_syscall, sys32_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep 74 .word sys_ni_syscall, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
75/*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun 75/*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
76 .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy 76 .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
77/*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink 77/*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 6430a6383853..c58b657f0097 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -47,13 +47,16 @@ ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include
47endif 47endif
48SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) 48SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
49 49
50# -Dvmap=kernel_vmap affects everything, and prevents anything from 50# -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
51# referencing the libpcap.o symbol so named. 51# named - it's a common symbol in libpcap, so we get a binary which crashes.
52# 52#
53# Same things for in6addr_loopback - found in libc. 53# Same things for in6addr_loopback and mktime - found in libc. For these two we
54# only get link-time error, luckily.
55#
56# These apply to USER_CFLAGS to.
54 57
55CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \ 58CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
56 $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ 59 $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
57 -Din6addr_loopback=kernel_in6addr_loopback 60 -Din6addr_loopback=kernel_in6addr_loopback
58 61
59AFLAGS += $(ARCH_INCLUDE) 62AFLAGS += $(ARCH_INCLUDE)
@@ -66,6 +69,7 @@ USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
66# kernel_errno to separate them from the libc errno. This allows -fno-common 69# kernel_errno to separate them from the libc errno. This allows -fno-common
67# in CFLAGS. Otherwise, it would cause ld to complain about the two different 70# in CFLAGS. Otherwise, it would cause ld to complain about the two different
68# errnos. 71# errnos.
72# These apply to kernelspace only.
69 73
70CFLAGS += -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 74CFLAGS += -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
71 -Dmktime=kernel_mktime 75 -Dmktime=kernel_mktime
@@ -168,10 +172,13 @@ else
168 $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch 172 $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch
169endif 173endif
170 174
171$(ARCH_DIR)/include/sysdep: 175$(objtree)/$(ARCH_DIR)/include:
176 @echo ' MKDIR $@'
177 $(Q)mkdir -p $@
178
179$(ARCH_DIR)/include/sysdep: $(objtree)/$(ARCH_DIR)/include
172 @echo ' SYMLINK $@' 180 @echo ' SYMLINK $@'
173ifneq ($(KBUILD_SRC),) 181ifneq ($(KBUILD_SRC),)
174 $(Q)mkdir -p $(ARCH_DIR)/include
175 $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep 182 $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep
176else 183else
177 $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep 184 $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep
@@ -214,7 +221,7 @@ $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/user-offsets.s
214 221
215CLEAN_FILES += $(ARCH_DIR)/user-offsets.s 222CLEAN_FILES += $(ARCH_DIR)/user-offsets.s
216 223
217$(ARCH_DIR)/include/kern_constants.h: 224$(ARCH_DIR)/include/kern_constants.h: $(objtree)/$(ARCH_DIR)/include
218 @echo ' SYMLINK $@' 225 @echo ' SYMLINK $@'
219 $(Q) ln -sf ../../../include/asm-um/asm-offsets.h $@ 226 $(Q) ln -sf ../../../include/asm-um/asm-offsets.h $@
220 227
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index ab0d0b170816..7218c754505b 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -403,7 +403,7 @@ int chan_window_size(struct list_head *chans, unsigned short *rows_out,
403 return 0; 403 return 0;
404} 404}
405 405
406void free_one_chan(struct chan *chan, int delay_free_irq) 406static void free_one_chan(struct chan *chan, int delay_free_irq)
407{ 407{
408 list_del(&chan->list); 408 list_del(&chan->list);
409 409
@@ -416,7 +416,7 @@ void free_one_chan(struct chan *chan, int delay_free_irq)
416 kfree(chan); 416 kfree(chan);
417} 417}
418 418
419void free_chan(struct list_head *chans, int delay_free_irq) 419static void free_chan(struct list_head *chans, int delay_free_irq)
420{ 420{
421 struct list_head *ele, *next; 421 struct list_head *ele, *next;
422 struct chan *chan; 422 struct chan *chan;
@@ -497,7 +497,7 @@ struct chan_type {
497 struct chan_ops *ops; 497 struct chan_ops *ops;
498}; 498};
499 499
500struct chan_type chan_table[] = { 500static struct chan_type chan_table[] = {
501 { "fd", &fd_ops }, 501 { "fd", &fd_ops },
502 502
503#ifdef CONFIG_NULL_CHAN 503#ifdef CONFIG_NULL_CHAN
diff --git a/arch/um/drivers/daemon_kern.c b/arch/um/drivers/daemon_kern.c
index 507e3cbac9d3..a61b7b46bc02 100644
--- a/arch/um/drivers/daemon_kern.c
+++ b/arch/um/drivers/daemon_kern.c
@@ -18,7 +18,7 @@ struct daemon_init {
18 char *ctl_sock; 18 char *ctl_sock;
19}; 19};
20 20
21void daemon_init(struct net_device *dev, void *data) 21static void daemon_init(struct net_device *dev, void *data)
22{ 22{
23 struct uml_net_private *pri; 23 struct uml_net_private *pri;
24 struct daemon_data *dpri; 24 struct daemon_data *dpri;
@@ -64,7 +64,7 @@ static struct net_kern_info daemon_kern_info = {
64 .write = daemon_write, 64 .write = daemon_write,
65}; 65};
66 66
67int daemon_setup(char *str, char **mac_out, void *data) 67static int daemon_setup(char *str, char **mac_out, void *data)
68{ 68{
69 struct daemon_init *init = data; 69 struct daemon_init *init = data;
70 char *remain; 70 char *remain;
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 46ceb25a9959..6c2d4ccaf20f 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -714,7 +714,7 @@ struct winch {
714 struct tty_struct *tty; 714 struct tty_struct *tty;
715}; 715};
716 716
717irqreturn_t winch_interrupt(int irq, void *data, struct pt_regs *unused) 717static irqreturn_t winch_interrupt(int irq, void *data, struct pt_regs *unused)
718{ 718{
719 struct winch *winch = data; 719 struct winch *winch = data;
720 struct tty_struct *tty; 720 struct tty_struct *tty;
diff --git a/arch/um/drivers/mcast_kern.c b/arch/um/drivers/mcast_kern.c
index 217438cdef33..c9b078fba03e 100644
--- a/arch/um/drivers/mcast_kern.c
+++ b/arch/um/drivers/mcast_kern.c
@@ -26,7 +26,7 @@ struct mcast_init {
26 int ttl; 26 int ttl;
27}; 27};
28 28
29void mcast_init(struct net_device *dev, void *data) 29static void mcast_init(struct net_device *dev, void *data)
30{ 30{
31 struct uml_net_private *pri; 31 struct uml_net_private *pri;
32 struct mcast_data *dpri; 32 struct mcast_data *dpri;
@@ -40,7 +40,7 @@ void mcast_init(struct net_device *dev, void *data)
40 dpri->dev = dev; 40 dpri->dev = dev;
41 41
42 printk("mcast backend "); 42 printk("mcast backend ");
43 printk("multicast adddress: %s:%u, TTL:%u ", 43 printk("multicast address: %s:%u, TTL:%u ",
44 dpri->addr, dpri->port, dpri->ttl); 44 dpri->addr, dpri->port, dpri->ttl);
45 45
46 printk("\n"); 46 printk("\n");
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index e3d576567172..54388d10bcf9 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -273,7 +273,7 @@ void mconsole_proc(struct mc_request *req)
273 config <dev> - Query the configuration of a device \n\ 273 config <dev> - Query the configuration of a device \n\
274 remove <dev> - Remove a device from UML \n\ 274 remove <dev> - Remove a device from UML \n\
275 sysrq <letter> - Performs the SysRq action controlled by the letter \n\ 275 sysrq <letter> - Performs the SysRq action controlled by the letter \n\
276 cad - invoke the Ctl-Alt-Del handler \n\ 276 cad - invoke the Ctrl-Alt-Del handler \n\
277 stop - pause the UML; it will do nothing until it receives a 'go' \n\ 277 stop - pause the UML; it will do nothing until it receives a 'go' \n\
278 go - continue the UML after a 'stop' \n\ 278 go - continue the UML after a 'stop' \n\
279 log <string> - make UML enter <string> into the kernel log\n\ 279 log <string> - make UML enter <string> into the kernel log\n\
@@ -327,7 +327,7 @@ void mconsole_stop(struct mc_request *req)
327 327
328/* This list is populated by __initcall routines. */ 328/* This list is populated by __initcall routines. */
329 329
330LIST_HEAD(mconsole_devices); 330static LIST_HEAD(mconsole_devices);
331 331
332void mconsole_register_dev(struct mc_device *new) 332void mconsole_register_dev(struct mc_device *new)
333{ 333{
@@ -561,6 +561,8 @@ void mconsole_sysrq(struct mc_request *req)
561} 561}
562#endif 562#endif
563 563
564#ifdef CONFIG_MODE_SKAS
565
564static void stack_proc(void *arg) 566static void stack_proc(void *arg)
565{ 567{
566 struct task_struct *from = current, *to = arg; 568 struct task_struct *from = current, *to = arg;
@@ -574,7 +576,7 @@ static void stack_proc(void *arg)
574 * Dumps a stacks registers to the linux console. 576 * Dumps a stacks registers to the linux console.
575 * Usage stack <pid>. 577 * Usage stack <pid>.
576 */ 578 */
577void do_stack(struct mc_request *req) 579static void do_stack_trace(struct mc_request *req)
578{ 580{
579 char *ptr = req->request.data; 581 char *ptr = req->request.data;
580 int pid_requested= -1; 582 int pid_requested= -1;
@@ -605,6 +607,7 @@ void do_stack(struct mc_request *req)
605 } 607 }
606 with_console(req, stack_proc, to); 608 with_console(req, stack_proc, to);
607} 609}
610#endif /* CONFIG_MODE_SKAS */
608 611
609void mconsole_stack(struct mc_request *req) 612void mconsole_stack(struct mc_request *req)
610{ 613{
@@ -613,7 +616,7 @@ void mconsole_stack(struct mc_request *req)
613 */ 616 */
614 CHOOSE_MODE(mconsole_reply(req, "Sorry, this doesn't work in TT mode", 617 CHOOSE_MODE(mconsole_reply(req, "Sorry, this doesn't work in TT mode",
615 1, 0), 618 1, 0),
616 do_stack(req)); 619 do_stack_trace(req));
617} 620}
618 621
619/* Changed by mconsole_setup, which is __setup, and called before SMP is 622/* Changed by mconsole_setup, which is __setup, and called before SMP is
diff --git a/arch/um/drivers/slip_common.h b/arch/um/drivers/slip_common.h
index 2ae76d8f1be1..d574e0a9dc13 100644
--- a/arch/um/drivers/slip_common.h
+++ b/arch/um/drivers/slip_common.h
@@ -88,12 +88,13 @@ struct slip_proto {
88 int esc; 88 int esc;
89}; 89};
90 90
91#define SLIP_PROTO_INIT { \ 91static inline void slip_proto_init(struct slip_proto * slip)
92 .ibuf = { '\0' }, \ 92{
93 .obuf = { '\0' }, \ 93 memset(slip->ibuf, 0, sizeof(slip->ibuf));
94 .more = 0, \ 94 memset(slip->obuf, 0, sizeof(slip->obuf));
95 .pos = 0, \ 95 slip->more = 0;
96 .esc = 0 \ 96 slip->pos = 0;
97 slip->esc = 0;
97} 98}
98 99
99extern int slip_proto_read(int fd, void *buf, int len, 100extern int slip_proto_read(int fd, void *buf, int len,
diff --git a/arch/um/drivers/slip_kern.c b/arch/um/drivers/slip_kern.c
index 9a6f5c85f902..a62f5ef445cf 100644
--- a/arch/um/drivers/slip_kern.c
+++ b/arch/um/drivers/slip_kern.c
@@ -21,13 +21,14 @@ void slip_init(struct net_device *dev, void *data)
21 21
22 private = dev->priv; 22 private = dev->priv;
23 spri = (struct slip_data *) private->user; 23 spri = (struct slip_data *) private->user;
24 *spri = ((struct slip_data) 24
25 { .name = { '\0' }, 25 memset(spri->name, 0, sizeof(spri->name));
26 .addr = NULL, 26 spri->addr = NULL;
27 .gate_addr = init->gate_addr, 27 spri->gate_addr = init->gate_addr;
28 .slave = -1, 28 spri->slave = -1;
29 .slip = SLIP_PROTO_INIT, 29 spri->dev = dev;
30 .dev = dev }); 30
31 slip_proto_init(&spri->slip);
31 32
32 dev->init = NULL; 33 dev->init = NULL;
33 dev->header_cache_update = NULL; 34 dev->header_cache_update = NULL;
diff --git a/arch/um/drivers/slirp_kern.c b/arch/um/drivers/slirp_kern.c
index 9864d27afdbe..33d7982be5d3 100644
--- a/arch/um/drivers/slirp_kern.c
+++ b/arch/um/drivers/slirp_kern.c
@@ -21,12 +21,13 @@ void slirp_init(struct net_device *dev, void *data)
21 21
22 private = dev->priv; 22 private = dev->priv;
23 spri = (struct slirp_data *) private->user; 23 spri = (struct slirp_data *) private->user;
24 *spri = ((struct slirp_data) 24
25 { .argw = init->argw, 25 spri->argw = init->argw;
26 .pid = -1, 26 spri->pid = -1;
27 .slave = -1, 27 spri->slave = -1;
28 .slip = SLIP_PROTO_INIT, 28 spri->dev = dev;
29 .dev = dev }); 29
30 slip_proto_init(&spri->slip);
30 31
31 dev->init = NULL; 32 dev->init = NULL;
32 dev->hard_header_len = 0; 33 dev->hard_header_len = 0;
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index a32ef55cb244..a4d6415bc8c4 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -33,7 +33,7 @@ static struct tty_driver *ssl_driver;
33 33
34#define NR_PORTS 64 34#define NR_PORTS 64
35 35
36void ssl_announce(char *dev_name, int dev) 36static void ssl_announce(char *dev_name, int dev)
37{ 37{
38 printk(KERN_INFO "Serial line %d assigned device '%s'\n", dev, 38 printk(KERN_INFO "Serial line %d assigned device '%s'\n", dev,
39 dev_name); 39 dev_name);
@@ -98,7 +98,7 @@ static int ssl_remove(int n)
98 return line_remove(serial_lines, ARRAY_SIZE(serial_lines), n); 98 return line_remove(serial_lines, ARRAY_SIZE(serial_lines), n);
99} 99}
100 100
101int ssl_open(struct tty_struct *tty, struct file *filp) 101static int ssl_open(struct tty_struct *tty, struct file *filp)
102{ 102{
103 return line_open(serial_lines, tty); 103 return line_open(serial_lines, tty);
104} 104}
@@ -182,7 +182,7 @@ static struct console ssl_cons = {
182 .index = -1, 182 .index = -1,
183}; 183};
184 184
185int ssl_init(void) 185static int ssl_init(void)
186{ 186{
187 char *new_title; 187 char *new_title;
188 188
diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h
index c649108a9e9f..07176d92e1c9 100644
--- a/arch/um/include/kern_util.h
+++ b/arch/um/include/kern_util.h
@@ -31,8 +31,6 @@ extern int timer_irq_inited;
31extern int jail; 31extern int jail;
32extern int nsyscalls; 32extern int nsyscalls;
33 33
34extern struct task_struct *idle_threads[NR_CPUS];
35
36#define UML_ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK)) 34#define UML_ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK))
37#define UML_ROUND_UP(addr) \ 35#define UML_ROUND_UP(addr) \
38 UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1) 36 UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1)
diff --git a/arch/um/kernel/exec_kern.c b/arch/um/kernel/exec_kern.c
index 569fe8b9b053..c264e1c05ab3 100644
--- a/arch/um/kernel/exec_kern.c
+++ b/arch/um/kernel/exec_kern.c
@@ -33,7 +33,7 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
33extern void log_exec(char **argv, void *tty); 33extern void log_exec(char **argv, void *tty);
34 34
35static long execve1(char *file, char __user * __user *argv, 35static long execve1(char *file, char __user * __user *argv,
36 char *__user __user *env) 36 char __user *__user *env)
37{ 37{
38 long error; 38 long error;
39 39
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
index f3b583a878a6..544665e04513 100644
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -265,7 +265,7 @@ int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem)
265 highmem_len = highmem_pages * sizeof(struct page); 265 highmem_len = highmem_pages * sizeof(struct page);
266 266
267 total_pages = phys_pages + iomem_pages + highmem_pages; 267 total_pages = phys_pages + iomem_pages + highmem_pages;
268 total_len = phys_len + iomem_pages + highmem_len; 268 total_len = phys_len + iomem_len + highmem_len;
269 269
270 if(kmalloc_ok){ 270 if(kmalloc_ok){
271 map = kmalloc(total_len, GFP_KERNEL); 271 map = kmalloc(total_len, GFP_KERNEL);
diff --git a/arch/um/kernel/reboot.c b/arch/um/kernel/reboot.c
index 6f1a3a288117..3ef73bf2e781 100644
--- a/arch/um/kernel/reboot.c
+++ b/arch/um/kernel/reboot.c
@@ -5,6 +5,7 @@
5 5
6#include "linux/module.h" 6#include "linux/module.h"
7#include "linux/sched.h" 7#include "linux/sched.h"
8#include "asm/smp.h"
8#include "user_util.h" 9#include "user_util.h"
9#include "kern_util.h" 10#include "kern_util.h"
10#include "kern.h" 11#include "kern.h"
diff --git a/arch/um/kernel/tt/syscall_kern.c b/arch/um/kernel/tt/syscall_kern.c
index 3d29c90514cc..3fda9a03c59a 100644
--- a/arch/um/kernel/tt/syscall_kern.c
+++ b/arch/um/kernel/tt/syscall_kern.c
@@ -23,16 +23,20 @@ void syscall_handler_tt(int sig, struct pt_regs *regs)
23 int syscall; 23 int syscall;
24#ifdef CONFIG_SYSCALL_DEBUG 24#ifdef CONFIG_SYSCALL_DEBUG
25 int index; 25 int index;
26 index = record_syscall_start(syscall);
27#endif 26#endif
28 sc = UPT_SC(&regs->regs); 27 sc = UPT_SC(&regs->regs);
29 SC_START_SYSCALL(sc); 28 SC_START_SYSCALL(sc);
30 29
30 syscall = UPT_SYSCALL_NR(&regs->regs);
31
32#ifdef CONFIG_SYSCALL_DEBUG
33 index = record_syscall_start(syscall);
34#endif
35
31 syscall_trace(&regs->regs, 0); 36 syscall_trace(&regs->regs, 0);
32 37
33 current->thread.nsyscalls++; 38 current->thread.nsyscalls++;
34 nsyscalls++; 39 nsyscalls++;
35 syscall = UPT_SYSCALL_NR(&regs->regs);
36 40
37 if((syscall >= NR_syscalls) || (syscall < 0)) 41 if((syscall >= NR_syscalls) || (syscall < 0))
38 result = -ENOSYS; 42 result = -ENOSYS;
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index 0cdfd4481d5e..1fa09a79a10b 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -16,7 +16,6 @@
16#include "choose-mode.h" 16#include "choose-mode.h"
17#include "kern.h" 17#include "kern.h"
18#include "mode_kern.h" 18#include "mode_kern.h"
19#include "proc_mm.h"
20#include "os.h" 19#include "os.h"
21 20
22extern int modify_ldt(int func, void *ptr, unsigned long bytecount); 21extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
@@ -90,6 +89,7 @@ out:
90#include "skas.h" 89#include "skas.h"
91#include "skas_ptrace.h" 90#include "skas_ptrace.h"
92#include "asm/mmu_context.h" 91#include "asm/mmu_context.h"
92#include "proc_mm.h"
93 93
94long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc, 94long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc,
95 void **addr, int done) 95 void **addr, int done)
diff --git a/arch/v850/kernel/simcons.c b/arch/v850/kernel/simcons.c
index 7f0efaa025c9..3975aa02cef8 100644
--- a/arch/v850/kernel/simcons.c
+++ b/arch/v850/kernel/simcons.c
@@ -117,6 +117,7 @@ late_initcall(simcons_tty_init);
117 tty driver. */ 117 tty driver. */
118void simcons_poll_tty (struct tty_struct *tty) 118void simcons_poll_tty (struct tty_struct *tty)
119{ 119{
120 char buf[32]; /* Not the nicest way to do it but I need it correct first */
120 int flip = 0, send_break = 0; 121 int flip = 0, send_break = 0;
121 struct pollfd pfd; 122 struct pollfd pfd;
122 pfd.fd = 0; 123 pfd.fd = 0;
@@ -124,21 +125,15 @@ void simcons_poll_tty (struct tty_struct *tty)
124 125
125 if (V850_SIM_SYSCALL (poll, &pfd, 1, 0) > 0) { 126 if (V850_SIM_SYSCALL (poll, &pfd, 1, 0) > 0) {
126 if (pfd.revents & POLLIN) { 127 if (pfd.revents & POLLIN) {
127 int left = TTY_FLIPBUF_SIZE - tty->flip.count; 128 /* Real block hardware knows the transfer size before
128 129 transfer so the new tty buffering doesn't try to handle
129 if (left > 0) { 130 this rather weird simulator specific case well */
130 unsigned char *buf = tty->flip.char_buf_ptr; 131 int rd = V850_SIM_SYSCALL (read, 0, buf, 32);
131 int rd = V850_SIM_SYSCALL (read, 0, buf, left); 132 if (rd > 0) {
132 133 tty_insert_flip_string(tty, buf, rd);
133 if (rd > 0) { 134 flip = 1;
134 tty->flip.count += rd; 135 } else
135 tty->flip.char_buf_ptr += rd; 136 send_break = 1;
136 memset (tty->flip.flag_buf_ptr, 0, rd);
137 tty->flip.flag_buf_ptr += rd;
138 flip = 1;
139 } else
140 send_break = 1;
141 }
142 } else if (pfd.revents & POLLERR) 137 } else if (pfd.revents & POLLERR)
143 send_break = 1; 138 send_break = 1;
144 } 139 }
diff --git a/arch/x86_64/Kconfig.debug b/arch/x86_64/Kconfig.debug
index fcb06a50fdd2..ea31b4c62105 100644
--- a/arch/x86_64/Kconfig.debug
+++ b/arch/x86_64/Kconfig.debug
@@ -2,13 +2,6 @@ menu "Kernel hacking"
2 2
3source "lib/Kconfig.debug" 3source "lib/Kconfig.debug"
4 4
5config INIT_DEBUG
6 bool "Debug __init statements"
7 depends on DEBUG_KERNEL
8 help
9 Fill __init and __initdata at the end of boot. This helps debugging
10 illegal uses of __init and __initdata after initialization.
11
12config DEBUG_RODATA 5config DEBUG_RODATA
13 bool "Write protect kernel read-only data structures" 6 bool "Write protect kernel read-only data structures"
14 depends on DEBUG_KERNEL 7 depends on DEBUG_KERNEL
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index 09a3eb743315..56832929a543 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/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.15-git12 3# Linux kernel version: 2.6.16-rc1-git2
4# Mon Jan 16 13:09:08 2006 4# Thu Jan 19 10:05:21 2006
5# 5#
6CONFIG_X86_64=y 6CONFIG_X86_64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -310,6 +310,11 @@ CONFIG_IPV6=y
310# SCTP Configuration (EXPERIMENTAL) 310# SCTP Configuration (EXPERIMENTAL)
311# 311#
312# CONFIG_IP_SCTP is not set 312# CONFIG_IP_SCTP is not set
313
314#
315# TIPC Configuration (EXPERIMENTAL)
316#
317# CONFIG_TIPC is not set
313# CONFIG_ATM is not set 318# CONFIG_ATM is not set
314# CONFIG_BRIDGE is not set 319# CONFIG_BRIDGE is not set
315# CONFIG_VLAN_8021Q is not set 320# CONFIG_VLAN_8021Q is not set
@@ -319,11 +324,6 @@ CONFIG_IPV6=y
319# CONFIG_ATALK is not set 324# CONFIG_ATALK is not set
320# CONFIG_X25 is not set 325# CONFIG_X25 is not set
321# CONFIG_LAPB is not set 326# CONFIG_LAPB is not set
322
323#
324# TIPC Configuration (EXPERIMENTAL)
325#
326# CONFIG_TIPC is not set
327# CONFIG_NET_DIVERT is not set 327# CONFIG_NET_DIVERT is not set
328# CONFIG_ECONET is not set 328# CONFIG_ECONET is not set
329# CONFIG_WAN_ROUTER is not set 329# CONFIG_WAN_ROUTER is not set
@@ -1098,6 +1098,12 @@ CONFIG_USB_MON=y
1098# 1098#
1099 1099
1100# 1100#
1101# EDAC - error detection and reporting (RAS)
1102#
1103# CONFIG_EDAC is not set
1104# CONFIG_EDAC_POLL is not set
1105
1106#
1101# Firmware Drivers 1107# Firmware Drivers
1102# 1108#
1103# CONFIG_EDD is not set 1109# CONFIG_EDD is not set
@@ -1290,6 +1296,7 @@ CONFIG_DEBUG_FS=y
1290# CONFIG_DEBUG_VM is not set 1296# CONFIG_DEBUG_VM is not set
1291# CONFIG_FRAME_POINTER is not set 1297# CONFIG_FRAME_POINTER is not set
1292# CONFIG_FORCED_INLINING is not set 1298# CONFIG_FORCED_INLINING is not set
1299# CONFIG_UNWIND_INFO is not set
1293# CONFIG_RCU_TORTURE_TEST is not set 1300# CONFIG_RCU_TORTURE_TEST is not set
1294CONFIG_INIT_DEBUG=y 1301CONFIG_INIT_DEBUG=y
1295# CONFIG_DEBUG_RODATA is not set 1302# CONFIG_DEBUG_RODATA is not set
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index f05c2a802489..067c0f47bd0d 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -676,7 +676,7 @@ ia32_sys_call_table:
676 .quad sys_mkdirat 676 .quad sys_mkdirat
677 .quad sys_mknodat 677 .quad sys_mknodat
678 .quad sys_fchownat 678 .quad sys_fchownat
679 .quad sys_futimesat 679 .quad compat_sys_futimesat
680 .quad compat_sys_newfstatat /* 300 */ 680 .quad compat_sys_newfstatat /* 300 */
681 .quad sys_unlinkat 681 .quad sys_unlinkat
682 .quad sys_renameat 682 .quad sys_renameat
diff --git a/arch/x86_64/kernel/acpi/Makefile b/arch/x86_64/kernel/acpi/Makefile
index 7da9ace890bd..4fe97071f297 100644
--- a/arch/x86_64/kernel/acpi/Makefile
+++ b/arch/x86_64/kernel/acpi/Makefile
@@ -1,3 +1,8 @@
1obj-y := boot.o 1obj-y := boot.o
2boot-y := ../../../i386/kernel/acpi/boot.o 2boot-y := ../../../i386/kernel/acpi/boot.o
3obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o 3obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o
4
5ifneq ($(CONFIG_ACPI_PROCESSOR),)
6obj-y += processor.o
7endif
8
diff --git a/arch/x86_64/kernel/acpi/processor.c b/arch/x86_64/kernel/acpi/processor.c
new file mode 100644
index 000000000000..3bdc2baa5bb1
--- /dev/null
+++ b/arch/x86_64/kernel/acpi/processor.c
@@ -0,0 +1,72 @@
1/*
2 * arch/x86_64/kernel/acpi/processor.c
3 *
4 * Copyright (C) 2005 Intel Corporation
5 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
6 * - Added _PDC for platforms with Intel CPUs
7 */
8
9#include <linux/kernel.h>
10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/acpi.h>
13
14#include <acpi/processor.h>
15#include <asm/acpi.h>
16
17static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c)
18{
19 struct acpi_object_list *obj_list;
20 union acpi_object *obj;
21 u32 *buf;
22
23 /* allocate and initialize pdc. It will be used later. */
24 obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
25 if (!obj_list) {
26 printk(KERN_ERR "Memory allocation error\n");
27 return;
28 }
29
30 obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
31 if (!obj) {
32 printk(KERN_ERR "Memory allocation error\n");
33 kfree(obj_list);
34 return;
35 }
36
37 buf = kmalloc(12, GFP_KERNEL);
38 if (!buf) {
39 printk(KERN_ERR "Memory allocation error\n");
40 kfree(obj);
41 kfree(obj_list);
42 return;
43 }
44
45 buf[0] = ACPI_PDC_REVISION_ID;
46 buf[1] = 1;
47 buf[2] = ACPI_PDC_EST_CAPABILITY_SMP;
48
49 obj->type = ACPI_TYPE_BUFFER;
50 obj->buffer.length = 12;
51 obj->buffer.pointer = (u8 *) buf;
52 obj_list->count = 1;
53 obj_list->pointer = obj;
54 pr->pdc = obj_list;
55
56 return;
57}
58
59/* Initialize _PDC data based on the CPU vendor */
60void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
61{
62 unsigned int cpu = pr->id;
63 struct cpuinfo_x86 *c = cpu_data + cpu;
64
65 pr->pdc = NULL;
66 if (c->x86_vendor == X86_VENDOR_INTEL && cpu_has(c, X86_FEATURE_EST))
67 init_intel_pdc(pr, c);
68
69 return;
70}
71
72EXPORT_SYMBOL(arch_acpi_processor_init_pdc);
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index 5d3c5b07b8db..6147770b4347 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -35,8 +35,12 @@
35#include <asm/mach_apic.h> 35#include <asm/mach_apic.h>
36#include <asm/nmi.h> 36#include <asm/nmi.h>
37#include <asm/idle.h> 37#include <asm/idle.h>
38#include <asm/proto.h>
39#include <asm/timex.h>
38 40
39int apic_verbosity; 41int apic_verbosity;
42int apic_runs_main_timer;
43int apic_calibrate_pmtmr __initdata;
40 44
41int disable_apic_timer __initdata; 45int disable_apic_timer __initdata;
42 46
@@ -68,6 +72,26 @@ int get_maxlvt(void)
68 return maxlvt; 72 return maxlvt;
69} 73}
70 74
75/*
76 * 'what should we do if we get a hw irq event on an illegal vector'.
77 * each architecture has to answer this themselves.
78 */
79void ack_bad_irq(unsigned int irq)
80{
81 printk("unexpected IRQ trap at vector %02x\n", irq);
82 /*
83 * Currently unexpected vectors happen only on SMP and APIC.
84 * We _must_ ack these because every local APIC has only N
85 * irq slots per priority level, and a 'hanging, unacked' IRQ
86 * holds up an irq slot - in excessive cases (when multiple
87 * unexpected vectors occur) that might lock up the APIC
88 * completely.
89 * But don't ack when the APIC is disabled. -AK
90 */
91 if (!disable_apic)
92 ack_APIC_irq();
93}
94
71void clear_local_APIC(void) 95void clear_local_APIC(void)
72{ 96{
73 int maxlvt; 97 int maxlvt;
@@ -702,9 +726,17 @@ static void setup_APIC_timer(unsigned int clocks)
702 c2 |= inb_p(0x40) << 8; 726 c2 |= inb_p(0x40) << 8;
703 } while (c2 - c1 < 300); 727 } while (c2 - c1 < 300);
704 } 728 }
705
706 __setup_APIC_LVTT(clocks); 729 __setup_APIC_LVTT(clocks);
707 730 /* Turn off PIT interrupt if we use APIC timer as main timer.
731 Only works with the PM timer right now
732 TBD fix it for HPET too. */
733 if (vxtime.mode == VXTIME_PMTMR &&
734 smp_processor_id() == boot_cpu_id &&
735 apic_runs_main_timer == 1 &&
736 !cpu_isset(boot_cpu_id, timer_interrupt_broadcast_ipi_mask)) {
737 stop_timer_interrupt();
738 apic_runs_main_timer++;
739 }
708 local_irq_restore(flags); 740 local_irq_restore(flags);
709} 741}
710 742
@@ -735,14 +767,27 @@ static int __init calibrate_APIC_clock(void)
735 __setup_APIC_LVTT(1000000000); 767 __setup_APIC_LVTT(1000000000);
736 768
737 apic_start = apic_read(APIC_TMCCT); 769 apic_start = apic_read(APIC_TMCCT);
738 rdtscl(tsc_start); 770#ifdef CONFIG_X86_PM_TIMER
739 771 if (apic_calibrate_pmtmr && pmtmr_ioport) {
740 do { 772 pmtimer_wait(5000); /* 5ms wait */
741 apic = apic_read(APIC_TMCCT); 773 apic = apic_read(APIC_TMCCT);
742 rdtscl(tsc); 774 result = (apic_start - apic) * 1000L / 5;
743 } while ((tsc - tsc_start) < TICK_COUNT && (apic - apic_start) < TICK_COUNT); 775 } else
776#endif
777 {
778 rdtscl(tsc_start);
779
780 do {
781 apic = apic_read(APIC_TMCCT);
782 rdtscl(tsc);
783 } while ((tsc - tsc_start) < TICK_COUNT &&
784 (apic - apic_start) < TICK_COUNT);
785
786 result = (apic_start - apic) * 1000L * cpu_khz /
787 (tsc - tsc_start);
788 }
789 printk("result %d\n", result);
744 790
745 result = (apic_start - apic) * 1000L * cpu_khz / (tsc - tsc_start);
746 791
747 printk(KERN_INFO "Detected %d.%03d MHz APIC timer.\n", 792 printk(KERN_INFO "Detected %d.%03d MHz APIC timer.\n",
748 result / 1000 / 1000, result / 1000 % 1000); 793 result / 1000 / 1000, result / 1000 % 1000);
@@ -872,6 +917,8 @@ void smp_local_timer_interrupt(struct pt_regs *regs)
872#ifdef CONFIG_SMP 917#ifdef CONFIG_SMP
873 update_process_times(user_mode(regs)); 918 update_process_times(user_mode(regs));
874#endif 919#endif
920 if (apic_runs_main_timer > 1 && smp_processor_id() == boot_cpu_id)
921 main_timer_handler(regs);
875 /* 922 /*
876 * We take the 'long' return path, and there every subsystem 923 * We take the 'long' return path, and there every subsystem
877 * grabs the appropriate locks (kernel lock/ irq lock). 924 * grabs the appropriate locks (kernel lock/ irq lock).
@@ -924,7 +971,7 @@ void smp_apic_timer_interrupt(struct pt_regs *regs)
924 * multi-chassis. Use available data to take a good guess. 971 * multi-chassis. Use available data to take a good guess.
925 * If in doubt, go HPET. 972 * If in doubt, go HPET.
926 */ 973 */
927__init int oem_force_hpet_timer(void) 974__cpuinit int oem_force_hpet_timer(void)
928{ 975{
929 int i, clusters, zeros; 976 int i, clusters, zeros;
930 unsigned id; 977 unsigned id;
@@ -1081,10 +1128,34 @@ static __init int setup_nolapic(char *str)
1081 1128
1082static __init int setup_noapictimer(char *str) 1129static __init int setup_noapictimer(char *str)
1083{ 1130{
1131 if (str[0] != ' ' && str[0] != 0)
1132 return -1;
1084 disable_apic_timer = 1; 1133 disable_apic_timer = 1;
1085 return 0; 1134 return 0;
1086} 1135}
1087 1136
1137static __init int setup_apicmaintimer(char *str)
1138{
1139 apic_runs_main_timer = 1;
1140 nohpet = 1;
1141 return 0;
1142}
1143__setup("apicmaintimer", setup_apicmaintimer);
1144
1145static __init int setup_noapicmaintimer(char *str)
1146{
1147 apic_runs_main_timer = -1;
1148 return 0;
1149}
1150__setup("noapicmaintimer", setup_noapicmaintimer);
1151
1152static __init int setup_apicpmtimer(char *s)
1153{
1154 apic_calibrate_pmtmr = 1;
1155 return setup_apicmaintimer(NULL);
1156}
1157__setup("apicpmtimer", setup_apicpmtimer);
1158
1088/* dummy parsing: see setup.c */ 1159/* dummy parsing: see setup.c */
1089 1160
1090__setup("disableapic", setup_disableapic); 1161__setup("disableapic", setup_disableapic);
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index dbdba56e8faa..b150c87a08c6 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -499,7 +499,9 @@ ENTRY(stub_rt_sigreturn)
499 movq %gs:pda_irqstackptr,%rax 499 movq %gs:pda_irqstackptr,%rax
500 cmoveq %rax,%rsp /*todo This needs CFI annotation! */ 500 cmoveq %rax,%rsp /*todo This needs CFI annotation! */
501 pushq %rdi # save old stack 501 pushq %rdi # save old stack
502#ifndef CONFIG_DEBUG_INFO
502 CFI_ADJUST_CFA_OFFSET 8 503 CFI_ADJUST_CFA_OFFSET 8
504#endif
503 call \func 505 call \func
504 .endm 506 .endm
505 507
@@ -509,7 +511,9 @@ ENTRY(common_interrupt)
509 /* 0(%rsp): oldrsp-ARGOFFSET */ 511 /* 0(%rsp): oldrsp-ARGOFFSET */
510ret_from_intr: 512ret_from_intr:
511 popq %rdi 513 popq %rdi
514#ifndef CONFIG_DEBUG_INFO
512 CFI_ADJUST_CFA_OFFSET -8 515 CFI_ADJUST_CFA_OFFSET -8
516#endif
513 cli 517 cli
514 decl %gs:pda_irqcount 518 decl %gs:pda_irqcount
515#ifdef CONFIG_DEBUG_INFO 519#ifdef CONFIG_DEBUG_INFO
@@ -922,7 +926,7 @@ KPROBE_ENTRY(debug)
922 .previous .text 926 .previous .text
923 927
924 /* runs on exception stack */ 928 /* runs on exception stack */
925ENTRY(nmi) 929KPROBE_ENTRY(nmi)
926 INTR_FRAME 930 INTR_FRAME
927 pushq $-1 931 pushq $-1
928 CFI_ADJUST_CFA_OFFSET 8 932 CFI_ADJUST_CFA_OFFSET 8
@@ -969,6 +973,7 @@ paranoid_schedule:
969 cli 973 cli
970 jmp paranoid_userspace 974 jmp paranoid_userspace
971 CFI_ENDPROC 975 CFI_ENDPROC
976 .previous .text
972 977
973KPROBE_ENTRY(int3) 978KPROBE_ENTRY(int3)
974 INTR_FRAME 979 INTR_FRAME
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index e8cf44ef8778..4282d72b2a26 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -304,6 +304,14 @@ void __init check_ioapic(void)
304#endif 304#endif
305 /* RED-PEN skip them on mptables too? */ 305 /* RED-PEN skip them on mptables too? */
306 return; 306 return;
307 case PCI_VENDOR_ID_ATI:
308 if (apic_runs_main_timer != 0)
309 break;
310 printk(KERN_INFO
311 "ATI board detected. Using APIC/PM timer.\n");
312 apic_runs_main_timer = 1;
313 nohpet = 1;
314 return;
307 } 315 }
308 316
309 /* No multi-function device? */ 317 /* No multi-function device? */
@@ -2027,7 +2035,7 @@ int __init io_apic_get_redir_entries (int ioapic)
2027} 2035}
2028 2036
2029 2037
2030int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low) 2038int io_apic_set_pci_routing (int ioapic, int pin, int irq, int triggering, int polarity)
2031{ 2039{
2032 struct IO_APIC_route_entry entry; 2040 struct IO_APIC_route_entry entry;
2033 unsigned long flags; 2041 unsigned long flags;
@@ -2049,8 +2057,8 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
2049 entry.delivery_mode = INT_DELIVERY_MODE; 2057 entry.delivery_mode = INT_DELIVERY_MODE;
2050 entry.dest_mode = INT_DEST_MODE; 2058 entry.dest_mode = INT_DEST_MODE;
2051 entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS); 2059 entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
2052 entry.trigger = edge_level; 2060 entry.trigger = triggering;
2053 entry.polarity = active_high_low; 2061 entry.polarity = polarity;
2054 entry.mask = 1; /* Disabled (masked) */ 2062 entry.mask = 1; /* Disabled (masked) */
2055 2063
2056 irq = gsi_irq_sharing(irq); 2064 irq = gsi_irq_sharing(irq);
@@ -2065,9 +2073,9 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
2065 apic_printk(APIC_VERBOSE,KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry (%d-%d -> 0x%x -> " 2073 apic_printk(APIC_VERBOSE,KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry (%d-%d -> 0x%x -> "
2066 "IRQ %d Mode:%i Active:%i)\n", ioapic, 2074 "IRQ %d Mode:%i Active:%i)\n", ioapic,
2067 mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq, 2075 mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq,
2068 edge_level, active_high_low); 2076 triggering, polarity);
2069 2077
2070 ioapic_register_intr(irq, entry.vector, edge_level); 2078 ioapic_register_intr(irq, entry.vector, triggering);
2071 2079
2072 if (!ioapic && (irq < 16)) 2080 if (!ioapic && (irq < 16))
2073 disable_8259A_irq(irq); 2081 disable_8259A_irq(irq);
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index 13a2eada6c95..b8b9529fa89e 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -380,7 +380,7 @@ static void __cpuinit mce_cpu_features(struct cpuinfo_x86 *c)
380 */ 380 */
381void __cpuinit mcheck_init(struct cpuinfo_x86 *c) 381void __cpuinit mcheck_init(struct cpuinfo_x86 *c)
382{ 382{
383 static cpumask_t mce_cpus __initdata = CPU_MASK_NONE; 383 static cpumask_t mce_cpus = CPU_MASK_NONE;
384 384
385 mce_cpu_quirks(c); 385 mce_cpu_quirks(c);
386 386
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
index 1105250bf02c..dc49bfb6db0a 100644
--- a/arch/x86_64/kernel/mpparse.c
+++ b/arch/x86_64/kernel/mpparse.c
@@ -915,7 +915,7 @@ void __init mp_config_acpi_legacy_irqs (void)
915 915
916#define MAX_GSI_NUM 4096 916#define MAX_GSI_NUM 4096
917 917
918int mp_register_gsi(u32 gsi, int edge_level, int active_high_low) 918int mp_register_gsi(u32 gsi, int triggering, int polarity)
919{ 919{
920 int ioapic = -1; 920 int ioapic = -1;
921 int ioapic_pin = 0; 921 int ioapic_pin = 0;
@@ -964,7 +964,7 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
964 964
965 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit); 965 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
966 966
967 if (edge_level) { 967 if (triggering == ACPI_LEVEL_SENSITIVE) {
968 /* 968 /*
969 * For PCI devices assign IRQs in order, avoiding gaps 969 * For PCI devices assign IRQs in order, avoiding gaps
970 * due to unused I/O APIC pins. 970 * due to unused I/O APIC pins.
@@ -986,8 +986,8 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
986 } 986 }
987 987
988 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi, 988 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
989 edge_level == ACPI_EDGE_SENSITIVE ? 0 : 1, 989 triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
990 active_high_low == ACPI_ACTIVE_HIGH ? 0 : 1); 990 polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
991 return gsi; 991 return gsi;
992} 992}
993 993
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 5fae6f0cd994..8be407a1f62d 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -24,6 +24,7 @@
24#include <linux/sysdev.h> 24#include <linux/sysdev.h>
25#include <linux/nmi.h> 25#include <linux/nmi.h>
26#include <linux/sysctl.h> 26#include <linux/sysctl.h>
27#include <linux/kprobes.h>
27 28
28#include <asm/smp.h> 29#include <asm/smp.h>
29#include <asm/mtrr.h> 30#include <asm/mtrr.h>
@@ -468,7 +469,7 @@ void touch_nmi_watchdog (void)
468 touch_softlockup_watchdog(); 469 touch_softlockup_watchdog();
469} 470}
470 471
471void nmi_watchdog_tick (struct pt_regs * regs, unsigned reason) 472void __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
472{ 473{
473 int sum; 474 int sum;
474 int touched = 0; 475 int touched = 0;
@@ -512,14 +513,14 @@ void nmi_watchdog_tick (struct pt_regs * regs, unsigned reason)
512 } 513 }
513} 514}
514 515
515static int dummy_nmi_callback(struct pt_regs * regs, int cpu) 516static __kprobes int dummy_nmi_callback(struct pt_regs * regs, int cpu)
516{ 517{
517 return 0; 518 return 0;
518} 519}
519 520
520static nmi_callback_t nmi_callback = dummy_nmi_callback; 521static nmi_callback_t nmi_callback = dummy_nmi_callback;
521 522
522asmlinkage void do_nmi(struct pt_regs * regs, long error_code) 523asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code)
523{ 524{
524 int cpu = safe_smp_processor_id(); 525 int cpu = safe_smp_processor_id();
525 526
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c
index 2f5d8328e2b9..4ed391edd47a 100644
--- a/arch/x86_64/kernel/pci-dma.c
+++ b/arch/x86_64/kernel/pci-dma.c
@@ -107,6 +107,9 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
107 goto again; 107 goto again;
108 } 108 }
109 109
110 /* Let low level make its own zone decisions */
111 gfp &= ~(GFP_DMA32|GFP_DMA);
112
110 if (dma_ops->alloc_coherent) 113 if (dma_ops->alloc_coherent)
111 return dma_ops->alloc_coherent(dev, size, 114 return dma_ops->alloc_coherent(dev, size,
112 dma_handle, gfp); 115 dma_handle, gfp);
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index c37fc7726ba6..2fe23a6c361b 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -457,9 +457,12 @@ int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
457error: 457error:
458 flush_gart(NULL); 458 flush_gart(NULL);
459 gart_unmap_sg(dev, sg, nents, dir); 459 gart_unmap_sg(dev, sg, nents, dir);
460 /* When it was forced try again unforced */ 460 /* When it was forced or merged try again in a dumb way */
461 if (force_iommu) 461 if (force_iommu || iommu_merge) {
462 return dma_map_sg_nonforce(dev, sg, nents, dir); 462 out = dma_map_sg_nonforce(dev, sg, nents, dir);
463 if (out > 0)
464 return out;
465 }
463 if (panic_on_overflow) 466 if (panic_on_overflow)
464 panic("dma_map_sg: overflow on %lu pages\n", pages); 467 panic("dma_map_sg: overflow on %lu pages\n", pages);
465 iommu_full(dev, pages << PAGE_SHIFT, dir); 468 iommu_full(dev, pages << PAGE_SHIFT, dir);
@@ -642,9 +645,18 @@ static int __init pci_iommu_init(void)
642 (no_agp && init_k8_gatt(&info) < 0)) { 645 (no_agp && init_k8_gatt(&info) < 0)) {
643 no_iommu = 1; 646 no_iommu = 1;
644 no_iommu_init(); 647 no_iommu_init();
648 printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n");
649 if (end_pfn > MAX_DMA32_PFN) {
650 printk(KERN_ERR "WARNING more than 4GB of memory "
651 "but IOMMU not compiled in.\n"
652 KERN_ERR "WARNING 32bit PCI may malfunction.\n"
653 KERN_ERR "You might want to enable "
654 "CONFIG_GART_IOMMU\n");
655 }
645 return -1; 656 return -1;
646 } 657 }
647 658
659 printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n");
648 aper_size = info.aper_size * 1024 * 1024; 660 aper_size = info.aper_size * 1024 * 1024;
649 iommu_size = check_iommu_size(info.aper_base, aper_size); 661 iommu_size = check_iommu_size(info.aper_base, aper_size);
650 iommu_pages = iommu_size >> PAGE_SHIFT; 662 iommu_pages = iommu_size >> PAGE_SHIFT;
@@ -718,7 +730,6 @@ static int __init pci_iommu_init(void)
718 730
719 flush_gart(NULL); 731 flush_gart(NULL);
720 732
721 printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n");
722 dma_ops = &gart_dma_ops; 733 dma_ops = &gart_dma_ops;
723 734
724 return 0; 735 return 0;
diff --git a/arch/x86_64/kernel/pci-nommu.c b/arch/x86_64/kernel/pci-nommu.c
index e41564975195..44adcc2d5e5b 100644
--- a/arch/x86_64/kernel/pci-nommu.c
+++ b/arch/x86_64/kernel/pci-nommu.c
@@ -88,12 +88,5 @@ void __init no_iommu_init(void)
88{ 88{
89 if (dma_ops) 89 if (dma_ops)
90 return; 90 return;
91 printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n");
92 dma_ops = &nommu_dma_ops; 91 dma_ops = &nommu_dma_ops;
93 if (end_pfn > MAX_DMA32_PFN) {
94 printk(KERN_ERR
95 "WARNING more than 4GB of memory but IOMMU not compiled in.\n"
96 KERN_ERR "WARNING 32bit PCI may malfunction.\n"
97 KERN_ERR "You might want to enable CONFIG_GART_IOMMU\n");
98 }
99} 92}
diff --git a/arch/x86_64/kernel/pci-swiotlb.c b/arch/x86_64/kernel/pci-swiotlb.c
index 3569a25ad7fb..990ed67896f2 100644
--- a/arch/x86_64/kernel/pci-swiotlb.c
+++ b/arch/x86_64/kernel/pci-swiotlb.c
@@ -35,8 +35,8 @@ void pci_swiotlb_init(void)
35 (end_pfn > MAX_DMA32_PFN || force_iommu)) 35 (end_pfn > MAX_DMA32_PFN || force_iommu))
36 swiotlb = 1; 36 swiotlb = 1;
37 if (swiotlb) { 37 if (swiotlb) {
38 swiotlb_init();
39 printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n"); 38 printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
39 swiotlb_init();
40 dma_ops = &swiotlb_dma_ops; 40 dma_ops = &swiotlb_dma_ops;
41 } 41 }
42} 42}
diff --git a/arch/x86_64/kernel/pmtimer.c b/arch/x86_64/kernel/pmtimer.c
index feb5f108dd26..5c51d10408a6 100644
--- a/arch/x86_64/kernel/pmtimer.c
+++ b/arch/x86_64/kernel/pmtimer.c
@@ -80,6 +80,31 @@ int pmtimer_mark_offset(void)
80 return lost - 1; 80 return lost - 1;
81} 81}
82 82
83static unsigned pmtimer_wait_tick(void)
84{
85 u32 a, b;
86 for (a = b = inl(pmtmr_ioport) & ACPI_PM_MASK;
87 a == b;
88 b = inl(pmtmr_ioport) & ACPI_PM_MASK)
89 ;
90 return b;
91}
92
93/* note: wait time is rounded up to one tick */
94void pmtimer_wait(unsigned us)
95{
96 u32 a, b;
97 a = pmtimer_wait_tick();
98 do {
99 b = inl(pmtmr_ioport);
100 } while (cyc2us(b - a) < us);
101}
102
103void pmtimer_resume(void)
104{
105 last_pmtmr_tick = inl(pmtmr_ioport);
106}
107
83unsigned int do_gettimeoffset_pm(void) 108unsigned int do_gettimeoffset_pm(void)
84{ 109{
85 u32 now, offset, delta = 0; 110 u32 now, offset, delta = 0;
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 8ded407e4a94..22a05dec81a2 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -516,8 +516,10 @@ out:
516 * This could still be optimized: 516 * This could still be optimized:
517 * - fold all the options into a flag word and test it with a single test. 517 * - fold all the options into a flag word and test it with a single test.
518 * - could test fs/gs bitsliced 518 * - could test fs/gs bitsliced
519 *
520 * Kprobes not supported here. Set the probe on schedule instead.
519 */ 521 */
520struct task_struct * 522__kprobes struct task_struct *
521__switch_to(struct task_struct *prev_p, struct task_struct *next_p) 523__switch_to(struct task_struct *prev_p, struct task_struct *next_p)
522{ 524{
523 struct thread_struct *prev = &prev_p->thread, 525 struct thread_struct *prev = &prev_p->thread,
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 28895c03cb11..363db5a003df 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -741,7 +741,7 @@ void __init setup_arch(char **cmdline_p)
741 e820_setup_gap(); 741 e820_setup_gap();
742 742
743#ifdef CONFIG_GART_IOMMU 743#ifdef CONFIG_GART_IOMMU
744 iommu_hole_init(); 744 iommu_hole_init();
745#endif 745#endif
746 746
747#ifdef CONFIG_VT 747#ifdef CONFIG_VT
@@ -877,6 +877,7 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
877static int __init init_amd(struct cpuinfo_x86 *c) 877static int __init init_amd(struct cpuinfo_x86 *c)
878{ 878{
879 int r; 879 int r;
880 unsigned level;
880 881
881#ifdef CONFIG_SMP 882#ifdef CONFIG_SMP
882 unsigned long value; 883 unsigned long value;
@@ -899,6 +900,11 @@ static int __init init_amd(struct cpuinfo_x86 *c)
899 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */ 900 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */
900 clear_bit(0*32+31, &c->x86_capability); 901 clear_bit(0*32+31, &c->x86_capability);
901 902
903 /* On C+ stepping K8 rep microcode works well for copy/memset */
904 level = cpuid_eax(1);
905 if (c->x86 == 15 && ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58))
906 set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
907
902 r = get_model_name(c); 908 r = get_model_name(c);
903 if (!r) { 909 if (!r) {
904 switch (c->x86) { 910 switch (c->x86) {
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index f8c47c688443..c0844bffbf84 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -51,7 +51,7 @@ extern int using_apic_timer;
51DEFINE_SPINLOCK(rtc_lock); 51DEFINE_SPINLOCK(rtc_lock);
52DEFINE_SPINLOCK(i8253_lock); 52DEFINE_SPINLOCK(i8253_lock);
53 53
54static int nohpet __initdata = 0; 54int nohpet __initdata = 0;
55static int notsc __initdata = 0; 55static int notsc __initdata = 0;
56 56
57#undef HPET_HACK_ENABLE_DANGEROUS 57#undef HPET_HACK_ENABLE_DANGEROUS
@@ -345,7 +345,7 @@ static noinline void handle_lost_ticks(int lost, struct pt_regs *regs)
345#endif 345#endif
346} 346}
347 347
348static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) 348void main_timer_handler(struct pt_regs *regs)
349{ 349{
350 static unsigned long rtc_update = 0; 350 static unsigned long rtc_update = 0;
351 unsigned long tsc; 351 unsigned long tsc;
@@ -458,12 +458,17 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
458 } 458 }
459 459
460 write_sequnlock(&xtime_lock); 460 write_sequnlock(&xtime_lock);
461}
461 462
463static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
464{
465 if (apic_runs_main_timer > 1)
466 return IRQ_HANDLED;
467 main_timer_handler(regs);
462#ifdef CONFIG_X86_LOCAL_APIC 468#ifdef CONFIG_X86_LOCAL_APIC
463 if (using_apic_timer) 469 if (using_apic_timer)
464 smp_send_timer_broadcast_ipi(); 470 smp_send_timer_broadcast_ipi();
465#endif 471#endif
466
467 return IRQ_HANDLED; 472 return IRQ_HANDLED;
468} 473}
469 474
@@ -843,17 +848,43 @@ static int hpet_reenable(void)
843 return hpet_timer_stop_set_go(hpet_tick); 848 return hpet_timer_stop_set_go(hpet_tick);
844} 849}
845 850
846void __init pit_init(void) 851#define PIT_MODE 0x43
852#define PIT_CH0 0x40
853
854static void __init __pit_init(int val, u8 mode)
847{ 855{
848 unsigned long flags; 856 unsigned long flags;
849 857
850 spin_lock_irqsave(&i8253_lock, flags); 858 spin_lock_irqsave(&i8253_lock, flags);
851 outb_p(0x34, 0x43); /* binary, mode 2, LSB/MSB, ch 0 */ 859 outb_p(mode, PIT_MODE);
852 outb_p(LATCH & 0xff, 0x40); /* LSB */ 860 outb_p(val & 0xff, PIT_CH0); /* LSB */
853 outb_p(LATCH >> 8, 0x40); /* MSB */ 861 outb_p(val >> 8, PIT_CH0); /* MSB */
854 spin_unlock_irqrestore(&i8253_lock, flags); 862 spin_unlock_irqrestore(&i8253_lock, flags);
855} 863}
856 864
865void __init pit_init(void)
866{
867 __pit_init(LATCH, 0x34); /* binary, mode 2, LSB/MSB, ch 0 */
868}
869
870void __init pit_stop_interrupt(void)
871{
872 __pit_init(0, 0x30); /* mode 0 */
873}
874
875void __init stop_timer_interrupt(void)
876{
877 char *name;
878 if (vxtime.hpet_address) {
879 name = "HPET";
880 hpet_timer_stop_set_go(0);
881 } else {
882 name = "PIT";
883 pit_stop_interrupt();
884 }
885 printk(KERN_INFO "timer: %s interrupt stopped.\n", name);
886}
887
857int __init time_setup(char *str) 888int __init time_setup(char *str)
858{ 889{
859 report_lost_ticks = 1; 890 report_lost_ticks = 1;
@@ -932,7 +963,7 @@ void __init time_init(void)
932 * Make an educated guess if the TSC is trustworthy and synchronized 963 * Make an educated guess if the TSC is trustworthy and synchronized
933 * over all CPUs. 964 * over all CPUs.
934 */ 965 */
935__init int unsynchronized_tsc(void) 966__cpuinit int unsynchronized_tsc(void)
936{ 967{
937#ifdef CONFIG_SMP 968#ifdef CONFIG_SMP
938 if (oem_force_hpet_timer()) 969 if (oem_force_hpet_timer())
@@ -1016,9 +1047,21 @@ static int timer_resume(struct sys_device *dev)
1016 write_seqlock_irqsave(&xtime_lock,flags); 1047 write_seqlock_irqsave(&xtime_lock,flags);
1017 xtime.tv_sec = sec; 1048 xtime.tv_sec = sec;
1018 xtime.tv_nsec = 0; 1049 xtime.tv_nsec = 0;
1050 if (vxtime.mode == VXTIME_HPET) {
1051 if (hpet_use_timer)
1052 vxtime.last = hpet_readl(HPET_T0_CMP) - hpet_tick;
1053 else
1054 vxtime.last = hpet_readl(HPET_COUNTER);
1055#ifdef CONFIG_X86_PM_TIMER
1056 } else if (vxtime.mode == VXTIME_PMTMR) {
1057 pmtimer_resume();
1058#endif
1059 } else
1060 vxtime.last_tsc = get_cycles_sync();
1019 write_sequnlock_irqrestore(&xtime_lock,flags); 1061 write_sequnlock_irqrestore(&xtime_lock,flags);
1020 jiffies += sleep_length; 1062 jiffies += sleep_length;
1021 wall_jiffies += sleep_length; 1063 wall_jiffies += sleep_length;
1064 monotonic_base += sleep_length * (NSEC_PER_SEC/HZ);
1022 touch_softlockup_watchdog(); 1065 touch_softlockup_watchdog();
1023 return 0; 1066 return 0;
1024} 1067}
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 8bb0aeda78b9..ee1b2da9e5e7 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -372,7 +372,7 @@ void out_of_line_bug(void)
372static DEFINE_SPINLOCK(die_lock); 372static DEFINE_SPINLOCK(die_lock);
373static int die_owner = -1; 373static int die_owner = -1;
374 374
375unsigned long oops_begin(void) 375unsigned __kprobes long oops_begin(void)
376{ 376{
377 int cpu = safe_smp_processor_id(); 377 int cpu = safe_smp_processor_id();
378 unsigned long flags; 378 unsigned long flags;
@@ -391,7 +391,7 @@ unsigned long oops_begin(void)
391 return flags; 391 return flags;
392} 392}
393 393
394void oops_end(unsigned long flags) 394void __kprobes oops_end(unsigned long flags)
395{ 395{
396 die_owner = -1; 396 die_owner = -1;
397 bust_spinlocks(0); 397 bust_spinlocks(0);
@@ -400,7 +400,7 @@ void oops_end(unsigned long flags)
400 panic("Oops"); 400 panic("Oops");
401} 401}
402 402
403void __die(const char * str, struct pt_regs * regs, long err) 403void __kprobes __die(const char * str, struct pt_regs * regs, long err)
404{ 404{
405 static int die_counter; 405 static int die_counter;
406 printk(KERN_EMERG "%s: %04lx [%u] ", str, err & 0xffff,++die_counter); 406 printk(KERN_EMERG "%s: %04lx [%u] ", str, err & 0xffff,++die_counter);
@@ -432,7 +432,7 @@ void die(const char * str, struct pt_regs * regs, long err)
432 do_exit(SIGSEGV); 432 do_exit(SIGSEGV);
433} 433}
434 434
435void die_nmi(char *str, struct pt_regs *regs) 435void __kprobes die_nmi(char *str, struct pt_regs *regs)
436{ 436{
437 unsigned long flags = oops_begin(); 437 unsigned long flags = oops_begin();
438 438
@@ -575,7 +575,8 @@ asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
575 } 575 }
576} 576}
577 577
578static void mem_parity_error(unsigned char reason, struct pt_regs * regs) 578static __kprobes void
579mem_parity_error(unsigned char reason, struct pt_regs * regs)
579{ 580{
580 printk("Uhhuh. NMI received. Dazed and confused, but trying to continue\n"); 581 printk("Uhhuh. NMI received. Dazed and confused, but trying to continue\n");
581 printk("You probably have a hardware problem with your RAM chips\n"); 582 printk("You probably have a hardware problem with your RAM chips\n");
@@ -585,7 +586,8 @@ static void mem_parity_error(unsigned char reason, struct pt_regs * regs)
585 outb(reason, 0x61); 586 outb(reason, 0x61);
586} 587}
587 588
588static void io_check_error(unsigned char reason, struct pt_regs * regs) 589static __kprobes void
590io_check_error(unsigned char reason, struct pt_regs * regs)
589{ 591{
590 printk("NMI: IOCK error (debug interrupt?)\n"); 592 printk("NMI: IOCK error (debug interrupt?)\n");
591 show_registers(regs); 593 show_registers(regs);
@@ -598,7 +600,8 @@ static void io_check_error(unsigned char reason, struct pt_regs * regs)
598 outb(reason, 0x61); 600 outb(reason, 0x61);
599} 601}
600 602
601static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs) 603static __kprobes void
604unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
602{ printk("Uhhuh. NMI received for unknown reason %02x.\n", reason); 605{ printk("Uhhuh. NMI received for unknown reason %02x.\n", reason);
603 printk("Dazed and confused, but trying to continue\n"); 606 printk("Dazed and confused, but trying to continue\n");
604 printk("Do you have a strange power saving mode enabled?\n"); 607 printk("Do you have a strange power saving mode enabled?\n");
@@ -606,7 +609,7 @@ static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
606 609
607/* Runs on IST stack. This code must keep interrupts off all the time. 610/* Runs on IST stack. This code must keep interrupts off all the time.
608 Nested NMIs are prevented by the CPU. */ 611 Nested NMIs are prevented by the CPU. */
609asmlinkage void default_do_nmi(struct pt_regs *regs) 612asmlinkage __kprobes void default_do_nmi(struct pt_regs *regs)
610{ 613{
611 unsigned char reason = 0; 614 unsigned char reason = 0;
612 int cpu; 615 int cpu;
@@ -658,7 +661,7 @@ asmlinkage void __kprobes do_int3(struct pt_regs * regs, long error_code)
658/* Help handler running on IST stack to switch back to user stack 661/* Help handler running on IST stack to switch back to user stack
659 for scheduling or signal handling. The actual stack switch is done in 662 for scheduling or signal handling. The actual stack switch is done in
660 entry.S */ 663 entry.S */
661asmlinkage struct pt_regs *sync_regs(struct pt_regs *eregs) 664asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
662{ 665{
663 struct pt_regs *regs = eregs; 666 struct pt_regs *regs = eregs;
664 /* Did already sync */ 667 /* Did already sync */
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index b0eed1faf740..74db0062d4a2 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -172,13 +172,15 @@ SECTIONS
172 . = ALIGN(4096); 172 . = ALIGN(4096);
173 __initramfs_start = .; 173 __initramfs_start = .;
174 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) } 174 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
175 __initramfs_end = .; 175 __initramfs_end = .;
176 . = ALIGN(32); 176 /* temporary here to work around NR_CPUS. If you see this comment in 2.6.17+
177 complain */
178 . = ALIGN(4096);
179 __init_end = .;
180 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
177 __per_cpu_start = .; 181 __per_cpu_start = .;
178 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) } 182 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
179 __per_cpu_end = .; 183 __per_cpu_end = .;
180 . = ALIGN(4096);
181 __init_end = .;
182 184
183 . = ALIGN(4096); 185 . = ALIGN(4096);
184 __nosave_begin = .; 186 __nosave_begin = .;
diff --git a/arch/x86_64/lib/Makefile b/arch/x86_64/lib/Makefile
index bba5db6cebd6..ccef6ae747a3 100644
--- a/arch/x86_64/lib/Makefile
+++ b/arch/x86_64/lib/Makefile
@@ -4,7 +4,7 @@
4 4
5CFLAGS_csum-partial.o := -funroll-loops 5CFLAGS_csum-partial.o := -funroll-loops
6 6
7obj-y := io.o 7obj-y := io.o iomap_copy.o
8 8
9lib-y := csum-partial.o csum-copy.o csum-wrappers.o delay.o \ 9lib-y := csum-partial.o csum-copy.o csum-wrappers.o delay.o \
10 usercopy.o getuser.o putuser.o \ 10 usercopy.o getuser.o putuser.o \
diff --git a/arch/x86_64/lib/clear_page.S b/arch/x86_64/lib/clear_page.S
index 43d9fa136180..1f81b79b796c 100644
--- a/arch/x86_64/lib/clear_page.S
+++ b/arch/x86_64/lib/clear_page.S
@@ -5,8 +5,46 @@
5 .globl clear_page 5 .globl clear_page
6 .p2align 4 6 .p2align 4
7clear_page: 7clear_page:
8 xorl %eax,%eax
9 movl $4096/64,%ecx
10 .p2align 4
11.Lloop:
12 decl %ecx
13#define PUT(x) movq %rax,x*8(%rdi)
14 movq %rax,(%rdi)
15 PUT(1)
16 PUT(2)
17 PUT(3)
18 PUT(4)
19 PUT(5)
20 PUT(6)
21 PUT(7)
22 leaq 64(%rdi),%rdi
23 jnz .Lloop
24 nop
25 ret
26clear_page_end:
27
28 /* Some CPUs run faster using the string instructions.
29 It is also a lot simpler. Use this when possible */
30
31#include <asm/cpufeature.h>
32
33 .section .altinstructions,"a"
34 .align 8
35 .quad clear_page
36 .quad clear_page_c
37 .byte X86_FEATURE_REP_GOOD
38 .byte clear_page_end-clear_page
39 .byte clear_page_c_end-clear_page_c
40 .previous
41
42 .section .altinstr_replacement,"ax"
43clear_page_c:
8 movl $4096/8,%ecx 44 movl $4096/8,%ecx
9 xorl %eax,%eax 45 xorl %eax,%eax
10 rep 46 rep
11 stosq 47 stosq
12 ret 48 ret
49clear_page_c_end:
50 .previous
diff --git a/arch/x86_64/lib/copy_page.S b/arch/x86_64/lib/copy_page.S
index 621a19769406..8fa19d96a7ee 100644
--- a/arch/x86_64/lib/copy_page.S
+++ b/arch/x86_64/lib/copy_page.S
@@ -8,7 +8,94 @@
8 .globl copy_page 8 .globl copy_page
9 .p2align 4 9 .p2align 4
10copy_page: 10copy_page:
11 subq $3*8,%rsp
12 movq %rbx,(%rsp)
13 movq %r12,1*8(%rsp)
14 movq %r13,2*8(%rsp)
15
16 movl $(4096/64)-5,%ecx
17 .p2align 4
18.Loop64:
19 dec %rcx
20
21 movq (%rsi), %rax
22 movq 8 (%rsi), %rbx
23 movq 16 (%rsi), %rdx
24 movq 24 (%rsi), %r8
25 movq 32 (%rsi), %r9
26 movq 40 (%rsi), %r10
27 movq 48 (%rsi), %r11
28 movq 56 (%rsi), %r12
29
30 prefetcht0 5*64(%rsi)
31
32 movq %rax, (%rdi)
33 movq %rbx, 8 (%rdi)
34 movq %rdx, 16 (%rdi)
35 movq %r8, 24 (%rdi)
36 movq %r9, 32 (%rdi)
37 movq %r10, 40 (%rdi)
38 movq %r11, 48 (%rdi)
39 movq %r12, 56 (%rdi)
40
41 leaq 64 (%rsi), %rsi
42 leaq 64 (%rdi), %rdi
43
44 jnz .Loop64
45
46 movl $5,%ecx
47 .p2align 4
48.Loop2:
49 decl %ecx
50
51 movq (%rsi), %rax
52 movq 8 (%rsi), %rbx
53 movq 16 (%rsi), %rdx
54 movq 24 (%rsi), %r8
55 movq 32 (%rsi), %r9
56 movq 40 (%rsi), %r10
57 movq 48 (%rsi), %r11
58 movq 56 (%rsi), %r12
59
60 movq %rax, (%rdi)
61 movq %rbx, 8 (%rdi)
62 movq %rdx, 16 (%rdi)
63 movq %r8, 24 (%rdi)
64 movq %r9, 32 (%rdi)
65 movq %r10, 40 (%rdi)
66 movq %r11, 48 (%rdi)
67 movq %r12, 56 (%rdi)
68
69 leaq 64(%rdi),%rdi
70 leaq 64(%rsi),%rsi
71
72 jnz .Loop2
73
74 movq (%rsp),%rbx
75 movq 1*8(%rsp),%r12
76 movq 2*8(%rsp),%r13
77 addq $3*8,%rsp
78 ret
79
80 /* Some CPUs run faster using the string copy instructions.
81 It is also a lot simpler. Use this when possible */
82
83#include <asm/cpufeature.h>
84
85 .section .altinstructions,"a"
86 .align 8
87 .quad copy_page
88 .quad copy_page_c
89 .byte X86_FEATURE_REP_GOOD
90 .byte copy_page_c_end-copy_page_c
91 .byte copy_page_c_end-copy_page_c
92 .previous
93
94 .section .altinstr_replacement,"ax"
95copy_page_c:
11 movl $4096/8,%ecx 96 movl $4096/8,%ecx
12 rep 97 rep
13 movsq 98 movsq
14 ret 99 ret
100copy_page_c_end:
101 .previous
diff --git a/arch/x86_64/lib/copy_user.S b/arch/x86_64/lib/copy_user.S
index 79422b6559c3..f64569b83b54 100644
--- a/arch/x86_64/lib/copy_user.S
+++ b/arch/x86_64/lib/copy_user.S
@@ -4,9 +4,12 @@
4 * Functions to copy from and to user space. 4 * Functions to copy from and to user space.
5 */ 5 */
6 6
7#define FIX_ALIGNMENT 1
8
7 #include <asm/current.h> 9 #include <asm/current.h>
8 #include <asm/asm-offsets.h> 10 #include <asm/asm-offsets.h>
9 #include <asm/thread_info.h> 11 #include <asm/thread_info.h>
12 #include <asm/cpufeature.h>
10 13
11/* Standard copy_to_user with segment limit checking */ 14/* Standard copy_to_user with segment limit checking */
12 .globl copy_to_user 15 .globl copy_to_user
@@ -18,7 +21,23 @@ copy_to_user:
18 jc bad_to_user 21 jc bad_to_user
19 cmpq threadinfo_addr_limit(%rax),%rcx 22 cmpq threadinfo_addr_limit(%rax),%rcx
20 jae bad_to_user 23 jae bad_to_user
21 jmp copy_user_generic 242:
25 .byte 0xe9 /* 32bit jump */
26 .long .Lcug-1f
271:
28
29 .section .altinstr_replacement,"ax"
303: .byte 0xe9 /* replacement jmp with 8 bit immediate */
31 .long copy_user_generic_c-1b /* offset */
32 .previous
33 .section .altinstructions,"a"
34 .align 8
35 .quad 2b
36 .quad 3b
37 .byte X86_FEATURE_REP_GOOD
38 .byte 5
39 .byte 5
40 .previous
22 41
23/* Standard copy_from_user with segment limit checking */ 42/* Standard copy_from_user with segment limit checking */
24 .globl copy_from_user 43 .globl copy_from_user
@@ -53,44 +72,230 @@ bad_to_user:
53 * rsi source 72 * rsi source
54 * rdx count 73 * rdx count
55 * 74 *
56 * Only 4GB of copy is supported. This shouldn't be a problem
57 * because the kernel normally only writes from/to page sized chunks
58 * even if user space passed a longer buffer.
59 * And more would be dangerous because both Intel and AMD have
60 * errata with rep movsq > 4GB. If someone feels the need to fix
61 * this please consider this.
62 *
63 * Output: 75 * Output:
64 * eax uncopied bytes or 0 if successful. 76 * eax uncopied bytes or 0 if successful.
65 */ 77 */
66
67 .globl copy_user_generic 78 .globl copy_user_generic
79 .p2align 4
68copy_user_generic: 80copy_user_generic:
81 .byte 0x66,0x66,0x90 /* 5 byte nop for replacement jump */
82 .byte 0x66,0x90
831:
84 .section .altinstr_replacement,"ax"
852: .byte 0xe9 /* near jump with 32bit immediate */
86 .long copy_user_generic_c-1b /* offset */
87 .previous
88 .section .altinstructions,"a"
89 .align 8
90 .quad copy_user_generic
91 .quad 2b
92 .byte X86_FEATURE_REP_GOOD
93 .byte 5
94 .byte 5
95 .previous
96.Lcug:
97 pushq %rbx
98 xorl %eax,%eax /*zero for the exception handler */
99
100#ifdef FIX_ALIGNMENT
101 /* check for bad alignment of destination */
102 movl %edi,%ecx
103 andl $7,%ecx
104 jnz .Lbad_alignment
105.Lafter_bad_alignment:
106#endif
107
108 movq %rdx,%rcx
109
110 movl $64,%ebx
111 shrq $6,%rdx
112 decq %rdx
113 js .Lhandle_tail
114
115 .p2align 4
116.Lloop:
117.Ls1: movq (%rsi),%r11
118.Ls2: movq 1*8(%rsi),%r8
119.Ls3: movq 2*8(%rsi),%r9
120.Ls4: movq 3*8(%rsi),%r10
121.Ld1: movq %r11,(%rdi)
122.Ld2: movq %r8,1*8(%rdi)
123.Ld3: movq %r9,2*8(%rdi)
124.Ld4: movq %r10,3*8(%rdi)
125
126.Ls5: movq 4*8(%rsi),%r11
127.Ls6: movq 5*8(%rsi),%r8
128.Ls7: movq 6*8(%rsi),%r9
129.Ls8: movq 7*8(%rsi),%r10
130.Ld5: movq %r11,4*8(%rdi)
131.Ld6: movq %r8,5*8(%rdi)
132.Ld7: movq %r9,6*8(%rdi)
133.Ld8: movq %r10,7*8(%rdi)
134
135 decq %rdx
136
137 leaq 64(%rsi),%rsi
138 leaq 64(%rdi),%rdi
139
140 jns .Lloop
141
142 .p2align 4
143.Lhandle_tail:
144 movl %ecx,%edx
145 andl $63,%ecx
146 shrl $3,%ecx
147 jz .Lhandle_7
148 movl $8,%ebx
149 .p2align 4
150.Lloop_8:
151.Ls9: movq (%rsi),%r8
152.Ld9: movq %r8,(%rdi)
153 decl %ecx
154 leaq 8(%rdi),%rdi
155 leaq 8(%rsi),%rsi
156 jnz .Lloop_8
157
158.Lhandle_7:
159 movl %edx,%ecx
160 andl $7,%ecx
161 jz .Lende
162 .p2align 4
163.Lloop_1:
164.Ls10: movb (%rsi),%bl
165.Ld10: movb %bl,(%rdi)
166 incq %rdi
167 incq %rsi
168 decl %ecx
169 jnz .Lloop_1
170
171.Lende:
172 popq %rbx
173 ret
174
175#ifdef FIX_ALIGNMENT
176 /* align destination */
177 .p2align 4
178.Lbad_alignment:
179 movl $8,%r9d
180 subl %ecx,%r9d
181 movl %r9d,%ecx
182 cmpq %r9,%rdx
183 jz .Lhandle_7
184 js .Lhandle_7
185.Lalign_1:
186.Ls11: movb (%rsi),%bl
187.Ld11: movb %bl,(%rdi)
188 incq %rsi
189 incq %rdi
190 decl %ecx
191 jnz .Lalign_1
192 subq %r9,%rdx
193 jmp .Lafter_bad_alignment
194#endif
195
196 /* table sorted by exception address */
197 .section __ex_table,"a"
198 .align 8
199 .quad .Ls1,.Ls1e
200 .quad .Ls2,.Ls2e
201 .quad .Ls3,.Ls3e
202 .quad .Ls4,.Ls4e
203 .quad .Ld1,.Ls1e
204 .quad .Ld2,.Ls2e
205 .quad .Ld3,.Ls3e
206 .quad .Ld4,.Ls4e
207 .quad .Ls5,.Ls5e
208 .quad .Ls6,.Ls6e
209 .quad .Ls7,.Ls7e
210 .quad .Ls8,.Ls8e
211 .quad .Ld5,.Ls5e
212 .quad .Ld6,.Ls6e
213 .quad .Ld7,.Ls7e
214 .quad .Ld8,.Ls8e
215 .quad .Ls9,.Le_quad
216 .quad .Ld9,.Le_quad
217 .quad .Ls10,.Le_byte
218 .quad .Ld10,.Le_byte
219#ifdef FIX_ALIGNMENT
220 .quad .Ls11,.Lzero_rest
221 .quad .Ld11,.Lzero_rest
222#endif
223 .quad .Le5,.Le_zero
224 .previous
225
226 /* compute 64-offset for main loop. 8 bytes accuracy with error on the
227 pessimistic side. this is gross. it would be better to fix the
228 interface. */
229 /* eax: zero, ebx: 64 */
230.Ls1e: addl $8,%eax
231.Ls2e: addl $8,%eax
232.Ls3e: addl $8,%eax
233.Ls4e: addl $8,%eax
234.Ls5e: addl $8,%eax
235.Ls6e: addl $8,%eax
236.Ls7e: addl $8,%eax
237.Ls8e: addl $8,%eax
238 addq %rbx,%rdi /* +64 */
239 subq %rax,%rdi /* correct destination with computed offset */
240
241 shlq $6,%rdx /* loop counter * 64 (stride length) */
242 addq %rax,%rdx /* add offset to loopcnt */
243 andl $63,%ecx /* remaining bytes */
244 addq %rcx,%rdx /* add them */
245 jmp .Lzero_rest
246
247 /* exception on quad word loop in tail handling */
248 /* ecx: loopcnt/8, %edx: length, rdi: correct */
249.Le_quad:
250 shll $3,%ecx
251 andl $7,%edx
252 addl %ecx,%edx
253 /* edx: bytes to zero, rdi: dest, eax:zero */
254.Lzero_rest:
255 movq %rdx,%rcx
256.Le_byte:
257 xorl %eax,%eax
258.Le5: rep
259 stosb
260 /* when there is another exception while zeroing the rest just return */
261.Le_zero:
262 movq %rdx,%rax
263 jmp .Lende
264
265 /* Some CPUs run faster using the string copy instructions.
266 This is also a lot simpler. Use them when possible.
267 Patch in jmps to this code instead of copying it fully
268 to avoid unwanted aliasing in the exception tables. */
269
270 /* rdi destination
271 * rsi source
272 * rdx count
273 *
274 * Output:
275 * eax uncopied bytes or 0 if successfull.
276 *
277 * Only 4GB of copy is supported. This shouldn't be a problem
278 * because the kernel normally only writes from/to page sized chunks
279 * even if user space passed a longer buffer.
280 * And more would be dangerous because both Intel and AMD have
281 * errata with rep movsq > 4GB. If someone feels the need to fix
282 * this please consider this.
283 */
284copy_user_generic_c:
69 movl %edx,%ecx 285 movl %edx,%ecx
70 shrl $3,%ecx 286 shrl $3,%ecx
71 andl $7,%edx 287 andl $7,%edx
72 jz 5f
731: rep 2881: rep
74 movsq 289 movsq
75 movl %edx,%ecx 290 movl %edx,%ecx
76 xor %eax,%eax
772: rep 2912: rep
78 movsb 292 movsb
2934: movl %ecx,%eax
79 ret 294 ret
80 /* align here? */
815: xorl %eax,%eax
826: rep movsq
83 ret
84
85 .section .fixup,"ax"
863: lea (%rdx,%rcx,8),%rax 2953: lea (%rdx,%rcx,8),%rax
87 ret 296 ret
884: movl %ecx,%eax
89 ret
90 .previous
91 297
92 .section __ex_table,"a" 298 .section __ex_table,"a"
93 .quad 1b,3b 299 .quad 1b,3b
94 .quad 2b,4b 300 .quad 2b,4b
95 .quad 6b,4b
96 .previous 301 .previous
diff --git a/arch/x86_64/lib/iomap_copy.S b/arch/x86_64/lib/iomap_copy.S
new file mode 100644
index 000000000000..8bbade5fea05
--- /dev/null
+++ b/arch/x86_64/lib/iomap_copy.S
@@ -0,0 +1,26 @@
1/*
2 * Copyright 2006 PathScale, Inc. All Rights Reserved.
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18/*
19 * override generic version in lib/iomap_copy.c
20 */
21 .globl __iowrite32_copy
22 .p2align 4
23__iowrite32_copy:
24 movl %edx,%ecx
25 rep movsd
26 ret
diff --git a/arch/x86_64/lib/memcpy.S b/arch/x86_64/lib/memcpy.S
index 92dd80544602..5554948b5554 100644
--- a/arch/x86_64/lib/memcpy.S
+++ b/arch/x86_64/lib/memcpy.S
@@ -11,8 +11,6 @@
11 * 11 *
12 * Output: 12 * Output:
13 * rax original destination 13 * rax original destination
14 *
15 * TODO: check best memcpy for PSC
16 */ 14 */
17 15
18 .globl __memcpy 16 .globl __memcpy
@@ -20,6 +18,95 @@
20 .p2align 4 18 .p2align 4
21__memcpy: 19__memcpy:
22memcpy: 20memcpy:
21 pushq %rbx
22 movq %rdi,%rax
23
24 movl %edx,%ecx
25 shrl $6,%ecx
26 jz .Lhandle_tail
27
28 .p2align 4
29.Lloop_64:
30 decl %ecx
31
32 movq (%rsi),%r11
33 movq 8(%rsi),%r8
34
35 movq %r11,(%rdi)
36 movq %r8,1*8(%rdi)
37
38 movq 2*8(%rsi),%r9
39 movq 3*8(%rsi),%r10
40
41 movq %r9,2*8(%rdi)
42 movq %r10,3*8(%rdi)
43
44 movq 4*8(%rsi),%r11
45 movq 5*8(%rsi),%r8
46
47 movq %r11,4*8(%rdi)
48 movq %r8,5*8(%rdi)
49
50 movq 6*8(%rsi),%r9
51 movq 7*8(%rsi),%r10
52
53 movq %r9,6*8(%rdi)
54 movq %r10,7*8(%rdi)
55
56 leaq 64(%rsi),%rsi
57 leaq 64(%rdi),%rdi
58 jnz .Lloop_64
59
60.Lhandle_tail:
61 movl %edx,%ecx
62 andl $63,%ecx
63 shrl $3,%ecx
64 jz .Lhandle_7
65 .p2align 4
66.Lloop_8:
67 decl %ecx
68 movq (%rsi),%r8
69 movq %r8,(%rdi)
70 leaq 8(%rdi),%rdi
71 leaq 8(%rsi),%rsi
72 jnz .Lloop_8
73
74.Lhandle_7:
75 movl %edx,%ecx
76 andl $7,%ecx
77 jz .Lende
78 .p2align 4
79.Lloop_1:
80 movb (%rsi),%r8b
81 movb %r8b,(%rdi)
82 incq %rdi
83 incq %rsi
84 decl %ecx
85 jnz .Lloop_1
86
87.Lende:
88 popq %rbx
89 ret
90.Lfinal:
91
92 /* Some CPUs run faster using the string copy instructions.
93 It is also a lot simpler. Use this when possible */
94
95 .section .altinstructions,"a"
96 .align 8
97 .quad memcpy
98 .quad memcpy_c
99 .byte X86_FEATURE_REP_GOOD
100 .byte .Lfinal-memcpy
101 .byte memcpy_c_end-memcpy_c
102 .previous
103
104 .section .altinstr_replacement,"ax"
105 /* rdi destination
106 * rsi source
107 * rdx count
108 */
109memcpy_c:
23 movq %rdi,%rax 110 movq %rdi,%rax
24 movl %edx,%ecx 111 movl %edx,%ecx
25 shrl $3,%ecx 112 shrl $3,%ecx
@@ -30,3 +117,5 @@ memcpy:
30 rep 117 rep
31 movsb 118 movsb
32 ret 119 ret
120memcpy_c_end:
121 .previous
diff --git a/arch/x86_64/lib/memset.S b/arch/x86_64/lib/memset.S
index 2aa48f24ed1e..ad397f2c7de8 100644
--- a/arch/x86_64/lib/memset.S
+++ b/arch/x86_64/lib/memset.S
@@ -13,6 +13,98 @@
13 .p2align 4 13 .p2align 4
14memset: 14memset:
15__memset: 15__memset:
16 movq %rdi,%r10
17 movq %rdx,%r11
18
19 /* expand byte value */
20 movzbl %sil,%ecx
21 movabs $0x0101010101010101,%rax
22 mul %rcx /* with rax, clobbers rdx */
23
24 /* align dst */
25 movl %edi,%r9d
26 andl $7,%r9d
27 jnz .Lbad_alignment
28.Lafter_bad_alignment:
29
30 movl %r11d,%ecx
31 shrl $6,%ecx
32 jz .Lhandle_tail
33
34 .p2align 4
35.Lloop_64:
36 decl %ecx
37 movq %rax,(%rdi)
38 movq %rax,8(%rdi)
39 movq %rax,16(%rdi)
40 movq %rax,24(%rdi)
41 movq %rax,32(%rdi)
42 movq %rax,40(%rdi)
43 movq %rax,48(%rdi)
44 movq %rax,56(%rdi)
45 leaq 64(%rdi),%rdi
46 jnz .Lloop_64
47
48 /* Handle tail in loops. The loops should be faster than hard
49 to predict jump tables. */
50 .p2align 4
51.Lhandle_tail:
52 movl %r11d,%ecx
53 andl $63&(~7),%ecx
54 jz .Lhandle_7
55 shrl $3,%ecx
56 .p2align 4
57.Lloop_8:
58 decl %ecx
59 movq %rax,(%rdi)
60 leaq 8(%rdi),%rdi
61 jnz .Lloop_8
62
63.Lhandle_7:
64 movl %r11d,%ecx
65 andl $7,%ecx
66 jz .Lende
67 .p2align 4
68.Lloop_1:
69 decl %ecx
70 movb %al,(%rdi)
71 leaq 1(%rdi),%rdi
72 jnz .Lloop_1
73
74.Lende:
75 movq %r10,%rax
76 ret
77
78.Lbad_alignment:
79 cmpq $7,%r11
80 jbe .Lhandle_7
81 movq %rax,(%rdi) /* unaligned store */
82 movq $8,%r8
83 subq %r9,%r8
84 addq %r8,%rdi
85 subq %r8,%r11
86 jmp .Lafter_bad_alignment
87
88 /* Some CPUs run faster using the string instructions.
89 It is also a lot simpler. Use this when possible */
90
91#include <asm/cpufeature.h>
92
93 .section .altinstructions,"a"
94 .align 8
95 .quad memset
96 .quad memset_c
97 .byte X86_FEATURE_REP_GOOD
98 .byte memset_c_end-memset_c
99 .byte memset_c_end-memset_c
100 .previous
101
102 .section .altinstr_replacement,"ax"
103 /* rdi destination
104 * rsi value
105 * rdx count
106 */
107memset_c:
16 movq %rdi,%r9 108 movq %rdi,%r9
17 movl %edx,%r8d 109 movl %edx,%r8d
18 andl $7,%r8d 110 andl $7,%r8d
@@ -29,3 +121,5 @@ __memset:
29 stosb 121 stosb
30 movq %r9,%rax 122 movq %r9,%rax
31 ret 123 ret
124memset_c_end:
125 .previous
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 26eac194064b..2e7c3c8ffe03 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -33,7 +33,6 @@
33#include <asm/proto.h> 33#include <asm/proto.h>
34#include <asm/kdebug.h> 34#include <asm/kdebug.h>
35#include <asm-generic/sections.h> 35#include <asm-generic/sections.h>
36#include <asm/kdebug.h>
37 36
38/* Page fault error code bits */ 37/* Page fault error code bits */
39#define PF_PROT (1<<0) /* or no page found */ 38#define PF_PROT (1<<0) /* or no page found */
@@ -157,8 +156,8 @@ void dump_pagetable(unsigned long address)
157 156
158 pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK); 157 pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK);
159 pgd += pgd_index(address); 158 pgd += pgd_index(address);
160 printk("PGD %lx ", pgd_val(*pgd));
161 if (bad_address(pgd)) goto bad; 159 if (bad_address(pgd)) goto bad;
160 printk("PGD %lx ", pgd_val(*pgd));
162 if (!pgd_present(*pgd)) goto ret; 161 if (!pgd_present(*pgd)) goto ret;
163 162
164 pud = __pud_offset_k((pud_t *)pgd_page(*pgd), address); 163 pud = __pud_offset_k((pud_t *)pgd_page(*pgd), address);
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
index 8b7f85608fa8..cd25300726fc 100644
--- a/arch/x86_64/mm/srat.c
+++ b/arch/x86_64/mm/srat.c
@@ -26,6 +26,10 @@ static nodemask_t nodes_found __initdata;
26static struct node nodes[MAX_NUMNODES] __initdata; 26static struct node nodes[MAX_NUMNODES] __initdata;
27static u8 pxm2node[256] = { [0 ... 255] = 0xff }; 27static u8 pxm2node[256] = { [0 ... 255] = 0xff };
28 28
29/* Too small nodes confuse the VM badly. Usually they result
30 from BIOS bugs. */
31#define NODE_MIN_SIZE (4*1024*1024)
32
29static int node_to_pxm(int n); 33static int node_to_pxm(int n);
30 34
31int pxm_to_node(int pxm) 35int pxm_to_node(int pxm)
@@ -131,7 +135,12 @@ void __init
131acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa) 135acpi_numa_processor_affinity_init(struct acpi_table_processor_affinity *pa)
132{ 136{
133 int pxm, node; 137 int pxm, node;
134 if (srat_disabled() || pa->flags.enabled == 0) 138 if (srat_disabled())
139 return;
140 if (pa->header.length != sizeof(struct acpi_table_processor_affinity)) { bad_srat();
141 return;
142 }
143 if (pa->flags.enabled == 0)
135 return; 144 return;
136 pxm = pa->proximity_domain; 145 pxm = pa->proximity_domain;
137 node = setup_node(pxm); 146 node = setup_node(pxm);
@@ -155,8 +164,16 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
155 int node, pxm; 164 int node, pxm;
156 int i; 165 int i;
157 166
158 if (srat_disabled() || ma->flags.enabled == 0) 167 if (srat_disabled())
168 return;
169 if (ma->header.length != sizeof(struct acpi_table_memory_affinity)) {
170 bad_srat();
159 return; 171 return;
172 }
173 if (ma->flags.enabled == 0)
174 return;
175 start = ma->base_addr_lo | ((u64)ma->base_addr_hi << 32);
176 end = start + (ma->length_lo | ((u64)ma->length_hi << 32));
160 pxm = ma->proximity_domain; 177 pxm = ma->proximity_domain;
161 node = setup_node(pxm); 178 node = setup_node(pxm);
162 if (node < 0) { 179 if (node < 0) {
@@ -164,8 +181,6 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
164 bad_srat(); 181 bad_srat();
165 return; 182 return;
166 } 183 }
167 start = ma->base_addr_lo | ((u64)ma->base_addr_hi << 32);
168 end = start + (ma->length_lo | ((u64)ma->length_hi << 32));
169 /* It is fine to add this area to the nodes data it will be used later*/ 184 /* It is fine to add this area to the nodes data it will be used later*/
170 if (ma->flags.hot_pluggable == 1) 185 if (ma->flags.hot_pluggable == 1)
171 printk(KERN_INFO "SRAT: hot plug zone found %lx - %lx \n", 186 printk(KERN_INFO "SRAT: hot plug zone found %lx - %lx \n",
@@ -223,6 +238,16 @@ static int nodes_cover_memory(void)
223 return 1; 238 return 1;
224} 239}
225 240
241static void unparse_node(int node)
242{
243 int i;
244 node_clear(node, nodes_parsed);
245 for (i = 0; i < MAX_LOCAL_APIC; i++) {
246 if (apicid_to_node[i] == node)
247 apicid_to_node[i] = NUMA_NO_NODE;
248 }
249}
250
226void __init acpi_numa_arch_fixup(void) {} 251void __init acpi_numa_arch_fixup(void) {}
227 252
228/* Use the information discovered above to actually set up the nodes. */ 253/* Use the information discovered above to actually set up the nodes. */
@@ -230,16 +255,16 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
230{ 255{
231 int i; 256 int i;
232 257
233 if (acpi_numa <= 0)
234 return -1;
235
236 /* First clean up the node list */ 258 /* First clean up the node list */
237 for_each_node_mask(i, nodes_parsed) { 259 for (i = 0; i < MAX_NUMNODES; i++) {
238 cutoff_node(i, start, end); 260 cutoff_node(i, start, end);
239 if (nodes[i].start == nodes[i].end) 261 if ((nodes[i].end - nodes[i].start) < NODE_MIN_SIZE)
240 node_clear(i, nodes_parsed); 262 unparse_node(i);
241 } 263 }
242 264
265 if (acpi_numa <= 0)
266 return -1;
267
243 if (!nodes_cover_memory()) { 268 if (!nodes_cover_memory()) {
244 bad_srat(); 269 bad_srat();
245 return -1; 270 return -1;
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
index f16c0d57c552..b4a3fe4ec249 100644
--- a/arch/x86_64/pci/mmconfig.c
+++ b/arch/x86_64/pci/mmconfig.c
@@ -29,11 +29,8 @@ static char __iomem *get_virt(unsigned int seg, unsigned bus)
29 29
30 while (1) { 30 while (1) {
31 ++cfg_num; 31 ++cfg_num;
32 if (cfg_num >= pci_mmcfg_config_num) { 32 if (cfg_num >= pci_mmcfg_config_num)
33 /* Not found - fall back to type 1. This happens 33 break;
34 e.g. on the internal devices of a K8 northbridge. */
35 return NULL;
36 }
37 cfg = pci_mmcfg_virt[cfg_num].cfg; 34 cfg = pci_mmcfg_virt[cfg_num].cfg;
38 if (cfg->pci_segment_group_number != seg) 35 if (cfg->pci_segment_group_number != seg)
39 continue; 36 continue;
@@ -41,6 +38,18 @@ static char __iomem *get_virt(unsigned int seg, unsigned bus)
41 (cfg->end_bus_number >= bus)) 38 (cfg->end_bus_number >= bus))
42 return pci_mmcfg_virt[cfg_num].virt; 39 return pci_mmcfg_virt[cfg_num].virt;
43 } 40 }
41
42 /* Handle more broken MCFG tables on Asus etc.
43 They only contain a single entry for bus 0-0. Assume
44 this applies to all busses. */
45 cfg = &pci_mmcfg_config[0];
46 if (pci_mmcfg_config_num == 1 &&
47 cfg->pci_segment_group_number == 0 &&
48 (cfg->start_bus_number | cfg->end_bus_number) == 0)
49 return pci_mmcfg_virt[0].virt;
50
51 /* Fall back to type 0 */
52 return 0;
44} 53}
45 54
46static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn) 55static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
diff --git a/arch/xtensa/platform-iss/console.c b/arch/xtensa/platform-iss/console.c
index 4fbddf92a921..94fdfe474ac1 100644
--- a/arch/xtensa/platform-iss/console.c
+++ b/arch/xtensa/platform-iss/console.c
@@ -128,9 +128,7 @@ static void rs_poll(unsigned long priv)
128 128
129 while (__simc(SYS_select_one, 0, XTISS_SELECT_ONE_READ, (int)&tv,0,0)){ 129 while (__simc(SYS_select_one, 0, XTISS_SELECT_ONE_READ, (int)&tv,0,0)){
130 __simc (SYS_read, 0, (unsigned long)&c, 1, 0, 0); 130 __simc (SYS_read, 0, (unsigned long)&c, 1, 0, 0);
131 tty->flip.count++; 131 tty_insert_flip_char(tty, c, TTY_NORMAL);
132 *tty->flip.char_buf_ptr++ = c;
133 *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
134 i++; 132 i++;
135 } 133 }
136 134
diff --git a/block/elevator.c b/block/elevator.c
index c9f424d5399c..2fc269f69726 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -139,35 +139,16 @@ static int elevator_attach(request_queue_t *q, struct elevator_type *e,
139 139
140static char chosen_elevator[16]; 140static char chosen_elevator[16];
141 141
142static void elevator_setup_default(void) 142static int __init elevator_setup(char *str)
143{ 143{
144 struct elevator_type *e;
145
146 /*
147 * If default has not been set, use the compiled-in selection.
148 */
149 if (!chosen_elevator[0])
150 strcpy(chosen_elevator, CONFIG_DEFAULT_IOSCHED);
151
152 /* 144 /*
153 * Be backwards-compatible with previous kernels, so users 145 * Be backwards-compatible with previous kernels, so users
154 * won't get the wrong elevator. 146 * won't get the wrong elevator.
155 */ 147 */
156 if (!strcmp(chosen_elevator, "as")) 148 if (!strcmp(str, "as"))
157 strcpy(chosen_elevator, "anticipatory"); 149 strcpy(chosen_elevator, "anticipatory");
158
159 /*
160 * If the given scheduler is not available, fall back to the default
161 */
162 if ((e = elevator_find(chosen_elevator)))
163 elevator_put(e);
164 else 150 else
165 strcpy(chosen_elevator, CONFIG_DEFAULT_IOSCHED); 151 strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
166}
167
168static int __init elevator_setup(char *str)
169{
170 strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
171 return 0; 152 return 0;
172} 153}
173 154
@@ -184,14 +165,16 @@ int elevator_init(request_queue_t *q, char *name)
184 q->end_sector = 0; 165 q->end_sector = 0;
185 q->boundary_rq = NULL; 166 q->boundary_rq = NULL;
186 167
187 elevator_setup_default(); 168 if (name && !(e = elevator_get(name)))
169 return -EINVAL;
188 170
189 if (!name) 171 if (!e && *chosen_elevator && !(e = elevator_get(chosen_elevator)))
190 name = chosen_elevator; 172 printk("I/O scheduler %s not found\n", chosen_elevator);
191 173
192 e = elevator_get(name); 174 if (!e && !(e = elevator_get(CONFIG_DEFAULT_IOSCHED))) {
193 if (!e) 175 printk("Default I/O scheduler not found, using no-op\n");
194 return -EINVAL; 176 e = elevator_get("noop");
177 }
195 178
196 eq = kmalloc(sizeof(struct elevator_queue), GFP_KERNEL); 179 eq = kmalloc(sizeof(struct elevator_queue), GFP_KERNEL);
197 if (!eq) { 180 if (!eq) {
@@ -340,7 +323,8 @@ void __elv_add_request(request_queue_t *q, struct request *rq, int where,
340 /* 323 /*
341 * toggle ordered color 324 * toggle ordered color
342 */ 325 */
343 q->ordcolor ^= 1; 326 if (blk_barrier_rq(rq))
327 q->ordcolor ^= 1;
344 328
345 /* 329 /*
346 * barriers implicitly indicate back insertion 330 * barriers implicitly indicate back insertion
@@ -669,8 +653,10 @@ int elv_register(struct elevator_type *e)
669 spin_unlock_irq(&elv_list_lock); 653 spin_unlock_irq(&elv_list_lock);
670 654
671 printk(KERN_INFO "io scheduler %s registered", e->elevator_name); 655 printk(KERN_INFO "io scheduler %s registered", e->elevator_name);
672 if (!strcmp(e->elevator_name, chosen_elevator)) 656 if (!strcmp(e->elevator_name, chosen_elevator) ||
673 printk(" (default)"); 657 (!*chosen_elevator &&
658 !strcmp(e->elevator_name, CONFIG_DEFAULT_IOSCHED)))
659 printk(" (default)");
674 printk("\n"); 660 printk("\n");
675 return 0; 661 return 0;
676} 662}
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 8e27d0ab0d7c..ee5ed98db4cd 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -304,6 +304,7 @@ static inline void rq_init(request_queue_t *q, struct request *rq)
304 * blk_queue_ordered - does this queue support ordered writes 304 * blk_queue_ordered - does this queue support ordered writes
305 * @q: the request queue 305 * @q: the request queue
306 * @ordered: one of QUEUE_ORDERED_* 306 * @ordered: one of QUEUE_ORDERED_*
307 * @prepare_flush_fn: rq setup helper for cache flush ordered writes
307 * 308 *
308 * Description: 309 * Description:
309 * For journalled file systems, doing ordered writes on a commit 310 * For journalled file systems, doing ordered writes on a commit
@@ -332,6 +333,7 @@ int blk_queue_ordered(request_queue_t *q, unsigned ordered,
332 return -EINVAL; 333 return -EINVAL;
333 } 334 }
334 335
336 q->ordered = ordered;
335 q->next_ordered = ordered; 337 q->next_ordered = ordered;
336 q->prepare_flush_fn = prepare_flush_fn; 338 q->prepare_flush_fn = prepare_flush_fn;
337 339
@@ -506,7 +508,7 @@ static inline struct request *start_ordered(request_queue_t *q,
506 508
507int blk_do_ordered(request_queue_t *q, struct request **rqp) 509int blk_do_ordered(request_queue_t *q, struct request **rqp)
508{ 510{
509 struct request *rq = *rqp, *allowed_rq; 511 struct request *rq = *rqp;
510 int is_barrier = blk_fs_request(rq) && blk_barrier_rq(rq); 512 int is_barrier = blk_fs_request(rq) && blk_barrier_rq(rq);
511 513
512 if (!q->ordseq) { 514 if (!q->ordseq) {
@@ -530,32 +532,26 @@ int blk_do_ordered(request_queue_t *q, struct request **rqp)
530 } 532 }
531 } 533 }
532 534
535 /*
536 * Ordered sequence in progress
537 */
538
539 /* Special requests are not subject to ordering rules. */
540 if (!blk_fs_request(rq) &&
541 rq != &q->pre_flush_rq && rq != &q->post_flush_rq)
542 return 1;
543
533 if (q->ordered & QUEUE_ORDERED_TAG) { 544 if (q->ordered & QUEUE_ORDERED_TAG) {
545 /* Ordered by tag. Blocking the next barrier is enough. */
534 if (is_barrier && rq != &q->bar_rq) 546 if (is_barrier && rq != &q->bar_rq)
535 *rqp = NULL; 547 *rqp = NULL;
536 return 1; 548 } else {
537 } 549 /* Ordered by draining. Wait for turn. */
538 550 WARN_ON(blk_ordered_req_seq(rq) < blk_ordered_cur_seq(q));
539 switch (blk_ordered_cur_seq(q)) { 551 if (blk_ordered_req_seq(rq) > blk_ordered_cur_seq(q))
540 case QUEUE_ORDSEQ_PREFLUSH: 552 *rqp = NULL;
541 allowed_rq = &q->pre_flush_rq;
542 break;
543 case QUEUE_ORDSEQ_BAR:
544 allowed_rq = &q->bar_rq;
545 break;
546 case QUEUE_ORDSEQ_POSTFLUSH:
547 allowed_rq = &q->post_flush_rq;
548 break;
549 default:
550 allowed_rq = NULL;
551 break;
552 } 553 }
553 554
554 if (rq != allowed_rq &&
555 (blk_fs_request(rq) || rq == &q->pre_flush_rq ||
556 rq == &q->post_flush_rq))
557 *rqp = NULL;
558
559 return 1; 555 return 1;
560} 556}
561 557
@@ -662,7 +658,7 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
662 * Enables a low level driver to set an upper limit on the size of 658 * Enables a low level driver to set an upper limit on the size of
663 * received requests. 659 * received requests.
664 **/ 660 **/
665void blk_queue_max_sectors(request_queue_t *q, unsigned short max_sectors) 661void blk_queue_max_sectors(request_queue_t *q, unsigned int max_sectors)
666{ 662{
667 if ((max_sectors << 9) < PAGE_CACHE_SIZE) { 663 if ((max_sectors << 9) < PAGE_CACHE_SIZE) {
668 max_sectors = 1 << (PAGE_CACHE_SHIFT - 9); 664 max_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
@@ -2577,6 +2573,8 @@ void disk_round_stats(struct gendisk *disk)
2577 disk->stamp = now; 2573 disk->stamp = now;
2578} 2574}
2579 2575
2576EXPORT_SYMBOL_GPL(disk_round_stats);
2577
2580/* 2578/*
2581 * queue lock must be held 2579 * queue lock must be held
2582 */ 2580 */
@@ -2632,6 +2630,7 @@ EXPORT_SYMBOL(blk_put_request);
2632/** 2630/**
2633 * blk_end_sync_rq - executes a completion event on a request 2631 * blk_end_sync_rq - executes a completion event on a request
2634 * @rq: request to complete 2632 * @rq: request to complete
2633 * @error: end io status of the request
2635 */ 2634 */
2636void blk_end_sync_rq(struct request *rq, int error) 2635void blk_end_sync_rq(struct request *rq, int error)
2637{ 2636{
@@ -3153,7 +3152,7 @@ static int __end_that_request_first(struct request *req, int uptodate,
3153 if (blk_fs_request(req) && req->rq_disk) { 3152 if (blk_fs_request(req) && req->rq_disk) {
3154 const int rw = rq_data_dir(req); 3153 const int rw = rq_data_dir(req);
3155 3154
3156 __disk_stat_add(req->rq_disk, sectors[rw], nr_bytes >> 9); 3155 disk_stat_add(req->rq_disk, sectors[rw], nr_bytes >> 9);
3157 } 3156 }
3158 3157
3159 total_bytes = bio_nbytes = 0; 3158 total_bytes = bio_nbytes = 0;
@@ -3448,7 +3447,7 @@ int __init blk_dev_init(void)
3448 iocontext_cachep = kmem_cache_create("blkdev_ioc", 3447 iocontext_cachep = kmem_cache_create("blkdev_ioc",
3449 sizeof(struct io_context), 0, SLAB_PANIC, NULL, NULL); 3448 sizeof(struct io_context), 0, SLAB_PANIC, NULL, NULL);
3450 3449
3451 for (i = 0; i < NR_CPUS; i++) 3450 for_each_cpu(i)
3452 INIT_LIST_HEAD(&per_cpu(blk_cpu_done, i)); 3451 INIT_LIST_HEAD(&per_cpu(blk_cpu_done, i));
3453 3452
3454 open_softirq(BLOCK_SOFTIRQ, blk_done_softirq, NULL); 3453 open_softirq(BLOCK_SOFTIRQ, blk_done_softirq, NULL);
diff --git a/drivers/Makefile b/drivers/Makefile
index 619dd964c51c..5c69b86db624 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -69,7 +69,7 @@ obj-$(CONFIG_EISA) += eisa/
69obj-$(CONFIG_CPU_FREQ) += cpufreq/ 69obj-$(CONFIG_CPU_FREQ) += cpufreq/
70obj-$(CONFIG_MMC) += mmc/ 70obj-$(CONFIG_MMC) += mmc/
71obj-$(CONFIG_INFINIBAND) += infiniband/ 71obj-$(CONFIG_INFINIBAND) += infiniband/
72obj-$(CONFIG_SGI_IOC4) += sn/ 72obj-$(CONFIG_SGI_SN) += sn/
73obj-y += firmware/ 73obj-y += firmware/
74obj-$(CONFIG_CRYPTO) += crypto/ 74obj-$(CONFIG_CRYPTO) += crypto/
75obj-$(CONFIG_SUPERH) += sh/ 75obj-$(CONFIG_SUPERH) += sh/
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 6d61945260a8..0cce28c4025b 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -267,7 +267,6 @@ config ACPI_DEBUG
267 267
268config ACPI_EC 268config ACPI_EC
269 bool 269 bool
270 depends on X86
271 default y 270 default y
272 help 271 help
273 This driver is required on some systems for the proper operation of 272 This driver is required on some systems for the proper operation of
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 2143609d2936..d882bf87fa96 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -71,8 +71,8 @@ static struct acpi_driver acpi_memory_device_driver = {
71struct acpi_memory_device { 71struct acpi_memory_device {
72 acpi_handle handle; 72 acpi_handle handle;
73 unsigned int state; /* State of the memory device */ 73 unsigned int state; /* State of the memory device */
74 unsigned short cache_attribute; /* memory cache attribute */ 74 unsigned short caching; /* memory cache attribute */
75 unsigned short read_write_attribute; /* memory read/write attribute */ 75 unsigned short write_protect; /* memory read/write attribute */
76 u64 start_addr; /* Memory Range start physical addr */ 76 u64 start_addr; /* Memory Range start physical addr */
77 u64 end_addr; /* Memory Range end physical addr */ 77 u64 end_addr; /* Memory Range end physical addr */
78}; 78};
@@ -97,12 +97,12 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
97 if (ACPI_SUCCESS(status)) { 97 if (ACPI_SUCCESS(status)) {
98 if (address64.resource_type == ACPI_MEMORY_RANGE) { 98 if (address64.resource_type == ACPI_MEMORY_RANGE) {
99 /* Populate the structure */ 99 /* Populate the structure */
100 mem_device->cache_attribute = 100 mem_device->caching =
101 address64.attribute.memory.cache_attribute; 101 address64.info.mem.caching;
102 mem_device->read_write_attribute = 102 mem_device->write_protect =
103 address64.attribute.memory.read_write_attribute; 103 address64.info.mem.write_protect;
104 mem_device->start_addr = address64.min_address_range; 104 mem_device->start_addr = address64.minimum;
105 mem_device->end_addr = address64.max_address_range; 105 mem_device->end_addr = address64.maximum;
106 } 106 }
107 } 107 }
108 108
@@ -250,7 +250,6 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
250 int result; 250 int result;
251 u64 start = mem_device->start_addr; 251 u64 start = mem_device->start_addr;
252 u64 len = mem_device->end_addr - start + 1; 252 u64 len = mem_device->end_addr - start + 1;
253 unsigned long attr = mem_device->read_write_attribute;
254 253
255 ACPI_FUNCTION_TRACE("acpi_memory_disable_device"); 254 ACPI_FUNCTION_TRACE("acpi_memory_disable_device");
256 255
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index fec895af6ae6..f4c87750dbf2 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -78,9 +78,9 @@ MODULE_LICENSE("GPL");
78static uid_t asus_uid; 78static uid_t asus_uid;
79static gid_t asus_gid; 79static gid_t asus_gid;
80module_param(asus_uid, uint, 0); 80module_param(asus_uid, uint, 0);
81MODULE_PARM_DESC(uid, "UID for entries in /proc/acpi/asus.\n"); 81MODULE_PARM_DESC(asus_uid, "UID for entries in /proc/acpi/asus.\n");
82module_param(asus_gid, uint, 0); 82module_param(asus_gid, uint, 0);
83MODULE_PARM_DESC(gid, "GID for entries in /proc/acpi/asus.\n"); 83MODULE_PARM_DESC(asus_gid, "GID for entries in /proc/acpi/asus.\n");
84 84
85/* For each model, all features implemented, 85/* For each model, all features implemented,
86 * those marked with R are relative to HOTK, A for absolute */ 86 * those marked with R are relative to HOTK, A for absolute */
@@ -302,7 +302,7 @@ static struct model_data model_conf[END_MODEL] = {
302 .brightness_set = "SPLV", 302 .brightness_set = "SPLV",
303 .brightness_get = "GPLV", 303 .brightness_get = "GPLV",
304 .display_set = "SDSP", 304 .display_set = "SDSP",
305 .display_get = "\\SSTE"}, 305 .display_get = "\\_SB.PCI0.P0P1.VGA.GETD"},
306 { 306 {
307 .name = "M6R", 307 .name = "M6R",
308 .mt_mled = "MLED", 308 .mt_mled = "MLED",
@@ -851,6 +851,8 @@ static int __init asus_hotk_add_fs(struct acpi_device *device)
851 mode = S_IFREG | S_IRUGO | S_IWUGO; 851 mode = S_IFREG | S_IRUGO | S_IWUGO;
852 } else { 852 } else {
853 mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP; 853 mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP;
854 printk(KERN_WARNING " asus_uid and asus_gid parameters are "
855 "deprecated, use chown and chmod instead!\n");
854 } 856 }
855 857
856 acpi_device_dir(device) = asus_proc_dir; 858 acpi_device_dir(device) = asus_proc_dir;
@@ -987,9 +989,21 @@ static int __init asus_hotk_get_info(void)
987 printk(KERN_NOTICE " BSTS called, 0x%02x returned\n", 989 printk(KERN_NOTICE " BSTS called, 0x%02x returned\n",
988 bsts_result); 990 bsts_result);
989 991
990 /* Samsung P30 has a device with a valid _HID whose INIT does not 992 /* This is unlikely with implicit return */
991 * return anything. Catch this one and any similar here */ 993 if (buffer.pointer == NULL)
992 if (buffer.pointer == NULL) { 994 return -EINVAL;
995
996 model = (union acpi_object *) buffer.pointer;
997 /*
998 * Samsung P30 has a device with a valid _HID whose INIT does not
999 * return anything. It used to be possible to catch this exception,
1000 * but the implicit return code will now happily confuse the
1001 * driver. We assume that every ACPI_TYPE_STRING is a valid model
1002 * identifier but it's still possible to get completely bogus data.
1003 */
1004 if (model->type == ACPI_TYPE_STRING) {
1005 printk(KERN_NOTICE " %s model detected, ", model->string.pointer);
1006 } else {
993 if (asus_info && /* Samsung P30 */ 1007 if (asus_info && /* Samsung P30 */
994 strncmp(asus_info->oem_table_id, "ODEM", 4) == 0) { 1008 strncmp(asus_info->oem_table_id, "ODEM", 4) == 0) {
995 hotk->model = P30; 1009 hotk->model = P30;
@@ -1002,13 +1016,10 @@ static int __init asus_hotk_get_info(void)
1002 "the developers with your DSDT\n"); 1016 "the developers with your DSDT\n");
1003 } 1017 }
1004 hotk->methods = &model_conf[hotk->model]; 1018 hotk->methods = &model_conf[hotk->model];
1005 return AE_OK; 1019
1006 } 1020 acpi_os_free(model);
1007 1021
1008 model = (union acpi_object *)buffer.pointer; 1022 return AE_OK;
1009 if (model->type == ACPI_TYPE_STRING) {
1010 printk(KERN_NOTICE " %s model detected, ",
1011 model->string.pointer);
1012 } 1023 }
1013 1024
1014 hotk->model = END_MODEL; 1025 hotk->model = END_MODEL;
diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/dispatcher/dsfield.c
index 2022aeaecfbb..76bc0463f6de 100644
--- a/drivers/acpi/dispatcher/dsfield.c
+++ b/drivers/acpi/dispatcher/dsfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -128,7 +128,7 @@ acpi_ds_create_buffer_field(union acpi_parse_object *op,
128 ACPI_IMODE_LOAD_PASS1, flags, walk_state, 128 ACPI_IMODE_LOAD_PASS1, flags, walk_state,
129 &(node)); 129 &(node));
130 if (ACPI_FAILURE(status)) { 130 if (ACPI_FAILURE(status)) {
131 ACPI_REPORT_NSERROR(arg->common.value.string, status); 131 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
132 return_ACPI_STATUS(status); 132 return_ACPI_STATUS(status);
133 } 133 }
134 } 134 }
@@ -232,7 +232,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
232 + (acpi_integer) arg->common.value.size; 232 + (acpi_integer) arg->common.value.size;
233 233
234 if (position > ACPI_UINT32_MAX) { 234 if (position > ACPI_UINT32_MAX) {
235 ACPI_REPORT_ERROR(("Bit offset within field too large (> 0xFFFFFFFF)\n")); 235 ACPI_ERROR((AE_INFO,
236 "Bit offset within field too large (> 0xFFFFFFFF)"));
236 return_ACPI_STATUS(AE_SUPPORT); 237 return_ACPI_STATUS(AE_SUPPORT);
237 } 238 }
238 239
@@ -268,8 +269,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
268 ACPI_NS_DONT_OPEN_SCOPE, 269 ACPI_NS_DONT_OPEN_SCOPE,
269 walk_state, &info->field_node); 270 walk_state, &info->field_node);
270 if (ACPI_FAILURE(status)) { 271 if (ACPI_FAILURE(status)) {
271 ACPI_REPORT_NSERROR((char *)&arg->named.name, 272 ACPI_ERROR_NAMESPACE((char *)&arg->named.name,
272 status); 273 status);
273 if (status != AE_ALREADY_EXISTS) { 274 if (status != AE_ALREADY_EXISTS) {
274 return_ACPI_STATUS(status); 275 return_ACPI_STATUS(status);
275 } 276 }
@@ -293,7 +294,11 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
293 + (acpi_integer) arg->common.value.size; 294 + (acpi_integer) arg->common.value.size;
294 295
295 if (position > ACPI_UINT32_MAX) { 296 if (position > ACPI_UINT32_MAX) {
296 ACPI_REPORT_ERROR(("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", (char *)&info->field_node->name)); 297 ACPI_ERROR((AE_INFO,
298 "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
299 ACPI_CAST_PTR(char,
300 &info->field_node->
301 name)));
297 return_ACPI_STATUS(AE_SUPPORT); 302 return_ACPI_STATUS(AE_SUPPORT);
298 } 303 }
299 304
@@ -302,9 +307,9 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
302 307
303 default: 308 default:
304 309
305 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 310 ACPI_ERROR((AE_INFO,
306 "Invalid opcode in field list: %X\n", 311 "Invalid opcode in field list: %X",
307 arg->common.aml_opcode)); 312 arg->common.aml_opcode));
308 return_ACPI_STATUS(AE_AML_BAD_OPCODE); 313 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
309 } 314 }
310 315
@@ -349,7 +354,7 @@ acpi_ds_create_field(union acpi_parse_object *op,
349 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 354 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
350 walk_state, &region_node); 355 walk_state, &region_node);
351 if (ACPI_FAILURE(status)) { 356 if (ACPI_FAILURE(status)) {
352 ACPI_REPORT_NSERROR(arg->common.value.name, status); 357 ACPI_ERROR_NAMESPACE(arg->common.value.name, status);
353 return_ACPI_STATUS(status); 358 return_ACPI_STATUS(status);
354 } 359 }
355 } 360 }
@@ -431,8 +436,8 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
431 ACPI_NS_ERROR_IF_FOUND, 436 ACPI_NS_ERROR_IF_FOUND,
432 walk_state, &node); 437 walk_state, &node);
433 if (ACPI_FAILURE(status)) { 438 if (ACPI_FAILURE(status)) {
434 ACPI_REPORT_NSERROR((char *)&arg->named.name, 439 ACPI_ERROR_NAMESPACE((char *)&arg->named.name,
435 status); 440 status);
436 if (status != AE_ALREADY_EXISTS) { 441 if (status != AE_ALREADY_EXISTS) {
437 return_ACPI_STATUS(status); 442 return_ACPI_STATUS(status);
438 } 443 }
@@ -488,7 +493,7 @@ acpi_ds_create_bank_field(union acpi_parse_object *op,
488 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 493 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
489 walk_state, &region_node); 494 walk_state, &region_node);
490 if (ACPI_FAILURE(status)) { 495 if (ACPI_FAILURE(status)) {
491 ACPI_REPORT_NSERROR(arg->common.value.name, status); 496 ACPI_ERROR_NAMESPACE(arg->common.value.name, status);
492 return_ACPI_STATUS(status); 497 return_ACPI_STATUS(status);
493 } 498 }
494 } 499 }
@@ -502,7 +507,7 @@ acpi_ds_create_bank_field(union acpi_parse_object *op,
502 ACPI_NS_SEARCH_PARENT, walk_state, 507 ACPI_NS_SEARCH_PARENT, walk_state,
503 &info.register_node); 508 &info.register_node);
504 if (ACPI_FAILURE(status)) { 509 if (ACPI_FAILURE(status)) {
505 ACPI_REPORT_NSERROR(arg->common.value.string, status); 510 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
506 return_ACPI_STATUS(status); 511 return_ACPI_STATUS(status);
507 } 512 }
508 513
@@ -560,7 +565,7 @@ acpi_ds_create_index_field(union acpi_parse_object *op,
560 ACPI_NS_SEARCH_PARENT, walk_state, 565 ACPI_NS_SEARCH_PARENT, walk_state,
561 &info.register_node); 566 &info.register_node);
562 if (ACPI_FAILURE(status)) { 567 if (ACPI_FAILURE(status)) {
563 ACPI_REPORT_NSERROR(arg->common.value.string, status); 568 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
564 return_ACPI_STATUS(status); 569 return_ACPI_STATUS(status);
565 } 570 }
566 571
@@ -573,7 +578,7 @@ acpi_ds_create_index_field(union acpi_parse_object *op,
573 ACPI_NS_SEARCH_PARENT, walk_state, 578 ACPI_NS_SEARCH_PARENT, walk_state,
574 &info.data_register_node); 579 &info.data_register_node);
575 if (ACPI_FAILURE(status)) { 580 if (ACPI_FAILURE(status)) {
576 ACPI_REPORT_NSERROR(arg->common.value.string, status); 581 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
577 return_ACPI_STATUS(status); 582 return_ACPI_STATUS(status);
578 } 583 }
579 584
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c
index 8693c704aea6..e65a07ad2422 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/dispatcher/dsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -84,7 +84,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
84 acpi_object_type type; 84 acpi_object_type type;
85 acpi_status status; 85 acpi_status status;
86 86
87 ACPI_FUNCTION_NAME("ds_init_one_object"); 87 ACPI_FUNCTION_ENTRY();
88 88
89 /* 89 /*
90 * We are only interested in NS nodes owned by the table that 90 * We are only interested in NS nodes owned by the table that
@@ -105,11 +105,10 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
105 105
106 status = acpi_ds_initialize_region(obj_handle); 106 status = acpi_ds_initialize_region(obj_handle);
107 if (ACPI_FAILURE(status)) { 107 if (ACPI_FAILURE(status)) {
108 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 108 ACPI_EXCEPTION((AE_INFO, status,
109 "Region %p [%4.4s] - Init failure, %s\n", 109 "During Region initialization %p [%4.4s]",
110 obj_handle, 110 obj_handle,
111 acpi_ut_get_node_name(obj_handle), 111 acpi_ut_get_node_name(obj_handle)));
112 acpi_format_exception(status)));
113 } 112 }
114 113
115 info->op_region_count++; 114 info->op_region_count++;
@@ -118,14 +117,6 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
118 case ACPI_TYPE_METHOD: 117 case ACPI_TYPE_METHOD:
119 118
120 /* 119 /*
121 * Print a dot for each method unless we are going to print
122 * the entire pathname
123 */
124 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
125 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
126 }
127
128 /*
129 * Set the execution data width (32 or 64) based upon the 120 * Set the execution data width (32 or 64) based upon the
130 * revision number of the parent ACPI table. 121 * revision number of the parent ACPI table.
131 * TBD: This is really for possible future support of integer width 122 * TBD: This is really for possible future support of integer width
@@ -134,6 +125,21 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
134 if (info->table_desc->pointer->revision == 1) { 125 if (info->table_desc->pointer->revision == 1) {
135 node->flags |= ANOBJ_DATA_WIDTH_32; 126 node->flags |= ANOBJ_DATA_WIDTH_32;
136 } 127 }
128#ifdef ACPI_INIT_PARSE_METHODS
129 /*
130 * Note 11/2005: Removed this code to parse all methods during table
131 * load because it causes problems if there are any errors during the
132 * parse. Also, it seems like overkill and we probably don't want to
133 * abort a table load because of an issue with a single method.
134 */
135
136 /*
137 * Print a dot for each method unless we are going to print
138 * the entire pathname
139 */
140 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
141 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
142 }
137 143
138 /* 144 /*
139 * Always parse methods to detect errors, we will delete 145 * Always parse methods to detect errors, we will delete
@@ -141,15 +147,15 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
141 */ 147 */
142 status = acpi_ds_parse_method(obj_handle); 148 status = acpi_ds_parse_method(obj_handle);
143 if (ACPI_FAILURE(status)) { 149 if (ACPI_FAILURE(status)) {
144 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 150 ACPI_ERROR((AE_INFO,
145 "\n+Method %p [%4.4s] - parse failure, %s\n", 151 "Method %p [%4.4s] - parse failure, %s",
146 obj_handle, 152 obj_handle,
147 acpi_ut_get_node_name(obj_handle), 153 acpi_ut_get_node_name(obj_handle),
148 acpi_format_exception(status))); 154 acpi_format_exception(status)));
149 155
150 /* This parse failed, but we will continue parsing more methods */ 156 /* This parse failed, but we will continue parsing more methods */
151 } 157 }
152 158#endif
153 info->method_count++; 159 info->method_count++;
154 break; 160 break;
155 161
@@ -207,8 +213,7 @@ acpi_ds_initialize_objects(struct acpi_table_desc * table_desc,
207 status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, 213 status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
208 acpi_ds_init_one_object, &info, NULL); 214 acpi_ds_init_one_object, &info, NULL);
209 if (ACPI_FAILURE(status)) { 215 if (ACPI_FAILURE(status)) {
210 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed, %s\n", 216 ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace"));
211 acpi_format_exception(status)));
212 } 217 }
213 218
214 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 219 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index 36c1ca0b9adb..c475546535b6 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,135 +47,66 @@
47#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
48#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h> 49#include <acpi/acnamesp.h>
50#include <acpi/acdisasm.h>
50 51
51#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dsmethod") 53ACPI_MODULE_NAME("dsmethod")
53 54
54/******************************************************************************* 55/*******************************************************************************
55 * 56 *
56 * FUNCTION: acpi_ds_parse_method 57 * FUNCTION: acpi_ds_method_error
57 * 58 *
58 * PARAMETERS: Node - Method node 59 * PARAMETERS: Status - Execution status
60 * walk_state - Current state
59 * 61 *
60 * RETURN: Status 62 * RETURN: Status
61 * 63 *
62 * DESCRIPTION: Parse the AML that is associated with the method. 64 * DESCRIPTION: Called on method error. Invoke the global exception handler if
65 * present, dump the method data if the disassembler is configured
63 * 66 *
64 * MUTEX: Assumes parser is locked 67 * Note: Allows the exception handler to change the status code
65 * 68 *
66 ******************************************************************************/ 69 ******************************************************************************/
67acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node) 70acpi_status
71acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
68{ 72{
69 acpi_status status; 73 ACPI_FUNCTION_ENTRY();
70 union acpi_operand_object *obj_desc;
71 union acpi_parse_object *op;
72 struct acpi_walk_state *walk_state;
73
74 ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node);
75 74
76 /* Parameter Validation */ 75 /* Ignore AE_OK and control exception codes */
77 76
78 if (!node) { 77 if (ACPI_SUCCESS(status) || (status & AE_CODE_CONTROL)) {
79 return_ACPI_STATUS(AE_NULL_ENTRY); 78 return (status);
80 } 79 }
81 80
82 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 81 /* Invoke the global exception handler */
83 "**** Parsing [%4.4s] **** named_obj=%p\n",
84 acpi_ut_get_node_name(node), node));
85
86 /* Extract the method object from the method Node */
87 82
88 obj_desc = acpi_ns_get_attached_object(node); 83 if (acpi_gbl_exception_handler) {
89 if (!obj_desc) { 84 /* Exit the interpreter, allow handler to execute methods */
90 return_ACPI_STATUS(AE_NULL_OBJECT);
91 }
92 85
93 /* Create a mutex for the method if there is a concurrency limit */ 86 acpi_ex_exit_interpreter();
94 87
95 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) && 88 /*
96 (!obj_desc->method.semaphore)) { 89 * Handler can map the exception code to anything it wants, including
97 status = acpi_os_create_semaphore(obj_desc->method.concurrency, 90 * AE_OK, in which case the executing method will not be aborted.
98 obj_desc->method.concurrency, 91 */
99 &obj_desc->method.semaphore); 92 status = acpi_gbl_exception_handler(status,
100 if (ACPI_FAILURE(status)) { 93 walk_state->method_node ?
101 return_ACPI_STATUS(status); 94 walk_state->method_node->
102 } 95 name.integer : 0,
103 } 96 walk_state->opcode,
104 97 walk_state->aml_offset,
105 /* 98 NULL);
106 * Allocate a new parser op to be the root of the parsed 99 (void)acpi_ex_enter_interpreter();
107 * method tree
108 */
109 op = acpi_ps_alloc_op(AML_METHOD_OP);
110 if (!op) {
111 return_ACPI_STATUS(AE_NO_MEMORY);
112 }
113
114 /* Init new op with the method name and pointer back to the Node */
115
116 acpi_ps_set_name(op, node->name.integer);
117 op->common.node = node;
118
119 /*
120 * Get a new owner_id for objects created by this method. Namespace
121 * objects (such as Operation Regions) can be created during the
122 * first pass parse.
123 */
124 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
125 if (ACPI_FAILURE(status)) {
126 goto cleanup;
127 }
128
129 /* Create and initialize a new walk state */
130
131 walk_state =
132 acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
133 NULL);
134 if (!walk_state) {
135 status = AE_NO_MEMORY;
136 goto cleanup2;
137 } 100 }
138 101#ifdef ACPI_DISASSEMBLER
139 status = acpi_ds_init_aml_walk(walk_state, op, node,
140 obj_desc->method.aml_start,
141 obj_desc->method.aml_length, NULL, 1);
142 if (ACPI_FAILURE(status)) { 102 if (ACPI_FAILURE(status)) {
143 acpi_ds_delete_walk_state(walk_state); 103 /* Display method locals/args if disassembler is present */
144 goto cleanup2;
145 }
146 104
147 /* 105 acpi_dm_dump_method_info(status, walk_state, walk_state->op);
148 * Parse the method, first pass
149 *
150 * The first pass load is where newly declared named objects are added into
151 * the namespace. Actual evaluation of the named objects (what would be
152 * called a "second pass") happens during the actual execution of the
153 * method so that operands to the named objects can take on dynamic
154 * run-time values.
155 */
156 status = acpi_ps_parse_aml(walk_state);
157 if (ACPI_FAILURE(status)) {
158 goto cleanup2;
159 } 106 }
107#endif
160 108
161 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 109 return (status);
162 "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
163 acpi_ut_get_node_name(node), node, op));
164
165 /*
166 * Delete the parse tree. We simply re-parse the method for every
167 * execution since there isn't much overhead (compared to keeping lots
168 * of parse trees around)
169 */
170 acpi_ns_delete_namespace_subtree(node);
171 acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
172
173 cleanup2:
174 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
175
176 cleanup:
177 acpi_ps_delete_parse_tree(op);
178 return_ACPI_STATUS(status);
179} 110}
180 111
181/******************************************************************************* 112/*******************************************************************************
@@ -195,9 +126,9 @@ acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
195 ******************************************************************************/ 126 ******************************************************************************/
196 127
197acpi_status 128acpi_status
198acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, 129acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node,
199 union acpi_operand_object *obj_desc, 130 union acpi_operand_object * obj_desc,
200 struct acpi_namespace_node *calling_method_node) 131 struct acpi_namespace_node * calling_method_node)
201{ 132{
202 acpi_status status = AE_OK; 133 acpi_status status = AE_OK;
203 134
@@ -210,7 +141,8 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
210 /* Prevent wraparound of thread count */ 141 /* Prevent wraparound of thread count */
211 142
212 if (obj_desc->method.thread_count == ACPI_UINT8_MAX) { 143 if (obj_desc->method.thread_count == ACPI_UINT8_MAX) {
213 ACPI_REPORT_ERROR(("Method reached maximum reentrancy limit (255)\n")); 144 ACPI_ERROR((AE_INFO,
145 "Method reached maximum reentrancy limit (255)"));
214 return_ACPI_STATUS(AE_AML_METHOD_LIMIT); 146 return_ACPI_STATUS(AE_AML_METHOD_LIMIT);
215 } 147 }
216 148
@@ -539,22 +471,61 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state)
539 acpi_os_signal_semaphore(walk_state->method_desc->method. 471 acpi_os_signal_semaphore(walk_state->method_desc->method.
540 semaphore, 1); 472 semaphore, 1);
541 if (ACPI_FAILURE(status)) { 473 if (ACPI_FAILURE(status)) {
542 ACPI_REPORT_ERROR(("Could not signal method semaphore\n")); 474 ACPI_ERROR((AE_INFO,
475 "Could not signal method semaphore"));
543 476
544 /* Ignore error and continue cleanup */ 477 /* Ignore error and continue cleanup */
545 } 478 }
546 } 479 }
547 480
481 /*
482 * There are no more threads executing this method. Perform
483 * additional cleanup.
484 *
485 * The method Node is stored in the walk state
486 */
487 method_node = walk_state->method_node;
488
489 /* Lock namespace for possible update */
490
491 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
492 if (ACPI_FAILURE(status)) {
493 goto exit;
494 }
495
496 /*
497 * Delete any namespace entries created immediately underneath
498 * the method
499 */
500 if (method_node->child) {
501 acpi_ns_delete_namespace_subtree(method_node);
502 }
503
504 /*
505 * Delete any namespace entries created anywhere else within
506 * the namespace by the execution of this method
507 */
508 acpi_ns_delete_namespace_by_owner(walk_state->method_desc->method.
509 owner_id);
510 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
511
512 /* Are there any other threads currently executing this method? */
513
548 if (walk_state->method_desc->method.thread_count) { 514 if (walk_state->method_desc->method.thread_count) {
515 /*
516 * Additional threads. Do not release the owner_id in this case,
517 * we immediately reuse it for the next thread executing this method
518 */
549 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 519 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
550 "*** Not deleting method namespace, there are still %d threads\n", 520 "*** Completed execution of one thread, %d threads remaining\n",
551 walk_state->method_desc->method. 521 walk_state->method_desc->method.
552 thread_count)); 522 thread_count));
553 } else { /* This is the last executing thread */ 523 } else {
524 /* This is the only executing thread for this method */
554 525
555 /* 526 /*
556 * Support to dynamically change a method from not_serialized to 527 * Support to dynamically change a method from not_serialized to
557 * Serialized if it appears that the method is written foolishly and 528 * Serialized if it appears that the method is incorrectly written and
558 * does not support multiple thread execution. The best example of this 529 * does not support multiple thread execution. The best example of this
559 * is if such a method creates namespace objects and blocks. A second 530 * is if such a method creates namespace objects and blocks. A second
560 * thread will fail with an AE_ALREADY_EXISTS exception 531 * thread will fail with an AE_ALREADY_EXISTS exception
@@ -570,34 +541,8 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state)
570 semaphore); 541 semaphore);
571 } 542 }
572 543
573 /* 544 /* No more threads, we can free the owner_id */
574 * There are no more threads executing this method. Perform
575 * additional cleanup.
576 *
577 * The method Node is stored in the walk state
578 */
579 method_node = walk_state->method_node;
580
581 /*
582 * Delete any namespace entries created immediately underneath
583 * the method
584 */
585 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
586 if (ACPI_FAILURE(status)) {
587 goto exit;
588 }
589
590 if (method_node->child) {
591 acpi_ns_delete_namespace_subtree(method_node);
592 }
593 545
594 /*
595 * Delete any namespace entries created anywhere else within
596 * the namespace
597 */
598 acpi_ns_delete_namespace_by_owner(walk_state->method_desc->
599 method.owner_id);
600 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
601 acpi_ut_release_owner_id(&walk_state->method_desc->method. 546 acpi_ut_release_owner_id(&walk_state->method_desc->method.
602 owner_id); 547 owner_id);
603 } 548 }
@@ -606,3 +551,140 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state)
606 (void)acpi_ut_release_mutex(ACPI_MTX_PARSER); 551 (void)acpi_ut_release_mutex(ACPI_MTX_PARSER);
607 return_VOID; 552 return_VOID;
608} 553}
554
555#ifdef ACPI_INIT_PARSE_METHODS
556 /*
557 * Note 11/2005: Removed this code to parse all methods during table
558 * load because it causes problems if there are any errors during the
559 * parse. Also, it seems like overkill and we probably don't want to
560 * abort a table load because of an issue with a single method.
561 */
562
563/*******************************************************************************
564 *
565 * FUNCTION: acpi_ds_parse_method
566 *
567 * PARAMETERS: Node - Method node
568 *
569 * RETURN: Status
570 *
571 * DESCRIPTION: Parse the AML that is associated with the method.
572 *
573 * MUTEX: Assumes parser is locked
574 *
575 ******************************************************************************/
576
577acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
578{
579 acpi_status status;
580 union acpi_operand_object *obj_desc;
581 union acpi_parse_object *op;
582 struct acpi_walk_state *walk_state;
583
584 ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node);
585
586 /* Parameter Validation */
587
588 if (!node) {
589 return_ACPI_STATUS(AE_NULL_ENTRY);
590 }
591
592 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
593 "**** Parsing [%4.4s] **** named_obj=%p\n",
594 acpi_ut_get_node_name(node), node));
595
596 /* Extract the method object from the method Node */
597
598 obj_desc = acpi_ns_get_attached_object(node);
599 if (!obj_desc) {
600 return_ACPI_STATUS(AE_NULL_OBJECT);
601 }
602
603 /* Create a mutex for the method if there is a concurrency limit */
604
605 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) &&
606 (!obj_desc->method.semaphore)) {
607 status = acpi_os_create_semaphore(obj_desc->method.concurrency,
608 obj_desc->method.concurrency,
609 &obj_desc->method.semaphore);
610 if (ACPI_FAILURE(status)) {
611 return_ACPI_STATUS(status);
612 }
613 }
614
615 /*
616 * Allocate a new parser op to be the root of the parsed
617 * method tree
618 */
619 op = acpi_ps_alloc_op(AML_METHOD_OP);
620 if (!op) {
621 return_ACPI_STATUS(AE_NO_MEMORY);
622 }
623
624 /* Init new op with the method name and pointer back to the Node */
625
626 acpi_ps_set_name(op, node->name.integer);
627 op->common.node = node;
628
629 /*
630 * Get a new owner_id for objects created by this method. Namespace
631 * objects (such as Operation Regions) can be created during the
632 * first pass parse.
633 */
634 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
635 if (ACPI_FAILURE(status)) {
636 goto cleanup;
637 }
638
639 /* Create and initialize a new walk state */
640
641 walk_state =
642 acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
643 NULL);
644 if (!walk_state) {
645 status = AE_NO_MEMORY;
646 goto cleanup2;
647 }
648
649 status = acpi_ds_init_aml_walk(walk_state, op, node,
650 obj_desc->method.aml_start,
651 obj_desc->method.aml_length, NULL, 1);
652 if (ACPI_FAILURE(status)) {
653 acpi_ds_delete_walk_state(walk_state);
654 goto cleanup2;
655 }
656
657 /*
658 * Parse the method, first pass
659 *
660 * The first pass load is where newly declared named objects are added into
661 * the namespace. Actual evaluation of the named objects (what would be
662 * called a "second pass") happens during the actual execution of the
663 * method so that operands to the named objects can take on dynamic
664 * run-time values.
665 */
666 status = acpi_ps_parse_aml(walk_state);
667 if (ACPI_FAILURE(status)) {
668 goto cleanup2;
669 }
670
671 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
672 "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n",
673 acpi_ut_get_node_name(node), node, op));
674
675 /*
676 * Delete the parse tree. We simply re-parse the method for every
677 * execution since there isn't much overhead (compared to keeping lots
678 * of parse trees around)
679 */
680 acpi_ns_delete_namespace_subtree(node);
681 acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
682
683 cleanup2:
684 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
685
686 cleanup:
687 acpi_ps_delete_parse_tree(op);
688 return_ACPI_STATUS(status);
689}
690#endif
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
index 4095ce70982b..c025674f938b 100644
--- a/drivers/acpi/dispatcher/dsmthdat.c
+++ b/drivers/acpi/dispatcher/dsmthdat.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -260,9 +260,9 @@ acpi_ds_method_data_get_node(u16 opcode,
260 case AML_LOCAL_OP: 260 case AML_LOCAL_OP:
261 261
262 if (index > ACPI_METHOD_MAX_LOCAL) { 262 if (index > ACPI_METHOD_MAX_LOCAL) {
263 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 263 ACPI_ERROR((AE_INFO,
264 "Local index %d is invalid (max %d)\n", 264 "Local index %d is invalid (max %d)",
265 index, ACPI_METHOD_MAX_LOCAL)); 265 index, ACPI_METHOD_MAX_LOCAL));
266 return_ACPI_STATUS(AE_AML_INVALID_INDEX); 266 return_ACPI_STATUS(AE_AML_INVALID_INDEX);
267 } 267 }
268 268
@@ -274,9 +274,9 @@ acpi_ds_method_data_get_node(u16 opcode,
274 case AML_ARG_OP: 274 case AML_ARG_OP:
275 275
276 if (index > ACPI_METHOD_MAX_ARG) { 276 if (index > ACPI_METHOD_MAX_ARG) {
277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 277 ACPI_ERROR((AE_INFO,
278 "Arg index %d is invalid (max %d)\n", 278 "Arg index %d is invalid (max %d)",
279 index, ACPI_METHOD_MAX_ARG)); 279 index, ACPI_METHOD_MAX_ARG));
280 return_ACPI_STATUS(AE_AML_INVALID_INDEX); 280 return_ACPI_STATUS(AE_AML_INVALID_INDEX);
281 } 281 }
282 282
@@ -286,8 +286,7 @@ acpi_ds_method_data_get_node(u16 opcode,
286 break; 286 break;
287 287
288 default: 288 default:
289 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Opcode %d is invalid\n", 289 ACPI_ERROR((AE_INFO, "Opcode %d is invalid", opcode));
290 opcode));
291 return_ACPI_STATUS(AE_AML_BAD_OPCODE); 290 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
292 } 291 }
293 292
@@ -378,8 +377,7 @@ acpi_ds_method_data_get_value(u16 opcode,
378 /* Validate the object descriptor */ 377 /* Validate the object descriptor */
379 378
380 if (!dest_desc) { 379 if (!dest_desc) {
381 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 380 ACPI_ERROR((AE_INFO, "Null object descriptor pointer"));
382 "Null object descriptor pointer\n"));
383 return_ACPI_STATUS(AE_BAD_PARAMETER); 381 return_ACPI_STATUS(AE_BAD_PARAMETER);
384 } 382 }
385 383
@@ -424,23 +422,24 @@ acpi_ds_method_data_get_value(u16 opcode,
424 switch (opcode) { 422 switch (opcode) {
425 case AML_ARG_OP: 423 case AML_ARG_OP:
426 424
427 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 425 ACPI_ERROR((AE_INFO,
428 "Uninitialized Arg[%d] at node %p\n", 426 "Uninitialized Arg[%d] at node %p",
429 index, node)); 427 index, node));
430 428
431 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); 429 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG);
432 430
433 case AML_LOCAL_OP: 431 case AML_LOCAL_OP:
434 432
435 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 433 ACPI_ERROR((AE_INFO,
436 "Uninitialized Local[%d] at node %p\n", 434 "Uninitialized Local[%d] at node %p",
437 index, node)); 435 index, node));
438 436
439 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); 437 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL);
440 438
441 default: 439 default:
442 ACPI_REPORT_ERROR(("Not Arg/Local opcode: %X\n", 440 ACPI_ERROR((AE_INFO,
443 opcode)); 441 "Not a Arg/Local opcode: %X",
442 opcode));
444 return_ACPI_STATUS(AE_AML_INTERNAL); 443 return_ACPI_STATUS(AE_AML_INTERNAL);
445 } 444 }
446 } 445 }
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c
index 8ac0cd93adb5..8b21f0f9e517 100644
--- a/drivers/acpi/dispatcher/dsobject.c
+++ b/drivers/acpi/dispatcher/dsobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,7 @@
51#define _COMPONENT ACPI_DISPATCHER 51#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dsobject") 52ACPI_MODULE_NAME("dsobject")
53 53
54/* Local prototypes */
54static acpi_status 55static acpi_status
55acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, 56acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
56 union acpi_parse_object *op, 57 union acpi_parse_object *op,
@@ -85,7 +86,7 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
85 *obj_desc_ptr = NULL; 86 *obj_desc_ptr = NULL;
86 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { 87 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
87 /* 88 /*
88 * This is an named object reference. If this name was 89 * This is a named object reference. If this name was
89 * previously looked up in the namespace, it was stored in this op. 90 * previously looked up in the namespace, it was stored in this op.
90 * Otherwise, go ahead and look it up now 91 * Otherwise, go ahead and look it up now
91 */ 92 */
@@ -96,18 +97,48 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
96 ACPI_IMODE_EXECUTE, 97 ACPI_IMODE_EXECUTE,
97 ACPI_NS_SEARCH_PARENT | 98 ACPI_NS_SEARCH_PARENT |
98 ACPI_NS_DONT_OPEN_SCOPE, NULL, 99 ACPI_NS_DONT_OPEN_SCOPE, NULL,
99 (struct acpi_namespace_node **) 100 ACPI_CAST_INDIRECT_PTR(struct
100 &(op->common.node)); 101 acpi_namespace_node,
101 102 &(op->
103 common.
104 node)));
102 if (ACPI_FAILURE(status)) { 105 if (ACPI_FAILURE(status)) {
103 ACPI_REPORT_NSERROR(op->common.value.string, 106 /* Check if we are resolving a named reference within a package */
104 status); 107
108 if ((status == AE_NOT_FOUND)
109 && (acpi_gbl_enable_interpreter_slack)
110 &&
111 ((op->common.parent->common.aml_opcode ==
112 AML_PACKAGE_OP)
113 || (op->common.parent->common.aml_opcode ==
114 AML_VAR_PACKAGE_OP))) {
115 /*
116 * We didn't find the target and we are populating elements
117 * of a package - ignore if slack enabled. Some ASL code
118 * contains dangling invalid references in packages and
119 * expects that no exception will be issued. Leave the
120 * element as a null element. It cannot be used, but it
121 * can be overwritten by subsequent ASL code - this is
122 * typically the case.
123 */
124 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
125 "Ignoring unresolved reference in package [%4.4s]\n",
126 walk_state->
127 scope_info->scope.
128 node->name.ascii));
129
130 return_ACPI_STATUS(AE_OK);
131 } else {
132 ACPI_ERROR_NAMESPACE(op->common.value.
133 string, status);
134 }
135
105 return_ACPI_STATUS(status); 136 return_ACPI_STATUS(status);
106 } 137 }
107 } 138 }
108 } 139 }
109 140
110 /* Create and init the internal ACPI object */ 141 /* Create and init a new internal ACPI object */
111 142
112 obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info 143 obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info
113 (op->common.aml_opcode))-> 144 (op->common.aml_opcode))->
@@ -157,13 +188,13 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
157 188
158 ACPI_FUNCTION_TRACE("ds_build_internal_buffer_obj"); 189 ACPI_FUNCTION_TRACE("ds_build_internal_buffer_obj");
159 190
191 /*
192 * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
193 * The buffer object already exists (from the NS node), otherwise it must
194 * be created.
195 */
160 obj_desc = *obj_desc_ptr; 196 obj_desc = *obj_desc_ptr;
161 if (obj_desc) { 197 if (!obj_desc) {
162 /*
163 * We are evaluating a Named buffer object "Name (xxxx, Buffer)".
164 * The buffer object already exists (from the NS node)
165 */
166 } else {
167 /* Create a new buffer object */ 198 /* Create a new buffer object */
168 199
169 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); 200 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
@@ -183,10 +214,9 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
183 byte_list = arg->named.next; 214 byte_list = arg->named.next;
184 if (byte_list) { 215 if (byte_list) {
185 if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) { 216 if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) {
186 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 217 ACPI_ERROR((AE_INFO,
187 "Expecting bytelist, got AML opcode %X in op %p\n", 218 "Expecting bytelist, got AML opcode %X in op %p",
188 byte_list->common.aml_opcode, 219 byte_list->common.aml_opcode, byte_list));
189 byte_list));
190 220
191 acpi_ut_remove_reference(obj_desc); 221 acpi_ut_remove_reference(obj_desc);
192 return (AE_TYPE); 222 return (AE_TYPE);
@@ -259,7 +289,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
259 union acpi_operand_object *obj_desc = NULL; 289 union acpi_operand_object *obj_desc = NULL;
260 u32 package_list_length; 290 u32 package_list_length;
261 acpi_status status = AE_OK; 291 acpi_status status = AE_OK;
262 u32 i; 292 acpi_native_uint i;
263 293
264 ACPI_FUNCTION_TRACE("ds_build_internal_package_obj"); 294 ACPI_FUNCTION_TRACE("ds_build_internal_package_obj");
265 295
@@ -271,13 +301,12 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
271 parent = parent->common.parent; 301 parent = parent->common.parent;
272 } 302 }
273 303
304 /*
305 * If we are evaluating a Named package object "Name (xxxx, Package)",
306 * the package object already exists, otherwise it must be created.
307 */
274 obj_desc = *obj_desc_ptr; 308 obj_desc = *obj_desc_ptr;
275 if (obj_desc) { 309 if (!obj_desc) {
276 /*
277 * We are evaluating a Named package object "Name (xxxx, Package)".
278 * Get the existing package object from the NS node
279 */
280 } else {
281 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); 310 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
282 *obj_desc_ptr = obj_desc; 311 *obj_desc_ptr = obj_desc;
283 if (!obj_desc) { 312 if (!obj_desc) {
@@ -291,11 +320,9 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
291 320
292 /* Count the number of items in the package list */ 321 /* Count the number of items in the package list */
293 322
294 package_list_length = 0;
295 arg = op->common.value.arg; 323 arg = op->common.value.arg;
296 arg = arg->common.next; 324 arg = arg->common.next;
297 while (arg) { 325 for (package_list_length = 0; arg; package_list_length++) {
298 package_list_length++;
299 arg = arg->common.next; 326 arg = arg->common.next;
300 } 327 }
301 328
@@ -322,12 +349,11 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
322 } 349 }
323 350
324 /* 351 /*
325 * Now init the elements of the package 352 * Initialize all elements of the package
326 */ 353 */
327 i = 0;
328 arg = op->common.value.arg; 354 arg = op->common.value.arg;
329 arg = arg->common.next; 355 arg = arg->common.next;
330 while (arg) { 356 for (i = 0; arg; i++) {
331 if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { 357 if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
332 /* Object (package or buffer) is already built */ 358 /* Object (package or buffer) is already built */
333 359
@@ -340,8 +366,6 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
340 package. 366 package.
341 elements[i]); 367 elements[i]);
342 } 368 }
343
344 i++;
345 arg = arg->common.next; 369 arg = arg->common.next;
346 } 370 }
347 371
@@ -518,9 +542,9 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
518 542
519 default: 543 default:
520 544
521 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 545 ACPI_ERROR((AE_INFO,
522 "Unknown constant opcode %X\n", 546 "Unknown constant opcode %X",
523 opcode)); 547 opcode));
524 status = AE_AML_OPERAND_TYPE; 548 status = AE_AML_OPERAND_TYPE;
525 break; 549 break;
526 } 550 }
@@ -535,9 +559,8 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
535 break; 559 break;
536 560
537 default: 561 default:
538 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 562 ACPI_ERROR((AE_INFO, "Unknown Integer type %X",
539 "Unknown Integer type %X\n", 563 op_info->type));
540 op_info->type));
541 status = AE_AML_OPERAND_TYPE; 564 status = AE_AML_OPERAND_TYPE;
542 break; 565 break;
543 } 566 }
@@ -615,9 +638,8 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
615 638
616 default: 639 default:
617 640
618 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 641 ACPI_ERROR((AE_INFO, "Unimplemented data type: %X",
619 "Unimplemented data type: %X\n", 642 ACPI_GET_OBJECT_TYPE(obj_desc)));
620 ACPI_GET_OBJECT_TYPE(obj_desc)));
621 643
622 status = AE_AML_OPERAND_TYPE; 644 status = AE_AML_OPERAND_TYPE;
623 break; 645 break;
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c
index 939d167bf87b..6229c10674e1 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/dispatcher/dsopcode.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -245,7 +245,9 @@ acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
245 245
246 node = obj_desc->buffer.node; 246 node = obj_desc->buffer.node;
247 if (!node) { 247 if (!node) {
248 ACPI_REPORT_ERROR(("No pointer back to NS node in buffer obj %p\n", obj_desc)); 248 ACPI_ERROR((AE_INFO,
249 "No pointer back to NS node in buffer obj %p",
250 obj_desc));
249 return_ACPI_STATUS(AE_AML_INTERNAL); 251 return_ACPI_STATUS(AE_AML_INTERNAL);
250 } 252 }
251 253
@@ -287,8 +289,9 @@ acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
287 289
288 node = obj_desc->package.node; 290 node = obj_desc->package.node;
289 if (!node) { 291 if (!node) {
290 ACPI_REPORT_ERROR(("No pointer back to NS node in package %p\n", 292 ACPI_ERROR((AE_INFO,
291 obj_desc)); 293 "No pointer back to NS node in package %p",
294 obj_desc));
292 return_ACPI_STATUS(AE_AML_INTERNAL); 295 return_ACPI_STATUS(AE_AML_INTERNAL);
293 } 296 }
294 297
@@ -413,9 +416,9 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
413 /* Host object must be a Buffer */ 416 /* Host object must be a Buffer */
414 417
415 if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) { 418 if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) {
416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 419 ACPI_ERROR((AE_INFO,
417 "Target of Create Field is not a Buffer object - %s\n", 420 "Target of Create Field is not a Buffer object - %s",
418 acpi_ut_get_object_type_name(buffer_desc))); 421 acpi_ut_get_object_type_name(buffer_desc)));
419 422
420 status = AE_AML_OPERAND_TYPE; 423 status = AE_AML_OPERAND_TYPE;
421 goto cleanup; 424 goto cleanup;
@@ -427,10 +430,10 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
427 * after resolution in acpi_ex_resolve_operands(). 430 * after resolution in acpi_ex_resolve_operands().
428 */ 431 */
429 if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) { 432 if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) {
430 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 433 ACPI_ERROR((AE_INFO,
431 "(%s) destination not a NS Node [%s]\n", 434 "(%s) destination not a NS Node [%s]",
432 acpi_ps_get_opcode_name(aml_opcode), 435 acpi_ps_get_opcode_name(aml_opcode),
433 acpi_ut_get_descriptor_name(result_desc))); 436 acpi_ut_get_descriptor_name(result_desc)));
434 437
435 status = AE_AML_OPERAND_TYPE; 438 status = AE_AML_OPERAND_TYPE;
436 goto cleanup; 439 goto cleanup;
@@ -453,8 +456,8 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
453 /* Must have a valid (>0) bit count */ 456 /* Must have a valid (>0) bit count */
454 457
455 if (bit_count == 0) { 458 if (bit_count == 0) {
456 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 459 ACPI_ERROR((AE_INFO,
457 "Attempt to create_field of length 0\n")); 460 "Attempt to create_field of length zero"));
458 status = AE_AML_OPERAND_VALUE; 461 status = AE_AML_OPERAND_VALUE;
459 goto cleanup; 462 goto cleanup;
460 } 463 }
@@ -507,9 +510,8 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
507 510
508 default: 511 default:
509 512
510 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 513 ACPI_ERROR((AE_INFO,
511 "Unknown field creation opcode %02x\n", 514 "Unknown field creation opcode %02x", aml_opcode));
512 aml_opcode));
513 status = AE_AML_BAD_OPCODE; 515 status = AE_AML_BAD_OPCODE;
514 goto cleanup; 516 goto cleanup;
515 } 517 }
@@ -517,13 +519,12 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
517 /* Entire field must fit within the current length of the buffer */ 519 /* Entire field must fit within the current length of the buffer */
518 520
519 if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) { 521 if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) {
520 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 522 ACPI_ERROR((AE_INFO,
521 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", 523 "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)",
522 acpi_ut_get_node_name(result_desc), 524 acpi_ut_get_node_name(result_desc),
523 bit_offset + bit_count, 525 bit_offset + bit_count,
524 acpi_ut_get_node_name(buffer_desc->buffer. 526 acpi_ut_get_node_name(buffer_desc->buffer.node),
525 node), 527 8 * (u32) buffer_desc->buffer.length));
526 8 * (u32) buffer_desc->buffer.length));
527 status = AE_AML_BUFFER_LIMIT; 528 status = AE_AML_BUFFER_LIMIT;
528 goto cleanup; 529 goto cleanup;
529 } 530 }
@@ -629,9 +630,9 @@ acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
629 "after acpi_ex_resolve_operands"); 630 "after acpi_ex_resolve_operands");
630 631
631 if (ACPI_FAILURE(status)) { 632 if (ACPI_FAILURE(status)) {
632 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", 633 ACPI_ERROR((AE_INFO, "(%s) bad operand(s) (%X)",
633 acpi_ps_get_opcode_name(op->common. 634 acpi_ps_get_opcode_name(op->common.aml_opcode),
634 aml_opcode), status)); 635 status));
635 636
636 return_ACPI_STATUS(status); 637 return_ACPI_STATUS(status);
637 } 638 }
@@ -1155,9 +1156,8 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1155 1156
1156 default: 1157 default:
1157 1158
1158 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1159 ACPI_ERROR((AE_INFO, "Unknown control opcode=%X Op=%p",
1159 "Unknown control opcode=%X Op=%p\n", 1160 op->common.aml_opcode, op));
1160 op->common.aml_opcode, op));
1161 1161
1162 status = AE_AML_BAD_OPCODE; 1162 status = AE_AML_BAD_OPCODE;
1163 break; 1163 break;
diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c
index 83ae1c1aa286..53356a591ac1 100644
--- a/drivers/acpi/dispatcher/dsutils.c
+++ b/drivers/acpi/dispatcher/dsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -176,8 +176,8 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
176 /* Must have both an Op and a Result Object */ 176 /* Must have both an Op and a Result Object */
177 177
178 if (!op) { 178 if (!op) {
179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); 179 ACPI_ERROR((AE_INFO, "Null Op"));
180 return_VALUE(TRUE); 180 return_UINT8(TRUE);
181 } 181 }
182 182
183 /* 183 /*
@@ -208,7 +208,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
208 "At Method level, result of [%s] not used\n", 208 "At Method level, result of [%s] not used\n",
209 acpi_ps_get_opcode_name(op->common. 209 acpi_ps_get_opcode_name(op->common.
210 aml_opcode))); 210 aml_opcode)));
211 return_VALUE(FALSE); 211 return_UINT8(FALSE);
212 } 212 }
213 213
214 /* Get info on the parent. The root_op is AML_SCOPE */ 214 /* Get info on the parent. The root_op is AML_SCOPE */
@@ -216,9 +216,8 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
216 parent_info = 216 parent_info =
217 acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode); 217 acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode);
218 if (parent_info->class == AML_CLASS_UNKNOWN) { 218 if (parent_info->class == AML_CLASS_UNKNOWN) {
219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 219 ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op));
220 "Unknown parent opcode. Op=%p\n", op)); 220 return_UINT8(FALSE);
221 return_VALUE(FALSE);
222 } 221 }
223 222
224 /* 223 /*
@@ -304,7 +303,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
304 acpi_ps_get_opcode_name(op->common.parent->common. 303 acpi_ps_get_opcode_name(op->common.parent->common.
305 aml_opcode), op)); 304 aml_opcode), op));
306 305
307 return_VALUE(TRUE); 306 return_UINT8(TRUE);
308 307
309 result_not_used: 308 result_not_used:
310 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 309 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
@@ -313,7 +312,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
313 acpi_ps_get_opcode_name(op->common.parent->common. 312 acpi_ps_get_opcode_name(op->common.parent->common.
314 aml_opcode), op)); 313 aml_opcode), op));
315 314
316 return_VALUE(FALSE); 315 return_UINT8(FALSE);
317} 316}
318 317
319/******************************************************************************* 318/*******************************************************************************
@@ -344,7 +343,7 @@ acpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
344 ACPI_FUNCTION_TRACE_PTR("ds_delete_result_if_not_used", result_obj); 343 ACPI_FUNCTION_TRACE_PTR("ds_delete_result_if_not_used", result_obj);
345 344
346 if (!op) { 345 if (!op) {
347 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); 346 ACPI_ERROR((AE_INFO, "Null Op"));
348 return_VOID; 347 return_VOID;
349 } 348 }
350 349
@@ -567,7 +566,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
567 } 566 }
568 567
569 if (ACPI_FAILURE(status)) { 568 if (ACPI_FAILURE(status)) {
570 ACPI_REPORT_NSERROR(name_string, status); 569 ACPI_ERROR_NAMESPACE(name_string, status);
571 } 570 }
572 } 571 }
573 572
@@ -616,7 +615,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
616 615
617 if (op_info->flags & AML_HAS_RETVAL) { 616 if (op_info->flags & AML_HAS_RETVAL) {
618 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 617 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
619 "Argument previously created, already stacked \n")); 618 "Argument previously created, already stacked\n"));
620 619
621 ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object 620 ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object
622 (walk_state-> 621 (walk_state->
@@ -635,10 +634,8 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
635 * Only error is underflow, and this indicates 634 * Only error is underflow, and this indicates
636 * a missing or null operand! 635 * a missing or null operand!
637 */ 636 */
638 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 637 ACPI_EXCEPTION((AE_INFO, status,
639 "Missing or null operand, %s\n", 638 "Missing or null operand"));
640 acpi_format_exception
641 (status)));
642 return_ACPI_STATUS(status); 639 return_ACPI_STATUS(status);
643 } 640 }
644 } else { 641 } else {
@@ -730,7 +727,7 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state,
730 */ 727 */
731 (void)acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state); 728 (void)acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state);
732 729
733 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "While creating Arg %d - %s\n", 730 ACPI_EXCEPTION((AE_INFO, status, "While creating Arg %d",
734 (arg_count + 1), acpi_format_exception(status))); 731 (arg_count + 1)));
735 return_ACPI_STATUS(status); 732 return_ACPI_STATUS(status);
736} 733}
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
index e522763bb692..f1af655ff113 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/dispatcher/dswexec.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -100,9 +100,8 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
100 if (result_obj) { 100 if (result_obj) {
101 status = acpi_ds_result_pop(&obj_desc, walk_state); 101 status = acpi_ds_result_pop(&obj_desc, walk_state);
102 if (ACPI_FAILURE(status)) { 102 if (ACPI_FAILURE(status)) {
103 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 103 ACPI_EXCEPTION((AE_INFO, status,
104 "Could not get result from predicate evaluation, %s\n", 104 "Could not get result from predicate evaluation"));
105 acpi_format_exception(status)));
106 105
107 return_ACPI_STATUS(status); 106 return_ACPI_STATUS(status);
108 } 107 }
@@ -123,9 +122,9 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
123 } 122 }
124 123
125 if (!obj_desc) { 124 if (!obj_desc) {
126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 125 ACPI_ERROR((AE_INFO,
127 "No predicate obj_desc=%p State=%p\n", 126 "No predicate obj_desc=%p State=%p",
128 obj_desc, walk_state)); 127 obj_desc, walk_state));
129 128
130 return_ACPI_STATUS(AE_AML_NO_OPERAND); 129 return_ACPI_STATUS(AE_AML_NO_OPERAND);
131 } 130 }
@@ -140,10 +139,10 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
140 } 139 }
141 140
142 if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) { 141 if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) {
143 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 142 ACPI_ERROR((AE_INFO,
144 "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n", 143 "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X",
145 obj_desc, walk_state, 144 obj_desc, walk_state,
146 ACPI_GET_OBJECT_TYPE(obj_desc))); 145 ACPI_GET_OBJECT_TYPE(obj_desc)));
147 146
148 status = AE_AML_OPERAND_TYPE; 147 status = AE_AML_OPERAND_TYPE;
149 goto cleanup; 148 goto cleanup;
@@ -314,12 +313,13 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
314 313
315 case AML_CLASS_EXECUTE: 314 case AML_CLASS_EXECUTE:
316 case AML_CLASS_CREATE: 315 case AML_CLASS_CREATE:
317
318 /* 316 /*
319 * Most operators with arguments. 317 * Most operators with arguments.
320 * Start a new result/operand state 318 * Start a new result/operand state
321 */ 319 */
322 status = acpi_ds_result_stack_push(walk_state); 320 if (walk_state->opcode != AML_CREATE_FIELD_OP) {
321 status = acpi_ds_result_stack_push(walk_state);
322 }
323 break; 323 break;
324 324
325 default: 325 default:
@@ -361,8 +361,8 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
361 op_class = walk_state->op_info->class; 361 op_class = walk_state->op_info->class;
362 362
363 if (op_class == AML_CLASS_UNKNOWN) { 363 if (op_class == AML_CLASS_UNKNOWN) {
364 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown opcode %X\n", 364 ACPI_ERROR((AE_INFO, "Unknown opcode %X",
365 op->common.aml_opcode)); 365 op->common.aml_opcode));
366 return_ACPI_STATUS(AE_NOT_IMPLEMENTED); 366 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
367 } 367 }
368 368
@@ -452,12 +452,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
452 walk_state->operands[1]->reference.offset)) { 452 walk_state->operands[1]->reference.offset)) {
453 status = AE_OK; 453 status = AE_OK;
454 } else { 454 } else {
455 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 455 ACPI_EXCEPTION((AE_INFO, status,
456 "[%s]: Could not resolve operands, %s\n", 456 "While resolving operands for [%s]",
457 acpi_ps_get_opcode_name 457 acpi_ps_get_opcode_name
458 (walk_state->opcode), 458 (walk_state->opcode)));
459 acpi_format_exception
460 (status)));
461 } 459 }
462 } 460 }
463 461
@@ -676,8 +674,8 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
676 674
677 case AML_TYPE_UNDEFINED: 675 case AML_TYPE_UNDEFINED:
678 676
679 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 677 ACPI_ERROR((AE_INFO,
680 "Undefined opcode type Op=%p\n", op)); 678 "Undefined opcode type Op=%p", op));
681 return_ACPI_STATUS(AE_NOT_IMPLEMENTED); 679 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
682 680
683 case AML_TYPE_BOGUS: 681 case AML_TYPE_BOGUS:
@@ -689,10 +687,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
689 687
690 default: 688 default:
691 689
692 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 690 ACPI_ERROR((AE_INFO,
693 "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", 691 "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p",
694 op_class, op_type, 692 op_class, op_type, op->common.aml_opcode,
695 op->common.aml_opcode, op)); 693 op));
696 694
697 status = AE_NOT_IMPLEMENTED; 695 status = AE_NOT_IMPLEMENTED;
698 break; 696 break;
@@ -723,20 +721,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
723 721
724 cleanup: 722 cleanup:
725 723
726 /* Invoke exception handler on error */
727
728 if (ACPI_FAILURE(status) &&
729 acpi_gbl_exception_handler && !(status & AE_CODE_CONTROL)) {
730 acpi_ex_exit_interpreter();
731 status = acpi_gbl_exception_handler(status,
732 walk_state->method_node->
733 name.integer,
734 walk_state->opcode,
735 walk_state->aml_offset,
736 NULL);
737 (void)acpi_ex_enter_interpreter();
738 }
739
740 if (walk_state->result_obj) { 724 if (walk_state->result_obj) {
741 /* Break to debugger to display result */ 725 /* Break to debugger to display result */
742 726
@@ -758,18 +742,14 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
758 } 742 }
759#endif 743#endif
760 744
761 /* Always clear the object stack */ 745 /* Invoke exception handler on error */
762
763 walk_state->num_operands = 0;
764
765#ifdef ACPI_DISASSEMBLER
766
767 /* On error, display method locals/args */
768 746
769 if (ACPI_FAILURE(status)) { 747 if (ACPI_FAILURE(status)) {
770 acpi_dm_dump_method_info(status, walk_state, op); 748 status = acpi_ds_method_error(status, walk_state);
771 } 749 }
772#endif
773 750
751 /* Always clear the object stack */
752
753 walk_state->num_operands = 0;
774 return_ACPI_STATUS(status); 754 return_ACPI_STATUS(status);
775} 755}
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index 411731261c29..d3d24da31c81 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -127,7 +127,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
127 char *path; 127 char *path;
128 u32 flags; 128 u32 flags;
129 129
130 ACPI_FUNCTION_NAME("ds_load1_begin_op"); 130 ACPI_FUNCTION_TRACE("ds_load1_begin_op");
131 131
132 op = walk_state->op; 132 op = walk_state->op;
133 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, 133 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
@@ -138,14 +138,14 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
138 if (op) { 138 if (op) {
139 if (!(walk_state->op_info->flags & AML_NAMED)) { 139 if (!(walk_state->op_info->flags & AML_NAMED)) {
140 *out_op = op; 140 *out_op = op;
141 return (AE_OK); 141 return_ACPI_STATUS(AE_OK);
142 } 142 }
143 143
144 /* Check if this object has already been installed in the namespace */ 144 /* Check if this object has already been installed in the namespace */
145 145
146 if (op->common.node) { 146 if (op->common.node) {
147 *out_op = op; 147 *out_op = op;
148 return (AE_OK); 148 return_ACPI_STATUS(AE_OK);
149 } 149 }
150 } 150 }
151 151
@@ -187,8 +187,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
187 } 187 }
188#endif 188#endif
189 if (ACPI_FAILURE(status)) { 189 if (ACPI_FAILURE(status)) {
190 ACPI_REPORT_NSERROR(path, status); 190 ACPI_ERROR_NAMESPACE(path, status);
191 return (status); 191 return_ACPI_STATUS(status);
192 } 192 }
193 193
194 /* 194 /*
@@ -233,9 +233,11 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
233 233
234 /* All other types are an error */ 234 /* All other types are an error */
235 235
236 ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", acpi_ut_get_type_name(node->type), path)); 236 ACPI_ERROR((AE_INFO,
237 "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)",
238 acpi_ut_get_type_name(node->type), path));
237 239
238 return (AE_AML_OPERAND_TYPE); 240 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
239 } 241 }
240 break; 242 break;
241 243
@@ -257,6 +259,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
257 * buffer_field, or Package), the name of the object is already 259 * buffer_field, or Package), the name of the object is already
258 * in the namespace. 260 * in the namespace.
259 */ 261 */
262
260 if (walk_state->deferred_node) { 263 if (walk_state->deferred_node) {
261 /* This name is already in the namespace, get the node */ 264 /* This name is already in the namespace, get the node */
262 265
@@ -265,6 +268,16 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
265 break; 268 break;
266 } 269 }
267 270
271 /*
272 * If we are executing a method, do not create any namespace objects
273 * during the load phase, only during execution.
274 */
275 if (walk_state->method_node) {
276 node = NULL;
277 status = AE_OK;
278 break;
279 }
280
268 flags = ACPI_NS_NO_UPSEARCH; 281 flags = ACPI_NS_NO_UPSEARCH;
269 if ((walk_state->opcode != AML_SCOPE_OP) && 282 if ((walk_state->opcode != AML_SCOPE_OP) &&
270 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) { 283 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
@@ -289,8 +302,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
289 ACPI_IMODE_LOAD_PASS1, flags, walk_state, 302 ACPI_IMODE_LOAD_PASS1, flags, walk_state,
290 &(node)); 303 &(node));
291 if (ACPI_FAILURE(status)) { 304 if (ACPI_FAILURE(status)) {
292 ACPI_REPORT_NSERROR(path, status); 305 ACPI_ERROR_NAMESPACE(path, status);
293 return (status); 306 return_ACPI_STATUS(status);
294 } 307 }
295 break; 308 break;
296 } 309 }
@@ -302,28 +315,29 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
302 315
303 op = acpi_ps_alloc_op(walk_state->opcode); 316 op = acpi_ps_alloc_op(walk_state->opcode);
304 if (!op) { 317 if (!op) {
305 return (AE_NO_MEMORY); 318 return_ACPI_STATUS(AE_NO_MEMORY);
306 } 319 }
307 } 320 }
308 321
309 /* Initialize */ 322 /* Initialize the op */
310
311 op->named.name = node->name.integer;
312 323
313#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) 324#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
314 op->named.path = (u8 *) path; 325 op->named.path = ACPI_CAST_PTR(u8, path);
315#endif 326#endif
316 327
317 /* 328 if (node) {
318 * Put the Node in the "op" object that the parser uses, so we 329 /*
319 * can get it again quickly when this scope is closed 330 * Put the Node in the "op" object that the parser uses, so we
320 */ 331 * can get it again quickly when this scope is closed
321 op->common.node = node; 332 */
333 op->common.node = node;
334 op->named.name = node->name.integer;
335 }
336
322 acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state), 337 acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state),
323 op); 338 op);
324
325 *out_op = op; 339 *out_op = op;
326 return (status); 340 return_ACPI_STATUS(status);
327} 341}
328 342
329/******************************************************************************* 343/*******************************************************************************
@@ -339,13 +353,13 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
339 * 353 *
340 ******************************************************************************/ 354 ******************************************************************************/
341 355
342acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) 356acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
343{ 357{
344 union acpi_parse_object *op; 358 union acpi_parse_object *op;
345 acpi_object_type object_type; 359 acpi_object_type object_type;
346 acpi_status status = AE_OK; 360 acpi_status status = AE_OK;
347 361
348 ACPI_FUNCTION_NAME("ds_load1_end_op"); 362 ACPI_FUNCTION_TRACE("ds_load1_end_op");
349 363
350 op = walk_state->op; 364 op = walk_state->op;
351 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, 365 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
@@ -354,7 +368,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
354 /* We are only interested in opcodes that have an associated name */ 368 /* We are only interested in opcodes that have an associated name */
355 369
356 if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) { 370 if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) {
357 return (AE_OK); 371 return_ACPI_STATUS(AE_OK);
358 } 372 }
359 373
360 /* Get the object type to determine if we should pop the scope */ 374 /* Get the object type to determine if we should pop the scope */
@@ -363,21 +377,37 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
363 377
364#ifndef ACPI_NO_METHOD_EXECUTION 378#ifndef ACPI_NO_METHOD_EXECUTION
365 if (walk_state->op_info->flags & AML_FIELD) { 379 if (walk_state->op_info->flags & AML_FIELD) {
366 if (walk_state->opcode == AML_FIELD_OP || 380 /*
367 walk_state->opcode == AML_BANK_FIELD_OP || 381 * If we are executing a method, do not create any namespace objects
368 walk_state->opcode == AML_INDEX_FIELD_OP) { 382 * during the load phase, only during execution.
369 status = acpi_ds_init_field_objects(op, walk_state); 383 */
384 if (!walk_state->method_node) {
385 if (walk_state->opcode == AML_FIELD_OP ||
386 walk_state->opcode == AML_BANK_FIELD_OP ||
387 walk_state->opcode == AML_INDEX_FIELD_OP) {
388 status =
389 acpi_ds_init_field_objects(op, walk_state);
390 }
370 } 391 }
371 return (status); 392 return_ACPI_STATUS(status);
372 } 393 }
373 394
374 if (op->common.aml_opcode == AML_REGION_OP) { 395 /*
375 status = acpi_ex_create_region(op->named.data, op->named.length, 396 * If we are executing a method, do not create any namespace objects
376 (acpi_adr_space_type) 397 * during the load phase, only during execution.
377 ((op->common.value.arg)->common. 398 */
378 value.integer), walk_state); 399 if (!walk_state->method_node) {
379 if (ACPI_FAILURE(status)) { 400 if (op->common.aml_opcode == AML_REGION_OP) {
380 return (status); 401 status =
402 acpi_ex_create_region(op->named.data,
403 op->named.length,
404 (acpi_adr_space_type)
405 ((op->common.value.arg)->
406 common.value.integer),
407 walk_state);
408 if (ACPI_FAILURE(status)) {
409 return_ACPI_STATUS(status);
410 }
381 } 411 }
382 } 412 }
383#endif 413#endif
@@ -391,47 +421,63 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
391 common. 421 common.
392 aml_opcode))-> 422 aml_opcode))->
393 object_type; 423 object_type;
394 op->common.node->type = (u8) object_type; 424
425 /* Set node type if we have a namespace node */
426
427 if (op->common.node) {
428 op->common.node->type = (u8) object_type;
429 }
395 } 430 }
396 } 431 }
397 432
398 if (op->common.aml_opcode == AML_METHOD_OP) { 433 /*
399 /* 434 * If we are executing a method, do not create any namespace objects
400 * method_op pkg_length name_string method_flags term_list 435 * during the load phase, only during execution.
401 * 436 */
402 * Note: We must create the method node/object pair as soon as we 437 if (!walk_state->method_node) {
403 * see the method declaration. This allows later pass1 parsing 438 if (op->common.aml_opcode == AML_METHOD_OP) {
404 * of invocations of the method (need to know the number of 439 /*
405 * arguments.) 440 * method_op pkg_length name_string method_flags term_list
406 */ 441 *
407 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 442 * Note: We must create the method node/object pair as soon as we
408 "LOADING-Method: State=%p Op=%p named_obj=%p\n", 443 * see the method declaration. This allows later pass1 parsing
409 walk_state, op, op->named.node)); 444 * of invocations of the method (need to know the number of
445 * arguments.)
446 */
447 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
448 "LOADING-Method: State=%p Op=%p named_obj=%p\n",
449 walk_state, op, op->named.node));
410 450
411 if (!acpi_ns_get_attached_object(op->named.node)) { 451 if (!acpi_ns_get_attached_object(op->named.node)) {
412 walk_state->operands[0] = (void *)op->named.node; 452 walk_state->operands[0] =
413 walk_state->num_operands = 1; 453 ACPI_CAST_PTR(void, op->named.node);
454 walk_state->num_operands = 1;
414 455
415 status = 456 status =
416 acpi_ds_create_operands(walk_state, 457 acpi_ds_create_operands(walk_state,
417 op->common.value.arg); 458 op->common.value.
418 if (ACPI_SUCCESS(status)) { 459 arg);
419 status = acpi_ex_create_method(op->named.data, 460 if (ACPI_SUCCESS(status)) {
420 op->named.length, 461 status =
421 walk_state); 462 acpi_ex_create_method(op->named.
422 } 463 data,
423 walk_state->operands[0] = NULL; 464 op->named.
424 walk_state->num_operands = 0; 465 length,
466 walk_state);
467 }
468 walk_state->operands[0] = NULL;
469 walk_state->num_operands = 0;
425 470
426 if (ACPI_FAILURE(status)) { 471 if (ACPI_FAILURE(status)) {
427 return (status); 472 return_ACPI_STATUS(status);
473 }
428 } 474 }
429 } 475 }
430 } 476 }
431 477
432 /* Pop the scope stack */ 478 /* Pop the scope stack (only if loading a table) */
433 479
434 if (acpi_ns_opens_scope(object_type)) { 480 if (!walk_state->method_node && acpi_ns_opens_scope(object_type)) {
435 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 481 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
436 "(%s): Popping scope for Op %p\n", 482 "(%s): Popping scope for Op %p\n",
437 acpi_ut_get_type_name(object_type), op)); 483 acpi_ut_get_type_name(object_type), op));
@@ -439,7 +485,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
439 status = acpi_ds_scope_stack_pop(walk_state); 485 status = acpi_ds_scope_stack_pop(walk_state);
440 } 486 }
441 487
442 return (status); 488 return_ACPI_STATUS(status);
443} 489}
444 490
445/******************************************************************************* 491/*******************************************************************************
@@ -456,8 +502,8 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
456 ******************************************************************************/ 502 ******************************************************************************/
457 503
458acpi_status 504acpi_status
459acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state, 505acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
460 union acpi_parse_object ** out_op) 506 union acpi_parse_object **out_op)
461{ 507{
462 union acpi_parse_object *op; 508 union acpi_parse_object *op;
463 struct acpi_namespace_node *node; 509 struct acpi_namespace_node *node;
@@ -574,10 +620,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
574 if (status == AE_NOT_FOUND) { 620 if (status == AE_NOT_FOUND) {
575 status = AE_OK; 621 status = AE_OK;
576 } else { 622 } else {
577 ACPI_REPORT_NSERROR(buffer_ptr, status); 623 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
578 } 624 }
579#else 625#else
580 ACPI_REPORT_NSERROR(buffer_ptr, status); 626 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
581#endif 627#endif
582 return_ACPI_STATUS(status); 628 return_ACPI_STATUS(status);
583 } 629 }
@@ -607,7 +653,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
607 * Scope (DEB) { ... } 653 * Scope (DEB) { ... }
608 */ 654 */
609 655
610 ACPI_REPORT_WARNING(("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", buffer_ptr, acpi_ut_get_type_name(node->type))); 656 ACPI_WARNING((AE_INFO,
657 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)",
658 buffer_ptr,
659 acpi_ut_get_type_name(node->type)));
611 660
612 node->type = ACPI_TYPE_ANY; 661 node->type = ACPI_TYPE_ANY;
613 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 662 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@@ -617,7 +666,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
617 666
618 /* All other types are an error */ 667 /* All other types are an error */
619 668
620 ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s]\n", acpi_ut_get_type_name(node->type), buffer_ptr)); 669 ACPI_ERROR((AE_INFO,
670 "Invalid type (%s) for target of Scope operator [%4.4s]",
671 acpi_ut_get_type_name(node->type),
672 buffer_ptr));
621 673
622 return (AE_AML_OPERAND_TYPE); 674 return (AE_AML_OPERAND_TYPE);
623 } 675 }
@@ -670,7 +722,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
670 } 722 }
671 723
672 if (ACPI_FAILURE(status)) { 724 if (ACPI_FAILURE(status)) {
673 ACPI_REPORT_NSERROR(buffer_ptr, status); 725 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
674 return_ACPI_STATUS(status); 726 return_ACPI_STATUS(status);
675 } 727 }
676 728
@@ -840,6 +892,13 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
840 892
841 case AML_TYPE_NAMED_FIELD: 893 case AML_TYPE_NAMED_FIELD:
842 894
895 /*
896 * If we are executing a method, initialize the field
897 */
898 if (walk_state->method_node) {
899 status = acpi_ds_init_field_objects(op, walk_state);
900 }
901
843 switch (op->common.aml_opcode) { 902 switch (op->common.aml_opcode) {
844 case AML_INDEX_FIELD_OP: 903 case AML_INDEX_FIELD_OP:
845 904
@@ -929,6 +988,24 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
929 switch (op->common.aml_opcode) { 988 switch (op->common.aml_opcode) {
930#ifndef ACPI_NO_METHOD_EXECUTION 989#ifndef ACPI_NO_METHOD_EXECUTION
931 case AML_REGION_OP: 990 case AML_REGION_OP:
991
992 /*
993 * If we are executing a method, initialize the region
994 */
995 if (walk_state->method_node) {
996 status =
997 acpi_ex_create_region(op->named.data,
998 op->named.length,
999 (acpi_adr_space_type)
1000 ((op->common.value.
1001 arg)->common.value.
1002 integer),
1003 walk_state);
1004 if (ACPI_FAILURE(status)) {
1005 return (status);
1006 }
1007 }
1008
932 /* 1009 /*
933 * The op_region is not fully parsed at this time. Only valid 1010 * The op_region is not fully parsed at this time. Only valid
934 * argument is the space_id. (We must save the address of the 1011 * argument is the space_id. (We must save the address of the
@@ -957,11 +1034,50 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
957 1034
958 status = acpi_ds_create_node(walk_state, node, op); 1035 status = acpi_ds_create_node(walk_state, node, op);
959 break; 1036 break;
1037
1038 case AML_METHOD_OP:
1039 /*
1040 * method_op pkg_length name_string method_flags term_list
1041 *
1042 * Note: We must create the method node/object pair as soon as we
1043 * see the method declaration. This allows later pass1 parsing
1044 * of invocations of the method (need to know the number of
1045 * arguments.)
1046 */
1047 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1048 "LOADING-Method: State=%p Op=%p named_obj=%p\n",
1049 walk_state, op, op->named.node));
1050
1051 if (!acpi_ns_get_attached_object(op->named.node)) {
1052 walk_state->operands[0] =
1053 ACPI_CAST_PTR(void, op->named.node);
1054 walk_state->num_operands = 1;
1055
1056 status =
1057 acpi_ds_create_operands(walk_state,
1058 op->common.value.
1059 arg);
1060 if (ACPI_SUCCESS(status)) {
1061 status =
1062 acpi_ex_create_method(op->named.
1063 data,
1064 op->named.
1065 length,
1066 walk_state);
1067 }
1068 walk_state->operands[0] = NULL;
1069 walk_state->num_operands = 0;
1070
1071 if (ACPI_FAILURE(status)) {
1072 return_ACPI_STATUS(status);
1073 }
1074 }
1075 break;
1076
960#endif /* ACPI_NO_METHOD_EXECUTION */ 1077#endif /* ACPI_NO_METHOD_EXECUTION */
961 1078
962 default: 1079 default:
963 /* All NAMED_COMPLEX opcodes must be handled above */ 1080 /* All NAMED_COMPLEX opcodes must be handled above */
964 /* Note: Method objects were already created in Pass 1 */
965 break; 1081 break;
966 } 1082 }
967 break; 1083 break;
@@ -1004,7 +1120,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1004 */ 1120 */
1005 op->common.node = new_node; 1121 op->common.node = new_node;
1006 } else { 1122 } else {
1007 ACPI_REPORT_NSERROR(arg->common.value.string, status); 1123 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
1008 } 1124 }
1009 break; 1125 break;
1010 1126
diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/dispatcher/dswscope.c
index defe956ef751..ada21ef4a174 100644
--- a/drivers/acpi/dispatcher/dswscope.c
+++ b/drivers/acpi/dispatcher/dswscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -107,14 +107,14 @@ acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
107 if (!node) { 107 if (!node) {
108 /* Invalid scope */ 108 /* Invalid scope */
109 109
110 ACPI_REPORT_ERROR(("ds_scope_stack_push: null scope passed\n")); 110 ACPI_ERROR((AE_INFO, "Null scope parameter"));
111 return_ACPI_STATUS(AE_BAD_PARAMETER); 111 return_ACPI_STATUS(AE_BAD_PARAMETER);
112 } 112 }
113 113
114 /* Make sure object type is valid */ 114 /* Make sure object type is valid */
115 115
116 if (!acpi_ut_valid_object_type(type)) { 116 if (!acpi_ut_valid_object_type(type)) {
117 ACPI_REPORT_WARNING(("ds_scope_stack_push: Invalid object type: 0x%X\n", type)); 117 ACPI_WARNING((AE_INFO, "Invalid object type: 0x%X", type));
118 } 118 }
119 119
120 /* Allocate a new scope object */ 120 /* Allocate a new scope object */
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c
index 7d68a5aaf3c4..fa78cb74ee36 100644
--- a/drivers/acpi/dispatcher/dswstate.c
+++ b/drivers/acpi/dispatcher/dswstate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -92,26 +92,23 @@ acpi_ds_result_remove(union acpi_operand_object **object,
92 92
93 state = walk_state->results; 93 state = walk_state->results;
94 if (!state) { 94 if (!state) {
95 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 95 ACPI_ERROR((AE_INFO, "No result object pushed! State=%p",
96 "No result object pushed! State=%p\n", 96 walk_state));
97 walk_state));
98 return (AE_NOT_EXIST); 97 return (AE_NOT_EXIST);
99 } 98 }
100 99
101 if (index >= ACPI_OBJ_MAX_OPERAND) { 100 if (index >= ACPI_OBJ_MAX_OPERAND) {
102 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 101 ACPI_ERROR((AE_INFO,
103 "Index out of range: %X State=%p Num=%X\n", 102 "Index out of range: %X State=%p Num=%X",
104 index, walk_state, 103 index, walk_state, state->results.num_results));
105 state->results.num_results));
106 } 104 }
107 105
108 /* Check for a valid result object */ 106 /* Check for a valid result object */
109 107
110 if (!state->results.obj_desc[index]) { 108 if (!state->results.obj_desc[index]) {
111 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 109 ACPI_ERROR((AE_INFO,
112 "Null operand! State=%p #Ops=%X, Index=%X\n", 110 "Null operand! State=%p #Ops=%X, Index=%X",
113 walk_state, state->results.num_results, 111 walk_state, state->results.num_results, index));
114 index));
115 return (AE_AML_NO_RETURN_VALUE); 112 return (AE_AML_NO_RETURN_VALUE);
116 } 113 }
117 114
@@ -163,9 +160,8 @@ acpi_ds_result_pop(union acpi_operand_object ** object,
163 } 160 }
164 161
165 if (!state->results.num_results) { 162 if (!state->results.num_results) {
166 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 163 ACPI_ERROR((AE_INFO, "Result stack is empty! State=%p",
167 "Result stack is empty! State=%p\n", 164 walk_state));
168 walk_state));
169 return (AE_AML_NO_RETURN_VALUE); 165 return (AE_AML_NO_RETURN_VALUE);
170 } 166 }
171 167
@@ -192,8 +188,7 @@ acpi_ds_result_pop(union acpi_operand_object ** object,
192 } 188 }
193 } 189 }
194 190
195 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 191 ACPI_ERROR((AE_INFO, "No result objects! State=%p", walk_state));
196 "No result objects! State=%p\n", walk_state));
197 return (AE_AML_NO_RETURN_VALUE); 192 return (AE_AML_NO_RETURN_VALUE);
198} 193}
199 194
@@ -222,15 +217,14 @@ acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object,
222 217
223 state = walk_state->results; 218 state = walk_state->results;
224 if (!state) { 219 if (!state) {
225 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 220 ACPI_ERROR((AE_INFO,
226 "Warning: No result object pushed! State=%p\n", 221 "No result object pushed! State=%p", walk_state));
227 walk_state));
228 return (AE_NOT_EXIST); 222 return (AE_NOT_EXIST);
229 } 223 }
230 224
231 if (!state->results.num_results) { 225 if (!state->results.num_results) {
232 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 226 ACPI_ERROR((AE_INFO, "No result objects! State=%p",
233 "No result objects! State=%p\n", walk_state)); 227 walk_state));
234 return (AE_AML_NO_RETURN_VALUE); 228 return (AE_AML_NO_RETURN_VALUE);
235 } 229 }
236 230
@@ -250,10 +244,10 @@ acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object,
250 /* Check for a valid result object */ 244 /* Check for a valid result object */
251 245
252 if (!*object) { 246 if (!*object) {
253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 247 ACPI_ERROR((AE_INFO,
254 "Null operand! State=%p #Ops=%X Index=%X\n", 248 "Null operand! State=%p #Ops=%X Index=%X",
255 walk_state, state->results.num_results, 249 walk_state, state->results.num_results,
256 (u32) index)); 250 (u32) index));
257 return (AE_AML_NO_RETURN_VALUE); 251 return (AE_AML_NO_RETURN_VALUE);
258 } 252 }
259 253
@@ -288,23 +282,21 @@ acpi_ds_result_push(union acpi_operand_object * object,
288 282
289 state = walk_state->results; 283 state = walk_state->results;
290 if (!state) { 284 if (!state) {
291 ACPI_REPORT_ERROR(("No result stack frame during push\n")); 285 ACPI_ERROR((AE_INFO, "No result stack frame during push"));
292 return (AE_AML_INTERNAL); 286 return (AE_AML_INTERNAL);
293 } 287 }
294 288
295 if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) { 289 if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) {
296 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 290 ACPI_ERROR((AE_INFO,
297 "Result stack overflow: Obj=%p State=%p Num=%X\n", 291 "Result stack overflow: Obj=%p State=%p Num=%X",
298 object, walk_state, 292 object, walk_state, state->results.num_results));
299 state->results.num_results));
300 return (AE_STACK_OVERFLOW); 293 return (AE_STACK_OVERFLOW);
301 } 294 }
302 295
303 if (!object) { 296 if (!object) {
304 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 297 ACPI_ERROR((AE_INFO,
305 "Null Object! Obj=%p State=%p Num=%X\n", 298 "Null Object! Obj=%p State=%p Num=%X",
306 object, walk_state, 299 object, walk_state, state->results.num_results));
307 state->results.num_results));
308 return (AE_BAD_PARAMETER); 300 return (AE_BAD_PARAMETER);
309 } 301 }
310 302
@@ -413,10 +405,9 @@ acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state)
413 /* Check for stack overflow */ 405 /* Check for stack overflow */
414 406
415 if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) { 407 if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) {
416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 408 ACPI_ERROR((AE_INFO,
417 "overflow! Obj=%p State=%p #Ops=%X\n", 409 "Object stack overflow! Obj=%p State=%p #Ops=%X",
418 object, walk_state, 410 object, walk_state, walk_state->num_operands));
419 walk_state->num_operands));
420 return (AE_STACK_OVERFLOW); 411 return (AE_STACK_OVERFLOW);
421 } 412 }
422 413
@@ -460,10 +451,10 @@ acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state)
460 /* Check for stack underflow */ 451 /* Check for stack underflow */
461 452
462 if (walk_state->num_operands == 0) { 453 if (walk_state->num_operands == 0) {
463 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 454 ACPI_ERROR((AE_INFO,
464 "Underflow! Count=%X State=%p #Ops=%X\n", 455 "Object stack underflow! Count=%X State=%p #Ops=%X",
465 pop_count, walk_state, 456 pop_count, walk_state,
466 walk_state->num_operands)); 457 walk_state->num_operands));
467 return (AE_STACK_UNDERFLOW); 458 return (AE_STACK_UNDERFLOW);
468 } 459 }
469 460
@@ -506,10 +497,10 @@ acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
506 /* Check for stack underflow */ 497 /* Check for stack underflow */
507 498
508 if (walk_state->num_operands == 0) { 499 if (walk_state->num_operands == 0) {
509 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 500 ACPI_ERROR((AE_INFO,
510 "Underflow! Count=%X State=%p #Ops=%X\n", 501 "Object stack underflow! Count=%X State=%p #Ops=%X",
511 pop_count, walk_state, 502 pop_count, walk_state,
512 walk_state->num_operands)); 503 walk_state->num_operands));
513 return (AE_STACK_UNDERFLOW); 504 return (AE_STACK_UNDERFLOW);
514 } 505 }
515 506
@@ -826,16 +817,14 @@ void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
826 } 817 }
827 818
828 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { 819 if (walk_state->data_type != ACPI_DESC_TYPE_WALK) {
829 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 820 ACPI_ERROR((AE_INFO, "%p is not a valid walk state",
830 "%p is not a valid walk state\n", 821 walk_state));
831 walk_state));
832 return; 822 return;
833 } 823 }
834 824
835 if (walk_state->parser_state.scope) { 825 if (walk_state->parser_state.scope) {
836 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 826 ACPI_ERROR((AE_INFO, "%p walk still has a scope list",
837 "%p walk still has a scope list\n", 827 walk_state));
838 walk_state));
839 } 828 }
840 829
841 /* Always must free any linked control states */ 830 /* Always must free any linked control states */
@@ -894,25 +883,24 @@ acpi_ds_result_insert(void *object,
894 883
895 state = walk_state->results; 884 state = walk_state->results;
896 if (!state) { 885 if (!state) {
897 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 886 ACPI_ERROR((AE_INFO, "No result object pushed! State=%p",
898 "No result object pushed! State=%p\n", 887 walk_state));
899 walk_state));
900 return (AE_NOT_EXIST); 888 return (AE_NOT_EXIST);
901 } 889 }
902 890
903 if (index >= ACPI_OBJ_NUM_OPERANDS) { 891 if (index >= ACPI_OBJ_NUM_OPERANDS) {
904 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 892 ACPI_ERROR((AE_INFO,
905 "Index out of range: %X Obj=%p State=%p Num=%X\n", 893 "Index out of range: %X Obj=%p State=%p Num=%X",
906 index, object, walk_state, 894 index, object, walk_state,
907 state->results.num_results)); 895 state->results.num_results));
908 return (AE_BAD_PARAMETER); 896 return (AE_BAD_PARAMETER);
909 } 897 }
910 898
911 if (!object) { 899 if (!object) {
912 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 900 ACPI_ERROR((AE_INFO,
913 "Null Object! Index=%X Obj=%p State=%p Num=%X\n", 901 "Null Object! Index=%X Obj=%p State=%p Num=%X",
914 index, object, walk_state, 902 index, object, walk_state,
915 state->results.num_results)); 903 state->results.num_results));
916 return (AE_BAD_PARAMETER); 904 return (AE_BAD_PARAMETER);
917 } 905 }
918 906
@@ -986,9 +974,9 @@ acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
986 /* Check for stack underflow */ 974 /* Check for stack underflow */
987 975
988 if (walk_state->num_operands == 0) { 976 if (walk_state->num_operands == 0) {
989 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 977 ACPI_ERROR((AE_INFO,
990 "Missing operand/stack empty! State=%p #Ops=%X\n", 978 "Missing operand/stack empty! State=%p #Ops=%X",
991 walk_state, walk_state->num_operands)); 979 walk_state, walk_state->num_operands));
992 *object = NULL; 980 *object = NULL;
993 return (AE_AML_NO_OPERAND); 981 return (AE_AML_NO_OPERAND);
994 } 982 }
@@ -1000,9 +988,9 @@ acpi_ds_obj_stack_pop_object(union acpi_operand_object **object,
1000 /* Check for a valid operand */ 988 /* Check for a valid operand */
1001 989
1002 if (!walk_state->operands[walk_state->num_operands]) { 990 if (!walk_state->operands[walk_state->num_operands]) {
1003 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 991 ACPI_ERROR((AE_INFO,
1004 "Null operand! State=%p #Ops=%X\n", 992 "Null operand! State=%p #Ops=%X",
1005 walk_state, walk_state->num_operands)); 993 walk_state, walk_state->num_operands));
1006 *object = NULL; 994 *object = NULL;
1007 return (AE_AML_NO_OPERAND); 995 return (AE_AML_NO_OPERAND);
1008 } 996 }
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 3758b558d2b5..79b09d76c180 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -60,20 +60,20 @@ ACPI_MODULE_NAME("acpi_ec")
60#define ACPI_EC_BURST_ENABLE 0x82 60#define ACPI_EC_BURST_ENABLE 0x82
61#define ACPI_EC_BURST_DISABLE 0x83 61#define ACPI_EC_BURST_DISABLE 0x83
62#define ACPI_EC_COMMAND_QUERY 0x84 62#define ACPI_EC_COMMAND_QUERY 0x84
63#define EC_POLLING 0xFF 63#define EC_POLL 0xFF
64#define EC_BURST 0x00 64#define EC_INTR 0x00
65static int acpi_ec_remove(struct acpi_device *device, int type); 65static int acpi_ec_remove(struct acpi_device *device, int type);
66static int acpi_ec_start(struct acpi_device *device); 66static int acpi_ec_start(struct acpi_device *device);
67static int acpi_ec_stop(struct acpi_device *device, int type); 67static int acpi_ec_stop(struct acpi_device *device, int type);
68static int acpi_ec_burst_add(struct acpi_device *device); 68static int acpi_ec_intr_add(struct acpi_device *device);
69static int acpi_ec_polling_add(struct acpi_device *device); 69static int acpi_ec_poll_add(struct acpi_device *device);
70 70
71static struct acpi_driver acpi_ec_driver = { 71static struct acpi_driver acpi_ec_driver = {
72 .name = ACPI_EC_DRIVER_NAME, 72 .name = ACPI_EC_DRIVER_NAME,
73 .class = ACPI_EC_CLASS, 73 .class = ACPI_EC_CLASS,
74 .ids = ACPI_EC_HID, 74 .ids = ACPI_EC_HID,
75 .ops = { 75 .ops = {
76 .add = acpi_ec_polling_add, 76 .add = acpi_ec_intr_add,
77 .remove = acpi_ec_remove, 77 .remove = acpi_ec_remove,
78 .start = acpi_ec_start, 78 .start = acpi_ec_start,
79 .stop = acpi_ec_stop, 79 .stop = acpi_ec_stop,
@@ -105,7 +105,7 @@ union acpi_ec {
105 atomic_t pending_gpe; 105 atomic_t pending_gpe;
106 struct semaphore sem; 106 struct semaphore sem;
107 wait_queue_head_t wait; 107 wait_queue_head_t wait;
108 } burst; 108 } intr;
109 109
110 struct { 110 struct {
111 u32 mode; 111 u32 mode;
@@ -117,37 +117,37 @@ union acpi_ec {
117 struct acpi_generic_address data_addr; 117 struct acpi_generic_address data_addr;
118 unsigned long global_lock; 118 unsigned long global_lock;
119 spinlock_t lock; 119 spinlock_t lock;
120 } polling; 120 } poll;
121}; 121};
122 122
123static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event); 123static int acpi_ec_poll_wait(union acpi_ec *ec, u8 event);
124static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event); 124static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event);
125static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data); 125static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data);
126static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data); 126static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data);
127static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data); 127static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data);
128static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data); 128static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data);
129static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data); 129static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data);
130static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data); 130static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data);
131static void acpi_ec_gpe_polling_query(void *ec_cxt); 131static void acpi_ec_gpe_poll_query(void *ec_cxt);
132static void acpi_ec_gpe_burst_query(void *ec_cxt); 132static void acpi_ec_gpe_intr_query(void *ec_cxt);
133static u32 acpi_ec_gpe_polling_handler(void *data); 133static u32 acpi_ec_gpe_poll_handler(void *data);
134static u32 acpi_ec_gpe_burst_handler(void *data); 134static u32 acpi_ec_gpe_intr_handler(void *data);
135static acpi_status __init 135static acpi_status __init
136acpi_fake_ecdt_polling_callback(acpi_handle handle, 136acpi_fake_ecdt_poll_callback(acpi_handle handle,
137 u32 Level, void *context, void **retval); 137 u32 Level, void *context, void **retval);
138 138
139static acpi_status __init 139static acpi_status __init
140acpi_fake_ecdt_burst_callback(acpi_handle handle, 140acpi_fake_ecdt_intr_callback(acpi_handle handle,
141 u32 Level, void *context, void **retval); 141 u32 Level, void *context, void **retval);
142 142
143static int __init acpi_ec_polling_get_real_ecdt(void); 143static int __init acpi_ec_poll_get_real_ecdt(void);
144static int __init acpi_ec_burst_get_real_ecdt(void); 144static int __init acpi_ec_intr_get_real_ecdt(void);
145/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 145/* If we find an EC via the ECDT, we need to keep a ptr to its context */
146static union acpi_ec *ec_ecdt; 146static union acpi_ec *ec_ecdt;
147 147
148/* External interfaces use first EC only, so remember */ 148/* External interfaces use first EC only, so remember */
149static struct acpi_device *first_ec; 149static struct acpi_device *first_ec;
150static int acpi_ec_polling_mode = EC_POLLING; 150static int acpi_ec_poll_mode = EC_INTR;
151 151
152/* -------------------------------------------------------------------------- 152/* --------------------------------------------------------------------------
153 Transaction Management 153 Transaction Management
@@ -163,13 +163,13 @@ static u32 acpi_ec_read_status(union acpi_ec *ec)
163 163
164static int acpi_ec_wait(union acpi_ec *ec, u8 event) 164static int acpi_ec_wait(union acpi_ec *ec, u8 event)
165{ 165{
166 if (acpi_ec_polling_mode) 166 if (acpi_ec_poll_mode)
167 return acpi_ec_polling_wait(ec, event); 167 return acpi_ec_poll_wait(ec, event);
168 else 168 else
169 return acpi_ec_burst_wait(ec, event); 169 return acpi_ec_intr_wait(ec, event);
170} 170}
171 171
172static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event) 172static int acpi_ec_poll_wait(union acpi_ec *ec, u8 event)
173{ 173{
174 u32 acpi_ec_status = 0; 174 u32 acpi_ec_status = 0;
175 u32 i = ACPI_EC_UDELAY_COUNT; 175 u32 i = ACPI_EC_UDELAY_COUNT;
@@ -203,36 +203,31 @@ static int acpi_ec_polling_wait(union acpi_ec *ec, u8 event)
203 203
204 return -ETIME; 204 return -ETIME;
205} 205}
206static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event) 206static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
207{ 207{
208 int result = 0; 208 int result = 0;
209 209
210 ACPI_FUNCTION_TRACE("acpi_ec_wait"); 210 ACPI_FUNCTION_TRACE("acpi_ec_wait");
211 211
212 ec->burst.expect_event = event; 212 ec->intr.expect_event = event;
213 smp_mb(); 213 smp_mb();
214 214
215 switch (event) { 215 switch (event) {
216 case ACPI_EC_EVENT_OBF:
217 if (acpi_ec_read_status(ec) & event) {
218 ec->burst.expect_event = 0;
219 return_VALUE(0);
220 }
221 break;
222
223 case ACPI_EC_EVENT_IBE: 216 case ACPI_EC_EVENT_IBE:
224 if (~acpi_ec_read_status(ec) & event) { 217 if (~acpi_ec_read_status(ec) & event) {
225 ec->burst.expect_event = 0; 218 ec->intr.expect_event = 0;
226 return_VALUE(0); 219 return_VALUE(0);
227 } 220 }
228 break; 221 break;
222 default:
223 break;
229 } 224 }
230 225
231 result = wait_event_timeout(ec->burst.wait, 226 result = wait_event_timeout(ec->intr.wait,
232 !ec->burst.expect_event, 227 !ec->intr.expect_event,
233 msecs_to_jiffies(ACPI_EC_DELAY)); 228 msecs_to_jiffies(ACPI_EC_DELAY));
234 229
235 ec->burst.expect_event = 0; 230 ec->intr.expect_event = 0;
236 smp_mb(); 231 smp_mb();
237 232
238 /* 233 /*
@@ -255,7 +250,12 @@ static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event)
255 return_VALUE(-ETIME); 250 return_VALUE(-ETIME);
256} 251}
257 252
258static int acpi_ec_enter_burst_mode(union acpi_ec *ec) 253#ifdef ACPI_FUTURE_USAGE
254/*
255 * Note: samsung nv5000 doesn't work with ec burst mode.
256 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
257 */
258int acpi_ec_enter_burst_mode(union acpi_ec *ec)
259{ 259{
260 u32 tmp = 0; 260 u32 tmp = 0;
261 int status = 0; 261 int status = 0;
@@ -270,45 +270,56 @@ static int acpi_ec_enter_burst_mode(union acpi_ec *ec)
270 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, 270 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE,
271 &ec->common.command_addr); 271 &ec->common.command_addr);
272 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 272 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
273 if (status)
274 return_VALUE(-EINVAL);
275 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); 273 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
276 if (tmp != 0x90) { /* Burst ACK byte */ 274 if (tmp != 0x90) { /* Burst ACK byte */
277 return_VALUE(-EINVAL); 275 return_VALUE(-EINVAL);
278 } 276 }
279 } 277 }
280 278
281 atomic_set(&ec->burst.leaving_burst, 0); 279 atomic_set(&ec->intr.leaving_burst, 0);
282 return_VALUE(0); 280 return_VALUE(0);
283 end: 281 end:
284 printk("Error in acpi_ec_wait\n"); 282 printk(KERN_WARNING PREFIX "Error in acpi_ec_wait\n");
285 return_VALUE(-1); 283 return_VALUE(-1);
286} 284}
287 285
288static int acpi_ec_leave_burst_mode(union acpi_ec *ec) 286int acpi_ec_leave_burst_mode(union acpi_ec *ec)
289{ 287{
288 int status = 0;
290 289
291 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); 290 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
292 291
293 atomic_set(&ec->burst.leaving_burst, 1); 292 status = acpi_ec_read_status(ec);
293 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
294 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
295 if(status)
296 goto end;
297 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr);
298 acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
299 }
300 atomic_set(&ec->intr.leaving_burst, 1);
294 return_VALUE(0); 301 return_VALUE(0);
302end:
303 printk(KERN_WARNING PREFIX "leave burst_mode:error\n");
304 return_VALUE(-1);
295} 305}
306#endif /* ACPI_FUTURE_USAGE */
296 307
297static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) 308static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data)
298{ 309{
299 if (acpi_ec_polling_mode) 310 if (acpi_ec_poll_mode)
300 return acpi_ec_polling_read(ec, address, data); 311 return acpi_ec_poll_read(ec, address, data);
301 else 312 else
302 return acpi_ec_burst_read(ec, address, data); 313 return acpi_ec_intr_read(ec, address, data);
303} 314}
304static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data) 315static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data)
305{ 316{
306 if (acpi_ec_polling_mode) 317 if (acpi_ec_poll_mode)
307 return acpi_ec_polling_write(ec, address, data); 318 return acpi_ec_poll_write(ec, address, data);
308 else 319 else
309 return acpi_ec_burst_write(ec, address, data); 320 return acpi_ec_intr_write(ec, address, data);
310} 321}
311static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data) 322static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data)
312{ 323{
313 acpi_status status = AE_OK; 324 acpi_status status = AE_OK;
314 int result = 0; 325 int result = 0;
@@ -328,7 +339,7 @@ static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data)
328 return_VALUE(-ENODEV); 339 return_VALUE(-ENODEV);
329 } 340 }
330 341
331 spin_lock_irqsave(&ec->polling.lock, flags); 342 spin_lock_irqsave(&ec->poll.lock, flags);
332 343
333 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, 344 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
334 &ec->common.command_addr); 345 &ec->common.command_addr);
@@ -347,7 +358,7 @@ static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data)
347 *data, address)); 358 *data, address));
348 359
349 end: 360 end:
350 spin_unlock_irqrestore(&ec->polling.lock, flags); 361 spin_unlock_irqrestore(&ec->poll.lock, flags);
351 362
352 if (ec->common.global_lock) 363 if (ec->common.global_lock)
353 acpi_release_global_lock(glk); 364 acpi_release_global_lock(glk);
@@ -355,7 +366,7 @@ static int acpi_ec_polling_read(union acpi_ec *ec, u8 address, u32 * data)
355 return_VALUE(result); 366 return_VALUE(result);
356} 367}
357 368
358static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data) 369static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data)
359{ 370{
360 int result = 0; 371 int result = 0;
361 acpi_status status = AE_OK; 372 acpi_status status = AE_OK;
@@ -373,7 +384,7 @@ static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data)
373 return_VALUE(-ENODEV); 384 return_VALUE(-ENODEV);
374 } 385 }
375 386
376 spin_lock_irqsave(&ec->polling.lock, flags); 387 spin_lock_irqsave(&ec->poll.lock, flags);
377 388
378 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, 389 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
379 &ec->common.command_addr); 390 &ec->common.command_addr);
@@ -395,7 +406,7 @@ static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data)
395 data, address)); 406 data, address));
396 407
397 end: 408 end:
398 spin_unlock_irqrestore(&ec->polling.lock, flags); 409 spin_unlock_irqrestore(&ec->poll.lock, flags);
399 410
400 if (ec->common.global_lock) 411 if (ec->common.global_lock)
401 acpi_release_global_lock(glk); 412 acpi_release_global_lock(glk);
@@ -403,7 +414,7 @@ static int acpi_ec_polling_write(union acpi_ec *ec, u8 address, u8 data)
403 return_VALUE(result); 414 return_VALUE(result);
404} 415}
405 416
406static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data) 417static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
407{ 418{
408 int status = 0; 419 int status = 0;
409 u32 glk; 420 u32 glk;
@@ -422,25 +433,24 @@ static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data)
422 } 433 }
423 434
424 WARN_ON(in_interrupt()); 435 WARN_ON(in_interrupt());
425 down(&ec->burst.sem); 436 down(&ec->intr.sem);
426 437
427 acpi_ec_enter_burst_mode(ec);
428 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 438 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
429 if (status) { 439 if (status) {
430 printk("read EC, IB not empty\n"); 440 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
431 goto end; 441 goto end;
432 } 442 }
433 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, 443 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
434 &ec->common.command_addr); 444 &ec->common.command_addr);
435 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 445 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
436 if (status) { 446 if (status) {
437 printk("read EC, IB not empty\n"); 447 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
438 } 448 }
439 449
440 acpi_hw_low_level_write(8, address, &ec->common.data_addr); 450 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
441 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 451 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
442 if (status) { 452 if (status) {
443 printk("read EC, OB not full\n"); 453 printk(KERN_DEBUG PREFIX "read EC, OB not full\n");
444 goto end; 454 goto end;
445 } 455 }
446 acpi_hw_low_level_read(8, data, &ec->common.data_addr); 456 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
@@ -448,8 +458,7 @@ static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data)
448 *data, address)); 458 *data, address));
449 459
450 end: 460 end:
451 acpi_ec_leave_burst_mode(ec); 461 up(&ec->intr.sem);
452 up(&ec->burst.sem);
453 462
454 if (ec->common.global_lock) 463 if (ec->common.global_lock)
455 acpi_release_global_lock(glk); 464 acpi_release_global_lock(glk);
@@ -457,7 +466,7 @@ static int acpi_ec_burst_read(union acpi_ec *ec, u8 address, u32 * data)
457 return_VALUE(status); 466 return_VALUE(status);
458} 467}
459 468
460static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data) 469static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
461{ 470{
462 int status = 0; 471 int status = 0;
463 u32 glk; 472 u32 glk;
@@ -474,25 +483,23 @@ static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data)
474 } 483 }
475 484
476 WARN_ON(in_interrupt()); 485 WARN_ON(in_interrupt());
477 down(&ec->burst.sem); 486 down(&ec->intr.sem);
478
479 acpi_ec_enter_burst_mode(ec);
480 487
481 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 488 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
482 if (status) { 489 if (status) {
483 printk("write EC, IB not empty\n"); 490 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
484 } 491 }
485 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, 492 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
486 &ec->common.command_addr); 493 &ec->common.command_addr);
487 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 494 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
488 if (status) { 495 if (status) {
489 printk("write EC, IB not empty\n"); 496 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
490 } 497 }
491 498
492 acpi_hw_low_level_write(8, address, &ec->common.data_addr); 499 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
493 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 500 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
494 if (status) { 501 if (status) {
495 printk("write EC, IB not empty\n"); 502 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
496 } 503 }
497 504
498 acpi_hw_low_level_write(8, data, &ec->common.data_addr); 505 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
@@ -500,8 +507,7 @@ static int acpi_ec_burst_write(union acpi_ec *ec, u8 address, u8 data)
500 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 507 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
501 data, address)); 508 data, address));
502 509
503 acpi_ec_leave_burst_mode(ec); 510 up(&ec->intr.sem);
504 up(&ec->burst.sem);
505 511
506 if (ec->common.global_lock) 512 if (ec->common.global_lock)
507 acpi_release_global_lock(glk); 513 acpi_release_global_lock(glk);
@@ -553,12 +559,12 @@ EXPORT_SYMBOL(ec_write);
553 559
554static int acpi_ec_query(union acpi_ec *ec, u32 * data) 560static int acpi_ec_query(union acpi_ec *ec, u32 * data)
555{ 561{
556 if (acpi_ec_polling_mode) 562 if (acpi_ec_poll_mode)
557 return acpi_ec_polling_query(ec, data); 563 return acpi_ec_poll_query(ec, data);
558 else 564 else
559 return acpi_ec_burst_query(ec, data); 565 return acpi_ec_intr_query(ec, data);
560} 566}
561static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data) 567static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data)
562{ 568{
563 int result = 0; 569 int result = 0;
564 acpi_status status = AE_OK; 570 acpi_status status = AE_OK;
@@ -583,7 +589,7 @@ static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data)
583 * Note that successful completion of the query causes the ACPI_EC_SCI 589 * Note that successful completion of the query causes the ACPI_EC_SCI
584 * bit to be cleared (and thus clearing the interrupt source). 590 * bit to be cleared (and thus clearing the interrupt source).
585 */ 591 */
586 spin_lock_irqsave(&ec->polling.lock, flags); 592 spin_lock_irqsave(&ec->poll.lock, flags);
587 593
588 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, 594 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY,
589 &ec->common.command_addr); 595 &ec->common.command_addr);
@@ -596,14 +602,14 @@ static int acpi_ec_polling_query(union acpi_ec *ec, u32 * data)
596 result = -ENODATA; 602 result = -ENODATA;
597 603
598 end: 604 end:
599 spin_unlock_irqrestore(&ec->polling.lock, flags); 605 spin_unlock_irqrestore(&ec->poll.lock, flags);
600 606
601 if (ec->common.global_lock) 607 if (ec->common.global_lock)
602 acpi_release_global_lock(glk); 608 acpi_release_global_lock(glk);
603 609
604 return_VALUE(result); 610 return_VALUE(result);
605} 611}
606static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data) 612static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data)
607{ 613{
608 int status = 0; 614 int status = 0;
609 u32 glk; 615 u32 glk;
@@ -620,11 +626,11 @@ static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data)
620 return_VALUE(-ENODEV); 626 return_VALUE(-ENODEV);
621 } 627 }
622 628
623 down(&ec->burst.sem); 629 down(&ec->intr.sem);
624 630
625 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 631 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
626 if (status) { 632 if (status) {
627 printk("query EC, IB not empty\n"); 633 printk(KERN_DEBUG PREFIX "query EC, IB not empty\n");
628 goto end; 634 goto end;
629 } 635 }
630 /* 636 /*
@@ -636,7 +642,7 @@ static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data)
636 &ec->common.command_addr); 642 &ec->common.command_addr);
637 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 643 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
638 if (status) { 644 if (status) {
639 printk("query EC, OB not full\n"); 645 printk(KERN_DEBUG PREFIX "query EC, OB not full\n");
640 goto end; 646 goto end;
641 } 647 }
642 648
@@ -645,7 +651,7 @@ static int acpi_ec_burst_query(union acpi_ec *ec, u32 * data)
645 status = -ENODATA; 651 status = -ENODATA;
646 652
647 end: 653 end:
648 up(&ec->burst.sem); 654 up(&ec->intr.sem);
649 655
650 if (ec->common.global_lock) 656 if (ec->common.global_lock)
651 acpi_release_global_lock(glk); 657 acpi_release_global_lock(glk);
@@ -664,13 +670,13 @@ union acpi_ec_query_data {
664 670
665static void acpi_ec_gpe_query(void *ec_cxt) 671static void acpi_ec_gpe_query(void *ec_cxt)
666{ 672{
667 if (acpi_ec_polling_mode) 673 if (acpi_ec_poll_mode)
668 acpi_ec_gpe_polling_query(ec_cxt); 674 acpi_ec_gpe_poll_query(ec_cxt);
669 else 675 else
670 acpi_ec_gpe_burst_query(ec_cxt); 676 acpi_ec_gpe_intr_query(ec_cxt);
671} 677}
672 678
673static void acpi_ec_gpe_polling_query(void *ec_cxt) 679static void acpi_ec_gpe_poll_query(void *ec_cxt)
674{ 680{
675 union acpi_ec *ec = (union acpi_ec *)ec_cxt; 681 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
676 u32 value = 0; 682 u32 value = 0;
@@ -685,9 +691,9 @@ static void acpi_ec_gpe_polling_query(void *ec_cxt)
685 if (!ec_cxt) 691 if (!ec_cxt)
686 goto end; 692 goto end;
687 693
688 spin_lock_irqsave(&ec->polling.lock, flags); 694 spin_lock_irqsave(&ec->poll.lock, flags);
689 acpi_hw_low_level_read(8, &value, &ec->common.command_addr); 695 acpi_hw_low_level_read(8, &value, &ec->common.command_addr);
690 spin_unlock_irqrestore(&ec->polling.lock, flags); 696 spin_unlock_irqrestore(&ec->poll.lock, flags);
691 697
692 /* TBD: Implement asynch events! 698 /* TBD: Implement asynch events!
693 * NOTE: All we care about are EC-SCI's. Other EC events are 699 * NOTE: All we care about are EC-SCI's. Other EC events are
@@ -711,7 +717,7 @@ static void acpi_ec_gpe_polling_query(void *ec_cxt)
711 end: 717 end:
712 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 718 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
713} 719}
714static void acpi_ec_gpe_burst_query(void *ec_cxt) 720static void acpi_ec_gpe_intr_query(void *ec_cxt)
715{ 721{
716 union acpi_ec *ec = (union acpi_ec *)ec_cxt; 722 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
717 u32 value; 723 u32 value;
@@ -736,18 +742,18 @@ static void acpi_ec_gpe_burst_query(void *ec_cxt)
736 742
737 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); 743 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
738 end: 744 end:
739 atomic_dec(&ec->burst.pending_gpe); 745 atomic_dec(&ec->intr.pending_gpe);
740 return; 746 return;
741} 747}
742 748
743static u32 acpi_ec_gpe_handler(void *data) 749static u32 acpi_ec_gpe_handler(void *data)
744{ 750{
745 if (acpi_ec_polling_mode) 751 if (acpi_ec_poll_mode)
746 return acpi_ec_gpe_polling_handler(data); 752 return acpi_ec_gpe_poll_handler(data);
747 else 753 else
748 return acpi_ec_gpe_burst_handler(data); 754 return acpi_ec_gpe_intr_handler(data);
749} 755}
750static u32 acpi_ec_gpe_polling_handler(void *data) 756static u32 acpi_ec_gpe_poll_handler(void *data)
751{ 757{
752 acpi_status status = AE_OK; 758 acpi_status status = AE_OK;
753 union acpi_ec *ec = (union acpi_ec *)data; 759 union acpi_ec *ec = (union acpi_ec *)data;
@@ -765,7 +771,7 @@ static u32 acpi_ec_gpe_polling_handler(void *data)
765 else 771 else
766 return ACPI_INTERRUPT_NOT_HANDLED; 772 return ACPI_INTERRUPT_NOT_HANDLED;
767} 773}
768static u32 acpi_ec_gpe_burst_handler(void *data) 774static u32 acpi_ec_gpe_intr_handler(void *data)
769{ 775{
770 acpi_status status = AE_OK; 776 acpi_status status = AE_OK;
771 u32 value; 777 u32 value;
@@ -777,22 +783,22 @@ static u32 acpi_ec_gpe_burst_handler(void *data)
777 acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 783 acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
778 value = acpi_ec_read_status(ec); 784 value = acpi_ec_read_status(ec);
779 785
780 switch (ec->burst.expect_event) { 786 switch (ec->intr.expect_event) {
781 case ACPI_EC_EVENT_OBF: 787 case ACPI_EC_EVENT_OBF:
782 if (!(value & ACPI_EC_FLAG_OBF)) 788 if (!(value & ACPI_EC_FLAG_OBF))
783 break; 789 break;
784 case ACPI_EC_EVENT_IBE: 790 case ACPI_EC_EVENT_IBE:
785 if ((value & ACPI_EC_FLAG_IBF)) 791 if ((value & ACPI_EC_FLAG_IBF))
786 break; 792 break;
787 ec->burst.expect_event = 0; 793 ec->intr.expect_event = 0;
788 wake_up(&ec->burst.wait); 794 wake_up(&ec->intr.wait);
789 return ACPI_INTERRUPT_HANDLED; 795 return ACPI_INTERRUPT_HANDLED;
790 default: 796 default:
791 break; 797 break;
792 } 798 }
793 799
794 if (value & ACPI_EC_FLAG_SCI) { 800 if (value & ACPI_EC_FLAG_SCI) {
795 atomic_add(1, &ec->burst.pending_gpe); 801 atomic_add(1, &ec->intr.pending_gpe);
796 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 802 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
797 acpi_ec_gpe_query, ec); 803 acpi_ec_gpe_query, ec);
798 return status == AE_OK ? 804 return status == AE_OK ?
@@ -980,7 +986,7 @@ static int acpi_ec_remove_fs(struct acpi_device *device)
980 Driver Interface 986 Driver Interface
981 -------------------------------------------------------------------------- */ 987 -------------------------------------------------------------------------- */
982 988
983static int acpi_ec_polling_add(struct acpi_device *device) 989static int acpi_ec_poll_add(struct acpi_device *device)
984{ 990{
985 int result = 0; 991 int result = 0;
986 acpi_status status = AE_OK; 992 acpi_status status = AE_OK;
@@ -999,7 +1005,7 @@ static int acpi_ec_polling_add(struct acpi_device *device)
999 1005
1000 ec->common.handle = device->handle; 1006 ec->common.handle = device->handle;
1001 ec->common.uid = -1; 1007 ec->common.uid = -1;
1002 spin_lock_init(&ec->polling.lock); 1008 spin_lock_init(&ec->poll.lock);
1003 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 1009 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1004 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 1010 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1005 acpi_driver_data(device) = ec; 1011 acpi_driver_data(device) = ec;
@@ -1038,7 +1044,7 @@ static int acpi_ec_polling_add(struct acpi_device *device)
1038 if (result) 1044 if (result)
1039 goto end; 1045 goto end;
1040 1046
1041 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", 1047 printk(KERN_INFO PREFIX "%s [%s] (gpe %d) polling mode.\n",
1042 acpi_device_name(device), acpi_device_bid(device), 1048 acpi_device_name(device), acpi_device_bid(device),
1043 (u32) ec->common.gpe_bit); 1049 (u32) ec->common.gpe_bit);
1044 1050
@@ -1051,7 +1057,7 @@ static int acpi_ec_polling_add(struct acpi_device *device)
1051 1057
1052 return_VALUE(result); 1058 return_VALUE(result);
1053} 1059}
1054static int acpi_ec_burst_add(struct acpi_device *device) 1060static int acpi_ec_intr_add(struct acpi_device *device)
1055{ 1061{
1056 int result = 0; 1062 int result = 0;
1057 acpi_status status = AE_OK; 1063 acpi_status status = AE_OK;
@@ -1070,10 +1076,10 @@ static int acpi_ec_burst_add(struct acpi_device *device)
1070 1076
1071 ec->common.handle = device->handle; 1077 ec->common.handle = device->handle;
1072 ec->common.uid = -1; 1078 ec->common.uid = -1;
1073 atomic_set(&ec->burst.pending_gpe, 0); 1079 atomic_set(&ec->intr.pending_gpe, 0);
1074 atomic_set(&ec->burst.leaving_burst, 1); 1080 atomic_set(&ec->intr.leaving_burst, 1);
1075 init_MUTEX(&ec->burst.sem); 1081 init_MUTEX(&ec->intr.sem);
1076 init_waitqueue_head(&ec->burst.wait); 1082 init_waitqueue_head(&ec->intr.wait);
1077 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 1083 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1078 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 1084 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1079 acpi_driver_data(device) = ec; 1085 acpi_driver_data(device) = ec;
@@ -1112,8 +1118,7 @@ static int acpi_ec_burst_add(struct acpi_device *device)
1112 if (result) 1118 if (result)
1113 goto end; 1119 goto end;
1114 1120
1115 printk("burst-mode-ec-10-Aug\n"); 1121 printk(KERN_INFO PREFIX "%s [%s] (gpe %d) interrupt mode.\n",
1116 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
1117 acpi_device_name(device), acpi_device_bid(device), 1122 acpi_device_name(device), acpi_device_bid(device),
1118 (u32) ec->common.gpe_bit); 1123 (u32) ec->common.gpe_bit);
1119 1124
@@ -1151,7 +1156,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1151 union acpi_ec *ec = (union acpi_ec *)context; 1156 union acpi_ec *ec = (union acpi_ec *)context;
1152 struct acpi_generic_address *addr; 1157 struct acpi_generic_address *addr;
1153 1158
1154 if (resource->id != ACPI_RSTYPE_IO) { 1159 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
1155 return AE_OK; 1160 return AE_OK;
1156 } 1161 }
1157 1162
@@ -1171,7 +1176,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1171 addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; 1176 addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
1172 addr->register_bit_width = 8; 1177 addr->register_bit_width = 8;
1173 addr->register_bit_offset = 0; 1178 addr->register_bit_offset = 0;
1174 addr->address = resource->data.io.min_base_address; 1179 addr->address = resource->data.io.minimum;
1175 1180
1176 return AE_OK; 1181 return AE_OK;
1177} 1182}
@@ -1267,16 +1272,16 @@ acpi_fake_ecdt_callback(acpi_handle handle,
1267 u32 Level, void *context, void **retval) 1272 u32 Level, void *context, void **retval)
1268{ 1273{
1269 1274
1270 if (acpi_ec_polling_mode) 1275 if (acpi_ec_poll_mode)
1271 return acpi_fake_ecdt_polling_callback(handle, 1276 return acpi_fake_ecdt_poll_callback(handle,
1272 Level, context, retval); 1277 Level, context, retval);
1273 else 1278 else
1274 return acpi_fake_ecdt_burst_callback(handle, 1279 return acpi_fake_ecdt_intr_callback(handle,
1275 Level, context, retval); 1280 Level, context, retval);
1276} 1281}
1277 1282
1278static acpi_status __init 1283static acpi_status __init
1279acpi_fake_ecdt_polling_callback(acpi_handle handle, 1284acpi_fake_ecdt_poll_callback(acpi_handle handle,
1280 u32 Level, void *context, void **retval) 1285 u32 Level, void *context, void **retval)
1281{ 1286{
1282 acpi_status status; 1287 acpi_status status;
@@ -1295,7 +1300,7 @@ acpi_fake_ecdt_polling_callback(acpi_handle handle,
1295 &ec_ecdt->common.gpe_bit); 1300 &ec_ecdt->common.gpe_bit);
1296 if (ACPI_FAILURE(status)) 1301 if (ACPI_FAILURE(status))
1297 return status; 1302 return status;
1298 spin_lock_init(&ec_ecdt->polling.lock); 1303 spin_lock_init(&ec_ecdt->poll.lock);
1299 ec_ecdt->common.global_lock = TRUE; 1304 ec_ecdt->common.global_lock = TRUE;
1300 ec_ecdt->common.handle = handle; 1305 ec_ecdt->common.handle = handle;
1301 1306
@@ -1308,13 +1313,13 @@ acpi_fake_ecdt_polling_callback(acpi_handle handle,
1308} 1313}
1309 1314
1310static acpi_status __init 1315static acpi_status __init
1311acpi_fake_ecdt_burst_callback(acpi_handle handle, 1316acpi_fake_ecdt_intr_callback(acpi_handle handle,
1312 u32 Level, void *context, void **retval) 1317 u32 Level, void *context, void **retval)
1313{ 1318{
1314 acpi_status status; 1319 acpi_status status;
1315 1320
1316 init_MUTEX(&ec_ecdt->burst.sem); 1321 init_MUTEX(&ec_ecdt->intr.sem);
1317 init_waitqueue_head(&ec_ecdt->burst.wait); 1322 init_waitqueue_head(&ec_ecdt->intr.wait);
1318 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 1323 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1319 acpi_ec_io_ports, ec_ecdt); 1324 acpi_ec_io_ports, ec_ecdt);
1320 if (ACPI_FAILURE(status)) 1325 if (ACPI_FAILURE(status))
@@ -1380,13 +1385,13 @@ static int __init acpi_ec_fake_ecdt(void)
1380 1385
1381static int __init acpi_ec_get_real_ecdt(void) 1386static int __init acpi_ec_get_real_ecdt(void)
1382{ 1387{
1383 if (acpi_ec_polling_mode) 1388 if (acpi_ec_poll_mode)
1384 return acpi_ec_polling_get_real_ecdt(); 1389 return acpi_ec_poll_get_real_ecdt();
1385 else 1390 else
1386 return acpi_ec_burst_get_real_ecdt(); 1391 return acpi_ec_intr_get_real_ecdt();
1387} 1392}
1388 1393
1389static int __init acpi_ec_polling_get_real_ecdt(void) 1394static int __init acpi_ec_poll_get_real_ecdt(void)
1390{ 1395{
1391 acpi_status status; 1396 acpi_status status;
1392 struct acpi_table_ecdt *ecdt_ptr; 1397 struct acpi_table_ecdt *ecdt_ptr;
@@ -1411,7 +1416,7 @@ static int __init acpi_ec_polling_get_real_ecdt(void)
1411 ec_ecdt->common.status_addr = ecdt_ptr->ec_control; 1416 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1412 ec_ecdt->common.data_addr = ecdt_ptr->ec_data; 1417 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1413 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit; 1418 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1414 spin_lock_init(&ec_ecdt->polling.lock); 1419 spin_lock_init(&ec_ecdt->poll.lock);
1415 /* use the GL just to be safe */ 1420 /* use the GL just to be safe */
1416 ec_ecdt->common.global_lock = TRUE; 1421 ec_ecdt->common.global_lock = TRUE;
1417 ec_ecdt->common.uid = ecdt_ptr->uid; 1422 ec_ecdt->common.uid = ecdt_ptr->uid;
@@ -1431,7 +1436,7 @@ static int __init acpi_ec_polling_get_real_ecdt(void)
1431 return -ENODEV; 1436 return -ENODEV;
1432} 1437}
1433 1438
1434static int __init acpi_ec_burst_get_real_ecdt(void) 1439static int __init acpi_ec_intr_get_real_ecdt(void)
1435{ 1440{
1436 acpi_status status; 1441 acpi_status status;
1437 struct acpi_table_ecdt *ecdt_ptr; 1442 struct acpi_table_ecdt *ecdt_ptr;
@@ -1452,8 +1457,8 @@ static int __init acpi_ec_burst_get_real_ecdt(void)
1452 return -ENOMEM; 1457 return -ENOMEM;
1453 memset(ec_ecdt, 0, sizeof(union acpi_ec)); 1458 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1454 1459
1455 init_MUTEX(&ec_ecdt->burst.sem); 1460 init_MUTEX(&ec_ecdt->intr.sem);
1456 init_waitqueue_head(&ec_ecdt->burst.wait); 1461 init_waitqueue_head(&ec_ecdt->intr.wait);
1457 ec_ecdt->common.command_addr = ecdt_ptr->ec_control; 1462 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1458 ec_ecdt->common.status_addr = ecdt_ptr->ec_control; 1463 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1459 ec_ecdt->common.data_addr = ecdt_ptr->ec_data; 1464 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
@@ -1571,22 +1576,22 @@ static int __init acpi_fake_ecdt_setup(char *str)
1571} 1576}
1572 1577
1573__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup); 1578__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1574static int __init acpi_ec_set_polling_mode(char *str) 1579static int __init acpi_ec_set_intr_mode(char *str)
1575{ 1580{
1576 int burst; 1581 int intr;
1577 1582
1578 if (!get_option(&str, &burst)) 1583 if (!get_option(&str, &intr))
1579 return 0; 1584 return 0;
1580 1585
1581 if (burst) { 1586 if (intr) {
1582 acpi_ec_polling_mode = EC_BURST; 1587 acpi_ec_poll_mode = EC_INTR;
1583 acpi_ec_driver.ops.add = acpi_ec_burst_add; 1588 acpi_ec_driver.ops.add = acpi_ec_intr_add;
1584 } else { 1589 } else {
1585 acpi_ec_polling_mode = EC_POLLING; 1590 acpi_ec_poll_mode = EC_POLL;
1586 acpi_ec_driver.ops.add = acpi_ec_polling_add; 1591 acpi_ec_driver.ops.add = acpi_ec_poll_add;
1587 } 1592 }
1588 printk(KERN_INFO PREFIX "EC %s mode.\n", burst ? "burst" : "polling"); 1593 printk(KERN_INFO PREFIX "EC %s mode.\n", intr ? "interrupt" : "polling");
1589 return 0; 1594 return 0;
1590} 1595}
1591 1596
1592__setup("ec_burst=", acpi_ec_set_polling_mode); 1597__setup("ec_intr=", acpi_ec_set_intr_mode);
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c
index 842d1e3fb37b..c9ac05c4685f 100644
--- a/drivers/acpi/events/evevent.c
+++ b/drivers/acpi/events/evevent.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -73,7 +73,7 @@ acpi_status acpi_ev_initialize_events(void)
73 /* Make sure we have ACPI tables */ 73 /* Make sure we have ACPI tables */
74 74
75 if (!acpi_gbl_DSDT) { 75 if (!acpi_gbl_DSDT) {
76 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No ACPI tables present!\n")); 76 ACPI_WARNING((AE_INFO, "No ACPI tables present!"));
77 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 77 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
78 } 78 }
79 79
@@ -84,14 +84,15 @@ acpi_status acpi_ev_initialize_events(void)
84 */ 84 */
85 status = acpi_ev_fixed_event_initialize(); 85 status = acpi_ev_fixed_event_initialize();
86 if (ACPI_FAILURE(status)) { 86 if (ACPI_FAILURE(status)) {
87 ACPI_REPORT_ERROR(("Unable to initialize fixed events, %s\n", 87 ACPI_EXCEPTION((AE_INFO, status,
88 acpi_format_exception(status))); 88 "Unable to initialize fixed events"));
89 return_ACPI_STATUS(status); 89 return_ACPI_STATUS(status);
90 } 90 }
91 91
92 status = acpi_ev_gpe_initialize(); 92 status = acpi_ev_gpe_initialize();
93 if (ACPI_FAILURE(status)) { 93 if (ACPI_FAILURE(status)) {
94 ACPI_REPORT_ERROR(("Unable to initialize general purpose events, %s\n", acpi_format_exception(status))); 94 ACPI_EXCEPTION((AE_INFO, status,
95 "Unable to initialize general purpose events"));
95 return_ACPI_STATUS(status); 96 return_ACPI_STATUS(status);
96 } 97 }
97 98
@@ -100,6 +101,48 @@ acpi_status acpi_ev_initialize_events(void)
100 101
101/******************************************************************************* 102/*******************************************************************************
102 * 103 *
104 * FUNCTION: acpi_ev_install_fadt_gpes
105 *
106 * PARAMETERS: None
107 *
108 * RETURN: Status
109 *
110 * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks
111 * (0 and 1). This causes the _PRW methods to be run, so the HW
112 * must be fully initialized at this point, including global lock
113 * support.
114 *
115 ******************************************************************************/
116
117acpi_status acpi_ev_install_fadt_gpes(void)
118{
119 acpi_status status;
120
121 ACPI_FUNCTION_TRACE("ev_install_fadt_gpes");
122
123 /* Namespace must be locked */
124
125 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
126 if (ACPI_FAILURE(status)) {
127 return (status);
128 }
129
130 /* FADT GPE Block 0 */
131
132 (void)acpi_ev_initialize_gpe_block(acpi_gbl_fadt_gpe_device,
133 acpi_gbl_gpe_fadt_blocks[0]);
134
135 /* FADT GPE Block 1 */
136
137 (void)acpi_ev_initialize_gpe_block(acpi_gbl_fadt_gpe_device,
138 acpi_gbl_gpe_fadt_blocks[1]);
139
140 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
141 return_ACPI_STATUS(AE_OK);
142}
143
144/*******************************************************************************
145 *
103 * FUNCTION: acpi_ev_install_xrupt_handlers 146 * FUNCTION: acpi_ev_install_xrupt_handlers
104 * 147 *
105 * PARAMETERS: None 148 * PARAMETERS: None
@@ -120,7 +163,8 @@ acpi_status acpi_ev_install_xrupt_handlers(void)
120 163
121 status = acpi_ev_install_sci_handler(); 164 status = acpi_ev_install_sci_handler();
122 if (ACPI_FAILURE(status)) { 165 if (ACPI_FAILURE(status)) {
123 ACPI_REPORT_ERROR(("Unable to install System Control Interrupt Handler, %s\n", acpi_format_exception(status))); 166 ACPI_EXCEPTION((AE_INFO, status,
167 "Unable to install System Control Interrupt handler"));
124 return_ACPI_STATUS(status); 168 return_ACPI_STATUS(status);
125 } 169 }
126 170
@@ -128,7 +172,8 @@ acpi_status acpi_ev_install_xrupt_handlers(void)
128 172
129 status = acpi_ev_init_global_lock_handler(); 173 status = acpi_ev_init_global_lock_handler();
130 if (ACPI_FAILURE(status)) { 174 if (ACPI_FAILURE(status)) {
131 ACPI_REPORT_ERROR(("Unable to initialize Global Lock handler, %s\n", acpi_format_exception(status))); 175 ACPI_EXCEPTION((AE_INFO, status,
176 "Unable to initialize Global Lock handler"));
132 return_ACPI_STATUS(status); 177 return_ACPI_STATUS(status);
133 } 178 }
134 179
@@ -262,7 +307,9 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
262 enable_register_id, 0, 307 enable_register_id, 0,
263 ACPI_MTX_DO_NOT_LOCK); 308 ACPI_MTX_DO_NOT_LOCK);
264 309
265 ACPI_REPORT_ERROR(("No installed handler for fixed event [%08X]\n", event)); 310 ACPI_ERROR((AE_INFO,
311 "No installed handler for fixed event [%08X]",
312 event));
266 313
267 return (ACPI_INTERRUPT_NOT_HANDLED); 314 return (ACPI_INTERRUPT_NOT_HANDLED);
268 } 315 }
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index b2f232df13d8..f64f977dd3d5 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -372,14 +372,14 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
372 372
373u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) 373u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
374{ 374{
375 acpi_status status;
376 struct acpi_gpe_block_info *gpe_block;
377 struct acpi_gpe_register_info *gpe_register_info;
375 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; 378 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
376 u8 enabled_status_byte; 379 u8 enabled_status_byte;
377 struct acpi_gpe_register_info *gpe_register_info;
378 u32 status_reg; 380 u32 status_reg;
379 u32 enable_reg; 381 u32 enable_reg;
380 u32 flags; 382 acpi_cpu_flags flags;
381 acpi_status status;
382 struct acpi_gpe_block_info *gpe_block;
383 acpi_native_uint i; 383 acpi_native_uint i;
384 acpi_native_uint j; 384 acpi_native_uint j;
385 385
@@ -546,7 +546,11 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
546 546
547 status = acpi_ns_evaluate_by_handle(&info); 547 status = acpi_ns_evaluate_by_handle(&info);
548 if (ACPI_FAILURE(status)) { 548 if (ACPI_FAILURE(status)) {
549 ACPI_REPORT_ERROR(("%s while evaluating method [%4.4s] for GPE[%2X]\n", acpi_format_exception(status), acpi_ut_get_node_name(local_gpe_event_info.dispatch.method_node), gpe_number)); 549 ACPI_EXCEPTION((AE_INFO, status,
550 "While evaluating method [%4.4s] for GPE[%2X]",
551 acpi_ut_get_node_name
552 (local_gpe_event_info.dispatch.
553 method_node), gpe_number));
550 } 554 }
551 } 555 }
552 556
@@ -599,8 +603,10 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
599 ACPI_GPE_EDGE_TRIGGERED) { 603 ACPI_GPE_EDGE_TRIGGERED) {
600 status = acpi_hw_clear_gpe(gpe_event_info); 604 status = acpi_hw_clear_gpe(gpe_event_info);
601 if (ACPI_FAILURE(status)) { 605 if (ACPI_FAILURE(status)) {
602 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 606 ACPI_EXCEPTION((AE_INFO, status,
603 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 607 "Unable to clear GPE[%2X]",
608 gpe_number));
609 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
604 } 610 }
605 } 611 }
606 612
@@ -637,8 +643,10 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
637 ACPI_GPE_LEVEL_TRIGGERED) { 643 ACPI_GPE_LEVEL_TRIGGERED) {
638 status = acpi_hw_clear_gpe(gpe_event_info); 644 status = acpi_hw_clear_gpe(gpe_event_info);
639 if (ACPI_FAILURE(status)) { 645 if (ACPI_FAILURE(status)) {
640 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 646 ACPI_EXCEPTION((AE_INFO, status,
641 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 647 "Unable to clear GPE[%2X]",
648 gpe_number));
649 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
642 } 650 }
643 } 651 }
644 break; 652 break;
@@ -651,8 +659,10 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
651 */ 659 */
652 status = acpi_ev_disable_gpe(gpe_event_info); 660 status = acpi_ev_disable_gpe(gpe_event_info);
653 if (ACPI_FAILURE(status)) { 661 if (ACPI_FAILURE(status)) {
654 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 662 ACPI_EXCEPTION((AE_INFO, status,
655 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 663 "Unable to disable GPE[%2X]",
664 gpe_number));
665 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
656 } 666 }
657 667
658 /* 668 /*
@@ -663,7 +673,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
663 acpi_ev_asynch_execute_gpe_method, 673 acpi_ev_asynch_execute_gpe_method,
664 gpe_event_info); 674 gpe_event_info);
665 if (ACPI_FAILURE(status)) { 675 if (ACPI_FAILURE(status)) {
666 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", acpi_format_exception(status), gpe_number)); 676 ACPI_EXCEPTION((AE_INFO, status,
677 "Unable to queue handler for GPE[%2X] - event disabled",
678 gpe_number));
667 } 679 }
668 break; 680 break;
669 681
@@ -671,7 +683,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
671 683
672 /* No handler or method to run! */ 684 /* No handler or method to run! */
673 685
674 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n", gpe_number)); 686 ACPI_ERROR((AE_INFO,
687 "No handler or method for GPE[%2X], disabling event",
688 gpe_number));
675 689
676 /* 690 /*
677 * Disable the GPE. The GPE will remain disabled until the ACPI 691 * Disable the GPE. The GPE will remain disabled until the ACPI
@@ -679,13 +693,15 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
679 */ 693 */
680 status = acpi_ev_disable_gpe(gpe_event_info); 694 status = acpi_ev_disable_gpe(gpe_event_info);
681 if (ACPI_FAILURE(status)) { 695 if (ACPI_FAILURE(status)) {
682 ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); 696 ACPI_EXCEPTION((AE_INFO, status,
683 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 697 "Unable to disable GPE[%2X]",
698 gpe_number));
699 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
684 } 700 }
685 break; 701 break;
686 } 702 }
687 703
688 return_VALUE(ACPI_INTERRUPT_HANDLED); 704 return_UINT32(ACPI_INTERRUPT_HANDLED);
689} 705}
690 706
691#ifdef ACPI_GPE_NOTIFY_CHECK 707#ifdef ACPI_GPE_NOTIFY_CHECK
@@ -722,7 +738,9 @@ acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info)
722 738
723 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); 739 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
724 740
725 ACPI_REPORT_INFO(("GPE %p was updated from wake/run to wake-only\n", gpe_event_info)); 741 ACPI_INFO((AE_INFO,
742 "GPE %p was updated from wake/run to wake-only",
743 gpe_event_info));
726 744
727 /* This was a wake-only GPE */ 745 /* This was a wake-only GPE */
728 746
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index b312eb33c43e..0fd00b5ad650 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -78,7 +78,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block);
78 * 78 *
79 * RETURN: TRUE if the gpe_event is valid 79 * RETURN: TRUE if the gpe_event is valid
80 * 80 *
81 * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. 81 * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL.
82 * Should be called only when the GPE lists are semaphore locked 82 * Should be called only when the GPE lists are semaphore locked
83 * and not subject to change. 83 * and not subject to change.
84 * 84 *
@@ -136,7 +136,7 @@ acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback)
136 struct acpi_gpe_block_info *gpe_block; 136 struct acpi_gpe_block_info *gpe_block;
137 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 137 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
138 acpi_status status = AE_OK; 138 acpi_status status = AE_OK;
139 u32 flags; 139 acpi_cpu_flags flags;
140 140
141 ACPI_FUNCTION_TRACE("ev_walk_gpe_list"); 141 ACPI_FUNCTION_TRACE("ev_walk_gpe_list");
142 142
@@ -264,7 +264,7 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
264 * 2) Edge/Level determination is based on the 2nd character 264 * 2) Edge/Level determination is based on the 2nd character
265 * of the method name 265 * of the method name
266 * 266 *
267 * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE 267 * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE
268 * if a _PRW object is found that points to this GPE. 268 * if a _PRW object is found that points to this GPE.
269 */ 269 */
270 switch (name[1]) { 270 switch (name[1]) {
@@ -279,9 +279,9 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
279 default: 279 default:
280 /* Unknown method type, just ignore it! */ 280 /* Unknown method type, just ignore it! */
281 281
282 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 282 ACPI_ERROR((AE_INFO,
283 "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n", 283 "Unknown GPE method type: %s (name not of form _Lxx or _Exx)",
284 name)); 284 name));
285 return_ACPI_STATUS(AE_OK); 285 return_ACPI_STATUS(AE_OK);
286 } 286 }
287 287
@@ -291,9 +291,9 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
291 if (gpe_number == ACPI_UINT32_MAX) { 291 if (gpe_number == ACPI_UINT32_MAX) {
292 /* Conversion failed; invalid method, just ignore it */ 292 /* Conversion failed; invalid method, just ignore it */
293 293
294 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 294 ACPI_ERROR((AE_INFO,
295 "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n", 295 "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)",
296 name)); 296 name));
297 return_ACPI_STATUS(AE_OK); 297 return_ACPI_STATUS(AE_OK);
298 } 298 }
299 299
@@ -313,14 +313,14 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
313 313
314 /* 314 /*
315 * Now we can add this information to the gpe_event_info block 315 * Now we can add this information to the gpe_event_info block
316 * for use during dispatch of this GPE. Default type is RUNTIME, although 316 * for use during dispatch of this GPE. Default type is RUNTIME, although
317 * this may change when the _PRW methods are executed later. 317 * this may change when the _PRW methods are executed later.
318 */ 318 */
319 gpe_event_info = 319 gpe_event_info =
320 &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 320 &gpe_block->event_info[gpe_number - gpe_block->block_base_number];
321 321
322 gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD | 322 gpe_event_info->flags = (u8)
323 ACPI_GPE_TYPE_RUNTIME); 323 (type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME);
324 324
325 gpe_event_info->dispatch.method_node = 325 gpe_event_info->dispatch.method_node =
326 (struct acpi_namespace_node *)obj_handle; 326 (struct acpi_namespace_node *)obj_handle;
@@ -341,11 +341,11 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
341 * 341 *
342 * PARAMETERS: Callback from walk_namespace 342 * PARAMETERS: Callback from walk_namespace
343 * 343 *
344 * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is 344 * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is
345 * not aborted on a single _PRW failure. 345 * not aborted on a single _PRW failure.
346 * 346 *
347 * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a 347 * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a
348 * Device. Run the _PRW method. If present, extract the GPE 348 * Device. Run the _PRW method. If present, extract the GPE
349 * number and mark the GPE as a WAKE GPE. 349 * number and mark the GPE as a WAKE GPE.
350 * 350 *
351 ******************************************************************************/ 351 ******************************************************************************/
@@ -443,6 +443,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
443 443
444 gpe_event_info->flags &= 444 gpe_event_info->flags &=
445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); 445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED);
446
446 status = 447 status =
447 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); 448 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
448 if (ACPI_FAILURE(status)) { 449 if (ACPI_FAILURE(status)) {
@@ -466,7 +467,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
466 * 467 *
467 * RETURN: A GPE interrupt block 468 * RETURN: A GPE interrupt block
468 * 469 *
469 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt 470 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
470 * block per unique interrupt level used for GPEs. 471 * block per unique interrupt level used for GPEs.
471 * Should be called only when the GPE lists are semaphore locked 472 * Should be called only when the GPE lists are semaphore locked
472 * and not subject to change. 473 * and not subject to change.
@@ -479,7 +480,7 @@ static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
479 struct acpi_gpe_xrupt_info *next_gpe_xrupt; 480 struct acpi_gpe_xrupt_info *next_gpe_xrupt;
480 struct acpi_gpe_xrupt_info *gpe_xrupt; 481 struct acpi_gpe_xrupt_info *gpe_xrupt;
481 acpi_status status; 482 acpi_status status;
482 u32 flags; 483 acpi_cpu_flags flags;
483 484
484 ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block"); 485 ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block");
485 486
@@ -526,9 +527,9 @@ static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
526 acpi_ev_gpe_xrupt_handler, 527 acpi_ev_gpe_xrupt_handler,
527 gpe_xrupt); 528 gpe_xrupt);
528 if (ACPI_FAILURE(status)) { 529 if (ACPI_FAILURE(status)) {
529 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 530 ACPI_ERROR((AE_INFO,
530 "Could not install GPE interrupt handler at level 0x%X\n", 531 "Could not install GPE interrupt handler at level 0x%X",
531 interrupt_number)); 532 interrupt_number));
532 return_PTR(NULL); 533 return_PTR(NULL);
533 } 534 }
534 } 535 }
@@ -553,7 +554,7 @@ static acpi_status
553acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) 554acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
554{ 555{
555 acpi_status status; 556 acpi_status status;
556 u32 flags; 557 acpi_cpu_flags flags;
557 558
558 ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt"); 559 ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt");
559 560
@@ -566,8 +567,9 @@ acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
566 567
567 /* Disable this interrupt */ 568 /* Disable this interrupt */
568 569
569 status = acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, 570 status =
570 acpi_ev_gpe_xrupt_handler); 571 acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number,
572 acpi_ev_gpe_xrupt_handler);
571 if (ACPI_FAILURE(status)) { 573 if (ACPI_FAILURE(status)) {
572 return_ACPI_STATUS(status); 574 return_ACPI_STATUS(status);
573 } 575 }
@@ -610,7 +612,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
610 struct acpi_gpe_block_info *next_gpe_block; 612 struct acpi_gpe_block_info *next_gpe_block;
611 struct acpi_gpe_xrupt_info *gpe_xrupt_block; 613 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
612 acpi_status status; 614 acpi_status status;
613 u32 flags; 615 acpi_cpu_flags flags;
614 616
615 ACPI_FUNCTION_TRACE("ev_install_gpe_block"); 617 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
616 618
@@ -663,7 +665,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
663acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block) 665acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
664{ 666{
665 acpi_status status; 667 acpi_status status;
666 u32 flags; 668 acpi_cpu_flags flags;
667 669
668 ACPI_FUNCTION_TRACE("ev_install_gpe_block"); 670 ACPI_FUNCTION_TRACE("ev_install_gpe_block");
669 671
@@ -743,22 +745,22 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
743 sizeof(struct 745 sizeof(struct
744 acpi_gpe_register_info)); 746 acpi_gpe_register_info));
745 if (!gpe_register_info) { 747 if (!gpe_register_info) {
746 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 748 ACPI_ERROR((AE_INFO,
747 "Could not allocate the gpe_register_info table\n")); 749 "Could not allocate the gpe_register_info table"));
748 return_ACPI_STATUS(AE_NO_MEMORY); 750 return_ACPI_STATUS(AE_NO_MEMORY);
749 } 751 }
750 752
751 /* 753 /*
752 * Allocate the GPE event_info block. There are eight distinct GPEs 754 * Allocate the GPE event_info block. There are eight distinct GPEs
753 * per register. Initialization to zeros is sufficient. 755 * per register. Initialization to zeros is sufficient.
754 */ 756 */
755 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block-> 757 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block->
756 register_count * 758 register_count *
757 ACPI_GPE_REGISTER_WIDTH) * 759 ACPI_GPE_REGISTER_WIDTH) *
758 sizeof(struct acpi_gpe_event_info)); 760 sizeof(struct acpi_gpe_event_info));
759 if (!gpe_event_info) { 761 if (!gpe_event_info) {
760 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 762 ACPI_ERROR((AE_INFO,
761 "Could not allocate the gpe_event_info table\n")); 763 "Could not allocate the gpe_event_info table"));
762 status = AE_NO_MEMORY; 764 status = AE_NO_MEMORY;
763 goto error_exit; 765 goto error_exit;
764 } 766 }
@@ -769,9 +771,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
769 gpe_block->event_info = gpe_event_info; 771 gpe_block->event_info = gpe_event_info;
770 772
771 /* 773 /*
772 * Initialize the GPE Register and Event structures. A goal of these 774 * Initialize the GPE Register and Event structures. A goal of these
773 * tables is to hide the fact that there are two separate GPE register sets 775 * tables is to hide the fact that there are two separate GPE register sets
774 * in a given gpe hardware block, the status registers occupy the first half, 776 * in a given GPE hardware block, the status registers occupy the first half,
775 * and the enable registers occupy the second half. 777 * and the enable registers occupy the second half.
776 */ 778 */
777 this_register = gpe_register_info; 779 this_register = gpe_register_info;
@@ -812,11 +814,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
812 this_event++; 814 this_event++;
813 } 815 }
814 816
815 /* 817 /* Disable all GPEs within this register */
816 * Clear the status/enable registers. Note that status registers 818
817 * are cleared by writing a '1', while enable registers are cleared
818 * by writing a '0'.
819 */
820 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00, 819 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00,
821 &this_register-> 820 &this_register->
822 enable_address); 821 enable_address);
@@ -824,6 +823,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
824 goto error_exit; 823 goto error_exit;
825 } 824 }
826 825
826 /* Clear any pending GPE events within this register */
827
827 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF, 828 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF,
828 &this_register-> 829 &this_register->
829 status_address); 830 status_address);
@@ -860,7 +861,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
860 * 861 *
861 * RETURN: Status 862 * RETURN: Status
862 * 863 *
863 * DESCRIPTION: Create and Install a block of GPE registers 864 * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within
865 * the block are disabled at exit.
866 * Note: Assumes namespace is locked.
864 * 867 *
865 ******************************************************************************/ 868 ******************************************************************************/
866 869
@@ -872,14 +875,8 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
872 u32 interrupt_number, 875 u32 interrupt_number,
873 struct acpi_gpe_block_info **return_gpe_block) 876 struct acpi_gpe_block_info **return_gpe_block)
874{ 877{
875 struct acpi_gpe_block_info *gpe_block;
876 struct acpi_gpe_event_info *gpe_event_info;
877 acpi_native_uint i;
878 acpi_native_uint j;
879 u32 wake_gpe_count;
880 u32 gpe_enabled_count;
881 acpi_status status; 878 acpi_status status;
882 struct acpi_gpe_walk_info gpe_info; 879 struct acpi_gpe_block_info *gpe_block;
883 880
884 ACPI_FUNCTION_TRACE("ev_create_gpe_block"); 881 ACPI_FUNCTION_TRACE("ev_create_gpe_block");
885 882
@@ -896,22 +893,24 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
896 893
897 /* Initialize the new GPE block */ 894 /* Initialize the new GPE block */
898 895
896 gpe_block->node = gpe_device;
899 gpe_block->register_count = register_count; 897 gpe_block->register_count = register_count;
900 gpe_block->block_base_number = gpe_block_base_number; 898 gpe_block->block_base_number = gpe_block_base_number;
901 gpe_block->node = gpe_device;
902 899
903 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address, 900 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address,
904 sizeof(struct acpi_generic_address)); 901 sizeof(struct acpi_generic_address));
905 902
906 /* Create the register_info and event_info sub-structures */ 903 /*
907 904 * Create the register_info and event_info sub-structures
905 * Note: disables and clears all GPEs in the block
906 */
908 status = acpi_ev_create_gpe_info_blocks(gpe_block); 907 status = acpi_ev_create_gpe_info_blocks(gpe_block);
909 if (ACPI_FAILURE(status)) { 908 if (ACPI_FAILURE(status)) {
910 ACPI_MEM_FREE(gpe_block); 909 ACPI_MEM_FREE(gpe_block);
911 return_ACPI_STATUS(status); 910 return_ACPI_STATUS(status);
912 } 911 }
913 912
914 /* Install the new block in the global list(s) */ 913 /* Install the new block in the global lists */
915 914
916 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); 915 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
917 if (ACPI_FAILURE(status)) { 916 if (ACPI_FAILURE(status)) {
@@ -926,16 +925,70 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
926 acpi_ev_save_method_info, gpe_block, 925 acpi_ev_save_method_info, gpe_block,
927 NULL); 926 NULL);
928 927
928 /* Return the new block */
929
930 if (return_gpe_block) {
931 (*return_gpe_block) = gpe_block;
932 }
933
934 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
935 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
936 (u32) gpe_block->block_base_number,
937 (u32) (gpe_block->block_base_number +
938 ((gpe_block->register_count *
939 ACPI_GPE_REGISTER_WIDTH) - 1)),
940 gpe_device->name.ascii, gpe_block->register_count,
941 interrupt_number));
942
943 return_ACPI_STATUS(AE_OK);
944}
945
946/*******************************************************************************
947 *
948 * FUNCTION: acpi_ev_initialize_gpe_block
949 *
950 * PARAMETERS: gpe_device - Handle to the parent GPE block
951 * gpe_block - Gpe Block info
952 *
953 * RETURN: Status
954 *
955 * DESCRIPTION: Initialize and enable a GPE block. First find and run any
956 * _PRT methods associated with the block, then enable the
957 * appropriate GPEs.
958 * Note: Assumes namespace is locked.
959 *
960 ******************************************************************************/
961
962acpi_status
963acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
964 struct acpi_gpe_block_info *gpe_block)
965{
966 acpi_status status;
967 struct acpi_gpe_event_info *gpe_event_info;
968 struct acpi_gpe_walk_info gpe_info;
969 u32 wake_gpe_count;
970 u32 gpe_enabled_count;
971 acpi_native_uint i;
972 acpi_native_uint j;
973
974 ACPI_FUNCTION_TRACE("ev_initialize_gpe_block");
975
976 /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */
977
978 if (!gpe_block) {
979 return_ACPI_STATUS(AE_OK);
980 }
981
929 /* 982 /*
930 * Runtime option: Should Wake GPEs be enabled at runtime? The default 983 * Runtime option: Should wake GPEs be enabled at runtime? The default
931 * is No, they should only be enabled just as the machine goes to sleep. 984 * is no, they should only be enabled just as the machine goes to sleep.
932 */ 985 */
933 if (acpi_gbl_leave_wake_gpes_disabled) { 986 if (acpi_gbl_leave_wake_gpes_disabled) {
934 /* 987 /*
935 * Differentiate RUNTIME vs WAKE GPEs, via the _PRW control methods. 988 * Differentiate runtime vs wake GPEs, via the _PRW control methods.
936 * (Each GPE that has one or more _PRWs that reference it is by 989 * Each GPE that has one or more _PRWs that reference it is by
937 * definition a WAKE GPE and will not be enabled while the machine 990 * definition a wake GPE and will not be enabled while the machine
938 * is running.) 991 * is running.
939 */ 992 */
940 gpe_info.gpe_block = gpe_block; 993 gpe_info.gpe_block = gpe_block;
941 gpe_info.gpe_device = gpe_device; 994 gpe_info.gpe_device = gpe_device;
@@ -948,9 +1001,12 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
948 } 1001 }
949 1002
950 /* 1003 /*
951 * Enable all GPEs in this block that are 1) "runtime" or "run/wake" GPEs, 1004 * Enable all GPEs in this block that have these attributes:
952 * and 2) have a corresponding _Lxx or _Exx method. All other GPEs must 1005 * 1) are "runtime" or "run/wake" GPEs, and
953 * be enabled via the acpi_enable_gpe() external interface. 1006 * 2) have a corresponding _Lxx or _Exx method
1007 *
1008 * Any other GPEs within this block must be enabled via the acpi_enable_gpe()
1009 * external interface.
954 */ 1010 */
955 wake_gpe_count = 0; 1011 wake_gpe_count = 0;
956 gpe_enabled_count = 0; 1012 gpe_enabled_count = 0;
@@ -976,32 +1032,19 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
976 } 1032 }
977 } 1033 }
978 1034
979 /* Dump info about this GPE block */
980
981 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
982 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
983 (u32) gpe_block->block_base_number,
984 (u32) (gpe_block->block_base_number +
985 ((gpe_block->register_count *
986 ACPI_GPE_REGISTER_WIDTH) - 1)),
987 gpe_device->name.ascii, gpe_block->register_count,
988 interrupt_number));
989
990 /* Enable all valid GPEs found above */
991
992 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
993
994 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 1035 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
995 "Found %u Wake, Enabled %u Runtime GPEs in this block\n", 1036 "Found %u Wake, Enabled %u Runtime GPEs in this block\n",
996 wake_gpe_count, gpe_enabled_count)); 1037 wake_gpe_count, gpe_enabled_count));
997 1038
998 /* Return the new block */ 1039 /* Enable all valid runtime GPEs found above */
999 1040
1000 if (return_gpe_block) { 1041 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
1001 (*return_gpe_block) = gpe_block; 1042 if (ACPI_FAILURE(status)) {
1043 ACPI_ERROR((AE_INFO, "Could not enable GPEs in gpe_block %p",
1044 gpe_block));
1002 } 1045 }
1003 1046
1004 return_ACPI_STATUS(AE_OK); 1047 return_ACPI_STATUS(status);
1005} 1048}
1006 1049
1007/******************************************************************************* 1050/*******************************************************************************
@@ -1072,8 +1115,8 @@ acpi_status acpi_ev_gpe_initialize(void)
1072 &acpi_gbl_gpe_fadt_blocks[0]); 1115 &acpi_gbl_gpe_fadt_blocks[0]);
1073 1116
1074 if (ACPI_FAILURE(status)) { 1117 if (ACPI_FAILURE(status)) {
1075 ACPI_REPORT_ERROR(("Could not create GPE Block 0, %s\n", 1118 ACPI_EXCEPTION((AE_INFO, status,
1076 acpi_format_exception(status))); 1119 "Could not create GPE Block 0"));
1077 } 1120 }
1078 } 1121 }
1079 1122
@@ -1086,7 +1129,12 @@ acpi_status acpi_ev_gpe_initialize(void)
1086 1129
1087 if ((register_count0) && 1130 if ((register_count0) &&
1088 (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) { 1131 (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) {
1089 ACPI_REPORT_ERROR(("GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n", gpe_number_max, acpi_gbl_FADT->gpe1_base, acpi_gbl_FADT->gpe1_base + ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1))); 1132 ACPI_ERROR((AE_INFO,
1133 "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1",
1134 gpe_number_max, acpi_gbl_FADT->gpe1_base,
1135 acpi_gbl_FADT->gpe1_base +
1136 ((register_count1 *
1137 ACPI_GPE_REGISTER_WIDTH) - 1)));
1090 1138
1091 /* Ignore GPE1 block by setting the register count to zero */ 1139 /* Ignore GPE1 block by setting the register count to zero */
1092 1140
@@ -1104,7 +1152,8 @@ acpi_status acpi_ev_gpe_initialize(void)
1104 [1]); 1152 [1]);
1105 1153
1106 if (ACPI_FAILURE(status)) { 1154 if (ACPI_FAILURE(status)) {
1107 ACPI_REPORT_ERROR(("Could not create GPE Block 1, %s\n", acpi_format_exception(status))); 1155 ACPI_EXCEPTION((AE_INFO, status,
1156 "Could not create GPE Block 1"));
1108 } 1157 }
1109 1158
1110 /* 1159 /*
@@ -1130,7 +1179,9 @@ acpi_status acpi_ev_gpe_initialize(void)
1130 /* Check for Max GPE number out-of-range */ 1179 /* Check for Max GPE number out-of-range */
1131 1180
1132 if (gpe_number_max > ACPI_GPE_MAX) { 1181 if (gpe_number_max > ACPI_GPE_MAX) {
1133 ACPI_REPORT_ERROR(("Maximum GPE number from FADT is too large: 0x%X\n", gpe_number_max)); 1182 ACPI_ERROR((AE_INFO,
1183 "Maximum GPE number from FADT is too large: 0x%X",
1184 gpe_number_max));
1134 status = AE_BAD_VALUE; 1185 status = AE_BAD_VALUE;
1135 goto cleanup; 1186 goto cleanup;
1136 } 1187 }
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 7e57b8470f55..0909ba69577e 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -303,7 +303,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context)
303 acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, 303 acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore,
304 acpi_gbl_global_lock_thread_count); 304 acpi_gbl_global_lock_thread_count);
305 if (ACPI_FAILURE(status)) { 305 if (ACPI_FAILURE(status)) {
306 ACPI_REPORT_ERROR(("Could not signal Global Lock semaphore\n")); 306 ACPI_ERROR((AE_INFO,
307 "Could not signal Global Lock semaphore"));
307 } 308 }
308 } 309 }
309} 310}
@@ -344,7 +345,8 @@ static u32 acpi_ev_global_lock_handler(void *context)
344 acpi_ev_global_lock_thread, 345 acpi_ev_global_lock_thread,
345 context); 346 context);
346 if (ACPI_FAILURE(status)) { 347 if (ACPI_FAILURE(status)) {
347 ACPI_REPORT_ERROR(("Could not queue Global Lock thread, %s\n", acpi_format_exception(status))); 348 ACPI_EXCEPTION((AE_INFO, status,
349 "Could not queue Global Lock thread"));
348 350
349 return (ACPI_INTERRUPT_NOT_HANDLED); 351 return (ACPI_INTERRUPT_NOT_HANDLED);
350 } 352 }
@@ -384,7 +386,8 @@ acpi_status acpi_ev_init_global_lock_handler(void)
384 * with an error. 386 * with an error.
385 */ 387 */
386 if (status == AE_NO_HARDWARE_RESPONSE) { 388 if (status == AE_NO_HARDWARE_RESPONSE) {
387 ACPI_REPORT_ERROR(("No response from Global Lock hardware, disabling lock\n")); 389 ACPI_ERROR((AE_INFO,
390 "No response from Global Lock hardware, disabling lock"));
388 391
389 acpi_gbl_global_lock_present = FALSE; 392 acpi_gbl_global_lock_present = FALSE;
390 status = AE_OK; 393 status = AE_OK;
@@ -480,7 +483,8 @@ acpi_status acpi_ev_release_global_lock(void)
480 ACPI_FUNCTION_TRACE("ev_release_global_lock"); 483 ACPI_FUNCTION_TRACE("ev_release_global_lock");
481 484
482 if (!acpi_gbl_global_lock_thread_count) { 485 if (!acpi_gbl_global_lock_thread_count) {
483 ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n")); 486 ACPI_WARNING((AE_INFO,
487 "Cannot release HW Global Lock, it has not been acquired"));
484 return_ACPI_STATUS(AE_NOT_ACQUIRED); 488 return_ACPI_STATUS(AE_NOT_ACQUIRED);
485 } 489 }
486 490
@@ -542,9 +546,9 @@ void acpi_ev_terminate(void)
542 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { 546 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
543 status = acpi_disable_event((u32) i, 0); 547 status = acpi_disable_event((u32) i, 0);
544 if (ACPI_FAILURE(status)) { 548 if (ACPI_FAILURE(status)) {
545 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 549 ACPI_ERROR((AE_INFO,
546 "Could not disable fixed event %d\n", 550 "Could not disable fixed event %d",
547 (u32) i)); 551 (u32) i));
548 } 552 }
549 } 553 }
550 554
@@ -556,8 +560,7 @@ void acpi_ev_terminate(void)
556 560
557 status = acpi_ev_remove_sci_handler(); 561 status = acpi_ev_remove_sci_handler();
558 if (ACPI_FAILURE(status)) { 562 if (ACPI_FAILURE(status)) {
559 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 563 ACPI_ERROR((AE_INFO, "Could not remove SCI handler"));
560 "Could not remove SCI handler\n"));
561 } 564 }
562 } 565 }
563 566
@@ -570,8 +573,7 @@ void acpi_ev_terminate(void)
570 if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) { 573 if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) {
571 status = acpi_disable(); 574 status = acpi_disable();
572 if (ACPI_FAILURE(status)) { 575 if (ACPI_FAILURE(status)) {
573 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 576 ACPI_WARNING((AE_INFO, "acpi_disable failed"));
574 "acpi_disable failed\n"));
575 } 577 }
576 } 578 }
577 return_VOID; 579 return_VOID;
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c
index 84fad082d80d..6da58e776413 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/events/evregion.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -295,12 +295,12 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
295 295
296 handler_desc = region_obj->region.handler; 296 handler_desc = region_obj->region.handler;
297 if (!handler_desc) { 297 if (!handler_desc) {
298 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 298 ACPI_ERROR((AE_INFO,
299 "No handler for Region [%4.4s] (%p) [%s]\n", 299 "No handler for Region [%4.4s] (%p) [%s]",
300 acpi_ut_get_node_name(region_obj->region. 300 acpi_ut_get_node_name(region_obj->region.node),
301 node), region_obj, 301 region_obj,
302 acpi_ut_get_region_name(region_obj->region. 302 acpi_ut_get_region_name(region_obj->region.
303 space_id))); 303 space_id)));
304 304
305 return_ACPI_STATUS(AE_NOT_EXIST); 305 return_ACPI_STATUS(AE_NOT_EXIST);
306 } 306 }
@@ -317,12 +317,11 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
317 if (!region_setup) { 317 if (!region_setup) {
318 /* No initialization routine, exit with error */ 318 /* No initialization routine, exit with error */
319 319
320 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 320 ACPI_ERROR((AE_INFO,
321 "No init routine for region(%p) [%s]\n", 321 "No init routine for region(%p) [%s]",
322 region_obj, 322 region_obj,
323 acpi_ut_get_region_name(region_obj-> 323 acpi_ut_get_region_name(region_obj->region.
324 region. 324 space_id)));
325 space_id)));
326 return_ACPI_STATUS(AE_NOT_EXIST); 325 return_ACPI_STATUS(AE_NOT_EXIST);
327 } 326 }
328 327
@@ -347,12 +346,11 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
347 /* Check for failure of the Region Setup */ 346 /* Check for failure of the Region Setup */
348 347
349 if (ACPI_FAILURE(status)) { 348 if (ACPI_FAILURE(status)) {
350 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 349 ACPI_EXCEPTION((AE_INFO, status,
351 "Region Init: %s [%s]\n", 350 "During region initialization: [%s]",
352 acpi_format_exception(status), 351 acpi_ut_get_region_name(region_obj->
353 acpi_ut_get_region_name(region_obj-> 352 region.
354 region. 353 space_id)));
355 space_id)));
356 return_ACPI_STATUS(status); 354 return_ACPI_STATUS(status);
357 } 355 }
358 356
@@ -406,10 +404,9 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
406 region_obj2->extra.region_context); 404 region_obj2->extra.region_context);
407 405
408 if (ACPI_FAILURE(status)) { 406 if (ACPI_FAILURE(status)) {
409 ACPI_REPORT_ERROR(("Handler for [%s] returned %s\n", 407 ACPI_EXCEPTION((AE_INFO, status, "Returned by Handler for [%s]",
410 acpi_ut_get_region_name(region_obj->region. 408 acpi_ut_get_region_name(region_obj->region.
411 space_id), 409 space_id)));
412 acpi_format_exception(status)));
413 } 410 }
414 411
415 if (! 412 if (!
@@ -501,12 +498,10 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
501 498
502 status = acpi_ev_execute_reg_method(region_obj, 0); 499 status = acpi_ev_execute_reg_method(region_obj, 0);
503 if (ACPI_FAILURE(status)) { 500 if (ACPI_FAILURE(status)) {
504 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 501 ACPI_EXCEPTION((AE_INFO, status,
505 "%s from region _REG, [%s]\n", 502 "from region _REG, [%s]",
506 acpi_format_exception(status), 503 acpi_ut_get_region_name
507 acpi_ut_get_region_name 504 (region_obj->region.space_id)));
508 (region_obj->region.
509 space_id)));
510 } 505 }
511 506
512 if (acpi_ns_is_locked) { 507 if (acpi_ns_is_locked) {
@@ -528,12 +523,10 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
528 /* Init routine may fail, Just ignore errors */ 523 /* Init routine may fail, Just ignore errors */
529 524
530 if (ACPI_FAILURE(status)) { 525 if (ACPI_FAILURE(status)) {
531 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 526 ACPI_EXCEPTION((AE_INFO, status,
532 "%s from region init, [%s]\n", 527 "from region init, [%s]",
533 acpi_format_exception(status), 528 acpi_ut_get_region_name
534 acpi_ut_get_region_name 529 (region_obj->region.space_id)));
535 (region_obj->region.
536 space_id)));
537 } 530 }
538 531
539 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE); 532 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index a1bd2da27c45..baed8c1a1b9f 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -233,7 +233,11 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
233 */ 233 */
234 status = AE_OK; 234 status = AE_OK;
235 } else { 235 } else {
236 ACPI_REPORT_ERROR(("Could not install pci_config handler for Root Bridge %4.4s, %s\n", acpi_ut_get_node_name(pci_root_node), acpi_format_exception(status))); 236 ACPI_EXCEPTION((AE_INFO,
237 status,
238 "Could not install pci_config handler for Root Bridge %4.4s",
239 acpi_ut_get_node_name
240 (pci_root_node)));
237 } 241 }
238 } 242 }
239 break; 243 break;
diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/events/evsci.c
index 141835977002..9a622169008a 100644
--- a/drivers/acpi/events/evsci.c
+++ b/drivers/acpi/events/evsci.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -88,7 +88,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
88 */ 88 */
89 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 89 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
90 90
91 return_VALUE(interrupt_handled); 91 return_UINT32(interrupt_handled);
92} 92}
93 93
94/******************************************************************************* 94/*******************************************************************************
@@ -121,7 +121,7 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
121 */ 121 */
122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
123 123
124 return_VALUE(interrupt_handled); 124 return_UINT32(interrupt_handled);
125} 125}
126 126
127/****************************************************************************** 127/******************************************************************************
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 43b33d19cdf9..b38b39dde543 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -143,8 +143,8 @@ acpi_install_fixed_event_handler(u32 event,
143 if (ACPI_SUCCESS(status)) 143 if (ACPI_SUCCESS(status))
144 status = acpi_enable_event(event, 0); 144 status = acpi_enable_event(event, 0);
145 if (ACPI_FAILURE(status)) { 145 if (ACPI_FAILURE(status)) {
146 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 146 ACPI_WARNING((AE_INFO, "Could not enable fixed event %X",
147 "Could not enable fixed event.\n")); 147 event));
148 148
149 /* Remove the handler */ 149 /* Remove the handler */
150 150
@@ -204,10 +204,11 @@ acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler)
204 acpi_gbl_fixed_event_handlers[event].context = NULL; 204 acpi_gbl_fixed_event_handlers[event].context = NULL;
205 205
206 if (ACPI_FAILURE(status)) { 206 if (ACPI_FAILURE(status)) {
207 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 207 ACPI_WARNING((AE_INFO,
208 "Could not write to fixed event enable register.\n")); 208 "Could not write to fixed event enable register %X",
209 event));
209 } else { 210 } else {
210 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X.\n", 211 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n",
211 event)); 212 event));
212 } 213 }
213 214
@@ -434,7 +435,7 @@ acpi_remove_notify_handler(acpi_handle device,
434 435
435 if (device == ACPI_ROOT_OBJECT) { 436 if (device == ACPI_ROOT_OBJECT) {
436 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 437 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
437 "Removing notify handler for ROOT object.\n")); 438 "Removing notify handler for namespace root object\n"));
438 439
439 if (((handler_type & ACPI_SYSTEM_NOTIFY) && 440 if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
440 !acpi_gbl_system_notify.handler) || 441 !acpi_gbl_system_notify.handler) ||
@@ -562,7 +563,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
562 struct acpi_gpe_event_info *gpe_event_info; 563 struct acpi_gpe_event_info *gpe_event_info;
563 struct acpi_handler_info *handler; 564 struct acpi_handler_info *handler;
564 acpi_status status; 565 acpi_status status;
565 u32 flags; 566 acpi_cpu_flags flags;
566 567
567 ACPI_FUNCTION_TRACE("acpi_install_gpe_handler"); 568 ACPI_FUNCTION_TRACE("acpi_install_gpe_handler");
568 569
@@ -653,7 +654,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
653 struct acpi_gpe_event_info *gpe_event_info; 654 struct acpi_gpe_event_info *gpe_event_info;
654 struct acpi_handler_info *handler; 655 struct acpi_handler_info *handler;
655 acpi_status status; 656 acpi_status status;
656 u32 flags; 657 acpi_cpu_flags flags;
657 658
658 ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler"); 659 ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler");
659 660
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c
index 887ff9f28a0d..ec9ce8429f15 100644
--- a/drivers/acpi/events/evxfevnt.c
+++ b/drivers/acpi/events/evxfevnt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -70,8 +70,7 @@ acpi_status acpi_enable(void)
70 /* Make sure we have the FADT */ 70 /* Make sure we have the FADT */
71 71
72 if (!acpi_gbl_FADT) { 72 if (!acpi_gbl_FADT) {
73 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 73 ACPI_WARNING((AE_INFO, "No FADT information present!"));
74 "No FADT information present!\n"));
75 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 74 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
76 } 75 }
77 76
@@ -83,7 +82,8 @@ acpi_status acpi_enable(void)
83 82
84 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI); 83 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
85 if (ACPI_FAILURE(status)) { 84 if (ACPI_FAILURE(status)) {
86 ACPI_REPORT_ERROR(("Could not transition to ACPI mode.\n")); 85 ACPI_ERROR((AE_INFO,
86 "Could not transition to ACPI mode"));
87 return_ACPI_STATUS(status); 87 return_ACPI_STATUS(status);
88 } 88 }
89 89
@@ -113,8 +113,7 @@ acpi_status acpi_disable(void)
113 ACPI_FUNCTION_TRACE("acpi_disable"); 113 ACPI_FUNCTION_TRACE("acpi_disable");
114 114
115 if (!acpi_gbl_FADT) { 115 if (!acpi_gbl_FADT) {
116 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 116 ACPI_WARNING((AE_INFO, "No FADT information present!"));
117 "No FADT information present!\n"));
118 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 117 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
119 } 118 }
120 119
@@ -127,8 +126,8 @@ acpi_status acpi_disable(void)
127 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY); 126 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
128 127
129 if (ACPI_FAILURE(status)) { 128 if (ACPI_FAILURE(status)) {
130 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 129 ACPI_ERROR((AE_INFO,
131 "Could not exit ACPI mode to legacy mode")); 130 "Could not exit ACPI mode to legacy mode"));
132 return_ACPI_STATUS(status); 131 return_ACPI_STATUS(status);
133 } 132 }
134 133
@@ -185,9 +184,9 @@ acpi_status acpi_enable_event(u32 event, u32 flags)
185 } 184 }
186 185
187 if (value != 1) { 186 if (value != 1) {
188 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 187 ACPI_ERROR((AE_INFO,
189 "Could not enable %s event\n", 188 "Could not enable %s event",
190 acpi_ut_get_event_name(event))); 189 acpi_ut_get_event_name(event)));
191 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); 190 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
192 } 191 }
193 192
@@ -384,9 +383,9 @@ acpi_status acpi_disable_event(u32 event, u32 flags)
384 } 383 }
385 384
386 if (value != 0) { 385 if (value != 0) {
387 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 386 ACPI_ERROR((AE_INFO,
388 "Could not disable %s events\n", 387 "Could not disable %s events",
389 acpi_ut_get_event_name(event))); 388 acpi_ut_get_event_name(event)));
390 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); 389 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
391 } 390 }
392 391
@@ -626,6 +625,13 @@ acpi_install_gpe_block(acpi_handle gpe_device,
626 goto unlock_and_exit; 625 goto unlock_and_exit;
627 } 626 }
628 627
628 /* Run the _PRW methods and enable the GPEs */
629
630 status = acpi_ev_initialize_gpe_block(node, gpe_block);
631 if (ACPI_FAILURE(status)) {
632 goto unlock_and_exit;
633 }
634
629 /* Get the device_object attached to the node */ 635 /* Get the device_object attached to the node */
630 636
631 obj_desc = acpi_ns_get_attached_object(node); 637 obj_desc = acpi_ns_get_attached_object(node);
diff --git a/drivers/acpi/events/evxfregn.c b/drivers/acpi/events/evxfregn.c
index 6f28ea2db5ba..abf5caca9ae5 100644
--- a/drivers/acpi/events/evxfregn.c
+++ b/drivers/acpi/events/evxfregn.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c
index 1ce365d651d8..a29782fe3ecf 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/executer/exconfig.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -413,9 +413,9 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
413 (!ACPI_STRNCMP(table_ptr->signature, 413 (!ACPI_STRNCMP(table_ptr->signature,
414 acpi_gbl_table_data[ACPI_TABLE_SSDT].signature, 414 acpi_gbl_table_data[ACPI_TABLE_SSDT].signature,
415 acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) { 415 acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) {
416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 416 ACPI_ERROR((AE_INFO,
417 "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", 417 "Table has invalid signature [%4.4s], must be SSDT or PSDT",
418 table_ptr->signature)); 418 table_ptr->signature));
419 status = AE_BAD_SIGNATURE; 419 status = AE_BAD_SIGNATURE;
420 goto cleanup; 420 goto cleanup;
421 } 421 }
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index 04e5194989a6..e6d52e12d77a 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -504,18 +504,12 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
504 } 504 }
505 505
506 /* 506 /*
507 * Perform the conversion. 507 * Create a new string object and string buffer
508 * (-1 because of extra separator included in string_length from above) 508 * (-1 because of extra separator included in string_length from above)
509 */ 509 */
510 string_length--;
511 if (string_length > ACPI_MAX_STRING_CONVERSION) { /* ACPI limit */
512 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
513 }
514
515 /* Create a new string object and string buffer */
516
517 return_desc = 510 return_desc =
518 acpi_ut_create_string_object((acpi_size) string_length); 511 acpi_ut_create_string_object((acpi_size)
512 (string_length - 1));
519 if (!return_desc) { 513 if (!return_desc) {
520 return_ACPI_STATUS(AE_NO_MEMORY); 514 return_ACPI_STATUS(AE_NO_MEMORY);
521 } 515 }
@@ -647,7 +641,9 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
647 break; 641 break;
648 642
649 default: 643 default:
650 ACPI_REPORT_ERROR(("Bad destination type during conversion: %X\n", destination_type)); 644 ACPI_ERROR((AE_INFO,
645 "Bad destination type during conversion: %X",
646 destination_type));
651 status = AE_AML_INTERNAL; 647 status = AE_AML_INTERNAL;
652 break; 648 break;
653 } 649 }
@@ -660,17 +656,13 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
660 break; 656 break;
661 657
662 default: 658 default:
663 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 659 ACPI_ERROR((AE_INFO,
664 "Unknown Target type ID 0x%X Op %s dest_type %s\n", 660 "Unknown Target type ID 0x%X aml_opcode %X dest_type %s",
665 GET_CURRENT_ARG_TYPE(walk_state->op_info-> 661 GET_CURRENT_ARG_TYPE(walk_state->op_info->
666 runtime_args), 662 runtime_args),
667 walk_state->op_info->name, 663 walk_state->opcode,
668 acpi_ut_get_type_name(destination_type))); 664 acpi_ut_get_type_name(destination_type)));
669 665 status = AE_AML_INTERNAL;
670 ACPI_REPORT_ERROR(("Bad Target Type (ARGI): %X\n",
671 GET_CURRENT_ARG_TYPE(walk_state->op_info->
672 runtime_args)))
673 status = AE_AML_INTERNAL;
674 } 666 }
675 667
676 /* 668 /*
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c
index 91c49188fb07..680575402835 100644
--- a/drivers/acpi/executer/excreate.c
+++ b/drivers/acpi/executer/excreate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -300,8 +300,8 @@ acpi_ex_create_region(u8 * aml_start,
300 */ 300 */
301 if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) && 301 if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) &&
302 (region_space < ACPI_USER_REGION_BEGIN)) { 302 (region_space < ACPI_USER_REGION_BEGIN)) {
303 ACPI_REPORT_ERROR(("Invalid address_space type %X\n", 303 ACPI_ERROR((AE_INFO, "Invalid address_space type %X",
304 region_space)); 304 region_space));
305 return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID); 305 return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
306 } 306 }
307 307
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index bc2fa996047e..a7cca8d4f855 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -55,20 +55,386 @@ ACPI_MODULE_NAME("exdump")
55 */ 55 */
56#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 56#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
57/* Local prototypes */ 57/* Local prototypes */
58#ifdef ACPI_FUTURE_USAGE
59static void acpi_ex_out_string(char *title, char *value); 58static void acpi_ex_out_string(char *title, char *value);
60 59
61static void acpi_ex_out_pointer(char *title, void *value); 60static void acpi_ex_out_pointer(char *title, void *value);
62 61
63static void acpi_ex_out_integer(char *title, u32 value);
64
65static void acpi_ex_out_address(char *title, acpi_physical_address value); 62static void acpi_ex_out_address(char *title, acpi_physical_address value);
66 63
67static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc); 64static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc);
68 65
69static void 66static void
70acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index); 67acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
71#endif /* ACPI_FUTURE_USAGE */ 68 u32 level, u32 index);
69
70/*******************************************************************************
71 *
72 * Object Descriptor info tables
73 *
74 * Note: The first table entry must be an INIT opcode and must contain
75 * the table length (number of table entries)
76 *
77 ******************************************************************************/
78
79static struct acpi_exdump_info acpi_ex_dump_integer[2] = {
80 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_integer), NULL},
81 {ACPI_EXD_UINT64, ACPI_EXD_OFFSET(integer.value), "Value"}
82};
83
84static struct acpi_exdump_info acpi_ex_dump_string[4] = {
85 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_string), NULL},
86 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(string.length), "Length"},
87 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(string.pointer), "Pointer"},
88 {ACPI_EXD_STRING, 0, NULL}
89};
90
91static struct acpi_exdump_info acpi_ex_dump_buffer[4] = {
92 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer), NULL},
93 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(buffer.length), "Length"},
94 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.pointer), "Pointer"},
95 {ACPI_EXD_BUFFER, 0, NULL}
96};
97
98static struct acpi_exdump_info acpi_ex_dump_package[5] = {
99 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL},
100 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"},
101 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Elements"},
102 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"},
103 {ACPI_EXD_PACKAGE, 0, NULL}
104};
105
106static struct acpi_exdump_info acpi_ex_dump_device[4] = {
107 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL},
108 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.handler), "Handler"},
109 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.system_notify),
110 "System Notify"},
111 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.device_notify),
112 "Device Notify"}
113};
114
115static struct acpi_exdump_info acpi_ex_dump_event[2] = {
116 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL},
117 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"}
118};
119
120static struct acpi_exdump_info acpi_ex_dump_method[8] = {
121 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
122 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "param_count"},
123 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"},
124 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"},
125 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
126 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
127 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
128 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"}
129};
130
131static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
132 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL},
133 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"},
134 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
135 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
136 "Acquire Depth"},
137 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.semaphore), "Semaphore"}
138};
139
140static struct acpi_exdump_info acpi_ex_dump_region[7] = {
141 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region), NULL},
142 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.space_id), "Space Id"},
143 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.flags), "Flags"},
144 {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(region.address), "Address"},
145 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(region.length), "Length"},
146 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.handler), "Handler"},
147 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.next), "Next"}
148};
149
150static struct acpi_exdump_info acpi_ex_dump_power[5] = {
151 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_power), NULL},
152 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.system_level),
153 "System Level"},
154 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.resource_order),
155 "Resource Order"},
156 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.system_notify),
157 "System Notify"},
158 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.device_notify),
159 "Device Notify"}
160};
161
162static struct acpi_exdump_info acpi_ex_dump_processor[7] = {
163 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_processor), NULL},
164 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(processor.proc_id), "Processor ID"},
165 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(processor.length), "Length"},
166 {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(processor.address), "Address"},
167 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.system_notify),
168 "System Notify"},
169 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.device_notify),
170 "Device Notify"},
171 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.handler), "Handler"}
172};
173
174static struct acpi_exdump_info acpi_ex_dump_thermal[4] = {
175 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_thermal), NULL},
176 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.system_notify),
177 "System Notify"},
178 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.device_notify),
179 "Device Notify"},
180 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.handler), "Handler"}
181};
182
183static struct acpi_exdump_info acpi_ex_dump_buffer_field[3] = {
184 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer_field), NULL},
185 {ACPI_EXD_FIELD, 0, NULL},
186 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer_field.buffer_obj),
187 "Buffer Object"}
188};
189
190static struct acpi_exdump_info acpi_ex_dump_region_field[3] = {
191 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region_field), NULL},
192 {ACPI_EXD_FIELD, 0, NULL},
193 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.region_obj), "Region Object"}
194};
195
196static struct acpi_exdump_info acpi_ex_dump_bank_field[5] = {
197 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
198 {ACPI_EXD_FIELD, 0, NULL},
199 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(bank_field.value), "Value"},
200 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.region_obj),
201 "Region Object"},
202 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.bank_obj), "Bank Object"}
203};
204
205static struct acpi_exdump_info acpi_ex_dump_index_field[5] = {
206 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
207 {ACPI_EXD_FIELD, 0, NULL},
208 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(index_field.value), "Value"},
209 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.index_obj),
210 "Index Object"},
211 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"}
212};
213
214static struct acpi_exdump_info acpi_ex_dump_reference[7] = {
215 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL},
216 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"},
217 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.offset), "Offset"},
218 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"},
219 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.node), "Node"},
220 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"},
221 {ACPI_EXD_REFERENCE, 0, NULL}
222};
223
224static struct acpi_exdump_info acpi_ex_dump_address_handler[6] = {
225 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_address_handler),
226 NULL},
227 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(address_space.space_id), "Space Id"},
228 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.next), "Next"},
229 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.region_list),
230 "Region List"},
231 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.node), "Node"},
232 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"}
233};
234
235static struct acpi_exdump_info acpi_ex_dump_notify[3] = {
236 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL},
237 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.node), "Node"},
238 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"}
239};
240
241/* Miscellaneous tables */
242
243static struct acpi_exdump_info acpi_ex_dump_common[4] = {
244 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_common), NULL},
245 {ACPI_EXD_TYPE, 0, NULL},
246 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(common.reference_count),
247 "Reference Count"},
248 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common.flags), "Flags"}
249};
250
251static struct acpi_exdump_info acpi_ex_dump_field_common[7] = {
252 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_field_common), NULL},
253 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.field_flags),
254 "Field Flags"},
255 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.access_byte_width),
256 "Access Byte Width"},
257 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.bit_length),
258 "Bit Length"},
259 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.start_field_bit_offset),
260 "Field Bit Offset"},
261 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.base_byte_offset),
262 "Base Byte Offset"},
263 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(common_field.node), "Parent Node"}
264};
265
266static struct acpi_exdump_info acpi_ex_dump_node[6] = {
267 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL},
268 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"},
269 {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"},
270 {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET(reference_count),
271 "Reference Count"},
272 {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(child), "Child List"},
273 {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(peer), "Next Peer"}
274};
275
276/* Dispatch table, indexed by object type */
277
278static struct acpi_exdump_info *acpi_ex_dump_info[] = {
279 NULL,
280 acpi_ex_dump_integer,
281 acpi_ex_dump_string,
282 acpi_ex_dump_buffer,
283 acpi_ex_dump_package,
284 NULL,
285 acpi_ex_dump_device,
286 acpi_ex_dump_event,
287 acpi_ex_dump_method,
288 acpi_ex_dump_mutex,
289 acpi_ex_dump_region,
290 acpi_ex_dump_power,
291 acpi_ex_dump_processor,
292 acpi_ex_dump_thermal,
293 acpi_ex_dump_buffer_field,
294 NULL,
295 NULL,
296 acpi_ex_dump_region_field,
297 acpi_ex_dump_bank_field,
298 acpi_ex_dump_index_field,
299 acpi_ex_dump_reference,
300 NULL,
301 NULL,
302 acpi_ex_dump_notify,
303 acpi_ex_dump_address_handler,
304 NULL,
305 NULL,
306 NULL
307};
308
309/*******************************************************************************
310 *
311 * FUNCTION: acpi_ex_dump_object
312 *
313 * PARAMETERS: obj_desc - Descriptor to dump
314 * Info - Info table corresponding to this object
315 * type
316 *
317 * RETURN: None
318 *
319 * DESCRIPTION: Walk the info table for this object
320 *
321 ******************************************************************************/
322
323static void
324acpi_ex_dump_object(union acpi_operand_object *obj_desc,
325 struct acpi_exdump_info *info)
326{
327 u8 *target;
328 char *name;
329 u8 count;
330
331 if (!info) {
332 acpi_os_printf
333 ("ex_dump_object: Display not implemented for object type %s\n",
334 acpi_ut_get_object_type_name(obj_desc));
335 return;
336 }
337
338 /* First table entry must contain the table length (# of table entries) */
339
340 count = info->offset;
341
342 while (count) {
343 target = ACPI_ADD_PTR(u8, obj_desc, info->offset);
344 name = info->name;
345
346 switch (info->opcode) {
347 case ACPI_EXD_INIT:
348 break;
349
350 case ACPI_EXD_TYPE:
351 acpi_ex_out_string("Type",
352 acpi_ut_get_object_type_name
353 (obj_desc));
354 break;
355
356 case ACPI_EXD_UINT8:
357
358 acpi_os_printf("%20s : %2.2X\n", name, *target);
359 break;
360
361 case ACPI_EXD_UINT16:
362
363 acpi_os_printf("%20s : %4.4X\n", name,
364 ACPI_GET16(target));
365 break;
366
367 case ACPI_EXD_UINT32:
368
369 acpi_os_printf("%20s : %8.8X\n", name,
370 ACPI_GET32(target));
371 break;
372
373 case ACPI_EXD_UINT64:
374
375 acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
376 ACPI_FORMAT_UINT64(ACPI_GET64(target)));
377 break;
378
379 case ACPI_EXD_POINTER:
380
381 acpi_ex_out_pointer(name,
382 *ACPI_CAST_PTR(void *, target));
383 break;
384
385 case ACPI_EXD_ADDRESS:
386
387 acpi_ex_out_address(name,
388 *ACPI_CAST_PTR
389 (acpi_physical_address, target));
390 break;
391
392 case ACPI_EXD_STRING:
393
394 acpi_ut_print_string(obj_desc->string.pointer,
395 ACPI_UINT8_MAX);
396 acpi_os_printf("\n");
397 break;
398
399 case ACPI_EXD_BUFFER:
400
401 ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
402 obj_desc->buffer.length);
403 break;
404
405 case ACPI_EXD_PACKAGE:
406
407 /* Dump the package contents */
408
409 acpi_os_printf("\nPackage Contents:\n");
410 acpi_ex_dump_package_obj(obj_desc, 0, 0);
411 break;
412
413 case ACPI_EXD_FIELD:
414
415 acpi_ex_dump_object(obj_desc,
416 acpi_ex_dump_field_common);
417 break;
418
419 case ACPI_EXD_REFERENCE:
420
421 acpi_ex_out_string("Opcode",
422 (acpi_ps_get_opcode_info
423 (obj_desc->reference.opcode))->
424 name);
425 acpi_ex_dump_reference_obj(obj_desc);
426 break;
427
428 default:
429 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
430 info->opcode);
431 return;
432 }
433
434 info++;
435 count--;
436 }
437}
72 438
73/******************************************************************************* 439/*******************************************************************************
74 * 440 *
@@ -214,7 +580,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
214 580
215 case ACPI_TYPE_BUFFER: 581 case ACPI_TYPE_BUFFER:
216 582
217 acpi_os_printf("Buffer len %X @ %p \n", 583 acpi_os_printf("Buffer len %X @ %p\n",
218 obj_desc->buffer.length, 584 obj_desc->buffer.length,
219 obj_desc->buffer.pointer); 585 obj_desc->buffer.pointer);
220 586
@@ -320,17 +686,17 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
320 686
321 case ACPI_TYPE_BUFFER_FIELD: 687 case ACPI_TYPE_BUFFER_FIELD:
322 688
323 acpi_os_printf("buffer_field: %X bits at byte %X bit %X of \n", 689 acpi_os_printf("buffer_field: %X bits at byte %X bit %X of\n",
324 obj_desc->buffer_field.bit_length, 690 obj_desc->buffer_field.bit_length,
325 obj_desc->buffer_field.base_byte_offset, 691 obj_desc->buffer_field.base_byte_offset,
326 obj_desc->buffer_field.start_field_bit_offset); 692 obj_desc->buffer_field.start_field_bit_offset);
327 693
328 if (!obj_desc->buffer_field.buffer_obj) { 694 if (!obj_desc->buffer_field.buffer_obj) {
329 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL* \n")); 695 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n"));
330 } else 696 } else
331 if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj) 697 if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj)
332 != ACPI_TYPE_BUFFER) { 698 != ACPI_TYPE_BUFFER) {
333 acpi_os_printf("*not a Buffer* \n"); 699 acpi_os_printf("*not a Buffer*\n");
334 } else { 700 } else {
335 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj, 701 acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
336 depth + 1); 702 depth + 1);
@@ -441,7 +807,6 @@ acpi_ex_dump_operands(union acpi_operand_object **operands,
441 return; 807 return;
442} 808}
443 809
444#ifdef ACPI_FUTURE_USAGE
445/******************************************************************************* 810/*******************************************************************************
446 * 811 *
447 * FUNCTION: acpi_ex_out* functions 812 * FUNCTION: acpi_ex_out* functions
@@ -465,11 +830,6 @@ static void acpi_ex_out_pointer(char *title, void *value)
465 acpi_os_printf("%20s : %p\n", title, value); 830 acpi_os_printf("%20s : %p\n", title, value);
466} 831}
467 832
468static void acpi_ex_out_integer(char *title, u32 value)
469{
470 acpi_os_printf("%20s : %.2X\n", title, value);
471}
472
473static void acpi_ex_out_address(char *title, acpi_physical_address value) 833static void acpi_ex_out_address(char *title, acpi_physical_address value)
474{ 834{
475 835
@@ -482,16 +842,16 @@ static void acpi_ex_out_address(char *title, acpi_physical_address value)
482 842
483/******************************************************************************* 843/*******************************************************************************
484 * 844 *
485 * FUNCTION: acpi_ex_dump_node 845 * FUNCTION: acpi_ex_dump_namespace_node
486 * 846 *
487 * PARAMETERS: *Node - Descriptor to dump 847 * PARAMETERS: Node - Descriptor to dump
488 * Flags - Force display if TRUE 848 * Flags - Force display if TRUE
489 * 849 *
490 * DESCRIPTION: Dumps the members of the given.Node 850 * DESCRIPTION: Dumps the members of the given.Node
491 * 851 *
492 ******************************************************************************/ 852 ******************************************************************************/
493 853
494void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags) 854void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
495{ 855{
496 856
497 ACPI_FUNCTION_ENTRY(); 857 ACPI_FUNCTION_ENTRY();
@@ -506,19 +866,17 @@ void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags)
506 866
507 acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node)); 867 acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
508 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type)); 868 acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type));
509 acpi_ex_out_integer("Flags", node->flags);
510 acpi_ex_out_integer("Owner Id", node->owner_id);
511 acpi_ex_out_integer("Reference Count", node->reference_count);
512 acpi_ex_out_pointer("Attached Object", 869 acpi_ex_out_pointer("Attached Object",
513 acpi_ns_get_attached_object(node)); 870 acpi_ns_get_attached_object(node));
514 acpi_ex_out_pointer("child_list", node->child);
515 acpi_ex_out_pointer("next_peer", node->peer);
516 acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node)); 871 acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node));
872
873 acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node),
874 acpi_ex_dump_node);
517} 875}
518 876
519/******************************************************************************* 877/*******************************************************************************
520 * 878 *
521 * FUNCTION: acpi_ex_dump_reference 879 * FUNCTION: acpi_ex_dump_reference_obj
522 * 880 *
523 * PARAMETERS: Object - Descriptor to dump 881 * PARAMETERS: Object - Descriptor to dump
524 * 882 *
@@ -526,14 +884,16 @@ void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags)
526 * 884 *
527 ******************************************************************************/ 885 ******************************************************************************/
528 886
529static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc) 887static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
530{ 888{
531 struct acpi_buffer ret_buf; 889 struct acpi_buffer ret_buf;
532 acpi_status status; 890 acpi_status status;
533 891
892 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
893
534 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { 894 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
535 acpi_os_printf("Named Object %p ", obj_desc->reference.node); 895 acpi_os_printf("Named Object %p ", obj_desc->reference.node);
536 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; 896
537 status = 897 status =
538 acpi_ns_handle_to_pathname(obj_desc->reference.node, 898 acpi_ns_handle_to_pathname(obj_desc->reference.node,
539 &ret_buf); 899 &ret_buf);
@@ -551,9 +911,9 @@ static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc)
551 911
552/******************************************************************************* 912/*******************************************************************************
553 * 913 *
554 * FUNCTION: acpi_ex_dump_package 914 * FUNCTION: acpi_ex_dump_package_obj
555 * 915 *
556 * PARAMETERS: Object - Descriptor to dump 916 * PARAMETERS: obj_desc - Descriptor to dump
557 * Level - Indentation Level 917 * Level - Indentation Level
558 * Index - Package index for this object 918 * Index - Package index for this object
559 * 919 *
@@ -562,7 +922,8 @@ static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc)
562 ******************************************************************************/ 922 ******************************************************************************/
563 923
564static void 924static void
565acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index) 925acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
926 u32 level, u32 index)
566{ 927{
567 u32 i; 928 u32 i;
568 929
@@ -608,7 +969,8 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
608 acpi_os_printf("[Buffer] Length %.2X = ", 969 acpi_os_printf("[Buffer] Length %.2X = ",
609 obj_desc->buffer.length); 970 obj_desc->buffer.length);
610 if (obj_desc->buffer.length) { 971 if (obj_desc->buffer.length) {
611 acpi_ut_dump_buffer((u8 *) obj_desc->buffer.pointer, 972 acpi_ut_dump_buffer(ACPI_CAST_PTR
973 (u8, obj_desc->buffer.pointer),
612 obj_desc->buffer.length, 974 obj_desc->buffer.length,
613 DB_DWORD_DISPLAY, _COMPONENT); 975 DB_DWORD_DISPLAY, _COMPONENT);
614 } else { 976 } else {
@@ -618,19 +980,19 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
618 980
619 case ACPI_TYPE_PACKAGE: 981 case ACPI_TYPE_PACKAGE:
620 982
621 acpi_os_printf("[Package] Contains %d Elements: \n", 983 acpi_os_printf("[Package] Contains %d Elements:\n",
622 obj_desc->package.count); 984 obj_desc->package.count);
623 985
624 for (i = 0; i < obj_desc->package.count; i++) { 986 for (i = 0; i < obj_desc->package.count; i++) {
625 acpi_ex_dump_package(obj_desc->package.elements[i], 987 acpi_ex_dump_package_obj(obj_desc->package.elements[i],
626 level + 1, i); 988 level + 1, i);
627 } 989 }
628 break; 990 break;
629 991
630 case ACPI_TYPE_LOCAL_REFERENCE: 992 case ACPI_TYPE_LOCAL_REFERENCE:
631 993
632 acpi_os_printf("[Object Reference] "); 994 acpi_os_printf("[Object Reference] ");
633 acpi_ex_dump_reference(obj_desc); 995 acpi_ex_dump_reference_obj(obj_desc);
634 break; 996 break;
635 997
636 default: 998 default:
@@ -645,7 +1007,7 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
645 * 1007 *
646 * FUNCTION: acpi_ex_dump_object_descriptor 1008 * FUNCTION: acpi_ex_dump_object_descriptor
647 * 1009 *
648 * PARAMETERS: Object - Descriptor to dump 1010 * PARAMETERS: obj_desc - Descriptor to dump
649 * Flags - Force display if TRUE 1011 * Flags - Force display if TRUE
650 * 1012 *
651 * DESCRIPTION: Dumps the members of the object descriptor given. 1013 * DESCRIPTION: Dumps the members of the object descriptor given.
@@ -670,11 +1032,13 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
670 } 1032 }
671 1033
672 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) { 1034 if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
673 acpi_ex_dump_node((struct acpi_namespace_node *)obj_desc, 1035 acpi_ex_dump_namespace_node((struct acpi_namespace_node *)
674 flags); 1036 obj_desc, flags);
1037
675 acpi_os_printf("\nAttached Object (%p):\n", 1038 acpi_os_printf("\nAttached Object (%p):\n",
676 ((struct acpi_namespace_node *)obj_desc)-> 1039 ((struct acpi_namespace_node *)obj_desc)->
677 object); 1040 object);
1041
678 acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *) 1042 acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *)
679 obj_desc)->object, flags); 1043 obj_desc)->object, flags);
680 return_VOID; 1044 return_VOID;
@@ -687,233 +1051,18 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
687 return_VOID; 1051 return_VOID;
688 } 1052 }
689 1053
690 /* Common Fields */ 1054 if (obj_desc->common.type > ACPI_TYPE_NS_NODE_MAX) {
691 1055 return_VOID;
692 acpi_ex_out_string("Type", acpi_ut_get_object_type_name(obj_desc)); 1056 }
693 acpi_ex_out_integer("Reference Count",
694 obj_desc->common.reference_count);
695 acpi_ex_out_integer("Flags", obj_desc->common.flags);
696
697 /* Object-specific Fields */
698
699 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
700 case ACPI_TYPE_INTEGER:
701
702 acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
703 ACPI_FORMAT_UINT64(obj_desc->integer.value));
704 break;
705
706 case ACPI_TYPE_STRING:
707
708 acpi_ex_out_integer("Length", obj_desc->string.length);
709
710 acpi_os_printf("%20s : %p ", "Pointer",
711 obj_desc->string.pointer);
712 acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
713 acpi_os_printf("\n");
714 break;
715
716 case ACPI_TYPE_BUFFER:
717
718 acpi_ex_out_integer("Length", obj_desc->buffer.length);
719 acpi_ex_out_pointer("Pointer", obj_desc->buffer.pointer);
720 ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
721 obj_desc->buffer.length);
722 break;
723
724 case ACPI_TYPE_PACKAGE:
725
726 acpi_ex_out_integer("Flags", obj_desc->package.flags);
727 acpi_ex_out_integer("Elements", obj_desc->package.count);
728 acpi_ex_out_pointer("Element List", obj_desc->package.elements);
729
730 /* Dump the package contents */
731
732 acpi_os_printf("\nPackage Contents:\n");
733 acpi_ex_dump_package(obj_desc, 0, 0);
734 break;
735
736 case ACPI_TYPE_DEVICE:
737
738 acpi_ex_out_pointer("Handler", obj_desc->device.handler);
739 acpi_ex_out_pointer("system_notify",
740 obj_desc->device.system_notify);
741 acpi_ex_out_pointer("device_notify",
742 obj_desc->device.device_notify);
743 break;
744
745 case ACPI_TYPE_EVENT:
746
747 acpi_ex_out_pointer("Semaphore", obj_desc->event.semaphore);
748 break;
749
750 case ACPI_TYPE_METHOD:
751
752 acpi_ex_out_integer("param_count",
753 obj_desc->method.param_count);
754 acpi_ex_out_integer("Concurrency",
755 obj_desc->method.concurrency);
756 acpi_ex_out_pointer("Semaphore", obj_desc->method.semaphore);
757 acpi_ex_out_integer("owner_id", obj_desc->method.owner_id);
758 acpi_ex_out_integer("aml_length", obj_desc->method.aml_length);
759 acpi_ex_out_pointer("aml_start", obj_desc->method.aml_start);
760 break;
761
762 case ACPI_TYPE_MUTEX:
763
764 acpi_ex_out_integer("sync_level", obj_desc->mutex.sync_level);
765 acpi_ex_out_pointer("owner_thread",
766 obj_desc->mutex.owner_thread);
767 acpi_ex_out_integer("acquire_depth",
768 obj_desc->mutex.acquisition_depth);
769 acpi_ex_out_pointer("Semaphore", obj_desc->mutex.semaphore);
770 break;
771
772 case ACPI_TYPE_REGION:
773
774 acpi_ex_out_integer("space_id", obj_desc->region.space_id);
775 acpi_ex_out_integer("Flags", obj_desc->region.flags);
776 acpi_ex_out_address("Address", obj_desc->region.address);
777 acpi_ex_out_integer("Length", obj_desc->region.length);
778 acpi_ex_out_pointer("Handler", obj_desc->region.handler);
779 acpi_ex_out_pointer("Next", obj_desc->region.next);
780 break;
781
782 case ACPI_TYPE_POWER:
783
784 acpi_ex_out_integer("system_level",
785 obj_desc->power_resource.system_level);
786 acpi_ex_out_integer("resource_order",
787 obj_desc->power_resource.resource_order);
788 acpi_ex_out_pointer("system_notify",
789 obj_desc->power_resource.system_notify);
790 acpi_ex_out_pointer("device_notify",
791 obj_desc->power_resource.device_notify);
792 break;
793
794 case ACPI_TYPE_PROCESSOR:
795
796 acpi_ex_out_integer("Processor ID",
797 obj_desc->processor.proc_id);
798 acpi_ex_out_integer("Length", obj_desc->processor.length);
799 acpi_ex_out_address("Address",
800 (acpi_physical_address) obj_desc->processor.
801 address);
802 acpi_ex_out_pointer("system_notify",
803 obj_desc->processor.system_notify);
804 acpi_ex_out_pointer("device_notify",
805 obj_desc->processor.device_notify);
806 acpi_ex_out_pointer("Handler", obj_desc->processor.handler);
807 break;
808
809 case ACPI_TYPE_THERMAL:
810
811 acpi_ex_out_pointer("system_notify",
812 obj_desc->thermal_zone.system_notify);
813 acpi_ex_out_pointer("device_notify",
814 obj_desc->thermal_zone.device_notify);
815 acpi_ex_out_pointer("Handler", obj_desc->thermal_zone.handler);
816 break;
817
818 case ACPI_TYPE_BUFFER_FIELD:
819 case ACPI_TYPE_LOCAL_REGION_FIELD:
820 case ACPI_TYPE_LOCAL_BANK_FIELD:
821 case ACPI_TYPE_LOCAL_INDEX_FIELD:
822
823 acpi_ex_out_integer("field_flags",
824 obj_desc->common_field.field_flags);
825 acpi_ex_out_integer("access_byte_width",
826 obj_desc->common_field.access_byte_width);
827 acpi_ex_out_integer("bit_length",
828 obj_desc->common_field.bit_length);
829 acpi_ex_out_integer("fld_bit_offset",
830 obj_desc->common_field.
831 start_field_bit_offset);
832 acpi_ex_out_integer("base_byte_offset",
833 obj_desc->common_field.base_byte_offset);
834 acpi_ex_out_pointer("parent_node", obj_desc->common_field.node);
835
836 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
837 case ACPI_TYPE_BUFFER_FIELD:
838 acpi_ex_out_pointer("buffer_obj",
839 obj_desc->buffer_field.buffer_obj);
840 break;
841
842 case ACPI_TYPE_LOCAL_REGION_FIELD:
843 acpi_ex_out_pointer("region_obj",
844 obj_desc->field.region_obj);
845 break;
846
847 case ACPI_TYPE_LOCAL_BANK_FIELD:
848 acpi_ex_out_integer("Value",
849 obj_desc->bank_field.value);
850 acpi_ex_out_pointer("region_obj",
851 obj_desc->bank_field.region_obj);
852 acpi_ex_out_pointer("bank_obj",
853 obj_desc->bank_field.bank_obj);
854 break;
855
856 case ACPI_TYPE_LOCAL_INDEX_FIELD:
857 acpi_ex_out_integer("Value",
858 obj_desc->index_field.value);
859 acpi_ex_out_pointer("Index",
860 obj_desc->index_field.index_obj);
861 acpi_ex_out_pointer("Data",
862 obj_desc->index_field.data_obj);
863 break;
864
865 default:
866 /* All object types covered above */
867 break;
868 }
869 break;
870
871 case ACPI_TYPE_LOCAL_REFERENCE:
872
873 acpi_ex_out_integer("target_type",
874 obj_desc->reference.target_type);
875 acpi_ex_out_string("Opcode",
876 (acpi_ps_get_opcode_info
877 (obj_desc->reference.opcode))->name);
878 acpi_ex_out_integer("Offset", obj_desc->reference.offset);
879 acpi_ex_out_pointer("obj_desc", obj_desc->reference.object);
880 acpi_ex_out_pointer("Node", obj_desc->reference.node);
881 acpi_ex_out_pointer("Where", obj_desc->reference.where);
882
883 acpi_ex_dump_reference(obj_desc);
884 break;
885
886 case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
887
888 acpi_ex_out_integer("space_id",
889 obj_desc->address_space.space_id);
890 acpi_ex_out_pointer("Next", obj_desc->address_space.next);
891 acpi_ex_out_pointer("region_list",
892 obj_desc->address_space.region_list);
893 acpi_ex_out_pointer("Node", obj_desc->address_space.node);
894 acpi_ex_out_pointer("Context", obj_desc->address_space.context);
895 break;
896 1057
897 case ACPI_TYPE_LOCAL_NOTIFY: 1058 /* Common Fields */
898 1059
899 acpi_ex_out_pointer("Node", obj_desc->notify.node); 1060 acpi_ex_dump_object(obj_desc, acpi_ex_dump_common);
900 acpi_ex_out_pointer("Context", obj_desc->notify.context);
901 break;
902 1061
903 case ACPI_TYPE_LOCAL_ALIAS: 1062 /* Object-specific fields */
904 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
905 case ACPI_TYPE_LOCAL_EXTRA:
906 case ACPI_TYPE_LOCAL_DATA:
907 default:
908
909 acpi_os_printf
910 ("ex_dump_object_descriptor: Display not implemented for object type %s\n",
911 acpi_ut_get_object_type_name(obj_desc));
912 break;
913 }
914 1063
1064 acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]);
915 return_VOID; 1065 return_VOID;
916} 1066}
917 1067
918#endif /* ACPI_FUTURE_USAGE */
919#endif 1068#endif
diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c
index ab1ba399aa28..e259201ce9a0 100644
--- a/drivers/acpi/executer/exfield.c
+++ b/drivers/acpi/executer/exfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -249,13 +249,18 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
249 * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). 249 * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE).
250 */ 250 */
251 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { 251 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) {
252 ACPI_REPORT_ERROR(("SMBus write requires Buffer, found type %s\n", acpi_ut_get_object_type_name(source_desc))); 252 ACPI_ERROR((AE_INFO,
253 "SMBus write requires Buffer, found type %s",
254 acpi_ut_get_object_type_name(source_desc)));
253 255
254 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 256 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
255 } 257 }
256 258
257 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) { 259 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) {
258 ACPI_REPORT_ERROR(("SMBus write requires Buffer of length %X, found length %X\n", ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length)); 260 ACPI_ERROR((AE_INFO,
261 "SMBus write requires Buffer of length %X, found length %X",
262 ACPI_SMBUS_BUFFER_SIZE,
263 source_desc->buffer.length));
259 264
260 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT); 265 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
261 } 266 }
diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c
index ba6e08843c29..bd1af35f7fcf 100644
--- a/drivers/acpi/executer/exfldio.c
+++ b/drivers/acpi/executer/exfldio.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -94,10 +94,9 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
94 /* We must have a valid region */ 94 /* We must have a valid region */
95 95
96 if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) { 96 if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) {
97 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 97 ACPI_ERROR((AE_INFO, "Needed Region, found type %X (%s)",
98 "Needed Region, found type %X (%s)\n", 98 ACPI_GET_OBJECT_TYPE(rgn_desc),
99 ACPI_GET_OBJECT_TYPE(rgn_desc), 99 acpi_ut_get_object_type_name(rgn_desc)));
100 acpi_ut_get_object_type_name(rgn_desc)));
101 100
102 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 101 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
103 } 102 }
@@ -162,31 +161,28 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
162 * than the region itself. For example, a region of length one 161 * than the region itself. For example, a region of length one
163 * byte, and a field with Dword access specified. 162 * byte, and a field with Dword access specified.
164 */ 163 */
165 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 164 ACPI_ERROR((AE_INFO,
166 "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", 165 "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)",
167 acpi_ut_get_node_name(obj_desc-> 166 acpi_ut_get_node_name(obj_desc->
168 common_field. 167 common_field.node),
169 node), 168 obj_desc->common_field.access_byte_width,
170 obj_desc->common_field. 169 acpi_ut_get_node_name(rgn_desc->region.
171 access_byte_width, 170 node),
172 acpi_ut_get_node_name(rgn_desc-> 171 rgn_desc->region.length));
173 region.node),
174 rgn_desc->region.length));
175 } 172 }
176 173
177 /* 174 /*
178 * Offset rounded up to next multiple of field width 175 * Offset rounded up to next multiple of field width
179 * exceeds region length, indicate an error 176 * exceeds region length, indicate an error
180 */ 177 */
181 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 178 ACPI_ERROR((AE_INFO,
182 "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n", 179 "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)",
183 acpi_ut_get_node_name(obj_desc->common_field. 180 acpi_ut_get_node_name(obj_desc->common_field.node),
184 node), 181 obj_desc->common_field.base_byte_offset,
185 obj_desc->common_field.base_byte_offset, 182 field_datum_byte_offset,
186 field_datum_byte_offset, 183 obj_desc->common_field.access_byte_width,
187 obj_desc->common_field.access_byte_width, 184 acpi_ut_get_node_name(rgn_desc->region.node),
188 acpi_ut_get_node_name(rgn_desc->region.node), 185 rgn_desc->region.length));
189 rgn_desc->region.length));
190 186
191 return_ACPI_STATUS(AE_AML_REGION_LIMIT); 187 return_ACPI_STATUS(AE_AML_REGION_LIMIT);
192 } 188 }
@@ -270,18 +266,17 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
270 266
271 if (ACPI_FAILURE(status)) { 267 if (ACPI_FAILURE(status)) {
272 if (status == AE_NOT_IMPLEMENTED) { 268 if (status == AE_NOT_IMPLEMENTED) {
273 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 269 ACPI_ERROR((AE_INFO,
274 "Region %s(%X) not implemented\n", 270 "Region %s(%X) not implemented",
275 acpi_ut_get_region_name(rgn_desc-> 271 acpi_ut_get_region_name(rgn_desc->region.
276 region. 272 space_id),
277 space_id), 273 rgn_desc->region.space_id));
278 rgn_desc->region.space_id));
279 } else if (status == AE_NOT_EXIST) { 274 } else if (status == AE_NOT_EXIST) {
280 ACPI_REPORT_ERROR(("Region %s(%X) has no handler\n", 275 ACPI_ERROR((AE_INFO,
281 acpi_ut_get_region_name(rgn_desc-> 276 "Region %s(%X) has no handler",
282 region. 277 acpi_ut_get_region_name(rgn_desc->region.
283 space_id), 278 space_id),
284 rgn_desc->region.space_id)); 279 rgn_desc->region.space_id));
285 } 280 }
286 } 281 }
287 282
@@ -514,8 +509,8 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
514 509
515 default: 510 default:
516 511
517 ACPI_REPORT_ERROR(("Wrong object type in field I/O %X\n", 512 ACPI_ERROR((AE_INFO, "Wrong object type in field I/O %X",
518 ACPI_GET_OBJECT_TYPE(obj_desc))); 513 ACPI_GET_OBJECT_TYPE(obj_desc)));
519 status = AE_AML_INTERNAL; 514 status = AE_AML_INTERNAL;
520 break; 515 break;
521 } 516 }
@@ -618,11 +613,11 @@ acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
618 613
619 default: 614 default:
620 615
621 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 616 ACPI_ERROR((AE_INFO,
622 "write_with_update_rule: Unknown update_rule setting: %X\n", 617 "Unknown update_rule value: %X",
623 (obj_desc->common_field. 618 (obj_desc->common_field.
624 field_flags & 619 field_flags &
625 AML_FIELD_UPDATE_RULE_MASK))); 620 AML_FIELD_UPDATE_RULE_MASK)));
626 return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 621 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
627 } 622 }
628 } 623 }
@@ -677,10 +672,9 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
677 672
678 if (buffer_length < 673 if (buffer_length <
679 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { 674 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
680 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 675 ACPI_ERROR((AE_INFO,
681 "Field size %X (bits) is too large for buffer (%X)\n", 676 "Field size %X (bits) is too large for buffer (%X)",
682 obj_desc->common_field.bit_length, 677 obj_desc->common_field.bit_length, buffer_length));
683 buffer_length));
684 678
685 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 679 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
686 } 680 }
@@ -792,10 +786,9 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
792 786
793 if (buffer_length < 787 if (buffer_length <
794 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { 788 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
795 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 789 ACPI_ERROR((AE_INFO,
796 "Field size %X (bits) is too large for buffer (%X)\n", 790 "Field size %X (bits) is too large for buffer (%X)",
797 obj_desc->common_field.bit_length, 791 obj_desc->common_field.bit_length, buffer_length));
798 buffer_length));
799 792
800 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 793 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
801 } 794 }
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index a3f4d72bedc9..48c18d29222a 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,7 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
47#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
48#include <acpi/amlresrc.h>
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exmisc") 51ACPI_MODULE_NAME("exmisc")
@@ -97,7 +98,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
97 98
98 default: 99 default:
99 100
100 ACPI_REPORT_ERROR(("Unknown Reference opcode in get_reference %X\n", obj_desc->reference.opcode)); 101 ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X",
102 obj_desc->reference.opcode));
101 return_ACPI_STATUS(AE_AML_INTERNAL); 103 return_ACPI_STATUS(AE_AML_INTERNAL);
102 } 104 }
103 break; 105 break;
@@ -112,7 +114,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
112 114
113 default: 115 default:
114 116
115 ACPI_REPORT_ERROR(("Invalid descriptor type in get_reference: %X\n", ACPI_GET_DESCRIPTOR_TYPE(obj_desc))); 117 ACPI_ERROR((AE_INFO, "Invalid descriptor type %X",
118 ACPI_GET_DESCRIPTOR_TYPE(obj_desc)));
116 return_ACPI_STATUS(AE_TYPE); 119 return_ACPI_STATUS(AE_TYPE);
117 } 120 }
118 121
@@ -157,48 +160,65 @@ acpi_ex_concat_template(union acpi_operand_object *operand0,
157 union acpi_operand_object **actual_return_desc, 160 union acpi_operand_object **actual_return_desc,
158 struct acpi_walk_state *walk_state) 161 struct acpi_walk_state *walk_state)
159{ 162{
163 acpi_status status;
160 union acpi_operand_object *return_desc; 164 union acpi_operand_object *return_desc;
161 u8 *new_buf; 165 u8 *new_buf;
162 u8 *end_tag1; 166 u8 *end_tag;
163 u8 *end_tag2; 167 acpi_size length0;
164 acpi_size length1; 168 acpi_size length1;
165 acpi_size length2; 169 acpi_size new_length;
166 170
167 ACPI_FUNCTION_TRACE("ex_concat_template"); 171 ACPI_FUNCTION_TRACE("ex_concat_template");
168 172
169 /* Find the end_tags in each resource template */ 173 /*
174 * Find the end_tag descriptor in each resource template.
175 * Note1: returned pointers point TO the end_tag, not past it.
176 * Note2: zero-length buffers are allowed; treated like one end_tag
177 */
178
179 /* Get the length of the first resource template */
170 180
171 end_tag1 = acpi_ut_get_resource_end_tag(operand0); 181 status = acpi_ut_get_resource_end_tag(operand0, &end_tag);
172 end_tag2 = acpi_ut_get_resource_end_tag(operand1); 182 if (ACPI_FAILURE(status)) {
173 if (!end_tag1 || !end_tag2) { 183 return_ACPI_STATUS(status);
174 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
175 } 184 }
176 185
177 /* Compute the length of each part */ 186 length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer);
187
188 /* Get the length of the second resource template */
189
190 status = acpi_ut_get_resource_end_tag(operand1, &end_tag);
191 if (ACPI_FAILURE(status)) {
192 return_ACPI_STATUS(status);
193 }
178 194
179 length1 = ACPI_PTR_DIFF(end_tag1, operand0->buffer.pointer); 195 length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer);
180 length2 = ACPI_PTR_DIFF(end_tag2, operand1->buffer.pointer) + 2; /* Size of END_TAG */
181 196
182 /* Create a new buffer object for the result */ 197 /* Combine both lengths, minimum size will be 2 for end_tag */
183 198
184 return_desc = acpi_ut_create_buffer_object(length1 + length2); 199 new_length = length0 + length1 + sizeof(struct aml_resource_end_tag);
200
201 /* Create a new buffer object for the result (with one end_tag) */
202
203 return_desc = acpi_ut_create_buffer_object(new_length);
185 if (!return_desc) { 204 if (!return_desc) {
186 return_ACPI_STATUS(AE_NO_MEMORY); 205 return_ACPI_STATUS(AE_NO_MEMORY);
187 } 206 }
188 207
189 /* Copy the templates to the new descriptor */ 208 /*
190 209 * Copy the templates to the new buffer, 0 first, then 1 follows. One
210 * end_tag descriptor is copied from Operand1.
211 */
191 new_buf = return_desc->buffer.pointer; 212 new_buf = return_desc->buffer.pointer;
192 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length1); 213 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0);
193 ACPI_MEMCPY(new_buf + length1, operand1->buffer.pointer, length2); 214 ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1);
194 215
195 /* Compute the new checksum */ 216 /* Insert end_tag and set the checksum to zero, means "ignore checksum" */
196 217
197 new_buf[return_desc->buffer.length - 1] = 218 new_buf[new_length - 1] = 0;
198 acpi_ut_generate_checksum(return_desc->buffer.pointer, 219 new_buf[new_length - 2] = ACPI_RESOURCE_NAME_END_TAG | 1;
199 (return_desc->buffer.length - 1));
200 220
201 /* Return the completed template descriptor */ 221 /* Return the completed resource template */
202 222
203 *actual_return_desc = return_desc; 223 *actual_return_desc = return_desc;
204 return_ACPI_STATUS(AE_OK); 224 return_ACPI_STATUS(AE_OK);
@@ -229,7 +249,6 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
229 union acpi_operand_object *return_desc; 249 union acpi_operand_object *return_desc;
230 char *new_buf; 250 char *new_buf;
231 acpi_status status; 251 acpi_status status;
232 acpi_size new_length;
233 252
234 ACPI_FUNCTION_TRACE("ex_do_concatenate"); 253 ACPI_FUNCTION_TRACE("ex_do_concatenate");
235 254
@@ -256,8 +275,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
256 break; 275 break;
257 276
258 default: 277 default:
259 ACPI_REPORT_ERROR(("Concat - invalid obj type: %X\n", 278 ACPI_ERROR((AE_INFO, "Invalid object type: %X",
260 ACPI_GET_OBJECT_TYPE(operand0))); 279 ACPI_GET_OBJECT_TYPE(operand0)));
261 status = AE_AML_INTERNAL; 280 status = AE_AML_INTERNAL;
262 } 281 }
263 282
@@ -296,8 +315,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
296 315
297 /* Copy the first integer, LSB first */ 316 /* Copy the first integer, LSB first */
298 317
299 ACPI_MEMCPY(new_buf, 318 ACPI_MEMCPY(new_buf, &operand0->integer.value,
300 &operand0->integer.value,
301 acpi_gbl_integer_byte_width); 319 acpi_gbl_integer_byte_width);
302 320
303 /* Copy the second integer (LSB first) after the first */ 321 /* Copy the second integer (LSB first) after the first */
@@ -311,14 +329,11 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
311 329
312 /* Result of two Strings is a String */ 330 /* Result of two Strings is a String */
313 331
314 new_length = (acpi_size) operand0->string.length + 332 return_desc = acpi_ut_create_string_object((acpi_size)
315 (acpi_size) local_operand1->string.length; 333 (operand0->string.
316 if (new_length > ACPI_MAX_STRING_CONVERSION) { 334 length +
317 status = AE_AML_STRING_LIMIT; 335 local_operand1->
318 goto cleanup; 336 string.length));
319 }
320
321 return_desc = acpi_ut_create_string_object(new_length);
322 if (!return_desc) { 337 if (!return_desc) {
323 status = AE_NO_MEMORY; 338 status = AE_NO_MEMORY;
324 goto cleanup; 339 goto cleanup;
@@ -338,11 +353,10 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
338 /* Result of two Buffers is a Buffer */ 353 /* Result of two Buffers is a Buffer */
339 354
340 return_desc = acpi_ut_create_buffer_object((acpi_size) 355 return_desc = acpi_ut_create_buffer_object((acpi_size)
341 operand0->buffer. 356 (operand0->buffer.
342 length + 357 length +
343 (acpi_size) 358 local_operand1->
344 local_operand1-> 359 buffer.length));
345 buffer.length);
346 if (!return_desc) { 360 if (!return_desc) {
347 status = AE_NO_MEMORY; 361 status = AE_NO_MEMORY;
348 goto cleanup; 362 goto cleanup;
@@ -352,8 +366,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
352 366
353 /* Concatenate the buffers */ 367 /* Concatenate the buffers */
354 368
355 ACPI_MEMCPY(new_buf, 369 ACPI_MEMCPY(new_buf, operand0->buffer.pointer,
356 operand0->buffer.pointer, operand0->buffer.length); 370 operand0->buffer.length);
357 ACPI_MEMCPY(new_buf + operand0->buffer.length, 371 ACPI_MEMCPY(new_buf + operand0->buffer.length,
358 local_operand1->buffer.pointer, 372 local_operand1->buffer.pointer,
359 local_operand1->buffer.length); 373 local_operand1->buffer.length);
@@ -363,8 +377,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
363 377
364 /* Invalid object type, should not happen here */ 378 /* Invalid object type, should not happen here */
365 379
366 ACPI_REPORT_ERROR(("Concatenate - Invalid object type: %X\n", 380 ACPI_ERROR((AE_INFO, "Invalid object type: %X",
367 ACPI_GET_OBJECT_TYPE(operand0))); 381 ACPI_GET_OBJECT_TYPE(operand0)));
368 status = AE_AML_INTERNAL; 382 status = AE_AML_INTERNAL;
369 goto cleanup; 383 goto cleanup;
370 } 384 }
@@ -625,9 +639,8 @@ acpi_ex_do_logical_op(u16 opcode,
625 639
626 /* Lexicographic compare: compare the data bytes */ 640 /* Lexicographic compare: compare the data bytes */
627 641
628 compare = ACPI_MEMCMP((const char *)operand0->buffer.pointer, 642 compare = ACPI_MEMCMP(operand0->buffer.pointer,
629 (const char *)local_operand1->buffer. 643 local_operand1->buffer.pointer,
630 pointer,
631 (length0 > length1) ? length1 : length0); 644 (length0 > length1) ? length1 : length0);
632 645
633 switch (opcode) { 646 switch (opcode) {
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c
index ab47f6d8b5c0..f843b22e20b9 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/executer/exmutex.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -153,7 +153,9 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
153 /* Sanity check -- we must have a valid thread ID */ 153 /* Sanity check -- we must have a valid thread ID */
154 154
155 if (!walk_state->thread) { 155 if (!walk_state->thread) {
156 ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node))); 156 ACPI_ERROR((AE_INFO,
157 "Cannot acquire Mutex [%4.4s], null thread info",
158 acpi_ut_get_node_name(obj_desc->mutex.node)));
157 return_ACPI_STATUS(AE_AML_INTERNAL); 159 return_ACPI_STATUS(AE_AML_INTERNAL);
158 } 160 }
159 161
@@ -162,7 +164,9 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
162 * mutex. This mechanism provides some deadlock prevention 164 * mutex. This mechanism provides some deadlock prevention
163 */ 165 */
164 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { 166 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
165 ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node))); 167 ACPI_ERROR((AE_INFO,
168 "Cannot acquire Mutex [%4.4s], incorrect sync_level",
169 acpi_ut_get_node_name(obj_desc->mutex.node)));
166 return_ACPI_STATUS(AE_AML_MUTEX_ORDER); 170 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
167 } 171 }
168 172
@@ -237,14 +241,18 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
237 /* The mutex must have been previously acquired in order to release it */ 241 /* The mutex must have been previously acquired in order to release it */
238 242
239 if (!obj_desc->mutex.owner_thread) { 243 if (!obj_desc->mutex.owner_thread) {
240 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], not acquired\n", acpi_ut_get_node_name(obj_desc->mutex.node))); 244 ACPI_ERROR((AE_INFO,
245 "Cannot release Mutex [%4.4s], not acquired",
246 acpi_ut_get_node_name(obj_desc->mutex.node)));
241 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); 247 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
242 } 248 }
243 249
244 /* Sanity check -- we must have a valid thread ID */ 250 /* Sanity check -- we must have a valid thread ID */
245 251
246 if (!walk_state->thread) { 252 if (!walk_state->thread) {
247 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node))); 253 ACPI_ERROR((AE_INFO,
254 "Cannot release Mutex [%4.4s], null thread info",
255 acpi_ut_get_node_name(obj_desc->mutex.node)));
248 return_ACPI_STATUS(AE_AML_INTERNAL); 256 return_ACPI_STATUS(AE_AML_INTERNAL);
249 } 257 }
250 258
@@ -255,7 +263,11 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
255 if ((obj_desc->mutex.owner_thread->thread_id != 263 if ((obj_desc->mutex.owner_thread->thread_id !=
256 walk_state->thread->thread_id) 264 walk_state->thread->thread_id)
257 && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { 265 && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) {
258 ACPI_REPORT_ERROR(("Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", walk_state->thread->thread_id, acpi_ut_get_node_name(obj_desc->mutex.node), obj_desc->mutex.owner_thread->thread_id)); 266 ACPI_ERROR((AE_INFO,
267 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X",
268 walk_state->thread->thread_id,
269 acpi_ut_get_node_name(obj_desc->mutex.node),
270 obj_desc->mutex.owner_thread->thread_id));
259 return_ACPI_STATUS(AE_AML_NOT_OWNER); 271 return_ACPI_STATUS(AE_AML_NOT_OWNER);
260 } 272 }
261 273
@@ -264,7 +276,9 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
264 * equal to the current sync level 276 * equal to the current sync level
265 */ 277 */
266 if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) { 278 if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) {
267 ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node))); 279 ACPI_ERROR((AE_INFO,
280 "Cannot release Mutex [%4.4s], incorrect sync_level",
281 acpi_ut_get_node_name(obj_desc->mutex.node)));
268 return_ACPI_STATUS(AE_AML_MUTEX_ORDER); 282 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
269 } 283 }
270 284
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c
index 239d8473e9a5..054fe5e1a314 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/executer/exnames.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -99,7 +99,8 @@ static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs)
99 */ 99 */
100 name_string = ACPI_MEM_ALLOCATE(size_needed); 100 name_string = ACPI_MEM_ALLOCATE(size_needed);
101 if (!name_string) { 101 if (!name_string) {
102 ACPI_REPORT_ERROR(("ex_allocate_name_string: Could not allocate size %d\n", size_needed)); 102 ACPI_ERROR((AE_INFO,
103 "Could not allocate size %d", size_needed));
103 return_PTR(NULL); 104 return_PTR(NULL);
104 } 105 }
105 106
@@ -167,8 +168,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
167 char_buf[0] = *aml_address; 168 char_buf[0] = *aml_address;
168 169
169 if ('0' <= char_buf[0] && char_buf[0] <= '9') { 170 if ('0' <= char_buf[0] && char_buf[0] <= '9') {
170 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "leading digit: %c\n", 171 ACPI_ERROR((AE_INFO, "Invalid leading digit: %c", char_buf[0]));
171 char_buf[0]));
172 return_ACPI_STATUS(AE_CTRL_PENDING); 172 return_ACPI_STATUS(AE_CTRL_PENDING);
173 } 173 }
174 174
@@ -191,10 +191,10 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
191 if (name_string) { 191 if (name_string) {
192 ACPI_STRCAT(name_string, char_buf); 192 ACPI_STRCAT(name_string, char_buf);
193 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 193 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
194 "Appended to - %s \n", name_string)); 194 "Appended to - %s\n", name_string));
195 } else { 195 } else {
196 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 196 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
197 "No Name string - %s \n", char_buf)); 197 "No Name string - %s\n", char_buf));
198 } 198 }
199 } else if (index == 0) { 199 } else if (index == 0) {
200 /* 200 /*
@@ -211,12 +211,12 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
211 * the required 4 211 * the required 4
212 */ 212 */
213 status = AE_AML_BAD_NAME; 213 status = AE_AML_BAD_NAME;
214 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 214 ACPI_ERROR((AE_INFO,
215 "Bad character %02x in name, at %p\n", 215 "Bad character %02x in name, at %p",
216 *aml_address, aml_address)); 216 *aml_address, aml_address));
217 } 217 }
218 218
219 *in_aml_address = (u8 *) aml_address; 219 *in_aml_address = ACPI_CAST_PTR(u8, aml_address);
220 return_ACPI_STATUS(status); 220 return_ACPI_STATUS(status);
221} 221}
222 222
@@ -412,8 +412,7 @@ acpi_ex_get_name_string(acpi_object_type data_type,
412 if (AE_CTRL_PENDING == status && has_prefix) { 412 if (AE_CTRL_PENDING == status && has_prefix) {
413 /* Ran out of segments after processing a prefix */ 413 /* Ran out of segments after processing a prefix */
414 414
415 ACPI_REPORT_ERROR(("ex_do_name: Malformed Name at %p\n", 415 ACPI_ERROR((AE_INFO, "Malformed Name at %p", name_string));
416 name_string));
417 status = AE_AML_BAD_NAME; 416 status = AE_AML_BAD_NAME;
418 } 417 }
419 418
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
index 97e34542f5e4..23d0823bcd5e 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/executer/exoparg1.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -111,7 +111,8 @@ acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state)
111 111
112 default: /* Unknown opcode */ 112 default: /* Unknown opcode */
113 113
114 ACPI_REPORT_ERROR(("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); 114 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
115 walk_state->opcode));
115 status = AE_AML_BAD_OPCODE; 116 status = AE_AML_BAD_OPCODE;
116 break; 117 break;
117 } 118 }
@@ -188,7 +189,8 @@ acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state)
188 189
189 default: /* Unknown opcode */ 190 default: /* Unknown opcode */
190 191
191 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); 192 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
193 walk_state->opcode));
192 status = AE_AML_BAD_OPCODE; 194 status = AE_AML_BAD_OPCODE;
193 break; 195 break;
194 } 196 }
@@ -227,7 +229,8 @@ acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state)
227 229
228 default: /* Unknown opcode */ 230 default: /* Unknown opcode */
229 231
230 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n", walk_state->opcode)); 232 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
233 walk_state->opcode));
231 status = AE_AML_BAD_OPCODE; 234 status = AE_AML_BAD_OPCODE;
232 goto cleanup; 235 goto cleanup;
233 } 236 }
@@ -346,9 +349,9 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
346 /* Check the range of the digit */ 349 /* Check the range of the digit */
347 350
348 if (temp32 > 9) { 351 if (temp32 > 9) {
349 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 352 ACPI_ERROR((AE_INFO,
350 "BCD digit too large (not decimal): 0x%X\n", 353 "BCD digit too large (not decimal): 0x%X",
351 temp32)); 354 temp32));
352 355
353 status = AE_AML_NUMERIC_OVERFLOW; 356 status = AE_AML_NUMERIC_OVERFLOW;
354 goto cleanup; 357 goto cleanup;
@@ -393,12 +396,10 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
393 /* Overflow if there is any data left in Digit */ 396 /* Overflow if there is any data left in Digit */
394 397
395 if (digit > 0) { 398 if (digit > 0) {
396 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 399 ACPI_ERROR((AE_INFO,
397 "Integer too large to convert to BCD: %8.8X%8.8X\n", 400 "Integer too large to convert to BCD: %8.8X%8.8X",
398 ACPI_FORMAT_UINT64(operand 401 ACPI_FORMAT_UINT64(operand[0]->
399 [0]-> 402 integer.value)));
400 integer.
401 value)));
402 status = AE_AML_NUMERIC_OVERFLOW; 403 status = AE_AML_NUMERIC_OVERFLOW;
403 goto cleanup; 404 goto cleanup;
404 } 405 }
@@ -525,15 +526,16 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state)
525 526
526 /* These are two obsolete opcodes */ 527 /* These are two obsolete opcodes */
527 528
528 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 529 ACPI_ERROR((AE_INFO,
529 "%s is obsolete and not implemented\n", 530 "%s is obsolete and not implemented",
530 acpi_ps_get_opcode_name(walk_state->opcode))); 531 acpi_ps_get_opcode_name(walk_state->opcode)));
531 status = AE_SUPPORT; 532 status = AE_SUPPORT;
532 goto cleanup; 533 goto cleanup;
533 534
534 default: /* Unknown opcode */ 535 default: /* Unknown opcode */
535 536
536 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n", walk_state->opcode)); 537 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
538 walk_state->opcode));
537 status = AE_AML_BAD_OPCODE; 539 status = AE_AML_BAD_OPCODE;
538 goto cleanup; 540 goto cleanup;
539 } 541 }
@@ -639,11 +641,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
639 acpi_ex_resolve_operands(AML_LNOT_OP, &temp_desc, 641 acpi_ex_resolve_operands(AML_LNOT_OP, &temp_desc,
640 walk_state); 642 walk_state);
641 if (ACPI_FAILURE(status)) { 643 if (ACPI_FAILURE(status)) {
642 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 644 ACPI_EXCEPTION((AE_INFO, status,
643 "%s: bad operand(s) %s\n", 645 "While resolving operands for [%s]",
644 acpi_ps_get_opcode_name(walk_state-> 646 acpi_ps_get_opcode_name(walk_state->
645 opcode), 647 opcode)));
646 acpi_format_exception(status)));
647 648
648 goto cleanup; 649 goto cleanup;
649 } 650 }
@@ -742,9 +743,9 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
742 break; 743 break;
743 744
744 default: 745 default:
745 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 746 ACPI_ERROR((AE_INFO,
746 "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n", 747 "Operand is not Buf/Int/Str/Pkg - found type %s",
747 acpi_ut_get_type_name(type))); 748 acpi_ut_get_type_name(type)));
748 status = AE_AML_OPERAND_TYPE; 749 status = AE_AML_OPERAND_TYPE;
749 goto cleanup; 750 goto cleanup;
750 } 751 }
@@ -941,11 +942,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
941 942
942 default: 943 default:
943 944
944 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 945 ACPI_ERROR((AE_INFO,
945 "Unknown Index target_type %X in obj %p\n", 946 "Unknown Index target_type %X in obj %p",
946 operand[0]->reference. 947 operand[0]->reference.
947 target_type, 948 target_type, operand[0]));
948 operand[0]));
949 status = AE_AML_OPERAND_TYPE; 949 status = AE_AML_OPERAND_TYPE;
950 goto cleanup; 950 goto cleanup;
951 } 951 }
@@ -971,11 +971,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
971 break; 971 break;
972 972
973 default: 973 default:
974 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 974 ACPI_ERROR((AE_INFO,
975 "Unknown opcode in ref(%p) - %X\n", 975 "Unknown opcode in ref(%p) - %X",
976 operand[0], 976 operand[0],
977 operand[0]->reference. 977 operand[0]->reference.opcode));
978 opcode));
979 978
980 status = AE_TYPE; 979 status = AE_TYPE;
981 goto cleanup; 980 goto cleanup;
@@ -985,7 +984,8 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
985 984
986 default: 985 default:
987 986
988 ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); 987 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
988 walk_state->opcode));
989 status = AE_AML_BAD_OPCODE; 989 status = AE_AML_BAD_OPCODE;
990 goto cleanup; 990 goto cleanup;
991 } 991 }
diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c
index 8d70c6beef00..e263a5ddd405 100644
--- a/drivers/acpi/executer/exoparg2.c
+++ b/drivers/acpi/executer/exoparg2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -111,9 +111,9 @@ acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state)
111 /* Are notifies allowed on this object? */ 111 /* Are notifies allowed on this object? */
112 112
113 if (!acpi_ev_is_notify_object(node)) { 113 if (!acpi_ev_is_notify_object(node)) {
114 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 114 ACPI_ERROR((AE_INFO,
115 "Unexpected notify object type [%s]\n", 115 "Unexpected notify object type [%s]",
116 acpi_ut_get_type_name(node->type))); 116 acpi_ut_get_type_name(node->type)));
117 117
118 status = AE_AML_OPERAND_TYPE; 118 status = AE_AML_OPERAND_TYPE;
119 break; 119 break;
@@ -157,7 +157,8 @@ acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state)
157 157
158 default: 158 default:
159 159
160 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); 160 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
161 walk_state->opcode));
161 status = AE_AML_BAD_OPCODE; 162 status = AE_AML_BAD_OPCODE;
162 } 163 }
163 164
@@ -221,7 +222,8 @@ acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state)
221 222
222 default: 223 default:
223 224
224 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n", walk_state->opcode)); 225 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
226 walk_state->opcode));
225 status = AE_AML_BAD_OPCODE; 227 status = AE_AML_BAD_OPCODE;
226 goto cleanup; 228 goto cleanup;
227 } 229 }
@@ -344,10 +346,6 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
344 (length < operand[1]->integer.value) && 346 (length < operand[1]->integer.value) &&
345 (operand[0]->buffer.pointer[length])) { 347 (operand[0]->buffer.pointer[length])) {
346 length++; 348 length++;
347 if (length > ACPI_MAX_STRING_CONVERSION) {
348 status = AE_AML_STRING_LIMIT;
349 goto cleanup;
350 }
351 } 349 }
352 350
353 /* Allocate a new string object */ 351 /* Allocate a new string object */
@@ -358,8 +356,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
358 goto cleanup; 356 goto cleanup;
359 } 357 }
360 358
361 /* Copy the raw buffer data with no transform. NULL terminated already */ 359 /*
362 360 * Copy the raw buffer data with no transform.
361 * (NULL terminated already)
362 */
363 ACPI_MEMCPY(return_desc->string.pointer, 363 ACPI_MEMCPY(return_desc->string.pointer,
364 operand[0]->buffer.pointer, length); 364 operand[0]->buffer.pointer, length);
365 break; 365 break;
@@ -391,10 +391,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
391 /* Object to be indexed is a Package */ 391 /* Object to be indexed is a Package */
392 392
393 if (index >= operand[0]->package.count) { 393 if (index >= operand[0]->package.count) {
394 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 394 ACPI_ERROR((AE_INFO,
395 "Index value (%X%8.8X) beyond package end (%X)\n", 395 "Index value (%X%8.8X) beyond package end (%X)",
396 ACPI_FORMAT_UINT64(index), 396 ACPI_FORMAT_UINT64(index),
397 operand[0]->package.count)); 397 operand[0]->package.count));
398 status = AE_AML_PACKAGE_LIMIT; 398 status = AE_AML_PACKAGE_LIMIT;
399 goto cleanup; 399 goto cleanup;
400 } 400 }
@@ -407,10 +407,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
407 /* Object to be indexed is a Buffer/String */ 407 /* Object to be indexed is a Buffer/String */
408 408
409 if (index >= operand[0]->buffer.length) { 409 if (index >= operand[0]->buffer.length) {
410 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 410 ACPI_ERROR((AE_INFO,
411 "Index value (%X%8.8X) beyond end of buffer (%X)\n", 411 "Index value (%X%8.8X) beyond end of buffer (%X)",
412 ACPI_FORMAT_UINT64(index), 412 ACPI_FORMAT_UINT64(index),
413 operand[0]->buffer.length)); 413 operand[0]->buffer.length));
414 status = AE_AML_BUFFER_LIMIT; 414 status = AE_AML_BUFFER_LIMIT;
415 goto cleanup; 415 goto cleanup;
416 } 416 }
@@ -442,7 +442,8 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
442 442
443 default: 443 default:
444 444
445 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n", walk_state->opcode)); 445 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
446 walk_state->opcode));
446 status = AE_AML_BAD_OPCODE; 447 status = AE_AML_BAD_OPCODE;
447 break; 448 break;
448 } 449 }
@@ -546,7 +547,8 @@ acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state)
546 547
547 default: 548 default:
548 549
549 ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); 550 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
551 walk_state->opcode));
550 status = AE_AML_BAD_OPCODE; 552 status = AE_AML_BAD_OPCODE;
551 goto cleanup; 553 goto cleanup;
552 } 554 }
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c
index 483365777670..6a3a883cb8a3 100644
--- a/drivers/acpi/executer/exoparg3.c
+++ b/drivers/acpi/executer/exoparg3.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -119,7 +119,8 @@ acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state)
119 119
120 default: 120 default:
121 121
122 ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); 122 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
123 walk_state->opcode));
123 status = AE_AML_BAD_OPCODE; 124 status = AE_AML_BAD_OPCODE;
124 goto cleanup; 125 goto cleanup;
125 } 126 }
@@ -223,8 +224,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
223 goto cleanup; 224 goto cleanup;
224 } 225 }
225 226
226 if (length > 0) { 227 if (buffer) {
227 /* Copy the portion requested */ 228 /* We have a buffer, copy the portion requested */
228 229
229 ACPI_MEMCPY(buffer, operand[0]->string.pointer + index, 230 ACPI_MEMCPY(buffer, operand[0]->string.pointer + index,
230 length); 231 length);
@@ -242,7 +243,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
242 243
243 default: 244 default:
244 245
245 ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); 246 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
247 walk_state->opcode));
246 status = AE_AML_BAD_OPCODE; 248 status = AE_AML_BAD_OPCODE;
247 goto cleanup; 249 goto cleanup;
248 } 250 }
diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/executer/exoparg6.c
index 5dee77139576..e043d924444f 100644
--- a/drivers/acpi/executer/exoparg6.c
+++ b/drivers/acpi/executer/exoparg6.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -234,8 +234,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
234 234
235 if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) || 235 if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) ||
236 (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { 236 (operand[3]->integer.value > MAX_MATCH_OPERATOR)) {
237 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 237 ACPI_ERROR((AE_INFO, "Match operator out of range"));
238 "Match operator out of range\n"));
239 status = AE_AML_OPERAND_VALUE; 238 status = AE_AML_OPERAND_VALUE;
240 goto cleanup; 239 goto cleanup;
241 } 240 }
@@ -244,10 +243,10 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
244 243
245 index = operand[5]->integer.value; 244 index = operand[5]->integer.value;
246 if (index >= operand[0]->package.count) { 245 if (index >= operand[0]->package.count) {
247 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 246 ACPI_ERROR((AE_INFO,
248 "Index (%X%8.8X) beyond package end (%X)\n", 247 "Index (%X%8.8X) beyond package end (%X)",
249 ACPI_FORMAT_UINT64(index), 248 ACPI_FORMAT_UINT64(index),
250 operand[0]->package.count)); 249 operand[0]->package.count));
251 status = AE_AML_PACKAGE_LIMIT; 250 status = AE_AML_PACKAGE_LIMIT;
252 goto cleanup; 251 goto cleanup;
253 } 252 }
@@ -316,7 +315,8 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state)
316 315
317 default: 316 default:
318 317
319 ACPI_REPORT_ERROR(("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); 318 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X",
319 walk_state->opcode));
320 status = AE_AML_BAD_OPCODE; 320 status = AE_AML_BAD_OPCODE;
321 goto cleanup; 321 goto cleanup;
322 } 322 }
diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c
index 7476c363e407..7719ae5d4f16 100644
--- a/drivers/acpi/executer/exprep.c
+++ b/drivers/acpi/executer/exprep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -274,9 +274,8 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
274 default: 274 default:
275 /* Invalid field access type */ 275 /* Invalid field access type */
276 276
277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 277 ACPI_ERROR((AE_INFO, "Unknown field access type %X", access));
278 "Unknown field access type %X\n", access)); 278 return_UINT32(0);
279 return_VALUE(0);
280 } 279 }
281 280
282 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { 281 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) {
@@ -289,7 +288,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
289 } 288 }
290 289
291 *return_byte_alignment = byte_alignment; 290 *return_byte_alignment = byte_alignment;
292 return_VALUE(bit_length); 291 return_UINT32(bit_length);
293} 292}
294 293
295/******************************************************************************* 294/*******************************************************************************
@@ -422,15 +421,15 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
422 421
423 if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) { 422 if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) {
424 if (!info->region_node) { 423 if (!info->region_node) {
425 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null region_node\n")); 424 ACPI_ERROR((AE_INFO, "Null region_node"));
426 return_ACPI_STATUS(AE_AML_NO_OPERAND); 425 return_ACPI_STATUS(AE_AML_NO_OPERAND);
427 } 426 }
428 427
429 type = acpi_ns_get_type(info->region_node); 428 type = acpi_ns_get_type(info->region_node);
430 if (type != ACPI_TYPE_REGION) { 429 if (type != ACPI_TYPE_REGION) {
431 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 430 ACPI_ERROR((AE_INFO,
432 "Needed Region, found type %X (%s)\n", 431 "Needed Region, found type %X (%s)",
433 type, acpi_ut_get_type_name(type))); 432 type, acpi_ut_get_type_name(type)));
434 433
435 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 434 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
436 } 435 }
@@ -499,17 +498,17 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
499 498
500 case ACPI_TYPE_LOCAL_INDEX_FIELD: 499 case ACPI_TYPE_LOCAL_INDEX_FIELD:
501 500
501 /* Get the Index and Data registers */
502
502 obj_desc->index_field.index_obj = 503 obj_desc->index_field.index_obj =
503 acpi_ns_get_attached_object(info->register_node); 504 acpi_ns_get_attached_object(info->register_node);
504 obj_desc->index_field.data_obj = 505 obj_desc->index_field.data_obj =
505 acpi_ns_get_attached_object(info->data_register_node); 506 acpi_ns_get_attached_object(info->data_register_node);
506 obj_desc->index_field.value = (u32)
507 (info->field_bit_position /
508 ACPI_MUL_8(obj_desc->field.access_byte_width));
509 507
510 if (!obj_desc->index_field.data_obj 508 if (!obj_desc->index_field.data_obj
511 || !obj_desc->index_field.index_obj) { 509 || !obj_desc->index_field.index_obj) {
512 ACPI_REPORT_ERROR(("Null Index Object during field prep\n")); 510 ACPI_ERROR((AE_INFO,
511 "Null Index Object during field prep"));
513 acpi_ut_delete_object_desc(obj_desc); 512 acpi_ut_delete_object_desc(obj_desc);
514 return_ACPI_STATUS(AE_AML_INTERNAL); 513 return_ACPI_STATUS(AE_AML_INTERNAL);
515 } 514 }
@@ -519,6 +518,15 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
519 acpi_ut_add_reference(obj_desc->index_field.data_obj); 518 acpi_ut_add_reference(obj_desc->index_field.data_obj);
520 acpi_ut_add_reference(obj_desc->index_field.index_obj); 519 acpi_ut_add_reference(obj_desc->index_field.index_obj);
521 520
521 /*
522 * The value written to the Index register is the byte offset of the
523 * target field
524 * Note: may change code to: ACPI_DIV_8 (Info->field_bit_position)
525 */
526 obj_desc->index_field.value = (u32)
527 (info->field_bit_position /
528 ACPI_MUL_8(obj_desc->field.access_byte_width));
529
522 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 530 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
523 "index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", 531 "index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
524 obj_desc->index_field.start_field_bit_offset, 532 obj_desc->index_field.start_field_bit_offset,
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
index 9a2f5bea3afe..6a4cfdff606d 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/executer/exregion.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -77,7 +77,7 @@ acpi_ex_system_memory_space_handler(u32 function,
77 struct acpi_mem_space_context *mem_info = region_context; 77 struct acpi_mem_space_context *mem_info = region_context;
78 u32 length; 78 u32 length;
79 acpi_size window_size; 79 acpi_size window_size;
80#ifndef ACPI_MISALIGNED_TRANSFERS 80#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
81 u32 remainder; 81 u32 remainder;
82#endif 82#endif
83 83
@@ -103,13 +103,12 @@ acpi_ex_system_memory_space_handler(u32 function,
103 break; 103 break;
104 104
105 default: 105 default:
106 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 106 ACPI_ERROR((AE_INFO, "Invalid system_memory width %d",
107 "Invalid system_memory width %d\n", 107 bit_width));
108 bit_width));
109 return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 108 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
110 } 109 }
111 110
112#ifndef ACPI_MISALIGNED_TRANSFERS 111#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
113 /* 112 /*
114 * Hardware does not support non-aligned data transfers, we must verify 113 * Hardware does not support non-aligned data transfers, we must verify
115 * the request. 114 * the request.
@@ -159,10 +158,10 @@ acpi_ex_system_memory_space_handler(u32 function,
159 (void **)&mem_info-> 158 (void **)&mem_info->
160 mapped_logical_address); 159 mapped_logical_address);
161 if (ACPI_FAILURE(status)) { 160 if (ACPI_FAILURE(status)) {
162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 161 ACPI_ERROR((AE_INFO,
163 "Could not map memory at %8.8X%8.8X, size %X\n", 162 "Could not map memory at %8.8X%8.8X, size %X",
164 ACPI_FORMAT_UINT64(address), 163 ACPI_FORMAT_UINT64(address),
165 (u32) window_size)); 164 (u32) window_size));
166 mem_info->mapped_length = 0; 165 mem_info->mapped_length = 0;
167 return_ACPI_STATUS(status); 166 return_ACPI_STATUS(status);
168 } 167 }
@@ -199,20 +198,20 @@ acpi_ex_system_memory_space_handler(u32 function,
199 *value = 0; 198 *value = 0;
200 switch (bit_width) { 199 switch (bit_width) {
201 case 8: 200 case 8:
202 *value = (acpi_integer) * ((u8 *) logical_addr_ptr); 201 *value = (acpi_integer) ACPI_GET8(logical_addr_ptr);
203 break; 202 break;
204 203
205 case 16: 204 case 16:
206 *value = (acpi_integer) * ((u16 *) logical_addr_ptr); 205 *value = (acpi_integer) ACPI_GET16(logical_addr_ptr);
207 break; 206 break;
208 207
209 case 32: 208 case 32:
210 *value = (acpi_integer) * ((u32 *) logical_addr_ptr); 209 *value = (acpi_integer) ACPI_GET32(logical_addr_ptr);
211 break; 210 break;
212 211
213#if ACPI_MACHINE_WIDTH != 16 212#if ACPI_MACHINE_WIDTH != 16
214 case 64: 213 case 64:
215 *value = (acpi_integer) * ((u64 *) logical_addr_ptr); 214 *value = (acpi_integer) ACPI_GET64(logical_addr_ptr);
216 break; 215 break;
217#endif 216#endif
218 default: 217 default:
@@ -225,20 +224,20 @@ acpi_ex_system_memory_space_handler(u32 function,
225 224
226 switch (bit_width) { 225 switch (bit_width) {
227 case 8: 226 case 8:
228 *(u8 *) logical_addr_ptr = (u8) * value; 227 ACPI_SET8(logical_addr_ptr) = (u8) * value;
229 break; 228 break;
230 229
231 case 16: 230 case 16:
232 *(u16 *) logical_addr_ptr = (u16) * value; 231 ACPI_SET16(logical_addr_ptr) = (u16) * value;
233 break; 232 break;
234 233
235 case 32: 234 case 32:
236 *(u32 *) logical_addr_ptr = (u32) * value; 235 ACPI_SET32(logical_addr_ptr) = (u32) * value;
237 break; 236 break;
238 237
239#if ACPI_MACHINE_WIDTH != 16 238#if ACPI_MACHINE_WIDTH != 16
240 case 64: 239 case 64:
241 *(u64 *) logical_addr_ptr = (u64) * value; 240 ACPI_SET64(logical_addr_ptr) = (u64) * value;
242 break; 241 break;
243#endif 242#endif
244 243
diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c
index ff5d8f97e8eb..01b26c80d22b 100644
--- a/drivers/acpi/executer/exresnte.c
+++ b/drivers/acpi/executer/exresnte.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -122,8 +122,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
122 } 122 }
123 123
124 if (!source_desc) { 124 if (!source_desc) {
125 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 125 ACPI_ERROR((AE_INFO, "No object attached to node %p", node));
126 "No object attached to node %p\n", node));
127 return_ACPI_STATUS(AE_AML_NO_OPERAND); 126 return_ACPI_STATUS(AE_AML_NO_OPERAND);
128 } 127 }
129 128
@@ -135,10 +134,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
135 case ACPI_TYPE_PACKAGE: 134 case ACPI_TYPE_PACKAGE:
136 135
137 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) { 136 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) {
138 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 137 ACPI_ERROR((AE_INFO, "Object not a Package, type %s",
139 "Object not a Package, type %s\n", 138 acpi_ut_get_object_type_name(source_desc)));
140 acpi_ut_get_object_type_name
141 (source_desc)));
142 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 139 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
143 } 140 }
144 141
@@ -154,10 +151,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
154 case ACPI_TYPE_BUFFER: 151 case ACPI_TYPE_BUFFER:
155 152
156 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { 153 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) {
157 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 154 ACPI_ERROR((AE_INFO, "Object not a Buffer, type %s",
158 "Object not a Buffer, type %s\n", 155 acpi_ut_get_object_type_name(source_desc)));
159 acpi_ut_get_object_type_name
160 (source_desc)));
161 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 156 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
162 } 157 }
163 158
@@ -173,10 +168,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
173 case ACPI_TYPE_STRING: 168 case ACPI_TYPE_STRING:
174 169
175 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) { 170 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) {
176 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 171 ACPI_ERROR((AE_INFO, "Object not a String, type %s",
177 "Object not a String, type %s\n", 172 acpi_ut_get_object_type_name(source_desc)));
178 acpi_ut_get_object_type_name
179 (source_desc)));
180 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 173 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
181 } 174 }
182 175
@@ -189,10 +182,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
189 case ACPI_TYPE_INTEGER: 182 case ACPI_TYPE_INTEGER:
190 183
191 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) { 184 if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) {
192 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 185 ACPI_ERROR((AE_INFO, "Object not a Integer, type %s",
193 "Object not a Integer, type %s\n", 186 acpi_ut_get_object_type_name(source_desc)));
194 acpi_ut_get_object_type_name
195 (source_desc)));
196 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 187 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
197 } 188 }
198 189
@@ -236,9 +227,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
236 227
237 case ACPI_TYPE_ANY: 228 case ACPI_TYPE_ANY:
238 229
239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 230 ACPI_ERROR((AE_INFO,
240 "Untyped entry %p, no attached object!\n", 231 "Untyped entry %p, no attached object!", node));
241 node));
242 232
243 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ 233 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
244 234
@@ -257,12 +247,11 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
257 default: 247 default:
258 /* No named references are allowed here */ 248 /* No named references are allowed here */
259 249
260 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 250 ACPI_ERROR((AE_INFO,
261 "Unsupported Reference opcode %X (%s)\n", 251 "Unsupported Reference opcode %X (%s)",
262 source_desc->reference.opcode, 252 source_desc->reference.opcode,
263 acpi_ps_get_opcode_name(source_desc-> 253 acpi_ps_get_opcode_name(source_desc->
264 reference. 254 reference.opcode)));
265 opcode)));
266 255
267 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 256 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
268 } 257 }
@@ -272,9 +261,9 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
272 261
273 /* Default case is for unknown types */ 262 /* Default case is for unknown types */
274 263
275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 264 ACPI_ERROR((AE_INFO,
276 "Node %p - Unknown object type %X\n", 265 "Node %p - Unknown object type %X",
277 node, entry_type)); 266 node, entry_type));
278 267
279 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 268 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
280 269
diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c
index 97eecbd3242d..1deed492fe88 100644
--- a/drivers/acpi/executer/exresolv.c
+++ b/drivers/acpi/executer/exresolv.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -81,7 +81,7 @@ acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
81 ACPI_FUNCTION_TRACE_PTR("ex_resolve_to_value", stack_ptr); 81 ACPI_FUNCTION_TRACE_PTR("ex_resolve_to_value", stack_ptr);
82 82
83 if (!stack_ptr || !*stack_ptr) { 83 if (!stack_ptr || !*stack_ptr) {
84 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Internal - null pointer\n")); 84 ACPI_ERROR((AE_INFO, "Internal - null pointer"));
85 return_ACPI_STATUS(AE_AML_NO_OPERAND); 85 return_ACPI_STATUS(AE_AML_NO_OPERAND);
86 } 86 }
87 87
@@ -97,8 +97,7 @@ acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
97 } 97 }
98 98
99 if (!*stack_ptr) { 99 if (!*stack_ptr) {
100 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 100 ACPI_ERROR((AE_INFO, "Internal - null pointer"));
101 "Internal - null pointer\n"));
102 return_ACPI_STATUS(AE_AML_NO_OPERAND); 101 return_ACPI_STATUS(AE_AML_NO_OPERAND);
103 } 102 }
104 } 103 }
@@ -228,9 +227,9 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
228 * A NULL object descriptor means an unitialized element of 227 * A NULL object descriptor means an unitialized element of
229 * the package, can't dereference it 228 * the package, can't dereference it
230 */ 229 */
231 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 230 ACPI_ERROR((AE_INFO,
232 "Attempt to deref an Index to NULL pkg element Idx=%p\n", 231 "Attempt to deref an Index to NULL pkg element Idx=%p",
233 stack_desc)); 232 stack_desc));
234 status = AE_AML_UNINITIALIZED_ELEMENT; 233 status = AE_AML_UNINITIALIZED_ELEMENT;
235 } 234 }
236 break; 235 break;
@@ -239,7 +238,10 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
239 238
240 /* Invalid reference object */ 239 /* Invalid reference object */
241 240
242 ACPI_REPORT_ERROR(("During resolve, Unknown target_type %X in Index/Reference obj %p\n", stack_desc->reference.target_type, stack_desc)); 241 ACPI_ERROR((AE_INFO,
242 "Unknown target_type %X in Index/Reference obj %p",
243 stack_desc->reference.target_type,
244 stack_desc));
243 status = AE_AML_INTERNAL; 245 status = AE_AML_INTERNAL;
244 break; 246 break;
245 } 247 }
@@ -264,7 +266,10 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
264 266
265 default: 267 default:
266 268
267 ACPI_REPORT_ERROR(("During resolve, Unknown Reference opcode %X (%s) in %p\n", opcode, acpi_ps_get_opcode_name(opcode), stack_desc)); 269 ACPI_ERROR((AE_INFO,
270 "Unknown Reference opcode %X (%s) in %p",
271 opcode, acpi_ps_get_opcode_name(opcode),
272 stack_desc));
268 status = AE_AML_INTERNAL; 273 status = AE_AML_INTERNAL;
269 break; 274 break;
270 } 275 }
@@ -386,7 +391,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
386 391
387 if (ACPI_GET_DESCRIPTOR_TYPE(node) != 392 if (ACPI_GET_DESCRIPTOR_TYPE(node) !=
388 ACPI_DESC_TYPE_NAMED) { 393 ACPI_DESC_TYPE_NAMED) {
389 ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node))); 394 ACPI_ERROR((AE_INFO, "Not a NS node %p [%s]",
395 node,
396 acpi_ut_get_descriptor_name(node)));
390 return_ACPI_STATUS(AE_AML_INTERNAL); 397 return_ACPI_STATUS(AE_AML_INTERNAL);
391 } 398 }
392 399
@@ -442,7 +449,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
442 449
443 if (ACPI_GET_DESCRIPTOR_TYPE(node) != 450 if (ACPI_GET_DESCRIPTOR_TYPE(node) !=
444 ACPI_DESC_TYPE_NAMED) { 451 ACPI_DESC_TYPE_NAMED) {
445 ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node))); 452 ACPI_ERROR((AE_INFO, "Not a NS node %p [%s]",
453 node,
454 acpi_ut_get_descriptor_name(node)));
446 return_ACPI_STATUS(AE_AML_INTERNAL); 455 return_ACPI_STATUS(AE_AML_INTERNAL);
447 } 456 }
448 457
@@ -511,7 +520,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
511 520
512 default: 521 default:
513 522
514 ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Unknown Reference subtype %X\n", obj_desc->reference.opcode)); 523 ACPI_ERROR((AE_INFO,
524 "Unknown Reference subtype %X",
525 obj_desc->reference.opcode));
515 return_ACPI_STATUS(AE_AML_INTERNAL); 526 return_ACPI_STATUS(AE_AML_INTERNAL);
516 } 527 }
517 } 528 }
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c
index ff064e79ab90..a1c000f5a415 100644
--- a/drivers/acpi/executer/exresop.c
+++ b/drivers/acpi/executer/exresop.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -46,6 +46,7 @@
46#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
47#include <acpi/acparser.h> 47#include <acpi/acparser.h>
48#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h>
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exresop") 52ACPI_MODULE_NAME("exresop")
@@ -73,7 +74,7 @@ static acpi_status
73acpi_ex_check_object_type(acpi_object_type type_needed, 74acpi_ex_check_object_type(acpi_object_type type_needed,
74 acpi_object_type this_type, void *object) 75 acpi_object_type this_type, void *object)
75{ 76{
76 ACPI_FUNCTION_NAME("ex_check_object_type"); 77 ACPI_FUNCTION_ENTRY();
77 78
78 if (type_needed == ACPI_TYPE_ANY) { 79 if (type_needed == ACPI_TYPE_ANY) {
79 /* All types OK, so we don't perform any typechecks */ 80 /* All types OK, so we don't perform any typechecks */
@@ -95,10 +96,10 @@ acpi_ex_check_object_type(acpi_object_type type_needed,
95 } 96 }
96 97
97 if (type_needed != this_type) { 98 if (type_needed != this_type) {
98 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 99 ACPI_ERROR((AE_INFO,
99 "Needed [%s], found [%s] %p\n", 100 "Needed type [%s], found [%s] %p",
100 acpi_ut_get_type_name(type_needed), 101 acpi_ut_get_type_name(type_needed),
101 acpi_ut_get_type_name(this_type), object)); 102 acpi_ut_get_type_name(this_type), object));
102 103
103 return (AE_AML_OPERAND_TYPE); 104 return (AE_AML_OPERAND_TYPE);
104 } 105 }
@@ -151,13 +152,13 @@ acpi_ex_resolve_operands(u16 opcode,
151 152
152 arg_types = op_info->runtime_args; 153 arg_types = op_info->runtime_args;
153 if (arg_types == ARGI_INVALID_OPCODE) { 154 if (arg_types == ARGI_INVALID_OPCODE) {
154 ACPI_REPORT_ERROR(("resolve_operands: %X is not a valid AML opcode\n", opcode)); 155 ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", opcode));
155 156
156 return_ACPI_STATUS(AE_AML_INTERNAL); 157 return_ACPI_STATUS(AE_AML_INTERNAL);
157 } 158 }
158 159
159 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 160 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
160 "Opcode %X [%s] required_operand_types=%8.8X \n", 161 "Opcode %X [%s] required_operand_types=%8.8X\n",
161 opcode, op_info->name, arg_types)); 162 opcode, op_info->name, arg_types));
162 163
163 /* 164 /*
@@ -169,7 +170,8 @@ acpi_ex_resolve_operands(u16 opcode,
169 */ 170 */
170 while (GET_CURRENT_ARG_TYPE(arg_types)) { 171 while (GET_CURRENT_ARG_TYPE(arg_types)) {
171 if (!stack_ptr || !*stack_ptr) { 172 if (!stack_ptr || !*stack_ptr) {
172 ACPI_REPORT_ERROR(("resolve_operands: Null stack entry at %p\n", stack_ptr)); 173 ACPI_ERROR((AE_INFO, "Null stack entry at %p",
174 stack_ptr));
173 175
174 return_ACPI_STATUS(AE_AML_INTERNAL); 176 return_ACPI_STATUS(AE_AML_INTERNAL);
175 } 177 }
@@ -187,6 +189,22 @@ acpi_ex_resolve_operands(u16 opcode,
187 189
188 object_type = 190 object_type =
189 ((struct acpi_namespace_node *)obj_desc)->type; 191 ((struct acpi_namespace_node *)obj_desc)->type;
192
193 /*
194 * Resolve an alias object. The construction of these objects
195 * guarantees that there is only one level of alias indirection;
196 * thus, the attached object is always the aliased namespace node
197 */
198 if (object_type == ACPI_TYPE_LOCAL_ALIAS) {
199 obj_desc =
200 acpi_ns_get_attached_object((struct
201 acpi_namespace_node
202 *)obj_desc);
203 *stack_ptr = obj_desc;
204 object_type =
205 ((struct acpi_namespace_node *)obj_desc)->
206 type;
207 }
190 break; 208 break;
191 209
192 case ACPI_DESC_TYPE_OPERAND: 210 case ACPI_DESC_TYPE_OPERAND:
@@ -198,9 +216,9 @@ acpi_ex_resolve_operands(u16 opcode,
198 /* Check for bad acpi_object_type */ 216 /* Check for bad acpi_object_type */
199 217
200 if (!acpi_ut_valid_object_type(object_type)) { 218 if (!acpi_ut_valid_object_type(object_type)) {
201 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 219 ACPI_ERROR((AE_INFO,
202 "Bad operand object type [%X]\n", 220 "Bad operand object type [%X]",
203 object_type)); 221 object_type));
204 222
205 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 223 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
206 } 224 }
@@ -238,13 +256,10 @@ acpi_ex_resolve_operands(u16 opcode,
238 break; 256 break;
239 257
240 default: 258 default:
241 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 259 ACPI_ERROR((AE_INFO,
242 "Operand is a Reference, Unknown Reference Opcode %X [%s]\n", 260 "Operand is a Reference, Unknown Reference Opcode: %X",
243 obj_desc->reference. 261 obj_desc->reference.
244 opcode, 262 opcode));
245 (acpi_ps_get_opcode_info
246 (obj_desc->reference.
247 opcode))->name));
248 263
249 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 264 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
250 } 265 }
@@ -255,11 +270,10 @@ acpi_ex_resolve_operands(u16 opcode,
255 270
256 /* Invalid descriptor */ 271 /* Invalid descriptor */
257 272
258 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 273 ACPI_ERROR((AE_INFO,
259 "Invalid descriptor %p [%s]\n", 274 "Invalid descriptor %p [%s]",
260 obj_desc, 275 obj_desc,
261 acpi_ut_get_descriptor_name 276 acpi_ut_get_descriptor_name(obj_desc)));
262 (obj_desc)));
263 277
264 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 278 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
265 } 279 }
@@ -417,11 +431,10 @@ acpi_ex_resolve_operands(u16 opcode,
417 acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16); 431 acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16);
418 if (ACPI_FAILURE(status)) { 432 if (ACPI_FAILURE(status)) {
419 if (status == AE_TYPE) { 433 if (status == AE_TYPE) {
420 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 434 ACPI_ERROR((AE_INFO,
421 "Needed [Integer/String/Buffer], found [%s] %p\n", 435 "Needed [Integer/String/Buffer], found [%s] %p",
422 acpi_ut_get_object_type_name 436 acpi_ut_get_object_type_name
423 (obj_desc), 437 (obj_desc), obj_desc));
424 obj_desc));
425 438
426 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 439 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
427 } 440 }
@@ -444,11 +457,10 @@ acpi_ex_resolve_operands(u16 opcode,
444 status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr); 457 status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr);
445 if (ACPI_FAILURE(status)) { 458 if (ACPI_FAILURE(status)) {
446 if (status == AE_TYPE) { 459 if (status == AE_TYPE) {
447 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 460 ACPI_ERROR((AE_INFO,
448 "Needed [Integer/String/Buffer], found [%s] %p\n", 461 "Needed [Integer/String/Buffer], found [%s] %p",
449 acpi_ut_get_object_type_name 462 acpi_ut_get_object_type_name
450 (obj_desc), 463 (obj_desc), obj_desc));
451 obj_desc));
452 464
453 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 465 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
454 } 466 }
@@ -472,11 +484,10 @@ acpi_ex_resolve_operands(u16 opcode,
472 ACPI_IMPLICIT_CONVERT_HEX); 484 ACPI_IMPLICIT_CONVERT_HEX);
473 if (ACPI_FAILURE(status)) { 485 if (ACPI_FAILURE(status)) {
474 if (status == AE_TYPE) { 486 if (status == AE_TYPE) {
475 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 487 ACPI_ERROR((AE_INFO,
476 "Needed [Integer/String/Buffer], found [%s] %p\n", 488 "Needed [Integer/String/Buffer], found [%s] %p",
477 acpi_ut_get_object_type_name 489 acpi_ut_get_object_type_name
478 (obj_desc), 490 (obj_desc), obj_desc));
479 obj_desc));
480 491
481 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 492 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
482 } 493 }
@@ -502,10 +513,10 @@ acpi_ex_resolve_operands(u16 opcode,
502 break; 513 break;
503 514
504 default: 515 default:
505 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 516 ACPI_ERROR((AE_INFO,
506 "Needed [Integer/String/Buffer], found [%s] %p\n", 517 "Needed [Integer/String/Buffer], found [%s] %p",
507 acpi_ut_get_object_type_name 518 acpi_ut_get_object_type_name
508 (obj_desc), obj_desc)); 519 (obj_desc), obj_desc));
509 520
510 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 521 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
511 } 522 }
@@ -539,10 +550,10 @@ acpi_ex_resolve_operands(u16 opcode,
539 break; 550 break;
540 551
541 default: 552 default:
542 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 553 ACPI_ERROR((AE_INFO,
543 "Needed [Integer/String/Buffer], found [%s] %p\n", 554 "Needed [Integer/String/Buffer], found [%s] %p",
544 acpi_ut_get_object_type_name 555 acpi_ut_get_object_type_name
545 (obj_desc), obj_desc)); 556 (obj_desc), obj_desc));
546 557
547 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 558 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
548 } 559 }
@@ -566,10 +577,10 @@ acpi_ex_resolve_operands(u16 opcode,
566 break; 577 break;
567 578
568 default: 579 default:
569 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 580 ACPI_ERROR((AE_INFO,
570 "Needed [Buffer/String/Package/Reference], found [%s] %p\n", 581 "Needed [Buffer/String/Package/Reference], found [%s] %p",
571 acpi_ut_get_object_type_name 582 acpi_ut_get_object_type_name
572 (obj_desc), obj_desc)); 583 (obj_desc), obj_desc));
573 584
574 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 585 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
575 } 586 }
@@ -588,10 +599,10 @@ acpi_ex_resolve_operands(u16 opcode,
588 break; 599 break;
589 600
590 default: 601 default:
591 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 602 ACPI_ERROR((AE_INFO,
592 "Needed [Buffer/String/Package], found [%s] %p\n", 603 "Needed [Buffer/String/Package], found [%s] %p",
593 acpi_ut_get_object_type_name 604 acpi_ut_get_object_type_name
594 (obj_desc), obj_desc)); 605 (obj_desc), obj_desc));
595 606
596 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 607 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
597 } 608 }
@@ -611,10 +622,10 @@ acpi_ex_resolve_operands(u16 opcode,
611 break; 622 break;
612 623
613 default: 624 default:
614 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 625 ACPI_ERROR((AE_INFO,
615 "Needed [Region/region_field], found [%s] %p\n", 626 "Needed [Region/region_field], found [%s] %p",
616 acpi_ut_get_object_type_name 627 acpi_ut_get_object_type_name
617 (obj_desc), obj_desc)); 628 (obj_desc), obj_desc));
618 629
619 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 630 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
620 } 631 }
@@ -656,10 +667,10 @@ acpi_ex_resolve_operands(u16 opcode,
656 break; 667 break;
657 } 668 }
658 669
659 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 670 ACPI_ERROR((AE_INFO,
660 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", 671 "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p",
661 acpi_ut_get_object_type_name 672 acpi_ut_get_object_type_name
662 (obj_desc), obj_desc)); 673 (obj_desc), obj_desc));
663 674
664 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 675 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
665 } 676 }
@@ -669,9 +680,9 @@ acpi_ex_resolve_operands(u16 opcode,
669 680
670 /* Unknown type */ 681 /* Unknown type */
671 682
672 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 683 ACPI_ERROR((AE_INFO,
673 "Internal - Unknown ARGI (required operand) type %X\n", 684 "Internal - Unknown ARGI (required operand) type %X",
674 this_arg_type)); 685 this_arg_type));
675 686
676 return_ACPI_STATUS(AE_BAD_PARAMETER); 687 return_ACPI_STATUS(AE_BAD_PARAMETER);
677 } 688 }
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
index a7d8eea305c2..3f020c0e2b95 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/executer/exstore.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -250,7 +250,7 @@ acpi_ex_store(union acpi_operand_object *source_desc,
250 /* Validate parameters */ 250 /* Validate parameters */
251 251
252 if (!source_desc || !dest_desc) { 252 if (!source_desc || !dest_desc) {
253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null parameter\n")); 253 ACPI_ERROR((AE_INFO, "Null parameter"));
254 return_ACPI_STATUS(AE_AML_NO_OPERAND); 254 return_ACPI_STATUS(AE_AML_NO_OPERAND);
255 } 255 }
256 256
@@ -290,10 +290,10 @@ acpi_ex_store(union acpi_operand_object *source_desc,
290 290
291 /* Destination is not a Reference object */ 291 /* Destination is not a Reference object */
292 292
293 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 293 ACPI_ERROR((AE_INFO,
294 "Target is not a Reference or Constant object - %s [%p]\n", 294 "Target is not a Reference or Constant object - %s [%p]",
295 acpi_ut_get_object_type_name(dest_desc), 295 acpi_ut_get_object_type_name(dest_desc),
296 dest_desc)); 296 dest_desc));
297 297
298 ACPI_DUMP_STACK_ENTRY(source_desc); 298 ACPI_DUMP_STACK_ENTRY(source_desc);
299 ACPI_DUMP_STACK_ENTRY(dest_desc); 299 ACPI_DUMP_STACK_ENTRY(dest_desc);
@@ -360,8 +360,8 @@ acpi_ex_store(union acpi_operand_object *source_desc,
360 360
361 default: 361 default:
362 362
363 ACPI_REPORT_ERROR(("ex_store: Unknown Reference opcode %X\n", 363 ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X",
364 ref_desc->reference.opcode)); 364 ref_desc->reference.opcode));
365 ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR); 365 ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR);
366 366
367 status = AE_AML_INTERNAL; 367 status = AE_AML_INTERNAL;
@@ -490,10 +490,9 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
490 490
491 /* All other types are invalid */ 491 /* All other types are invalid */
492 492
493 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 493 ACPI_ERROR((AE_INFO,
494 "Source must be Integer/Buffer/String type, not %s\n", 494 "Source must be Integer/Buffer/String type, not %s",
495 acpi_ut_get_object_type_name 495 acpi_ut_get_object_type_name(source_desc)));
496 (source_desc)));
497 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 496 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
498 } 497 }
499 498
@@ -503,8 +502,8 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
503 break; 502 break;
504 503
505 default: 504 default:
506 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 505 ACPI_ERROR((AE_INFO,
507 "Target is not a Package or buffer_field\n")); 506 "Target is not a Package or buffer_field"));
508 status = AE_AML_OPERAND_TYPE; 507 status = AE_AML_OPERAND_TYPE;
509 break; 508 break;
510 } 509 }
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c
index 382f63c14ea1..42967baf760d 100644
--- a/drivers/acpi/executer/exstoren.c
+++ b/drivers/acpi/executer/exstoren.c
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2005, R. Byron Moore 10 * Copyright (C) 2000 - 2006, R. Byron Moore
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
@@ -123,11 +123,10 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
123 && (source_desc->reference.opcode == AML_LOAD_OP))) { 123 && (source_desc->reference.opcode == AML_LOAD_OP))) {
124 /* Conversion successful but still not a valid type */ 124 /* Conversion successful but still not a valid type */
125 125
126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 126 ACPI_ERROR((AE_INFO,
127 "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", 127 "Cannot assign type %s to %s (must be type Int/Str/Buf)",
128 acpi_ut_get_object_type_name 128 acpi_ut_get_object_type_name(source_desc),
129 (source_desc), 129 acpi_ut_get_type_name(target_type)));
130 acpi_ut_get_type_name(target_type)));
131 status = AE_AML_OPERAND_TYPE; 130 status = AE_AML_OPERAND_TYPE;
132 } 131 }
133 break; 132 break;
@@ -135,9 +134,11 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
135 case ACPI_TYPE_LOCAL_ALIAS: 134 case ACPI_TYPE_LOCAL_ALIAS:
136 case ACPI_TYPE_LOCAL_METHOD_ALIAS: 135 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
137 136
138 /* Aliases are resolved by acpi_ex_prep_operands */ 137 /*
139 138 * All aliases should have been resolved earlier, during the
140 ACPI_REPORT_ERROR(("Store into Alias - should never happen\n")); 139 * operand resolution phase.
140 */
141 ACPI_ERROR((AE_INFO, "Store into an unresolved Alias object"));
141 status = AE_AML_INTERNAL; 142 status = AE_AML_INTERNAL;
142 break; 143 break;
143 144
@@ -280,9 +281,8 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
280 /* 281 /*
281 * All other types come here. 282 * All other types come here.
282 */ 283 */
283 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 284 ACPI_WARNING((AE_INFO, "Store into type %s not implemented",
284 "Store into type %s not implemented\n", 285 acpi_ut_get_object_type_name(dest_desc)));
285 acpi_ut_get_object_type_name(dest_desc)));
286 286
287 status = AE_NOT_IMPLEMENTED; 287 status = AE_NOT_IMPLEMENTED;
288 break; 288 break;
diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c
index c4ff654a6697..6ab707087750 100644
--- a/drivers/acpi/executer/exstorob.c
+++ b/drivers/acpi/executer/exstorob.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -71,7 +71,7 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
71 71
72 /* We know that source_desc is a buffer by now */ 72 /* We know that source_desc is a buffer by now */
73 73
74 buffer = (u8 *) source_desc->buffer.pointer; 74 buffer = ACPI_CAST_PTR(u8, source_desc->buffer.pointer);
75 length = source_desc->buffer.length; 75 length = source_desc->buffer.length;
76 76
77 /* 77 /*
@@ -160,7 +160,7 @@ acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
160 160
161 /* We know that source_desc is a string by now */ 161 /* We know that source_desc is a string by now */
162 162
163 buffer = (u8 *) source_desc->string.pointer; 163 buffer = ACPI_CAST_PTR(u8, source_desc->string.pointer);
164 length = source_desc->string.length; 164 length = source_desc->string.length;
165 165
166 /* 166 /*
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c
index 8a88b841237d..ea9144f42e1f 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/executer/exsystem.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -129,8 +129,8 @@ acpi_status acpi_ex_system_do_stall(u32 how_long)
129 * (ACPI specifies 100 usec as max, but this gives some slack in 129 * (ACPI specifies 100 usec as max, but this gives some slack in
130 * order to support existing BIOSs) 130 * order to support existing BIOSs)
131 */ 131 */
132 ACPI_REPORT_ERROR(("Stall: Time parameter is too large (%d)\n", 132 ACPI_ERROR((AE_INFO, "Time parameter is too large (%d)",
133 how_long)); 133 how_long));
134 status = AE_AML_OPERAND_VALUE; 134 status = AE_AML_OPERAND_VALUE;
135 } else { 135 } else {
136 acpi_os_stall(how_long); 136 acpi_os_stall(how_long);
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
index 1ee79d8c8f88..f73a61aeb7ec 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/executer/exutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -91,7 +91,7 @@ acpi_status acpi_ex_enter_interpreter(void)
91 91
92 status = acpi_ut_acquire_mutex(ACPI_MTX_EXECUTE); 92 status = acpi_ut_acquire_mutex(ACPI_MTX_EXECUTE);
93 if (ACPI_FAILURE(status)) { 93 if (ACPI_FAILURE(status)) {
94 ACPI_REPORT_ERROR(("Could not acquire interpreter mutex\n")); 94 ACPI_ERROR((AE_INFO, "Could not acquire interpreter mutex"));
95 } 95 }
96 96
97 return_ACPI_STATUS(status); 97 return_ACPI_STATUS(status);
@@ -127,7 +127,7 @@ void acpi_ex_exit_interpreter(void)
127 127
128 status = acpi_ut_release_mutex(ACPI_MTX_EXECUTE); 128 status = acpi_ut_release_mutex(ACPI_MTX_EXECUTE);
129 if (ACPI_FAILURE(status)) { 129 if (ACPI_FAILURE(status)) {
130 ACPI_REPORT_ERROR(("Could not release interpreter mutex\n")); 130 ACPI_ERROR((AE_INFO, "Could not release interpreter mutex"));
131 } 131 }
132 132
133 return_VOID; 133 return_VOID;
@@ -200,13 +200,12 @@ u8 acpi_ex_acquire_global_lock(u32 field_flags)
200 if (ACPI_SUCCESS(status)) { 200 if (ACPI_SUCCESS(status)) {
201 locked = TRUE; 201 locked = TRUE;
202 } else { 202 } else {
203 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 203 ACPI_EXCEPTION((AE_INFO, status,
204 "Could not acquire Global Lock, %s\n", 204 "Could not acquire Global Lock"));
205 acpi_format_exception(status)));
206 } 205 }
207 } 206 }
208 207
209 return_VALUE(locked); 208 return_UINT8(locked);
210} 209}
211 210
212/******************************************************************************* 211/*******************************************************************************
@@ -237,7 +236,8 @@ void acpi_ex_release_global_lock(u8 locked_by_me)
237 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
238 /* Report the error, but there isn't much else we can do */ 237 /* Report the error, but there isn't much else we can do */
239 238
240 ACPI_REPORT_ERROR(("Could not release ACPI Global Lock, %s\n", acpi_format_exception(status))); 239 ACPI_EXCEPTION((AE_INFO, status,
240 "Could not release ACPI Global Lock"));
241 } 241 }
242 } 242 }
243 243
@@ -268,7 +268,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
268 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ 268 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */
269 269
270 if (value == 0) { 270 if (value == 0) {
271 return_VALUE(1); 271 return_UINT32(1);
272 } 272 }
273 273
274 current_value = value; 274 current_value = value;
@@ -282,7 +282,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
282 num_digits++; 282 num_digits++;
283 } 283 }
284 284
285 return_VALUE(num_digits); 285 return_UINT32(num_digits);
286} 286}
287 287
288/******************************************************************************* 288/*******************************************************************************
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index aa993715d644..8daef57b994c 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -99,15 +99,15 @@ do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
99 unsigned long *busnr = (unsigned long *)data; 99 unsigned long *busnr = (unsigned long *)data;
100 struct acpi_resource_address64 address; 100 struct acpi_resource_address64 address;
101 101
102 if (resource->id != ACPI_RSTYPE_ADDRESS16 && 102 if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
103 resource->id != ACPI_RSTYPE_ADDRESS32 && 103 resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
104 resource->id != ACPI_RSTYPE_ADDRESS64) 104 resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
105 return AE_OK; 105 return AE_OK;
106 106
107 acpi_resource_to_address64(resource, &address); 107 acpi_resource_to_address64(resource, &address);
108 if ((address.address_length > 0) && 108 if ((address.address_length > 0) &&
109 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) 109 (address.resource_type == ACPI_BUS_NUMBER_RANGE))
110 *busnr = address.min_address_range; 110 *busnr = address.minimum;
111 111
112 return AE_OK; 112 return AE_OK;
113} 113}
diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c
index 1bb3463d7040..ea2f13271ff1 100644
--- a/drivers/acpi/hardware/hwacpi.c
+++ b/drivers/acpi/hardware/hwacpi.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -68,8 +68,7 @@ acpi_status acpi_hw_initialize(void)
68 /* We must have the ACPI tables by the time we get here */ 68 /* We must have the ACPI tables by the time we get here */
69 69
70 if (!acpi_gbl_FADT) { 70 if (!acpi_gbl_FADT) {
71 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No FADT is present\n")); 71 ACPI_ERROR((AE_INFO, "No FADT is present"));
72
73 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 72 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
74 } 73 }
75 74
@@ -108,7 +107,8 @@ acpi_status acpi_hw_set_mode(u32 mode)
108 * system does not support mode transition. 107 * system does not support mode transition.
109 */ 108 */
110 if (!acpi_gbl_FADT->smi_cmd) { 109 if (!acpi_gbl_FADT->smi_cmd) {
111 ACPI_REPORT_ERROR(("No SMI_CMD in FADT, mode transition failed.\n")); 110 ACPI_ERROR((AE_INFO,
111 "No SMI_CMD in FADT, mode transition failed"));
112 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); 112 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
113 } 113 }
114 114
@@ -120,7 +120,8 @@ acpi_status acpi_hw_set_mode(u32 mode)
120 * transitions are not supported. 120 * transitions are not supported.
121 */ 121 */
122 if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) { 122 if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) {
123 ACPI_REPORT_ERROR(("No ACPI mode transition supported in this system (enable/disable both zero)\n")); 123 ACPI_ERROR((AE_INFO,
124 "No ACPI mode transition supported in this system (enable/disable both zero)"));
124 return_ACPI_STATUS(AE_OK); 125 return_ACPI_STATUS(AE_OK);
125 } 126 }
126 127
@@ -154,8 +155,8 @@ acpi_status acpi_hw_set_mode(u32 mode)
154 } 155 }
155 156
156 if (ACPI_FAILURE(status)) { 157 if (ACPI_FAILURE(status)) {
157 ACPI_REPORT_ERROR(("Could not write mode change, %s\n", 158 ACPI_EXCEPTION((AE_INFO, status,
158 acpi_format_exception(status))); 159 "Could not write ACPI mode change"));
159 return_ACPI_STATUS(status); 160 return_ACPI_STATUS(status);
160 } 161 }
161 162
@@ -175,7 +176,7 @@ acpi_status acpi_hw_set_mode(u32 mode)
175 retry--; 176 retry--;
176 } 177 }
177 178
178 ACPI_REPORT_ERROR(("Hardware never changed modes\n")); 179 ACPI_ERROR((AE_INFO, "Hardware did not change modes"));
179 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); 180 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
180} 181}
181 182
@@ -204,18 +205,18 @@ u32 acpi_hw_get_mode(void)
204 * system does not support mode transition. 205 * system does not support mode transition.
205 */ 206 */
206 if (!acpi_gbl_FADT->smi_cmd) { 207 if (!acpi_gbl_FADT->smi_cmd) {
207 return_VALUE(ACPI_SYS_MODE_ACPI); 208 return_UINT32(ACPI_SYS_MODE_ACPI);
208 } 209 }
209 210
210 status = 211 status =
211 acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK); 212 acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK);
212 if (ACPI_FAILURE(status)) { 213 if (ACPI_FAILURE(status)) {
213 return_VALUE(ACPI_SYS_MODE_LEGACY); 214 return_UINT32(ACPI_SYS_MODE_LEGACY);
214 } 215 }
215 216
216 if (value) { 217 if (value) {
217 return_VALUE(ACPI_SYS_MODE_ACPI); 218 return_UINT32(ACPI_SYS_MODE_ACPI);
218 } else { 219 } else {
219 return_VALUE(ACPI_SYS_MODE_LEGACY); 220 return_UINT32(ACPI_SYS_MODE_LEGACY);
220 } 221 }
221} 222}
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c
index 5c8e5dfd024e..d84942d22dd5 100644
--- a/drivers/acpi/hardware/hwgpe.c
+++ b/drivers/acpi/hardware/hwgpe.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index 536a7aea80c9..e1fe75498415 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -7,7 +7,7 @@
7 ******************************************************************************/ 7 ******************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2005, R. Byron Moore 10 * Copyright (C) 2000 - 2006, R. Byron Moore
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
@@ -144,7 +144,8 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
144 144
145 info.parameters = NULL; 145 info.parameters = NULL;
146 info.return_object = NULL; 146 info.return_object = NULL;
147 sleep_state_name = (char *)acpi_gbl_sleep_state_names[sleep_state]; 147 sleep_state_name =
148 ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]);
148 149
149 status = acpi_ns_evaluate_by_name(sleep_state_name, &info); 150 status = acpi_ns_evaluate_by_name(sleep_state_name, &info);
150 if (ACPI_FAILURE(status)) { 151 if (ACPI_FAILURE(status)) {
@@ -159,15 +160,16 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
159 /* Must have a return object */ 160 /* Must have a return object */
160 161
161 if (!info.return_object) { 162 if (!info.return_object) {
162 ACPI_REPORT_ERROR(("No Sleep State object returned from [%s]\n", 163 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]",
163 sleep_state_name)); 164 sleep_state_name));
164 status = AE_NOT_EXIST; 165 status = AE_NOT_EXIST;
165 } 166 }
166 167
167 /* It must be of type Package */ 168 /* It must be of type Package */
168 169
169 else if (ACPI_GET_OBJECT_TYPE(info.return_object) != ACPI_TYPE_PACKAGE) { 170 else if (ACPI_GET_OBJECT_TYPE(info.return_object) != ACPI_TYPE_PACKAGE) {
170 ACPI_REPORT_ERROR(("Sleep State return object is not a Package\n")); 171 ACPI_ERROR((AE_INFO,
172 "Sleep State return object is not a Package"));
171 status = AE_AML_OPERAND_TYPE; 173 status = AE_AML_OPERAND_TYPE;
172 } 174 }
173 175
@@ -179,7 +181,8 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
179 * one per sleep type (A/B). 181 * one per sleep type (A/B).
180 */ 182 */
181 else if (info.return_object->package.count < 2) { 183 else if (info.return_object->package.count < 2) {
182 ACPI_REPORT_ERROR(("Sleep State return package does not have at least two elements\n")); 184 ACPI_ERROR((AE_INFO,
185 "Sleep State return package does not have at least two elements"));
183 status = AE_AML_NO_OPERAND; 186 status = AE_AML_NO_OPERAND;
184 } 187 }
185 188
@@ -189,7 +192,12 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
189 != ACPI_TYPE_INTEGER) || 192 != ACPI_TYPE_INTEGER) ||
190 (ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[1]) 193 (ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[1])
191 != ACPI_TYPE_INTEGER)) { 194 != ACPI_TYPE_INTEGER)) {
192 ACPI_REPORT_ERROR(("Sleep State return package elements are not both Integers (%s, %s)\n", acpi_ut_get_object_type_name(info.return_object->package.elements[0]), acpi_ut_get_object_type_name(info.return_object->package.elements[1]))); 195 ACPI_ERROR((AE_INFO,
196 "Sleep State return package elements are not both Integers (%s, %s)",
197 acpi_ut_get_object_type_name(info.return_object->
198 package.elements[0]),
199 acpi_ut_get_object_type_name(info.return_object->
200 package.elements[1])));
193 status = AE_AML_OPERAND_TYPE; 201 status = AE_AML_OPERAND_TYPE;
194 } else { 202 } else {
195 /* Valid _Sx_ package size, type, and value */ 203 /* Valid _Sx_ package size, type, and value */
@@ -201,12 +209,11 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
201 } 209 }
202 210
203 if (ACPI_FAILURE(status)) { 211 if (ACPI_FAILURE(status)) {
204 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 212 ACPI_EXCEPTION((AE_INFO, status,
205 "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n", 213 "While evaluating sleep_state [%s], bad Sleep object %p type %s",
206 acpi_format_exception(status), 214 sleep_state_name, info.return_object,
207 sleep_state_name, info.return_object, 215 acpi_ut_get_object_type_name(info.
208 acpi_ut_get_object_type_name(info. 216 return_object)));
209 return_object)));
210 } 217 }
211 218
212 acpi_ut_remove_reference(info.return_object); 219 acpi_ut_remove_reference(info.return_object);
@@ -229,12 +236,11 @@ EXPORT_SYMBOL(acpi_get_sleep_type_data);
229 236
230struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) 237struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
231{ 238{
232 ACPI_FUNCTION_NAME("hw_get_bit_register_info"); 239 ACPI_FUNCTION_ENTRY();
233 240
234 if (register_id > ACPI_BITREG_MAX) { 241 if (register_id > ACPI_BITREG_MAX) {
235 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 242 ACPI_ERROR((AE_INFO, "Invalid bit_register ID: %X",
236 "Invalid bit_register ID: %X\n", 243 register_id));
237 register_id));
238 return (NULL); 244 return (NULL);
239 } 245 }
240 246
@@ -334,8 +340,8 @@ acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags)
334 340
335 bit_reg_info = acpi_hw_get_bit_register_info(register_id); 341 bit_reg_info = acpi_hw_get_bit_register_info(register_id);
336 if (!bit_reg_info) { 342 if (!bit_reg_info) {
337 ACPI_REPORT_ERROR(("Bad ACPI HW register_id: %X\n", 343 ACPI_ERROR((AE_INFO, "Bad ACPI HW register_id: %X",
338 register_id)); 344 register_id));
339 return_ACPI_STATUS(AE_BAD_PARAMETER); 345 return_ACPI_STATUS(AE_BAD_PARAMETER);
340 } 346 }
341 347
@@ -569,8 +575,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
569 break; 575 break;
570 576
571 default: 577 default:
572 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown Register ID: %X\n", 578 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id));
573 register_id));
574 status = AE_BAD_PARAMETER; 579 status = AE_BAD_PARAMETER;
575 break; 580 break;
576 } 581 }
@@ -765,9 +770,9 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
765 break; 770 break;
766 771
767 default: 772 default:
768 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 773 ACPI_ERROR((AE_INFO,
769 "Unsupported address space: %X\n", 774 "Unsupported address space: %X",
770 reg->address_space_id)); 775 reg->address_space_id));
771 return (AE_BAD_PARAMETER); 776 return (AE_BAD_PARAMETER);
772 } 777 }
773 778
@@ -836,9 +841,9 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
836 break; 841 break;
837 842
838 default: 843 default:
839 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 844 ACPI_ERROR((AE_INFO,
840 "Unsupported address space: %X\n", 845 "Unsupported address space: %X",
841 reg->address_space_id)); 846 reg->address_space_id));
842 return (AE_BAD_PARAMETER); 847 return (AE_BAD_PARAMETER);
843 } 848 }
844 849
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 34519069050c..89269272fd62 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -199,8 +199,8 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
199 199
200 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 200 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
201 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 201 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
202 ACPI_REPORT_ERROR(("Method _SST failed, %s\n", 202 ACPI_EXCEPTION((AE_INFO, status,
203 acpi_format_exception(status))); 203 "While executing method _SST"));
204 } 204 }
205 205
206 return_ACPI_STATUS(AE_OK); 206 return_ACPI_STATUS(AE_OK);
@@ -232,9 +232,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
232 232
233 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || 233 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
234 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { 234 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
235 ACPI_REPORT_ERROR(("Sleep values out of range: A=%X B=%X\n", 235 ACPI_ERROR((AE_INFO, "Sleep values out of range: A=%X B=%X",
236 acpi_gbl_sleep_type_a, 236 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
237 acpi_gbl_sleep_type_b));
238 return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 237 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
239 } 238 }
240 239
@@ -533,21 +532,18 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
533 arg.integer.value = ACPI_SST_WAKING; 532 arg.integer.value = ACPI_SST_WAKING;
534 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 533 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
535 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 534 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
536 ACPI_REPORT_ERROR(("Method _SST failed, %s\n", 535 ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
537 acpi_format_exception(status)));
538 } 536 }
539 537
540 arg.integer.value = sleep_state; 538 arg.integer.value = sleep_state;
541 status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL); 539 status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
542 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 540 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
543 ACPI_REPORT_ERROR(("Method _BFS failed, %s\n", 541 ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
544 acpi_format_exception(status)));
545 } 542 }
546 543
547 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); 544 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
548 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 545 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
549 ACPI_REPORT_ERROR(("Method _WAK failed, %s\n", 546 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK"));
550 acpi_format_exception(status)));
551 } 547 }
552 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ 548 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
553 549
@@ -582,8 +578,7 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
582 arg.integer.value = ACPI_SST_WORKING; 578 arg.integer.value = ACPI_SST_WORKING;
583 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 579 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
584 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 580 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
585 ACPI_REPORT_ERROR(("Method _SST failed, %s\n", 581 ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
586 acpi_format_exception(status)));
587 } 582 }
588 583
589 return_ACPI_STATUS(status); 584 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c
index aff6dc141784..fc10b7cb456f 100644
--- a/drivers/acpi/hardware/hwtimer.c
+++ b/drivers/acpi/hardware/hwtimer.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
index e928e8c2c6ec..468244147ec1 100644
--- a/drivers/acpi/motherboard.c
+++ b/drivers/acpi/motherboard.c
@@ -54,36 +54,36 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
54 54
55 ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges"); 55 ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges");
56 56
57 if (res->id == ACPI_RSTYPE_IO) { 57 if (res->type == ACPI_RESOURCE_TYPE_IO) {
58 struct acpi_resource_io *io_res = &res->data.io; 58 struct acpi_resource_io *io_res = &res->data.io;
59 59
60 if (io_res->min_base_address != io_res->max_base_address) 60 if (io_res->minimum != io_res->maximum)
61 return_VALUE(AE_OK); 61 return_VALUE(AE_OK);
62 if (IS_RESERVED_ADDR 62 if (IS_RESERVED_ADDR
63 (io_res->min_base_address, io_res->range_length)) { 63 (io_res->minimum, io_res->address_length)) {
64 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 64 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
65 "Motherboard resources 0x%08x - 0x%08x\n", 65 "Motherboard resources 0x%08x - 0x%08x\n",
66 io_res->min_base_address, 66 io_res->minimum,
67 io_res->min_base_address + 67 io_res->minimum +
68 io_res->range_length)); 68 io_res->address_length));
69 requested_res = 69 requested_res =
70 request_region(io_res->min_base_address, 70 request_region(io_res->minimum,
71 io_res->range_length, "motherboard"); 71 io_res->address_length, "motherboard");
72 } 72 }
73 } else if (res->id == ACPI_RSTYPE_FIXED_IO) { 73 } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_IO) {
74 struct acpi_resource_fixed_io *fixed_io_res = 74 struct acpi_resource_fixed_io *fixed_io_res =
75 &res->data.fixed_io; 75 &res->data.fixed_io;
76 76
77 if (IS_RESERVED_ADDR 77 if (IS_RESERVED_ADDR
78 (fixed_io_res->base_address, fixed_io_res->range_length)) { 78 (fixed_io_res->address, fixed_io_res->address_length)) {
79 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 79 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
80 "Motherboard resources 0x%08x - 0x%08x\n", 80 "Motherboard resources 0x%08x - 0x%08x\n",
81 fixed_io_res->base_address, 81 fixed_io_res->address,
82 fixed_io_res->base_address + 82 fixed_io_res->address +
83 fixed_io_res->range_length)); 83 fixed_io_res->address_length));
84 requested_res = 84 requested_res =
85 request_region(fixed_io_res->base_address, 85 request_region(fixed_io_res->address,
86 fixed_io_res->range_length, 86 fixed_io_res->address_length,
87 "motherboard"); 87 "motherboard");
88 } 88 }
89 } else { 89 } else {
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index edfbe34600f5..1149bc18fb35 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -110,10 +110,9 @@ acpi_status acpi_ns_root_initialize(void)
110 ACPI_NS_NO_UPSEARCH, NULL, &new_node); 110 ACPI_NS_NO_UPSEARCH, NULL, &new_node);
111 111
112 if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */ 112 if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */
113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 113 ACPI_EXCEPTION((AE_INFO, status,
114 "Could not create predefined name %s, %s\n", 114 "Could not create predefined name %s",
115 init_val->name, 115 init_val->name));
116 acpi_format_exception(status)));
117 } 116 }
118 117
119 /* 118 /*
@@ -124,9 +123,9 @@ acpi_status acpi_ns_root_initialize(void)
124 if (init_val->val) { 123 if (init_val->val) {
125 status = acpi_os_predefined_override(init_val, &val); 124 status = acpi_os_predefined_override(init_val, &val);
126 if (ACPI_FAILURE(status)) { 125 if (ACPI_FAILURE(status)) {
127 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 126 ACPI_ERROR((AE_INFO,
128 "Could not override predefined %s\n", 127 "Could not override predefined %s",
129 init_val->name)); 128 init_val->name));
130 } 129 }
131 130
132 if (!val) { 131 if (!val) {
@@ -233,7 +232,9 @@ acpi_status acpi_ns_root_initialize(void)
233 232
234 default: 233 default:
235 234
236 ACPI_REPORT_ERROR(("Unsupported initial type value %X\n", init_val->type)); 235 ACPI_ERROR((AE_INFO,
236 "Unsupported initial type value %X",
237 init_val->type));
237 acpi_ut_remove_reference(obj_desc); 238 acpi_ut_remove_reference(obj_desc);
238 obj_desc = NULL; 239 obj_desc = NULL;
239 continue; 240 continue;
@@ -339,7 +340,9 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
339 prefix_node = scope_info->scope.node; 340 prefix_node = scope_info->scope.node;
340 if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) != 341 if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) !=
341 ACPI_DESC_TYPE_NAMED) { 342 ACPI_DESC_TYPE_NAMED) {
342 ACPI_REPORT_ERROR(("ns_lookup: %p is not a namespace node [%s]\n", prefix_node, acpi_ut_get_descriptor_name(prefix_node))); 343 ACPI_ERROR((AE_INFO, "%p is not a namespace node [%s]",
344 prefix_node,
345 acpi_ut_get_descriptor_name(prefix_node)));
343 return_ACPI_STATUS(AE_AML_INTERNAL); 346 return_ACPI_STATUS(AE_AML_INTERNAL);
344 } 347 }
345 348
@@ -429,7 +432,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
429 if (!this_node) { 432 if (!this_node) {
430 /* Current scope has no parent scope */ 433 /* Current scope has no parent scope */
431 434
432 ACPI_REPORT_ERROR(("ACPI path has too many parent prefixes (^) - reached beyond root node\n")); 435 ACPI_ERROR((AE_INFO,
436 "ACPI path has too many parent prefixes (^) - reached beyond root node"));
433 return_ACPI_STATUS(AE_NOT_FOUND); 437 return_ACPI_STATUS(AE_NOT_FOUND);
434 } 438 }
435 } 439 }
@@ -498,7 +502,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
498 path++; 502 path++;
499 503
500 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 504 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
501 "Multi Pathname (%d Segments, Flags=%X) \n", 505 "Multi Pathname (%d Segments, Flags=%X)\n",
502 num_segments, flags)); 506 num_segments, flags));
503 break; 507 break;
504 508
@@ -600,7 +604,12 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
600 (this_node->type != type_to_check_for)) { 604 (this_node->type != type_to_check_for)) {
601 /* Complain about a type mismatch */ 605 /* Complain about a type mismatch */
602 606
603 ACPI_REPORT_WARNING(("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n", (char *)&simple_name, acpi_ut_get_type_name(this_node->type), acpi_ut_get_type_name(type_to_check_for))); 607 ACPI_WARNING((AE_INFO,
608 "ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)",
609 ACPI_CAST_PTR(char, &simple_name),
610 acpi_ut_get_type_name(this_node->type),
611 acpi_ut_get_type_name
612 (type_to_check_for)));
604 } 613 }
605 614
606 /* 615 /*
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index cc7a85f8cfe6..9b871f38b61b 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -272,9 +272,8 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
272 /* Grandchildren should have all been deleted already */ 272 /* Grandchildren should have all been deleted already */
273 273
274 if (child_node->child) { 274 if (child_node->child) {
275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 275 ACPI_ERROR((AE_INFO, "Found a grandchild! P=%p C=%p",
276 "Found a grandchild! P=%p C=%p\n", 276 parent_node, child_node));
277 parent_node, child_node));
278 } 277 }
279 278
280 /* Now we can free this child object */ 279 /* Now we can free this child object */
@@ -302,7 +301,9 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
302 /* There should be only one reference remaining on this node */ 301 /* There should be only one reference remaining on this node */
303 302
304 if (child_node->reference_count != 1) { 303 if (child_node->reference_count != 1) {
305 ACPI_REPORT_WARNING(("Existing references (%d) on node being deleted (%p)\n", child_node->reference_count, child_node)); 304 ACPI_WARNING((AE_INFO,
305 "Existing references (%d) on node being deleted (%p)",
306 child_node->reference_count, child_node));
306 } 307 }
307 308
308 /* Now we can delete the node */ 309 /* Now we can delete the node */
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
index 9faf1d5c86ed..a2807317a84b 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/namespace/nsdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -198,12 +198,13 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
198 /* Check the node type and name */ 198 /* Check the node type and name */
199 199
200 if (type > ACPI_TYPE_LOCAL_MAX) { 200 if (type > ACPI_TYPE_LOCAL_MAX) {
201 ACPI_REPORT_WARNING(("Invalid ACPI Type %08X\n", type)); 201 ACPI_WARNING((AE_INFO, "Invalid ACPI Object Type %08X",
202 type));
202 } 203 }
203 204
204 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) { 205 if (!acpi_ut_valid_acpi_name(this_node->name.integer)) {
205 ACPI_REPORT_WARNING(("Invalid ACPI Name %08X\n", 206 ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X",
206 this_node->name.integer)); 207 this_node->name.integer));
207 } 208 }
208 209
209 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); 210 acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node));
@@ -212,7 +213,9 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
212 /* 213 /*
213 * Now we can print out the pertinent information 214 * Now we can print out the pertinent information
214 */ 215 */
215 acpi_os_printf(" %-12s %p ", acpi_ut_get_type_name(type), this_node); 216 acpi_os_printf(" %-12s %p %2.2X ",
217 acpi_ut_get_type_name(type), this_node,
218 this_node->owner_id);
216 219
217 dbg_level = acpi_dbg_level; 220 dbg_level = acpi_dbg_level;
218 acpi_dbg_level = 0; 221 acpi_dbg_level = 0;
diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c
index 55de883943d6..aff899a935e3 100644
--- a/drivers/acpi/namespace/nsdumpdv.c
+++ b/drivers/acpi/namespace/nsdumpdv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index 0191c7d92824..19d7b94d40c3 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -373,8 +373,7 @@ acpi_ns_execute_control_method(struct acpi_parameter_info *info)
373 373
374 info->obj_desc = acpi_ns_get_attached_object(info->node); 374 info->obj_desc = acpi_ns_get_attached_object(info->node);
375 if (!info->obj_desc) { 375 if (!info->obj_desc) {
376 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 376 ACPI_ERROR((AE_INFO, "No attached method object"));
377 "No attached method object\n"));
378 377
379 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 378 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
380 return_ACPI_STATUS(AE_NULL_OBJECT); 379 return_ACPI_STATUS(AE_NULL_OBJECT);
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
index 0a08d2f04a06..9f929e479fd8 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/namespace/nsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -93,8 +93,7 @@ acpi_status acpi_ns_initialize_objects(void)
93 ACPI_UINT32_MAX, acpi_ns_init_one_object, 93 ACPI_UINT32_MAX, acpi_ns_init_one_object,
94 &info, NULL); 94 &info, NULL);
95 if (ACPI_FAILURE(status)) { 95 if (ACPI_FAILURE(status)) {
96 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", 96 ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace"));
97 acpi_format_exception(status)));
98 } 97 }
99 98
100 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 99 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
@@ -159,12 +158,11 @@ acpi_status acpi_ns_initialize_devices(void)
159 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 158 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
160 159
161 if (ACPI_FAILURE(status)) { 160 if (ACPI_FAILURE(status)) {
162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", 161 ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace"));
163 acpi_format_exception(status)));
164 } 162 }
165 163
166 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 164 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
167 "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n", 165 "\n%hd Devices found - executed %hd _STA, %hd _INI methods\n",
168 info.device_count, info.num_STA, info.num_INI)); 166 info.device_count, info.num_STA, info.num_INI));
169 167
170 return_ACPI_STATUS(status); 168 return_ACPI_STATUS(status);
@@ -289,12 +287,10 @@ acpi_ns_init_one_object(acpi_handle obj_handle,
289 } 287 }
290 288
291 if (ACPI_FAILURE(status)) { 289 if (ACPI_FAILURE(status)) {
292 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, "\n")); 290 ACPI_EXCEPTION((AE_INFO, status,
293 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 291 "Could not execute arguments for [%4.4s] (%s)",
294 "Could not execute arguments for [%4.4s] (%s), %s\n", 292 acpi_ut_get_node_name(node),
295 acpi_ut_get_node_name(node), 293 acpi_ut_get_type_name(type)));
296 acpi_ut_get_type_name(type),
297 acpi_format_exception(status)));
298 } 294 }
299 295
300 /* 296 /*
@@ -336,23 +332,22 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
336 struct acpi_parameter_info pinfo; 332 struct acpi_parameter_info pinfo;
337 u32 flags; 333 u32 flags;
338 acpi_status status; 334 acpi_status status;
335 struct acpi_namespace_node *ini_node;
336 struct acpi_namespace_node *device_node;
339 337
340 ACPI_FUNCTION_TRACE("ns_init_one_device"); 338 ACPI_FUNCTION_TRACE("ns_init_one_device");
341 339
342 pinfo.parameters = NULL; 340 device_node = acpi_ns_map_handle_to_node(obj_handle);
343 pinfo.parameter_type = ACPI_PARAM_ARGS; 341 if (!device_node) {
344
345 pinfo.node = acpi_ns_map_handle_to_node(obj_handle);
346 if (!pinfo.node) {
347 return_ACPI_STATUS(AE_BAD_PARAMETER); 342 return_ACPI_STATUS(AE_BAD_PARAMETER);
348 } 343 }
349 344
350 /* 345 /*
351 * We will run _STA/_INI on Devices, Processors and thermal_zones only 346 * We will run _STA/_INI on Devices, Processors and thermal_zones only
352 */ 347 */
353 if ((pinfo.node->type != ACPI_TYPE_DEVICE) && 348 if ((device_node->type != ACPI_TYPE_DEVICE) &&
354 (pinfo.node->type != ACPI_TYPE_PROCESSOR) && 349 (device_node->type != ACPI_TYPE_PROCESSOR) &&
355 (pinfo.node->type != ACPI_TYPE_THERMAL)) { 350 (device_node->type != ACPI_TYPE_THERMAL)) {
356 return_ACPI_STATUS(AE_OK); 351 return_ACPI_STATUS(AE_OK);
357 } 352 }
358 353
@@ -364,57 +359,69 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
364 info->device_count++; 359 info->device_count++;
365 360
366 /* 361 /*
367 * Run _STA to determine if we can run _INI on the device. 362 * Check if the _INI method exists for this device -
363 * if _INI does not exist, there is no need to run _STA
364 * No _INI means device requires no initialization
365 */
366 status = acpi_ns_search_node(*ACPI_CAST_PTR(u32, METHOD_NAME__INI),
367 device_node, ACPI_TYPE_METHOD, &ini_node);
368 if (ACPI_FAILURE(status)) {
369 /* No _INI method found - move on to next device */
370
371 return_ACPI_STATUS(AE_OK);
372 }
373
374 /*
375 * Run _STA to determine if we can run _INI on the device -
376 * the device must be present before _INI can be run.
377 * However, _STA is not required - assume device present if no _STA
368 */ 378 */
369 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, 379 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD,
370 pinfo.node, 380 device_node,
371 METHOD_NAME__STA)); 381 METHOD_NAME__STA));
372 status = acpi_ut_execute_STA(pinfo.node, &flags);
373 382
383 pinfo.node = device_node;
384 pinfo.parameters = NULL;
385 pinfo.parameter_type = ACPI_PARAM_ARGS;
386
387 status = acpi_ut_execute_STA(pinfo.node, &flags);
374 if (ACPI_FAILURE(status)) { 388 if (ACPI_FAILURE(status)) {
375 if (pinfo.node->type == ACPI_TYPE_DEVICE) { 389 /* Ignore error and move on to next device */
376 /* Ignore error and move on to next device */
377 390
378 return_ACPI_STATUS(AE_OK); 391 return_ACPI_STATUS(AE_OK);
379 } 392 }
380 393
381 /* _STA is not required for Processor or thermal_zone objects */ 394 if (flags != ACPI_UINT32_MAX) {
382 } else {
383 info->num_STA++; 395 info->num_STA++;
396 }
384 397
385 if (!(flags & 0x01)) { 398 if (!(flags & ACPI_STA_DEVICE_PRESENT)) {
386 /* Don't look at children of a not present device */ 399 /* Don't look at children of a not present device */
387 400
388 return_ACPI_STATUS(AE_CTRL_DEPTH); 401 return_ACPI_STATUS(AE_CTRL_DEPTH);
389 }
390 } 402 }
391 403
392 /* 404 /*
393 * The device is present. Run _INI. 405 * The device is present and _INI exists. Run the _INI method.
406 * (We already have the _INI node from above)
394 */ 407 */
395 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, 408 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD,
396 pinfo.node, 409 pinfo.node,
397 METHOD_NAME__INI)); 410 METHOD_NAME__INI));
398 status = acpi_ns_evaluate_relative(METHOD_NAME__INI, &pinfo);
399 if (ACPI_FAILURE(status)) {
400 /* No _INI (AE_NOT_FOUND) means device requires no initialization */
401 411
402 if (status != AE_NOT_FOUND) { 412 pinfo.node = ini_node;
403 /* Ignore error and move on to next device */ 413 status = acpi_ns_evaluate_by_handle(&pinfo);
414 if (ACPI_FAILURE(status)) {
415 /* Ignore error and move on to next device */
404 416
405#ifdef ACPI_DEBUG_OUTPUT 417#ifdef ACPI_DEBUG_OUTPUT
406 char *scope_name = 418 char *scope_name = acpi_ns_get_external_pathname(ini_node);
407 acpi_ns_get_external_pathname(pinfo.node);
408 419
409 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n", 420 ACPI_WARNING((AE_INFO, "%s._INI failed: %s",
410 scope_name, 421 scope_name, acpi_format_exception(status)));
411 acpi_format_exception(status)));
412 422
413 ACPI_MEM_FREE(scope_name); 423 ACPI_MEM_FREE(scope_name);
414#endif 424#endif
415 }
416
417 status = AE_OK;
418 } else { 425 } else {
419 /* Delete any return object (especially if implicit_return is enabled) */ 426 /* Delete any return object (especially if implicit_return is enabled) */
420 427
@@ -434,5 +441,5 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
434 acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI); 441 acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI);
435 } 442 }
436 443
437 return_ACPI_STATUS(status); 444 return_ACPI_STATUS(AE_OK);
438} 445}
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c
index c28849de465a..4e0b0524c188 100644
--- a/drivers/acpi/namespace/nsload.c
+++ b/drivers/acpi/namespace/nsload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -92,7 +92,7 @@ acpi_ns_load_table(struct acpi_table_desc *table_desc,
92 /* Check validity of the AML start and length */ 92 /* Check validity of the AML start and length */
93 93
94 if (!table_desc->aml_start) { 94 if (!table_desc->aml_start) {
95 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null AML pointer\n")); 95 ACPI_ERROR((AE_INFO, "Null AML pointer"));
96 return_ACPI_STATUS(AE_BAD_PARAMETER); 96 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 } 97 }
98 98
@@ -102,8 +102,8 @@ acpi_ns_load_table(struct acpi_table_desc *table_desc,
102 /* Ignore table if there is no AML contained within */ 102 /* Ignore table if there is no AML contained within */
103 103
104 if (!table_desc->aml_length) { 104 if (!table_desc->aml_length) {
105 ACPI_REPORT_WARNING(("Zero-length AML block in table [%4.4s]\n", 105 ACPI_WARNING((AE_INFO, "Zero-length AML block in table [%4.4s]",
106 table_desc->pointer->signature)); 106 table_desc->pointer->signature));
107 return_ACPI_STATUS(AE_OK); 107 return_ACPI_STATUS(AE_OK);
108 } 108 }
109 109
@@ -263,7 +263,7 @@ acpi_status acpi_ns_load_namespace(void)
263 /* There must be at least a DSDT installed */ 263 /* There must be at least a DSDT installed */
264 264
265 if (acpi_gbl_DSDT == NULL) { 265 if (acpi_gbl_DSDT == NULL) {
266 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "DSDT is not in memory\n")); 266 ACPI_ERROR((AE_INFO, "DSDT is not in memory"));
267 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 267 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
268 } 268 }
269 269
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index d5e8dea61c27..639f653b4b6b 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -75,7 +75,7 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node,
75 acpi_size index; 75 acpi_size index;
76 struct acpi_namespace_node *parent_node; 76 struct acpi_namespace_node *parent_node;
77 77
78 ACPI_FUNCTION_NAME("ns_build_external_path"); 78 ACPI_FUNCTION_ENTRY();
79 79
80 /* Special case for root */ 80 /* Special case for root */
81 81
@@ -110,9 +110,9 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node,
110 name_buffer[index] = AML_ROOT_PREFIX; 110 name_buffer[index] = AML_ROOT_PREFIX;
111 111
112 if (index != 0) { 112 if (index != 0) {
113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 113 ACPI_ERROR((AE_INFO,
114 "Could not construct pathname; index=%X, size=%X, Path=%s\n", 114 "Could not construct pathname; index=%X, size=%X, Path=%s",
115 (u32) index, (u32) size, &name_buffer[size])); 115 (u32) index, (u32) size, &name_buffer[size]));
116 } 116 }
117 117
118 return; 118 return;
@@ -148,7 +148,7 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
148 148
149 name_buffer = ACPI_MEM_CALLOCATE(size); 149 name_buffer = ACPI_MEM_CALLOCATE(size);
150 if (!name_buffer) { 150 if (!name_buffer) {
151 ACPI_REPORT_ERROR(("ns_get_table_pathname: allocation failure\n")); 151 ACPI_ERROR((AE_INFO, "Allocation failure"));
152 return_PTR(NULL); 152 return_PTR(NULL);
153 } 153 }
154 154
@@ -241,7 +241,7 @@ acpi_ns_handle_to_pathname(acpi_handle target_handle,
241 241
242 acpi_ns_build_external_path(node, required_size, buffer->pointer); 242 acpi_ns_build_external_path(node, required_size, buffer->pointer);
243 243
244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X] \n", 244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X]\n",
245 (char *)buffer->pointer, (u32) required_size)); 245 (char *)buffer->pointer, (u32) required_size));
246 return_ACPI_STATUS(AE_OK); 246 return_ACPI_STATUS(AE_OK);
247} 247}
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c
index fc9be946ebed..10ae6292bca4 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/namespace/nsobject.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -84,22 +84,23 @@ acpi_ns_attach_object(struct acpi_namespace_node *node,
84 if (!node) { 84 if (!node) {
85 /* Invalid handle */ 85 /* Invalid handle */
86 86
87 ACPI_REPORT_ERROR(("ns_attach_object: Null named_obj handle\n")); 87 ACPI_ERROR((AE_INFO, "Null named_obj handle"));
88 return_ACPI_STATUS(AE_BAD_PARAMETER); 88 return_ACPI_STATUS(AE_BAD_PARAMETER);
89 } 89 }
90 90
91 if (!object && (ACPI_TYPE_ANY != type)) { 91 if (!object && (ACPI_TYPE_ANY != type)) {
92 /* Null object */ 92 /* Null object */
93 93
94 ACPI_REPORT_ERROR(("ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n")); 94 ACPI_ERROR((AE_INFO,
95 "Null object, but type not ACPI_TYPE_ANY"));
95 return_ACPI_STATUS(AE_BAD_PARAMETER); 96 return_ACPI_STATUS(AE_BAD_PARAMETER);
96 } 97 }
97 98
98 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { 99 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
99 /* Not a name handle */ 100 /* Not a name handle */
100 101
101 ACPI_REPORT_ERROR(("ns_attach_object: Invalid handle %p [%s]\n", 102 ACPI_ERROR((AE_INFO, "Invalid handle %p [%s]",
102 node, acpi_ut_get_descriptor_name(node))); 103 node, acpi_ut_get_descriptor_name(node)));
103 return_ACPI_STATUS(AE_BAD_PARAMETER); 104 return_ACPI_STATUS(AE_BAD_PARAMETER);
104 } 105 }
105 106
@@ -254,7 +255,7 @@ union acpi_operand_object *acpi_ns_get_attached_object(struct
254 ACPI_FUNCTION_TRACE_PTR("ns_get_attached_object", node); 255 ACPI_FUNCTION_TRACE_PTR("ns_get_attached_object", node);
255 256
256 if (!node) { 257 if (!node) {
257 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Null Node ptr\n")); 258 ACPI_WARNING((AE_INFO, "Null Node ptr"));
258 return_PTR(NULL); 259 return_PTR(NULL);
259 } 260 }
260 261
diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c
index 433442a9ec74..232be4303653 100644
--- a/drivers/acpi/namespace/nsparse.c
+++ b/drivers/acpi/namespace/nsparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
index 50a3ca5470ed..d64b78952f24 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/namespace/nssearch.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -99,8 +99,8 @@ acpi_ns_search_node(u32 target_name,
99 if (scope_name) { 99 if (scope_name) {
100 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 100 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
101 "Searching %s (%p) For [%4.4s] (%s)\n", 101 "Searching %s (%p) For [%4.4s] (%s)\n",
102 scope_name, node, 102 scope_name, node, ACPI_CAST_PTR(char,
103 (char *)&target_name, 103 &target_name),
104 acpi_ut_get_type_name(type))); 104 acpi_ut_get_type_name(type)));
105 105
106 ACPI_MEM_FREE(scope_name); 106 ACPI_MEM_FREE(scope_name);
@@ -131,7 +131,7 @@ acpi_ns_search_node(u32 target_name,
131 */ 131 */
132 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 132 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
133 "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", 133 "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n",
134 (char *)&target_name, 134 ACPI_CAST_PTR(char, &target_name),
135 acpi_ut_get_type_name(next_node-> 135 acpi_ut_get_type_name(next_node->
136 type), 136 type),
137 next_node, 137 next_node,
@@ -160,7 +160,8 @@ acpi_ns_search_node(u32 target_name,
160 160
161 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 161 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
162 "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", 162 "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n",
163 (char *)&target_name, acpi_ut_get_type_name(type), 163 ACPI_CAST_PTR(char, &target_name),
164 acpi_ut_get_type_name(type),
164 acpi_ut_get_node_name(node), node, node->child)); 165 acpi_ut_get_node_name(node), node, node->child));
165 166
166 return_ACPI_STATUS(AE_NOT_FOUND); 167 return_ACPI_STATUS(AE_NOT_FOUND);
@@ -210,14 +211,14 @@ acpi_ns_search_parent_tree(u32 target_name,
210 */ 211 */
211 if (!parent_node) { 212 if (!parent_node) {
212 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[%4.4s] has no parent\n", 213 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
213 (char *)&target_name)); 214 ACPI_CAST_PTR(char, &target_name)));
214 return_ACPI_STATUS(AE_NOT_FOUND); 215 return_ACPI_STATUS(AE_NOT_FOUND);
215 } 216 }
216 217
217 if (acpi_ns_local(type)) { 218 if (acpi_ns_local(type)) {
218 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 219 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
219 "[%4.4s] type [%s] must be local to this scope (no parent search)\n", 220 "[%4.4s] type [%s] must be local to this scope (no parent search)\n",
220 (char *)&target_name, 221 ACPI_CAST_PTR(char, &target_name),
221 acpi_ut_get_type_name(type))); 222 acpi_ut_get_type_name(type)));
222 return_ACPI_STATUS(AE_NOT_FOUND); 223 return_ACPI_STATUS(AE_NOT_FOUND);
223 } 224 }
@@ -227,7 +228,7 @@ acpi_ns_search_parent_tree(u32 target_name,
227 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 228 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
228 "Searching parent [%4.4s] for [%4.4s]\n", 229 "Searching parent [%4.4s] for [%4.4s]\n",
229 acpi_ut_get_node_name(parent_node), 230 acpi_ut_get_node_name(parent_node),
230 (char *)&target_name)); 231 ACPI_CAST_PTR(char, &target_name)));
231 232
232 /* 233 /*
233 * Search parents until target is found or we have backed up to the root 234 * Search parents until target is found or we have backed up to the root
@@ -297,18 +298,17 @@ acpi_ns_search_and_enter(u32 target_name,
297 /* Parameter validation */ 298 /* Parameter validation */
298 299
299 if (!node || !target_name || !return_node) { 300 if (!node || !target_name || !return_node) {
300 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 301 ACPI_ERROR((AE_INFO,
301 "Null param: Node %p Name %X return_node %p\n", 302 "Null param: Node %p Name %X return_node %p",
302 node, target_name, return_node)); 303 node, target_name, return_node));
303
304 ACPI_REPORT_ERROR(("ns_search_and_enter: Null parameter\n"));
305 return_ACPI_STATUS(AE_BAD_PARAMETER); 304 return_ACPI_STATUS(AE_BAD_PARAMETER);
306 } 305 }
307 306
308 /* Name must consist of printable characters */ 307 /* Name must consist of printable characters */
309 308
310 if (!acpi_ut_valid_acpi_name(target_name)) { 309 if (!acpi_ut_valid_acpi_name(target_name)) {
311 ACPI_REPORT_ERROR(("ns_search_and_enter: Bad character in ACPI Name: %X\n", target_name)); 310 ACPI_ERROR((AE_INFO, "Bad character in ACPI Name: %X",
311 target_name));
312 return_ACPI_STATUS(AE_BAD_CHARACTER); 312 return_ACPI_STATUS(AE_BAD_CHARACTER);
313 } 313 }
314 314
@@ -360,7 +360,7 @@ acpi_ns_search_and_enter(u32 target_name,
360 if (interpreter_mode == ACPI_IMODE_EXECUTE) { 360 if (interpreter_mode == ACPI_IMODE_EXECUTE) {
361 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 361 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
362 "%4.4s Not found in %p [Not adding]\n", 362 "%4.4s Not found in %p [Not adding]\n",
363 (char *)&target_name, node)); 363 ACPI_CAST_PTR(char, &target_name), node));
364 364
365 return_ACPI_STATUS(AE_NOT_FOUND); 365 return_ACPI_STATUS(AE_NOT_FOUND);
366 } 366 }
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
index ebec036423c9..3e7cad549a38 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/namespace/nsutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -63,7 +63,6 @@ acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
63 * 63 *
64 * PARAMETERS: module_name - Caller's module name (for error output) 64 * PARAMETERS: module_name - Caller's module name (for error output)
65 * line_number - Caller's line number (for error output) 65 * line_number - Caller's line number (for error output)
66 * component_id - Caller's component ID (for error output)
67 * internal_name - Name or path of the namespace node 66 * internal_name - Name or path of the namespace node
68 * lookup_status - Exception code from NS lookup 67 * lookup_status - Exception code from NS lookup
69 * 68 *
@@ -76,19 +75,17 @@ acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
76void 75void
77acpi_ns_report_error(char *module_name, 76acpi_ns_report_error(char *module_name,
78 u32 line_number, 77 u32 line_number,
79 u32 component_id,
80 char *internal_name, acpi_status lookup_status) 78 char *internal_name, acpi_status lookup_status)
81{ 79{
82 acpi_status status; 80 acpi_status status;
83 char *name = NULL; 81 char *name = NULL;
84 82
85 acpi_os_printf("%8s-%04d: *** Error: Looking up ", 83 acpi_ut_report_error(module_name, line_number);
86 module_name, line_number);
87 84
88 if (lookup_status == AE_BAD_CHARACTER) { 85 if (lookup_status == AE_BAD_CHARACTER) {
89 /* There is a non-ascii character in the name */ 86 /* There is a non-ascii character in the name */
90 87
91 acpi_os_printf("[0x%4.4X] (NON-ASCII)\n", 88 acpi_os_printf("[0x%4.4X] (NON-ASCII)",
92 *(ACPI_CAST_PTR(u32, internal_name))); 89 *(ACPI_CAST_PTR(u32, internal_name)));
93 } else { 90 } else {
94 /* Convert path to external format */ 91 /* Convert path to external format */
@@ -109,7 +106,7 @@ acpi_ns_report_error(char *module_name,
109 } 106 }
110 } 107 }
111 108
112 acpi_os_printf(" in namespace, %s\n", 109 acpi_os_printf(" Namespace lookup failure, %s\n",
113 acpi_format_exception(lookup_status)); 110 acpi_format_exception(lookup_status));
114} 111}
115 112
@@ -119,10 +116,9 @@ acpi_ns_report_error(char *module_name,
119 * 116 *
120 * PARAMETERS: module_name - Caller's module name (for error output) 117 * PARAMETERS: module_name - Caller's module name (for error output)
121 * line_number - Caller's line number (for error output) 118 * line_number - Caller's line number (for error output)
122 * component_id - Caller's component ID (for error output)
123 * Message - Error message to use on failure 119 * Message - Error message to use on failure
124 * prefix_node - Prefix relative to the path 120 * prefix_node - Prefix relative to the path
125 * Path - Path to the node 121 * Path - Path to the node (optional)
126 * method_status - Execution status 122 * method_status - Execution status
127 * 123 *
128 * RETURN: None 124 * RETURN: None
@@ -134,7 +130,6 @@ acpi_ns_report_error(char *module_name,
134void 130void
135acpi_ns_report_method_error(char *module_name, 131acpi_ns_report_method_error(char *module_name,
136 u32 line_number, 132 u32 line_number,
137 u32 component_id,
138 char *message, 133 char *message,
139 struct acpi_namespace_node *prefix_node, 134 struct acpi_namespace_node *prefix_node,
140 char *path, acpi_status method_status) 135 char *path, acpi_status method_status)
@@ -142,17 +137,16 @@ acpi_ns_report_method_error(char *module_name,
142 acpi_status status; 137 acpi_status status;
143 struct acpi_namespace_node *node = prefix_node; 138 struct acpi_namespace_node *node = prefix_node;
144 139
140 acpi_ut_report_error(module_name, line_number);
141
145 if (path) { 142 if (path) {
146 status = acpi_ns_get_node_by_path(path, prefix_node, 143 status = acpi_ns_get_node_by_path(path, prefix_node,
147 ACPI_NS_NO_UPSEARCH, &node); 144 ACPI_NS_NO_UPSEARCH, &node);
148 if (ACPI_FAILURE(status)) { 145 if (ACPI_FAILURE(status)) {
149 acpi_os_printf 146 acpi_os_printf("[Could not get node by pathname]");
150 ("report_method_error: Could not get node\n");
151 return;
152 } 147 }
153 } 148 }
154 149
155 acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number);
156 acpi_ns_print_node_pathname(node, message); 150 acpi_ns_print_node_pathname(node, message);
157 acpi_os_printf(", %s\n", acpi_format_exception(method_status)); 151 acpi_os_printf(", %s\n", acpi_format_exception(method_status));
158} 152}
@@ -248,11 +242,11 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
248 ACPI_FUNCTION_TRACE("ns_get_type"); 242 ACPI_FUNCTION_TRACE("ns_get_type");
249 243
250 if (!node) { 244 if (!node) {
251 ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n")); 245 ACPI_WARNING((AE_INFO, "Null Node parameter"));
252 return_VALUE(ACPI_TYPE_ANY); 246 return_UINT32(ACPI_TYPE_ANY);
253 } 247 }
254 248
255 return_VALUE((acpi_object_type) node->type); 249 return_UINT32((acpi_object_type) node->type);
256} 250}
257 251
258/******************************************************************************* 252/*******************************************************************************
@@ -275,11 +269,11 @@ u32 acpi_ns_local(acpi_object_type type)
275 if (!acpi_ut_valid_object_type(type)) { 269 if (!acpi_ut_valid_object_type(type)) {
276 /* Type code out of range */ 270 /* Type code out of range */
277 271
278 ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n")); 272 ACPI_WARNING((AE_INFO, "Invalid Object Type %X", type));
279 return_VALUE(ACPI_NS_NORMAL); 273 return_UINT32(ACPI_NS_NORMAL);
280 } 274 }
281 275
282 return_VALUE((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); 276 return_UINT32((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
283} 277}
284 278
285/******************************************************************************* 279/*******************************************************************************
@@ -627,7 +621,7 @@ acpi_ns_externalize_name(u32 internal_name_length,
627 * with internal_name (invalid format). 621 * with internal_name (invalid format).
628 */ 622 */
629 if (required_length > internal_name_length) { 623 if (required_length > internal_name_length) {
630 ACPI_REPORT_ERROR(("ns_externalize_name: Invalid internal name\n")); 624 ACPI_ERROR((AE_INFO, "Invalid internal name"));
631 return_ACPI_STATUS(AE_BAD_PATHNAME); 625 return_ACPI_STATUS(AE_BAD_PATHNAME);
632 } 626 }
633 627
@@ -803,12 +797,11 @@ u32 acpi_ns_opens_scope(acpi_object_type type)
803 if (!acpi_ut_valid_object_type(type)) { 797 if (!acpi_ut_valid_object_type(type)) {
804 /* type code out of range */ 798 /* type code out of range */
805 799
806 ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n", 800 ACPI_WARNING((AE_INFO, "Invalid Object Type %X", type));
807 type)); 801 return_UINT32(ACPI_NS_NORMAL);
808 return_VALUE(ACPI_NS_NORMAL);
809 } 802 }
810 803
811 return_VALUE(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); 804 return_UINT32(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
812} 805}
813 806
814/******************************************************************************* 807/*******************************************************************************
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c
index 5f164c0df33b..fcab1e784b81 100644
--- a/drivers/acpi/namespace/nswalk.c
+++ b/drivers/acpi/namespace/nswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index c07b046659ff..a95f636dc35d 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -112,8 +112,7 @@ acpi_evaluate_object_typed(acpi_handle handle,
112 if (return_buffer->length == 0) { 112 if (return_buffer->length == 0) {
113 /* Error because caller specifically asked for a return value */ 113 /* Error because caller specifically asked for a return value */
114 114
115 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No return value\n")); 115 ACPI_ERROR((AE_INFO, "No return value"));
116
117 return_ACPI_STATUS(AE_NULL_OBJECT); 116 return_ACPI_STATUS(AE_NULL_OBJECT);
118 } 117 }
119 118
@@ -125,11 +124,11 @@ acpi_evaluate_object_typed(acpi_handle handle,
125 124
126 /* Return object type does not match requested type */ 125 /* Return object type does not match requested type */
127 126
128 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 127 ACPI_ERROR((AE_INFO,
129 "Incorrect return type [%s] requested [%s]\n", 128 "Incorrect return type [%s] requested [%s]",
130 acpi_ut_get_type_name(((union acpi_object *) 129 acpi_ut_get_type_name(((union acpi_object *)return_buffer->
131 return_buffer->pointer)->type), 130 pointer)->type),
132 acpi_ut_get_type_name(return_type))); 131 acpi_ut_get_type_name(return_type)));
133 132
134 if (must_free) { 133 if (must_free) {
135 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ 134 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
@@ -236,11 +235,11 @@ acpi_evaluate_object(acpi_handle handle,
236 * qualified names above, this is an error 235 * qualified names above, this is an error
237 */ 236 */
238 if (!pathname) { 237 if (!pathname) {
239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 238 ACPI_ERROR((AE_INFO,
240 "Both Handle and Pathname are NULL\n")); 239 "Both Handle and Pathname are NULL"));
241 } else { 240 } else {
242 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 241 ACPI_ERROR((AE_INFO,
243 "Handle is NULL and Pathname is relative\n")); 242 "Handle is NULL and Pathname is relative"));
244 } 243 }
245 244
246 status = AE_BAD_PARAMETER; 245 status = AE_BAD_PARAMETER;
@@ -399,7 +398,7 @@ acpi_walk_namespace(acpi_object_type type,
399 398
400 /* Parameter validation */ 399 /* Parameter validation */
401 400
402 if ((type > ACPI_TYPE_EXTERNAL_MAX) || (!max_depth) || (!user_function)) { 401 if ((type > ACPI_TYPE_LOCAL_MAX) || (!max_depth) || (!user_function)) {
403 return_ACPI_STATUS(AE_BAD_PARAMETER); 402 return_ACPI_STATUS(AE_BAD_PARAMETER);
404 } 403 }
405 404
@@ -473,8 +472,8 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
473 return (AE_CTRL_DEPTH); 472 return (AE_CTRL_DEPTH);
474 } 473 }
475 474
476 if (!(flags & 0x01)) { 475 if (!(flags & ACPI_STA_DEVICE_PRESENT)) {
477 /* Don't return at the device or children of the device if not there */ 476 /* Don't examine children of the device if not present */
478 477
479 return (AE_CTRL_DEPTH); 478 return (AE_CTRL_DEPTH);
480 } 479 }
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
index 6b5f8d4481d1..8cd8675a47c0 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/namespace/nsxfname.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -300,8 +300,7 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
300 300
301 status = acpi_ut_execute_CID(node, &cid_list); 301 status = acpi_ut_execute_CID(node, &cid_list);
302 if (ACPI_SUCCESS(status)) { 302 if (ACPI_SUCCESS(status)) {
303 size += ((acpi_size) cid_list->count - 1) * 303 size += cid_list->size;
304 sizeof(struct acpi_compatible_id);
305 info->valid |= ACPI_VALID_CID; 304 info->valid |= ACPI_VALID_CID;
306 } 305 }
307 306
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c
index 0856d42e6909..a0332595677a 100644
--- a/drivers/acpi/namespace/nsxfobj.c
+++ b/drivers/acpi/namespace/nsxfobj.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 20c9a37643c7..ac5bbaedac1b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -838,7 +838,7 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
838 static const int quantum_ms = 1000 / HZ; 838 static const int quantum_ms = 1000 / HZ;
839 839
840 ret = down_trylock(sem); 840 ret = down_trylock(sem);
841 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) { 841 for (i = timeout; (i > 0 && ret != 0); i -= quantum_ms) {
842 schedule_timeout_interruptible(1); 842 schedule_timeout_interruptible(1);
843 ret = down_trylock(sem); 843 ret = down_trylock(sem);
844 } 844 }
@@ -1060,13 +1060,11 @@ EXPORT_SYMBOL(max_cstate);
1060 * Acquire a spinlock. 1060 * Acquire a spinlock.
1061 * 1061 *
1062 * handle is a pointer to the spinlock_t. 1062 * handle is a pointer to the spinlock_t.
1063 * flags is *not* the result of save_flags - it is an ACPI-specific flag variable
1064 * that indicates whether we are at interrupt level.
1065 */ 1063 */
1066 1064
1067unsigned long acpi_os_acquire_lock(acpi_handle handle) 1065acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle)
1068{ 1066{
1069 unsigned long flags; 1067 acpi_cpu_flags flags;
1070 spin_lock_irqsave((spinlock_t *) handle, flags); 1068 spin_lock_irqsave((spinlock_t *) handle, flags);
1071 return flags; 1069 return flags;
1072} 1070}
@@ -1075,7 +1073,7 @@ unsigned long acpi_os_acquire_lock(acpi_handle handle)
1075 * Release a spinlock. See above. 1073 * Release a spinlock. See above.
1076 */ 1074 */
1077 1075
1078void acpi_os_release_lock(acpi_handle handle, unsigned long flags) 1076void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags)
1079{ 1077{
1080 spin_unlock_irqrestore((spinlock_t *) handle, flags); 1078 spin_unlock_irqrestore((spinlock_t *) handle, flags);
1081} 1079}
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c
index 5858188f94a6..de573be52718 100644
--- a/drivers/acpi/parser/psargs.c
+++ b/drivers/acpi/parser/psargs.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,7 @@
45#include <acpi/acparser.h> 45#include <acpi/acparser.h>
46#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
48#include <acpi/acdispat.h>
48 49
49#define _COMPONENT ACPI_PARSER 50#define _COMPONENT ACPI_PARSER
50ACPI_MODULE_NAME("psargs") 51ACPI_MODULE_NAME("psargs")
@@ -62,61 +63,51 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
62 * 63 *
63 * PARAMETERS: parser_state - Current parser state object 64 * PARAMETERS: parser_state - Current parser state object
64 * 65 *
65 * RETURN: Decoded package length. On completion, the AML pointer points 66 * RETURN: Decoded package length. On completion, the AML pointer points
66 * past the length byte or bytes. 67 * past the length byte or bytes.
67 * 68 *
68 * DESCRIPTION: Decode and return a package length field 69 * DESCRIPTION: Decode and return a package length field.
70 * Note: Largest package length is 28 bits, from ACPI specification
69 * 71 *
70 ******************************************************************************/ 72 ******************************************************************************/
71 73
72static u32 74static u32
73acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) 75acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
74{ 76{
75 u32 encoded_length; 77 u8 *aml = parser_state->aml;
76 u32 length = 0; 78 u32 package_length = 0;
79 acpi_native_uint byte_count;
80 u8 byte_zero_mask = 0x3F; /* Default [0:5] */
77 81
78 ACPI_FUNCTION_TRACE("ps_get_next_package_length"); 82 ACPI_FUNCTION_TRACE("ps_get_next_package_length");
79 83
80 encoded_length = (u32) ACPI_GET8(parser_state->aml); 84 /*
81 parser_state->aml++; 85 * Byte 0 bits [6:7] contain the number of additional bytes
82 86 * used to encode the package length, either 0,1,2, or 3
83 switch (encoded_length >> 6) { /* bits 6-7 contain encoding scheme */ 87 */
84 case 0: /* 1-byte encoding (bits 0-5) */ 88 byte_count = (aml[0] >> 6);
85 89 parser_state->aml += (byte_count + 1);
86 length = (encoded_length & 0x3F);
87 break;
88
89 case 1: /* 2-byte encoding (next byte + bits 0-3) */
90
91 length = ((ACPI_GET8(parser_state->aml) << 04) |
92 (encoded_length & 0x0F));
93 parser_state->aml++;
94 break;
95
96 case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */
97
98 length = ((ACPI_GET8(parser_state->aml + 1) << 12) |
99 (ACPI_GET8(parser_state->aml) << 04) |
100 (encoded_length & 0x0F));
101 parser_state->aml += 2;
102 break;
103 90
104 case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ 91 /* Get bytes 3, 2, 1 as needed */
105 92
106 length = ((ACPI_GET8(parser_state->aml + 2) << 20) | 93 while (byte_count) {
107 (ACPI_GET8(parser_state->aml + 1) << 12) | 94 /*
108 (ACPI_GET8(parser_state->aml) << 04) | 95 * Final bit positions for the package length bytes:
109 (encoded_length & 0x0F)); 96 * Byte3->[20:27]
110 parser_state->aml += 3; 97 * Byte2->[12:19]
111 break; 98 * Byte1->[04:11]
112 99 * Byte0->[00:03]
113 default: 100 */
101 package_length |= (aml[byte_count] << ((byte_count << 3) - 4));
114 102
115 /* Can't get here, only 2 bits / 4 cases */ 103 byte_zero_mask = 0x0F; /* Use bits [0:3] of byte 0 */
116 break; 104 byte_count--;
117 } 105 }
118 106
119 return_VALUE(length); 107 /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
108
109 package_length |= (aml[0] & byte_zero_mask);
110 return_UINT32(package_length);
120} 111}
121 112
122/******************************************************************************* 113/*******************************************************************************
@@ -135,16 +126,15 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
135u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state) 126u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state)
136{ 127{
137 u8 *start = parser_state->aml; 128 u8 *start = parser_state->aml;
138 acpi_native_uint length; 129 u32 package_length;
139 130
140 ACPI_FUNCTION_TRACE("ps_get_next_package_end"); 131 ACPI_FUNCTION_TRACE("ps_get_next_package_end");
141 132
142 /* Function below changes parser_state->Aml */ 133 /* Function below updates parser_state->Aml */
143 134
144 length = 135 package_length = acpi_ps_get_next_package_length(parser_state);
145 (acpi_native_uint) acpi_ps_get_next_package_length(parser_state);
146 136
147 return_PTR(start + length); /* end of package */ 137 return_PTR(start + package_length); /* end of package */
148} 138}
149 139
150/******************************************************************************* 140/*******************************************************************************
@@ -169,17 +159,15 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
169 159
170 ACPI_FUNCTION_TRACE("ps_get_next_namestring"); 160 ACPI_FUNCTION_TRACE("ps_get_next_namestring");
171 161
172 /* Handle multiple prefix characters */ 162 /* Point past any namestring prefix characters (backslash or carat) */
173
174 while (acpi_ps_is_prefix_char(ACPI_GET8(end))) {
175 /* Include prefix '\\' or '^' */
176 163
164 while (acpi_ps_is_prefix_char(*end)) {
177 end++; 165 end++;
178 } 166 }
179 167
180 /* Decode the path */ 168 /* Decode the path prefix character */
181 169
182 switch (ACPI_GET8(end)) { 170 switch (*end) {
183 case 0: 171 case 0:
184 172
185 /* null_name */ 173 /* null_name */
@@ -199,9 +187,9 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
199 187
200 case AML_MULTI_NAME_PREFIX_OP: 188 case AML_MULTI_NAME_PREFIX_OP:
201 189
202 /* Multiple name segments, 4 chars each */ 190 /* Multiple name segments, 4 chars each, count in next byte */
203 191
204 end += 2 + ((acpi_size) ACPI_GET8(end + 1) * ACPI_NAME_SIZE); 192 end += 2 + (*(end + 1) * ACPI_NAME_SIZE);
205 break; 193 break;
206 194
207 default: 195 default:
@@ -212,7 +200,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
212 break; 200 break;
213 } 201 }
214 202
215 parser_state->aml = (u8 *) end; 203 parser_state->aml = end;
216 return_PTR((char *)start); 204 return_PTR((char *)start);
217} 205}
218 206
@@ -224,7 +212,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
224 * Arg - Where the namepath will be stored 212 * Arg - Where the namepath will be stored
225 * arg_count - If the namepath points to a control method 213 * arg_count - If the namepath points to a control method
226 * the method's argument is returned here. 214 * the method's argument is returned here.
227 * method_call - Whether the namepath can possibly be the 215 * possible_method_call - Whether the namepath can possibly be the
228 * start of a method call 216 * start of a method call
229 * 217 *
230 * RETURN: Status 218 * RETURN: Status
@@ -240,11 +228,11 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
240acpi_status 228acpi_status
241acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, 229acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
242 struct acpi_parse_state *parser_state, 230 struct acpi_parse_state *parser_state,
243 union acpi_parse_object *arg, u8 method_call) 231 union acpi_parse_object *arg, u8 possible_method_call)
244{ 232{
245 char *path; 233 char *path;
246 union acpi_parse_object *name_op; 234 union acpi_parse_object *name_op;
247 acpi_status status = AE_OK; 235 acpi_status status;
248 union acpi_operand_object *method_desc; 236 union acpi_operand_object *method_desc;
249 struct acpi_namespace_node *node; 237 struct acpi_namespace_node *node;
250 union acpi_generic_state scope_info; 238 union acpi_generic_state scope_info;
@@ -252,115 +240,129 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
252 ACPI_FUNCTION_TRACE("ps_get_next_namepath"); 240 ACPI_FUNCTION_TRACE("ps_get_next_namepath");
253 241
254 path = acpi_ps_get_next_namestring(parser_state); 242 path = acpi_ps_get_next_namestring(parser_state);
243 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP);
255 244
256 /* Null path case is allowed */ 245 /* Null path case is allowed, just exit */
257 246
258 if (path) { 247 if (!path) {
259 /* 248 arg->common.value.name = path;
260 * Lookup the name in the internal namespace 249 return_ACPI_STATUS(AE_OK);
261 */ 250 }
262 scope_info.scope.node = NULL;
263 node = parser_state->start_node;
264 if (node) {
265 scope_info.scope.node = node;
266 }
267 251
268 /* 252 /* Setup search scope info */
269 * Lookup object. We don't want to add anything new to the namespace
270 * here, however. So we use MODE_EXECUTE. Allow searching of the
271 * parent tree, but don't open a new scope -- we just want to lookup the
272 * object (MUST BE mode EXECUTE to perform upsearch)
273 */
274 status = acpi_ns_lookup(&scope_info, path, ACPI_TYPE_ANY,
275 ACPI_IMODE_EXECUTE,
276 ACPI_NS_SEARCH_PARENT |
277 ACPI_NS_DONT_OPEN_SCOPE, NULL, &node);
278 if (ACPI_SUCCESS(status) && method_call) {
279 if (node->type == ACPI_TYPE_METHOD) {
280 /* This name is actually a control method invocation */
281
282 method_desc = acpi_ns_get_attached_object(node);
283 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
284 "Control Method - %p Desc %p Path=%p\n",
285 node, method_desc, path));
286
287 name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
288 if (!name_op) {
289 return_ACPI_STATUS(AE_NO_MEMORY);
290 }
291 253
292 /* Change arg into a METHOD CALL and attach name to it */ 254 scope_info.scope.node = NULL;
255 node = parser_state->start_node;
256 if (node) {
257 scope_info.scope.node = node;
258 }
293 259
294 acpi_ps_init_op(arg, AML_INT_METHODCALL_OP); 260 /*
295 name_op->common.value.name = path; 261 * Lookup the name in the internal namespace. We don't want to add
262 * anything new to the namespace here, however, so we use MODE_EXECUTE.
263 * Allow searching of the parent tree, but don't open a new scope -
264 * we just want to lookup the object (must be mode EXECUTE to perform
265 * the upsearch)
266 */
267 status =
268 acpi_ns_lookup(&scope_info, path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
269 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
270 NULL, &node);
296 271
297 /* Point METHODCALL/NAME to the METHOD Node */ 272 /*
273 * If this name is a control method invocation, we must
274 * setup the method call
275 */
276 if (ACPI_SUCCESS(status) &&
277 possible_method_call && (node->type == ACPI_TYPE_METHOD)) {
278 /* This name is actually a control method invocation */
298 279
299 name_op->common.node = node; 280 method_desc = acpi_ns_get_attached_object(node);
300 acpi_ps_append_arg(arg, name_op); 281 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
282 "Control Method - %p Desc %p Path=%p\n", node,
283 method_desc, path));
301 284
302 if (!method_desc) { 285 name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP);
303 ACPI_REPORT_ERROR(("ps_get_next_namepath: Control Method %p has no attached object\n", node)); 286 if (!name_op) {
304 return_ACPI_STATUS(AE_AML_INTERNAL); 287 return_ACPI_STATUS(AE_NO_MEMORY);
305 } 288 }
306 289
307 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 290 /* Change Arg into a METHOD CALL and attach name to it */
308 "Control Method - %p Args %X\n",
309 node,
310 method_desc->method.
311 param_count));
312 291
313 /* Get the number of arguments to expect */ 292 acpi_ps_init_op(arg, AML_INT_METHODCALL_OP);
293 name_op->common.value.name = path;
314 294
315 walk_state->arg_count = 295 /* Point METHODCALL/NAME to the METHOD Node */
316 method_desc->method.param_count;
317 return_ACPI_STATUS(AE_OK);
318 }
319 296
320 /* 297 name_op->common.node = node;
321 * Else this is normal named object reference. 298 acpi_ps_append_arg(arg, name_op);
322 * Just init the NAMEPATH object with the pathname.
323 * (See code below)
324 */
325 }
326 299
327 if (ACPI_FAILURE(status)) { 300 if (!method_desc) {
328 /* 301 ACPI_ERROR((AE_INFO,
329 * 1) Any error other than NOT_FOUND is always severe 302 "Control Method %p has no attached object",
330 * 2) NOT_FOUND is only important if we are executing a method. 303 node));
331 * 3) If executing a cond_ref_of opcode, NOT_FOUND is ok. 304 return_ACPI_STATUS(AE_AML_INTERNAL);
332 */
333 if ((((walk_state->
334 parse_flags & ACPI_PARSE_MODE_MASK) ==
335 ACPI_PARSE_EXECUTE) && (status == AE_NOT_FOUND)
336 && (walk_state->op->common.aml_opcode !=
337 AML_COND_REF_OF_OP))
338 || (status != AE_NOT_FOUND)) {
339 ACPI_REPORT_NSERROR(path, status);
340
341 acpi_os_printf
342 ("search_node %p start_node %p return_node %p\n",
343 scope_info.scope.node,
344 parser_state->start_node, node);
345
346 } else {
347 /*
348 * We got a NOT_FOUND during table load or we encountered
349 * a cond_ref_of(x) where the target does not exist.
350 * Either case is ok
351 */
352 status = AE_OK;
353 }
354 } 305 }
306
307 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
308 "Control Method - %p Args %X\n",
309 node, method_desc->method.param_count));
310
311 /* Get the number of arguments to expect */
312
313 walk_state->arg_count = method_desc->method.param_count;
314 return_ACPI_STATUS(AE_OK);
355 } 315 }
356 316
357 /* 317 /*
358 * Regardless of success/failure above, 318 * Special handling if the name was not found during the lookup -
359 * Just initialize the Op with the pathname. 319 * some not_found cases are allowed
360 */ 320 */
361 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); 321 if (status == AE_NOT_FOUND) {
362 arg->common.value.name = path; 322 /* 1) not_found is ok during load pass 1/2 (allow forward references) */
323
324 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) !=
325 ACPI_PARSE_EXECUTE) {
326 status = AE_OK;
327 }
328
329 /* 2) not_found during a cond_ref_of(x) is ok by definition */
330
331 else if (walk_state->op->common.aml_opcode ==
332 AML_COND_REF_OF_OP) {
333 status = AE_OK;
334 }
335
336 /*
337 * 3) not_found while building a Package is ok at this point, we
338 * may flag as an error later if slack mode is not enabled.
339 * (Some ASL code depends on allowing this behavior)
340 */
341 else if ((arg->common.parent) &&
342 ((arg->common.parent->common.aml_opcode ==
343 AML_PACKAGE_OP)
344 || (arg->common.parent->common.aml_opcode ==
345 AML_VAR_PACKAGE_OP))) {
346 status = AE_OK;
347 }
348 }
349
350 /* Final exception check (may have been changed from code above) */
363 351
352 if (ACPI_FAILURE(status)) {
353 ACPI_ERROR_NAMESPACE(path, status);
354
355 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
356 ACPI_PARSE_EXECUTE) {
357 /* Report a control method execution error */
358
359 status = acpi_ds_method_error(status, walk_state);
360 }
361 }
362
363 /* Save the namepath */
364
365 arg->common.value.name = path;
364 return_ACPI_STATUS(status); 366 return_ACPI_STATUS(status);
365} 367}
366 368
@@ -382,59 +384,63 @@ void
382acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, 384acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
383 u32 arg_type, union acpi_parse_object *arg) 385 u32 arg_type, union acpi_parse_object *arg)
384{ 386{
387 u32 length;
388 u16 opcode;
389 u8 *aml = parser_state->aml;
385 390
386 ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type); 391 ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type);
387 392
388 switch (arg_type) { 393 switch (arg_type) {
389 case ARGP_BYTEDATA: 394 case ARGP_BYTEDATA:
390 395
391 acpi_ps_init_op(arg, AML_BYTE_OP); 396 /* Get 1 byte from the AML stream */
392 arg->common.value.integer = (u32) ACPI_GET8(parser_state->aml); 397
393 parser_state->aml++; 398 opcode = AML_BYTE_OP;
399 arg->common.value.integer = (acpi_integer) * aml;
400 length = 1;
394 break; 401 break;
395 402
396 case ARGP_WORDDATA: 403 case ARGP_WORDDATA:
397 404
398 acpi_ps_init_op(arg, AML_WORD_OP);
399
400 /* Get 2 bytes from the AML stream */ 405 /* Get 2 bytes from the AML stream */
401 406
402 ACPI_MOVE_16_TO_32(&arg->common.value.integer, 407 opcode = AML_WORD_OP;
403 parser_state->aml); 408 ACPI_MOVE_16_TO_64(&arg->common.value.integer, aml);
404 parser_state->aml += 2; 409 length = 2;
405 break; 410 break;
406 411
407 case ARGP_DWORDDATA: 412 case ARGP_DWORDDATA:
408 413
409 acpi_ps_init_op(arg, AML_DWORD_OP);
410
411 /* Get 4 bytes from the AML stream */ 414 /* Get 4 bytes from the AML stream */
412 415
413 ACPI_MOVE_32_TO_32(&arg->common.value.integer, 416 opcode = AML_DWORD_OP;
414 parser_state->aml); 417 ACPI_MOVE_32_TO_64(&arg->common.value.integer, aml);
415 parser_state->aml += 4; 418 length = 4;
416 break; 419 break;
417 420
418 case ARGP_QWORDDATA: 421 case ARGP_QWORDDATA:
419 422
420 acpi_ps_init_op(arg, AML_QWORD_OP);
421
422 /* Get 8 bytes from the AML stream */ 423 /* Get 8 bytes from the AML stream */
423 424
424 ACPI_MOVE_64_TO_64(&arg->common.value.integer, 425 opcode = AML_QWORD_OP;
425 parser_state->aml); 426 ACPI_MOVE_64_TO_64(&arg->common.value.integer, aml);
426 parser_state->aml += 8; 427 length = 8;
427 break; 428 break;
428 429
429 case ARGP_CHARLIST: 430 case ARGP_CHARLIST:
430 431
431 acpi_ps_init_op(arg, AML_STRING_OP); 432 /* Get a pointer to the string, point past the string */
432 arg->common.value.string = (char *)parser_state->aml; 433
434 opcode = AML_STRING_OP;
435 arg->common.value.string = ACPI_CAST_PTR(char, aml);
433 436
434 while (ACPI_GET8(parser_state->aml) != '\0') { 437 /* Find the null terminator */
435 parser_state->aml++; 438
439 length = 0;
440 while (aml[length]) {
441 length++;
436 } 442 }
437 parser_state->aml++; 443 length++;
438 break; 444 break;
439 445
440 case ARGP_NAME: 446 case ARGP_NAME:
@@ -443,14 +449,16 @@ acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
443 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); 449 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP);
444 arg->common.value.name = 450 arg->common.value.name =
445 acpi_ps_get_next_namestring(parser_state); 451 acpi_ps_get_next_namestring(parser_state);
446 break; 452 return_VOID;
447 453
448 default: 454 default:
449 455
450 ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type)); 456 ACPI_ERROR((AE_INFO, "Invalid arg_type %X", arg_type));
451 break; 457 return_VOID;
452 } 458 }
453 459
460 acpi_ps_init_op(arg, opcode);
461 parser_state->aml += length;
454 return_VOID; 462 return_VOID;
455} 463}
456 464
@@ -540,7 +548,7 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
540 * access_type is first operand, access_attribute is second 548 * access_type is first operand, access_attribute is second
541 */ 549 */
542 field->common.value.integer = 550 field->common.value.integer =
543 (ACPI_GET8(parser_state->aml) << 8); 551 (((u32) ACPI_GET8(parser_state->aml) << 8));
544 parser_state->aml++; 552 parser_state->aml++;
545 field->common.value.integer |= ACPI_GET8(parser_state->aml); 553 field->common.value.integer |= ACPI_GET8(parser_state->aml);
546 parser_state->aml++; 554 parser_state->aml++;
@@ -703,7 +711,7 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
703 711
704 default: 712 default:
705 713
706 ACPI_REPORT_ERROR(("Invalid arg_type: %X\n", arg_type)); 714 ACPI_ERROR((AE_INFO, "Invalid arg_type: %X", arg_type));
707 status = AE_AML_OPERAND_TYPE; 715 status = AE_AML_OPERAND_TYPE;
708 break; 716 break;
709 } 717 }
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c
index 088d33999d90..00b072e15d19 100644
--- a/drivers/acpi/parser/psloop.c
+++ b/drivers/acpi/parser/psloop.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -123,16 +123,12 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
123 && ((status & AE_CODE_MASK) != 123 && ((status & AE_CODE_MASK) !=
124 AE_CODE_CONTROL)) { 124 AE_CODE_CONTROL)) {
125 if (status == AE_AML_NO_RETURN_VALUE) { 125 if (status == AE_AML_NO_RETURN_VALUE) {
126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 126 ACPI_EXCEPTION((AE_INFO, status,
127 "Invoked method did not return a value, %s\n", 127 "Invoked method did not return a value"));
128 acpi_format_exception
129 (status)));
130 128
131 } 129 }
132 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 130 ACPI_EXCEPTION((AE_INFO, status,
133 "get_predicate Failed, %s\n", 131 "get_predicate Failed"));
134 acpi_format_exception
135 (status)));
136 return_ACPI_STATUS(status); 132 return_ACPI_STATUS(status);
137 } 133 }
138 134
@@ -190,11 +186,11 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
190 186
191 /* The opcode is unrecognized. Just skip unknown opcodes */ 187 /* The opcode is unrecognized. Just skip unknown opcodes */
192 188
193 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 189 ACPI_ERROR((AE_INFO,
194 "Found unknown opcode %X at AML address %p offset %X, ignoring\n", 190 "Found unknown opcode %X at AML address %p offset %X, ignoring",
195 walk_state->opcode, 191 walk_state->opcode,
196 parser_state->aml, 192 parser_state->aml,
197 walk_state->aml_offset)); 193 walk_state->aml_offset));
198 194
199 ACPI_DUMP_BUFFER(parser_state->aml, 128); 195 ACPI_DUMP_BUFFER(parser_state->aml, 128);
200 196
@@ -281,10 +277,8 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
281 walk_state->descending_callback(walk_state, 277 walk_state->descending_callback(walk_state,
282 &op); 278 &op);
283 if (ACPI_FAILURE(status)) { 279 if (ACPI_FAILURE(status)) {
284 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 280 ACPI_EXCEPTION((AE_INFO, status,
285 "During name lookup/catalog, %s\n", 281 "During name lookup/catalog"));
286 acpi_format_exception
287 (status)));
288 goto close_this_op; 282 goto close_this_op;
289 } 283 }
290 284
@@ -704,6 +698,15 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
704 acpi_ps_pop_scope(parser_state, &op, 698 acpi_ps_pop_scope(parser_state, &op,
705 &walk_state->arg_types, 699 &walk_state->arg_types,
706 &walk_state->arg_count); 700 &walk_state->arg_count);
701
702 if (op->common.aml_opcode != AML_WHILE_OP) {
703 status2 =
704 acpi_ds_result_stack_pop
705 (walk_state);
706 if (ACPI_FAILURE(status2)) {
707 return_ACPI_STATUS(status2);
708 }
709 }
707 } 710 }
708 711
709 /* Close this iteration of the While loop */ 712 /* Close this iteration of the While loop */
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c
index 229ae86afe8b..11d6351ab8b2 100644
--- a/drivers/acpi/parser/psopcode.c
+++ b/drivers/acpi/parser/psopcode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -747,7 +747,7 @@ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
747 747
748 /* Unknown AML opcode */ 748 /* Unknown AML opcode */
749 749
750 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 750 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
751 "Unknown AML opcode [%4.4X]\n", opcode)); 751 "Unknown AML opcode [%4.4X]\n", opcode));
752 752
753 return (&acpi_gbl_aml_op_info[_UNK]); 753 return (&acpi_gbl_aml_op_info[_UNK]);
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index 76d4d640d83c..a9f3229f4106 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -333,7 +333,6 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
333 333
334 switch (callback_status) { 334 switch (callback_status) {
335 case AE_CTRL_TERMINATE: 335 case AE_CTRL_TERMINATE:
336
337 /* 336 /*
338 * A control method was terminated via a RETURN statement. 337 * A control method was terminated via a RETURN statement.
339 * The walk of this method is complete. 338 * The walk of this method is complete.
@@ -346,13 +345,19 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
346 345
347 parser_state->aml = walk_state->aml_last_while; 346 parser_state->aml = walk_state->aml_last_while;
348 walk_state->control_state->common.value = FALSE; 347 walk_state->control_state->common.value = FALSE;
349 status = AE_CTRL_BREAK; 348 status = acpi_ds_result_stack_pop(walk_state);
349 if (ACPI_SUCCESS(status)) {
350 status = AE_CTRL_BREAK;
351 }
350 break; 352 break;
351 353
352 case AE_CTRL_CONTINUE: 354 case AE_CTRL_CONTINUE:
353 355
354 parser_state->aml = walk_state->aml_last_while; 356 parser_state->aml = walk_state->aml_last_while;
355 status = AE_CTRL_CONTINUE; 357 status = acpi_ds_result_stack_pop(walk_state);
358 if (ACPI_SUCCESS(status)) {
359 status = AE_CTRL_CONTINUE;
360 }
356 break; 361 break;
357 362
358 case AE_CTRL_PENDING: 363 case AE_CTRL_PENDING:
@@ -369,16 +374,18 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
369#endif 374#endif
370 375
371 case AE_CTRL_TRUE: 376 case AE_CTRL_TRUE:
372
373 /* 377 /*
374 * Predicate of an IF was true, and we are at the matching ELSE. 378 * Predicate of an IF was true, and we are at the matching ELSE.
375 * Just close out this package 379 * Just close out this package
376 */ 380 */
377 parser_state->aml = acpi_ps_get_next_package_end(parser_state); 381 parser_state->aml = acpi_ps_get_next_package_end(parser_state);
382 status = acpi_ds_result_stack_pop(walk_state);
383 if (ACPI_SUCCESS(status)) {
384 status = AE_CTRL_PENDING;
385 }
378 break; 386 break;
379 387
380 case AE_CTRL_FALSE: 388 case AE_CTRL_FALSE:
381
382 /* 389 /*
383 * Either an IF/WHILE Predicate was false or we encountered a BREAK 390 * Either an IF/WHILE Predicate was false or we encountered a BREAK
384 * opcode. In both cases, we do not execute the rest of the 391 * opcode. In both cases, we do not execute the rest of the
@@ -503,22 +510,23 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
503 } else if (status == AE_CTRL_TERMINATE) { 510 } else if (status == AE_CTRL_TERMINATE) {
504 status = AE_OK; 511 status = AE_OK;
505 } else if ((status != AE_OK) && (walk_state->method_desc)) { 512 } else if ((status != AE_OK) && (walk_state->method_desc)) {
506 ACPI_REPORT_METHOD_ERROR("Method execution failed", 513 /* Either the method parse or actual execution failed */
507 walk_state->method_node, NULL,
508 status);
509
510 /* Ensure proper cleanup */
511 514
512 walk_state->parse_flags |= ACPI_PARSE_EXECUTE; 515 ACPI_ERROR_METHOD("Method parse/execution failed",
516 walk_state->method_node, NULL,
517 status);
513 518
514 /* Check for possible multi-thread reentrancy problem */ 519 /* Check for possible multi-thread reentrancy problem */
515 520
516 if ((status == AE_ALREADY_EXISTS) && 521 if ((status == AE_ALREADY_EXISTS) &&
517 (!walk_state->method_desc->method.semaphore)) { 522 (!walk_state->method_desc->method.semaphore)) {
518 /* 523 /*
519 * This method is marked not_serialized, but it tried to create 524 * Method tried to create an object twice. The probable cause is
525 * that the method cannot handle reentrancy.
526 *
527 * The method is marked not_serialized, but it tried to create
520 * a named object, causing the second thread entrance to fail. 528 * a named object, causing the second thread entrance to fail.
521 * We will workaround this by marking the method permanently 529 * Workaround this problem by marking the method permanently
522 * as Serialized. 530 * as Serialized.
523 */ 531 */
524 walk_state->method_desc->method.method_flags |= 532 walk_state->method_desc->method.method_flags |=
@@ -536,15 +544,23 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
536 acpi_ds_scope_stack_clear(walk_state); 544 acpi_ds_scope_stack_clear(walk_state);
537 545
538 /* 546 /*
539 * If we just returned from the execution of a control method, 547 * If we just returned from the execution of a control method or if we
540 * there's lots of cleanup to do 548 * encountered an error during the method parse phase, there's lots of
549 * cleanup to do
541 */ 550 */
542 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == 551 if (((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
543 ACPI_PARSE_EXECUTE) { 552 ACPI_PARSE_EXECUTE) || (ACPI_FAILURE(status))) {
544 if (walk_state->method_desc) { 553 if (walk_state->method_desc) {
545 /* Decrement the thread count on the method parse tree */ 554 /* Decrement the thread count on the method parse tree */
546 555
547 walk_state->method_desc->method.thread_count--; 556 if (walk_state->method_desc->method.
557 thread_count) {
558 walk_state->method_desc->method.
559 thread_count--;
560 } else {
561 ACPI_ERROR((AE_INFO,
562 "Invalid zero thread count in method"));
563 }
548 } 564 }
549 565
550 acpi_ds_terminate_control_method(walk_state); 566 acpi_ds_terminate_control_method(walk_state);
@@ -553,7 +569,6 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
553 /* Delete this walk state and all linked control states */ 569 /* Delete this walk state and all linked control states */
554 570
555 acpi_ps_cleanup_scope(&walk_state->parser_state); 571 acpi_ps_cleanup_scope(&walk_state->parser_state);
556
557 previous_walk_state = walk_state; 572 previous_walk_state = walk_state;
558 573
559 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 574 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c
index 1c953b6f1af1..bc6047caccd9 100644
--- a/drivers/acpi/parser/psscope.c
+++ b/drivers/acpi/parser/psscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c
index f0e755884eea..dd6f16726fc4 100644
--- a/drivers/acpi/parser/pstree.c
+++ b/drivers/acpi/parser/pstree.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -132,7 +132,8 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg)
132 if (op_info->class == AML_CLASS_UNKNOWN) { 132 if (op_info->class == AML_CLASS_UNKNOWN) {
133 /* Invalid opcode */ 133 /* Invalid opcode */
134 134
135 ACPI_REPORT_ERROR(("ps_append_arg: Invalid AML Opcode: 0x%2.2X\n", op->common.aml_opcode)); 135 ACPI_ERROR((AE_INFO, "Invalid AML Opcode: 0x%2.2X",
136 op->common.aml_opcode));
136 return; 137 return;
137 } 138 }
138 139
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c
index 2075efbb4324..3e07cb9cb748 100644
--- a/drivers/acpi/parser/psutils.c
+++ b/drivers/acpi/parser/psutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c
index 08f2321b6ded..06f05bfd7612 100644
--- a/drivers/acpi/parser/pswalk.c
+++ b/drivers/acpi/parser/pswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c
index 4dcbd443160e..2dd48cbb7c02 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/parser/psxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -50,6 +50,10 @@
50ACPI_MODULE_NAME("psxface") 50ACPI_MODULE_NAME("psxface")
51 51
52/* Local Prototypes */ 52/* Local Prototypes */
53static void acpi_ps_start_trace(struct acpi_parameter_info *info);
54
55static void acpi_ps_stop_trace(struct acpi_parameter_info *info);
56
53static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info); 57static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info);
54 58
55static void 59static void
@@ -57,6 +61,136 @@ acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action);
57 61
58/******************************************************************************* 62/*******************************************************************************
59 * 63 *
64 * FUNCTION: acpi_debug_trace
65 *
66 * PARAMETERS: method_name - Valid ACPI name string
67 * debug_level - Optional level mask. 0 to use default
68 * debug_layer - Optional layer mask. 0 to use default
69 * Flags - bit 1: one shot(1) or persistent(0)
70 *
71 * RETURN: Status
72 *
73 * DESCRIPTION: External interface to enable debug tracing during control
74 * method execution
75 *
76 ******************************************************************************/
77
78acpi_status
79acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags)
80{
81 acpi_status status;
82
83 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
84 if (ACPI_FAILURE(status)) {
85 return (status);
86 }
87
88 /* TBDs: Validate name, allow full path or just nameseg */
89
90 acpi_gbl_trace_method_name = *ACPI_CAST_PTR(u32, name);
91 acpi_gbl_trace_flags = flags;
92
93 if (debug_level) {
94 acpi_gbl_trace_dbg_level = debug_level;
95 }
96 if (debug_layer) {
97 acpi_gbl_trace_dbg_layer = debug_layer;
98 }
99
100 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
101 return (AE_OK);
102}
103
104/*******************************************************************************
105 *
106 * FUNCTION: acpi_ps_start_trace
107 *
108 * PARAMETERS: Info - Method info struct
109 *
110 * RETURN: None
111 *
112 * DESCRIPTION: Start control method execution trace
113 *
114 ******************************************************************************/
115
116static void acpi_ps_start_trace(struct acpi_parameter_info *info)
117{
118 acpi_status status;
119
120 ACPI_FUNCTION_ENTRY();
121
122 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
123 if (ACPI_FAILURE(status)) {
124 return;
125 }
126
127 if ((!acpi_gbl_trace_method_name) ||
128 (acpi_gbl_trace_method_name != info->node->name.integer)) {
129 goto exit;
130 }
131
132 acpi_gbl_original_dbg_level = acpi_dbg_level;
133 acpi_gbl_original_dbg_layer = acpi_dbg_layer;
134
135 acpi_dbg_level = 0x00FFFFFF;
136 acpi_dbg_layer = ACPI_UINT32_MAX;
137
138 if (acpi_gbl_trace_dbg_level) {
139 acpi_dbg_level = acpi_gbl_trace_dbg_level;
140 }
141 if (acpi_gbl_trace_dbg_layer) {
142 acpi_dbg_layer = acpi_gbl_trace_dbg_layer;
143 }
144
145 exit:
146 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
147}
148
149/*******************************************************************************
150 *
151 * FUNCTION: acpi_ps_stop_trace
152 *
153 * PARAMETERS: Info - Method info struct
154 *
155 * RETURN: None
156 *
157 * DESCRIPTION: Stop control method execution trace
158 *
159 ******************************************************************************/
160
161static void acpi_ps_stop_trace(struct acpi_parameter_info *info)
162{
163 acpi_status status;
164
165 ACPI_FUNCTION_ENTRY();
166
167 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
168 if (ACPI_FAILURE(status)) {
169 return;
170 }
171
172 if ((!acpi_gbl_trace_method_name) ||
173 (acpi_gbl_trace_method_name != info->node->name.integer)) {
174 goto exit;
175 }
176
177 /* Disable further tracing if type is one-shot */
178
179 if (acpi_gbl_trace_flags & 1) {
180 acpi_gbl_trace_method_name = 0;
181 acpi_gbl_trace_dbg_level = 0;
182 acpi_gbl_trace_dbg_layer = 0;
183 }
184
185 acpi_dbg_level = acpi_gbl_original_dbg_level;
186 acpi_dbg_layer = acpi_gbl_original_dbg_layer;
187
188 exit:
189 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
190}
191
192/*******************************************************************************
193 *
60 * FUNCTION: acpi_ps_execute_method 194 * FUNCTION: acpi_ps_execute_method
61 * 195 *
62 * PARAMETERS: Info - Method info block, contains: 196 * PARAMETERS: Info - Method info block, contains:
@@ -104,6 +238,10 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info)
104 */ 238 */
105 acpi_ps_update_parameter_list(info, REF_INCREMENT); 239 acpi_ps_update_parameter_list(info, REF_INCREMENT);
106 240
241 /* Begin tracing if requested */
242
243 acpi_ps_start_trace(info);
244
107 /* 245 /*
108 * 1) Perform the first pass parse of the method to enter any 246 * 1) Perform the first pass parse of the method to enter any
109 * named objects that it creates into the namespace 247 * named objects that it creates into the namespace
@@ -129,6 +267,10 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info)
129 status = acpi_ps_execute_pass(info); 267 status = acpi_ps_execute_pass(info);
130 268
131 cleanup: 269 cleanup:
270 /* End optional tracing */
271
272 acpi_ps_stop_trace(info);
273
132 /* Take away the extra reference that we gave the parameters above */ 274 /* Take away the extra reference that we gave the parameters above */
133 275
134 acpi_ps_update_parameter_list(info, REF_DECREMENT); 276 acpi_ps_update_parameter_list(info, REF_DECREMENT);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index e567c03b238e..65aee79b3971 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -258,7 +258,7 @@ typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **);
258 258
259static int 259static int
260acpi_pci_allocate_irq(struct acpi_prt_entry *entry, 260acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
261 int *edge_level, int *active_high_low, char **link) 261 int *triggering, int *polarity, char **link)
262{ 262{
263 int irq; 263 int irq;
264 264
@@ -266,8 +266,8 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
266 266
267 if (entry->link.handle) { 267 if (entry->link.handle) {
268 irq = acpi_pci_link_allocate_irq(entry->link.handle, 268 irq = acpi_pci_link_allocate_irq(entry->link.handle,
269 entry->link.index, edge_level, 269 entry->link.index, triggering,
270 active_high_low, link); 270 polarity, link);
271 if (irq < 0) { 271 if (irq < 0) {
272 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 272 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
273 "Invalid IRQ link routing entry\n")); 273 "Invalid IRQ link routing entry\n"));
@@ -275,8 +275,8 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
275 } 275 }
276 } else { 276 } else {
277 irq = entry->link.index; 277 irq = entry->link.index;
278 *edge_level = ACPI_LEVEL_SENSITIVE; 278 *triggering = ACPI_LEVEL_SENSITIVE;
279 *active_high_low = ACPI_ACTIVE_LOW; 279 *polarity = ACPI_ACTIVE_LOW;
280 } 280 }
281 281
282 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq)); 282 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
@@ -285,7 +285,7 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
285 285
286static int 286static int
287acpi_pci_free_irq(struct acpi_prt_entry *entry, 287acpi_pci_free_irq(struct acpi_prt_entry *entry,
288 int *edge_level, int *active_high_low, char **link) 288 int *triggering, int *polarity, char **link)
289{ 289{
290 int irq; 290 int irq;
291 291
@@ -307,8 +307,8 @@ static int
307acpi_pci_irq_lookup(struct pci_bus *bus, 307acpi_pci_irq_lookup(struct pci_bus *bus,
308 int device, 308 int device,
309 int pin, 309 int pin,
310 int *edge_level, 310 int *triggering,
311 int *active_high_low, char **link, irq_lookup_func func) 311 int *polarity, char **link, irq_lookup_func func)
312{ 312{
313 struct acpi_prt_entry *entry = NULL; 313 struct acpi_prt_entry *entry = NULL;
314 int segment = pci_domain_nr(bus); 314 int segment = pci_domain_nr(bus);
@@ -327,7 +327,7 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
327 return_VALUE(-1); 327 return_VALUE(-1);
328 } 328 }
329 329
330 ret = func(entry, edge_level, active_high_low, link); 330 ret = func(entry, triggering, polarity, link);
331 return_VALUE(ret); 331 return_VALUE(ret);
332} 332}
333 333
@@ -339,8 +339,8 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
339static int 339static int
340acpi_pci_irq_derive(struct pci_dev *dev, 340acpi_pci_irq_derive(struct pci_dev *dev,
341 int pin, 341 int pin,
342 int *edge_level, 342 int *triggering,
343 int *active_high_low, char **link, irq_lookup_func func) 343 int *polarity, char **link, irq_lookup_func func)
344{ 344{
345 struct pci_dev *bridge = dev; 345 struct pci_dev *bridge = dev;
346 int irq = -1; 346 int irq = -1;
@@ -374,7 +374,7 @@ acpi_pci_irq_derive(struct pci_dev *dev,
374 } 374 }
375 375
376 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), 376 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn),
377 pin, edge_level, active_high_low, 377 pin, triggering, polarity,
378 link, func); 378 link, func);
379 } 379 }
380 380
@@ -401,8 +401,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
401{ 401{
402 int irq = 0; 402 int irq = 0;
403 u8 pin = 0; 403 u8 pin = 0;
404 int edge_level = ACPI_LEVEL_SENSITIVE; 404 int triggering = ACPI_LEVEL_SENSITIVE;
405 int active_high_low = ACPI_ACTIVE_LOW; 405 int polarity = ACPI_ACTIVE_LOW;
406 char *link = NULL; 406 char *link = NULL;
407 int rc; 407 int rc;
408 408
@@ -431,7 +431,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
431 * values override any BIOS-assigned IRQs set during boot. 431 * values override any BIOS-assigned IRQs set during boot.
432 */ 432 */
433 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 433 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
434 &edge_level, &active_high_low, &link, 434 &triggering, &polarity, &link,
435 acpi_pci_allocate_irq); 435 acpi_pci_allocate_irq);
436 436
437 /* 437 /*
@@ -439,8 +439,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
439 * device's parent bridge. 439 * device's parent bridge.
440 */ 440 */
441 if (irq < 0) 441 if (irq < 0)
442 irq = acpi_pci_irq_derive(dev, pin, &edge_level, 442 irq = acpi_pci_irq_derive(dev, pin, &triggering,
443 &active_high_low, &link, 443 &polarity, &link,
444 acpi_pci_allocate_irq); 444 acpi_pci_allocate_irq);
445 445
446 /* 446 /*
@@ -462,7 +462,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
462 } 462 }
463 } 463 }
464 464
465 rc = acpi_register_gsi(irq, edge_level, active_high_low); 465 rc = acpi_register_gsi(irq, triggering, polarity);
466 if (rc < 0) { 466 if (rc < 0) {
467 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " 467 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed "
468 "to register GSI\n", pci_name(dev), ('A' + pin)); 468 "to register GSI\n", pci_name(dev), ('A' + pin));
@@ -477,8 +477,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
477 printk("Link [%s] -> ", link); 477 printk("Link [%s] -> ", link);
478 478
479 printk("GSI %u (%s, %s) -> IRQ %d\n", irq, 479 printk("GSI %u (%s, %s) -> IRQ %d\n", irq,
480 (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 480 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
481 (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 481 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
482 482
483 return_VALUE(0); 483 return_VALUE(0);
484} 484}
@@ -494,8 +494,8 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
494{ 494{
495 int gsi = 0; 495 int gsi = 0;
496 u8 pin = 0; 496 u8 pin = 0;
497 int edge_level = ACPI_LEVEL_SENSITIVE; 497 int triggering = ACPI_LEVEL_SENSITIVE;
498 int active_high_low = ACPI_ACTIVE_LOW; 498 int polarity = ACPI_ACTIVE_LOW;
499 499
500 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); 500 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable");
501 501
@@ -511,7 +511,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
511 * First we check the PCI IRQ routing table (PRT) for an IRQ. 511 * First we check the PCI IRQ routing table (PRT) for an IRQ.
512 */ 512 */
513 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 513 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
514 &edge_level, &active_high_low, NULL, 514 &triggering, &polarity, NULL,
515 acpi_pci_free_irq); 515 acpi_pci_free_irq);
516 /* 516 /*
517 * If no PRT entry was found, we'll try to derive an IRQ from the 517 * If no PRT entry was found, we'll try to derive an IRQ from the
@@ -519,7 +519,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
519 */ 519 */
520 if (gsi < 0) 520 if (gsi < 0)
521 gsi = acpi_pci_irq_derive(dev, pin, 521 gsi = acpi_pci_irq_derive(dev, pin,
522 &edge_level, &active_high_low, NULL, 522 &triggering, &polarity, NULL,
523 acpi_pci_free_irq); 523 acpi_pci_free_irq);
524 if (gsi < 0) 524 if (gsi < 0)
525 return_VOID; 525 return_VOID;
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 78927c0f1551..07bc6dfe662b 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -70,8 +70,8 @@ static struct acpi_driver acpi_pci_link_driver = {
70 */ 70 */
71struct acpi_pci_link_irq { 71struct acpi_pci_link_irq {
72 u8 active; /* Current IRQ */ 72 u8 active; /* Current IRQ */
73 u8 edge_level; /* All IRQs */ 73 u8 triggering; /* All IRQs */
74 u8 active_high_low; /* All IRQs */ 74 u8 polarity; /* All IRQs */
75 u8 resource_type; 75 u8 resource_type;
76 u8 possible_count; 76 u8 possible_count;
77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; 77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
@@ -108,19 +108,19 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
108 108
109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible"); 109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
110 110
111 switch (resource->id) { 111 switch (resource->type) {
112 case ACPI_RSTYPE_START_DPF: 112 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
113 return_ACPI_STATUS(AE_OK); 113 return_ACPI_STATUS(AE_OK);
114 case ACPI_RSTYPE_IRQ: 114 case ACPI_RESOURCE_TYPE_IRQ:
115 { 115 {
116 struct acpi_resource_irq *p = &resource->data.irq; 116 struct acpi_resource_irq *p = &resource->data.irq;
117 if (!p || !p->number_of_interrupts) { 117 if (!p || !p->interrupt_count) {
118 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 118 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
119 "Blank IRQ resource\n")); 119 "Blank IRQ resource\n"));
120 return_ACPI_STATUS(AE_OK); 120 return_ACPI_STATUS(AE_OK);
121 } 121 }
122 for (i = 0; 122 for (i = 0;
123 (i < p->number_of_interrupts 123 (i < p->interrupt_count
124 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 124 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
125 if (!p->interrupts[i]) { 125 if (!p->interrupts[i]) {
126 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 126 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
@@ -131,22 +131,22 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
131 link->irq.possible[i] = p->interrupts[i]; 131 link->irq.possible[i] = p->interrupts[i];
132 link->irq.possible_count++; 132 link->irq.possible_count++;
133 } 133 }
134 link->irq.edge_level = p->edge_level; 134 link->irq.triggering = p->triggering;
135 link->irq.active_high_low = p->active_high_low; 135 link->irq.polarity = p->polarity;
136 link->irq.resource_type = ACPI_RSTYPE_IRQ; 136 link->irq.resource_type = ACPI_RESOURCE_TYPE_IRQ;
137 break; 137 break;
138 } 138 }
139 case ACPI_RSTYPE_EXT_IRQ: 139 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
140 { 140 {
141 struct acpi_resource_ext_irq *p = 141 struct acpi_resource_extended_irq *p =
142 &resource->data.extended_irq; 142 &resource->data.extended_irq;
143 if (!p || !p->number_of_interrupts) { 143 if (!p || !p->interrupt_count) {
144 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 144 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
145 "Blank EXT IRQ resource\n")); 145 "Blank EXT IRQ resource\n"));
146 return_ACPI_STATUS(AE_OK); 146 return_ACPI_STATUS(AE_OK);
147 } 147 }
148 for (i = 0; 148 for (i = 0;
149 (i < p->number_of_interrupts 149 (i < p->interrupt_count
150 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 150 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
151 if (!p->interrupts[i]) { 151 if (!p->interrupts[i]) {
152 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 152 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
@@ -157,9 +157,9 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
157 link->irq.possible[i] = p->interrupts[i]; 157 link->irq.possible[i] = p->interrupts[i];
158 link->irq.possible_count++; 158 link->irq.possible_count++;
159 } 159 }
160 link->irq.edge_level = p->edge_level; 160 link->irq.triggering = p->triggering;
161 link->irq.active_high_low = p->active_high_low; 161 link->irq.polarity = p->polarity;
162 link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ; 162 link->irq.resource_type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
163 break; 163 break;
164 } 164 }
165 default: 165 default:
@@ -201,11 +201,11 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
201 201
202 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current"); 202 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
203 203
204 switch (resource->id) { 204 switch (resource->type) {
205 case ACPI_RSTYPE_IRQ: 205 case ACPI_RESOURCE_TYPE_IRQ:
206 { 206 {
207 struct acpi_resource_irq *p = &resource->data.irq; 207 struct acpi_resource_irq *p = &resource->data.irq;
208 if (!p || !p->number_of_interrupts) { 208 if (!p || !p->interrupt_count) {
209 /* 209 /*
210 * IRQ descriptors may have no IRQ# bits set, 210 * IRQ descriptors may have no IRQ# bits set,
211 * particularly those those w/ _STA disabled 211 * particularly those those w/ _STA disabled
@@ -217,11 +217,11 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
217 *irq = p->interrupts[0]; 217 *irq = p->interrupts[0];
218 break; 218 break;
219 } 219 }
220 case ACPI_RSTYPE_EXT_IRQ: 220 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
221 { 221 {
222 struct acpi_resource_ext_irq *p = 222 struct acpi_resource_extended_irq *p =
223 &resource->data.extended_irq; 223 &resource->data.extended_irq;
224 if (!p || !p->number_of_interrupts) { 224 if (!p || !p->interrupt_count) {
225 /* 225 /*
226 * extended IRQ descriptors must 226 * extended IRQ descriptors must
227 * return at least 1 IRQ 227 * return at least 1 IRQ
@@ -233,8 +233,10 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
233 *irq = p->interrupts[0]; 233 *irq = p->interrupts[0];
234 break; 234 break;
235 } 235 }
236 break;
236 default: 237 default:
237 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource isn't an IRQ\n")); 238 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource %d isn't an IRQ\n", resource->type));
239 case ACPI_RESOURCE_TYPE_END_TAG:
238 return_ACPI_STATUS(AE_OK); 240 return_ACPI_STATUS(AE_OK);
239 } 241 }
240 return_ACPI_STATUS(AE_CTRL_TERMINATE); 242 return_ACPI_STATUS(AE_CTRL_TERMINATE);
@@ -325,36 +327,36 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
325 buffer.pointer = resource; 327 buffer.pointer = resource;
326 328
327 switch (link->irq.resource_type) { 329 switch (link->irq.resource_type) {
328 case ACPI_RSTYPE_IRQ: 330 case ACPI_RESOURCE_TYPE_IRQ:
329 resource->res.id = ACPI_RSTYPE_IRQ; 331 resource->res.type = ACPI_RESOURCE_TYPE_IRQ;
330 resource->res.length = sizeof(struct acpi_resource); 332 resource->res.length = sizeof(struct acpi_resource);
331 resource->res.data.irq.edge_level = link->irq.edge_level; 333 resource->res.data.irq.triggering = link->irq.triggering;
332 resource->res.data.irq.active_high_low = 334 resource->res.data.irq.polarity =
333 link->irq.active_high_low; 335 link->irq.polarity;
334 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) 336 if (link->irq.triggering == ACPI_EDGE_SENSITIVE)
335 resource->res.data.irq.shared_exclusive = 337 resource->res.data.irq.sharable =
336 ACPI_EXCLUSIVE; 338 ACPI_EXCLUSIVE;
337 else 339 else
338 resource->res.data.irq.shared_exclusive = ACPI_SHARED; 340 resource->res.data.irq.sharable = ACPI_SHARED;
339 resource->res.data.irq.number_of_interrupts = 1; 341 resource->res.data.irq.interrupt_count = 1;
340 resource->res.data.irq.interrupts[0] = irq; 342 resource->res.data.irq.interrupts[0] = irq;
341 break; 343 break;
342 344
343 case ACPI_RSTYPE_EXT_IRQ: 345 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
344 resource->res.id = ACPI_RSTYPE_EXT_IRQ; 346 resource->res.type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
345 resource->res.length = sizeof(struct acpi_resource); 347 resource->res.length = sizeof(struct acpi_resource);
346 resource->res.data.extended_irq.producer_consumer = 348 resource->res.data.extended_irq.producer_consumer =
347 ACPI_CONSUMER; 349 ACPI_CONSUMER;
348 resource->res.data.extended_irq.edge_level = 350 resource->res.data.extended_irq.triggering =
349 link->irq.edge_level; 351 link->irq.triggering;
350 resource->res.data.extended_irq.active_high_low = 352 resource->res.data.extended_irq.polarity =
351 link->irq.active_high_low; 353 link->irq.polarity;
352 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) 354 if (link->irq.triggering == ACPI_EDGE_SENSITIVE)
353 resource->res.data.irq.shared_exclusive = 355 resource->res.data.irq.sharable =
354 ACPI_EXCLUSIVE; 356 ACPI_EXCLUSIVE;
355 else 357 else
356 resource->res.data.irq.shared_exclusive = ACPI_SHARED; 358 resource->res.data.irq.sharable = ACPI_SHARED;
357 resource->res.data.extended_irq.number_of_interrupts = 1; 359 resource->res.data.extended_irq.interrupt_count = 1;
358 resource->res.data.extended_irq.interrupts[0] = irq; 360 resource->res.data.extended_irq.interrupts[0] = irq;
359 /* ignore resource_source, it's optional */ 361 /* ignore resource_source, it's optional */
360 break; 362 break;
@@ -364,7 +366,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
364 goto end; 366 goto end;
365 367
366 } 368 }
367 resource->end.id = ACPI_RSTYPE_END_TAG; 369 resource->end.type = ACPI_RESOURCE_TYPE_END_TAG;
368 370
369 /* Attempt to set the resource */ 371 /* Attempt to set the resource */
370 status = acpi_set_current_resources(link->handle, &buffer); 372 status = acpi_set_current_resources(link->handle, &buffer);
@@ -613,7 +615,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
613int 615int
614acpi_pci_link_allocate_irq(acpi_handle handle, 616acpi_pci_link_allocate_irq(acpi_handle handle,
615 int index, 617 int index,
616 int *edge_level, int *active_high_low, char **name) 618 int *triggering, int *polarity, char **name)
617{ 619{
618 int result = 0; 620 int result = 0;
619 struct acpi_device *device = NULL; 621 struct acpi_device *device = NULL;
@@ -653,10 +655,10 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
653 link->refcnt++; 655 link->refcnt++;
654 up(&acpi_link_lock); 656 up(&acpi_link_lock);
655 657
656 if (edge_level) 658 if (triggering)
657 *edge_level = link->irq.edge_level; 659 *triggering = link->irq.triggering;
658 if (active_high_low) 660 if (polarity)
659 *active_high_low = link->irq.active_high_low; 661 *polarity = link->irq.polarity;
660 if (name) 662 if (name)
661 *name = acpi_device_bid(link->device); 663 *name = acpi_device_bid(link->device);
662 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 664 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 0fd9988c283d..4c313eab6313 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -122,15 +122,15 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
122 int *busnr = (int *)data; 122 int *busnr = (int *)data;
123 struct acpi_resource_address64 address; 123 struct acpi_resource_address64 address;
124 124
125 if (resource->id != ACPI_RSTYPE_ADDRESS16 && 125 if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 &&
126 resource->id != ACPI_RSTYPE_ADDRESS32 && 126 resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
127 resource->id != ACPI_RSTYPE_ADDRESS64) 127 resource->type != ACPI_RESOURCE_TYPE_ADDRESS64)
128 return AE_OK; 128 return AE_OK;
129 129
130 acpi_resource_to_address64(resource, &address); 130 acpi_resource_to_address64(resource, &address);
131 if ((address.address_length > 0) && 131 if ((address.address_length > 0) &&
132 (address.resource_type == ACPI_BUS_NUMBER_RANGE)) 132 (address.resource_type == ACPI_BUS_NUMBER_RANGE))
133 *busnr = address.min_address_range; 133 *busnr = address.minimum;
134 134
135 return AE_OK; 135 return AE_OK;
136} 136}
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 1278aca96fe3..99a3a28594da 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -253,31 +253,21 @@ static int acpi_processor_errata(struct acpi_processor *pr)
253 * _PDC is required for a BIOS-OS handshake for most of the newer 253 * _PDC is required for a BIOS-OS handshake for most of the newer
254 * ACPI processor features. 254 * ACPI processor features.
255 */ 255 */
256 256static int acpi_processor_set_pdc(struct acpi_processor *pr)
257int acpi_processor_set_pdc(struct acpi_processor *pr,
258 struct acpi_object_list *pdc_in)
259{ 257{
258 struct acpi_object_list *pdc_in = pr->pdc;
260 acpi_status status = AE_OK; 259 acpi_status status = AE_OK;
261 u32 arg0_buf[3];
262 union acpi_object arg0 = { ACPI_TYPE_BUFFER };
263 struct acpi_object_list no_object = { 1, &arg0 };
264 struct acpi_object_list *pdc;
265 260
266 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc"); 261 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
267 262
268 arg0.buffer.length = 12; 263 if (!pdc_in)
269 arg0.buffer.pointer = (u8 *) arg0_buf; 264 return_VALUE(status);
270 arg0_buf[0] = ACPI_PDC_REVISION_ID;
271 arg0_buf[1] = 0;
272 arg0_buf[2] = 0;
273
274 pdc = (pdc_in) ? pdc_in : &no_object;
275 265
276 status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL); 266 status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
277 267
278 if ((ACPI_FAILURE(status)) && (pdc_in)) 268 if (ACPI_FAILURE(status))
279 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 269 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
280 "Error evaluating _PDC, using legacy perf. control...\n")); 270 "Could not evaluate _PDC, using legacy perf. control...\n"));
281 271
282 return_VALUE(status); 272 return_VALUE(status);
283} 273}
@@ -357,7 +347,6 @@ static int acpi_processor_add_fs(struct acpi_device *device)
357 ACPI_PROCESSOR_FILE_THROTTLING)); 347 ACPI_PROCESSOR_FILE_THROTTLING));
358 else { 348 else {
359 entry->proc_fops = &acpi_processor_throttling_fops; 349 entry->proc_fops = &acpi_processor_throttling_fops;
360 entry->proc_fops->write = acpi_processor_write_throttling;
361 entry->data = acpi_driver_data(device); 350 entry->data = acpi_driver_data(device);
362 entry->owner = THIS_MODULE; 351 entry->owner = THIS_MODULE;
363 } 352 }
@@ -372,7 +361,6 @@ static int acpi_processor_add_fs(struct acpi_device *device)
372 ACPI_PROCESSOR_FILE_LIMIT)); 361 ACPI_PROCESSOR_FILE_LIMIT));
373 else { 362 else {
374 entry->proc_fops = &acpi_processor_limit_fops; 363 entry->proc_fops = &acpi_processor_limit_fops;
375 entry->proc_fops->write = acpi_processor_write_limit;
376 entry->data = acpi_driver_data(device); 364 entry->data = acpi_driver_data(device);
377 entry->owner = THIS_MODULE; 365 entry->owner = THIS_MODULE;
378 } 366 }
@@ -589,6 +577,10 @@ static int acpi_processor_start(struct acpi_device *device)
589 "Error installing device notify handler\n")); 577 "Error installing device notify handler\n"));
590 } 578 }
591 579
580 /* _PDC call should be done before doing anything else (if reqd.). */
581 arch_acpi_processor_init_pdc(pr);
582 acpi_processor_set_pdc(pr);
583
592 acpi_processor_power_init(pr, device); 584 acpi_processor_power_init(pr, device);
593 585
594 if (pr->flags.throttling) { 586 if (pr->flags.throttling) {
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index cc049338e418..eb730a80952c 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -94,23 +94,60 @@ static int set_max_cstate(struct dmi_system_id *id)
94 return 0; 94 return 0;
95} 95}
96 96
97static struct dmi_system_id __initdata processor_power_dmi_table[] = { 97/* Actually this shouldn't be __cpuinitdata, would be better to fix the
98 {set_max_cstate, "IBM ThinkPad R40e", { 98 callers to only run once -AK */
99 DMI_MATCH(DMI_BIOS_VENDOR, 99static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = {
100 "IBM"), 100 { set_max_cstate, "IBM ThinkPad R40e", {
101 DMI_MATCH(DMI_BIOS_VERSION, 101 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
102 "1SET60WW")}, 102 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW")}, (void *)1},
103 (void *)1}, 103 { set_max_cstate, "IBM ThinkPad R40e", {
104 {set_max_cstate, "Medion 41700", { 104 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
105 DMI_MATCH(DMI_BIOS_VENDOR, 105 DMI_MATCH(DMI_BIOS_VERSION,"1SET43WW") }, (void*)1},
106 "Phoenix Technologies LTD"), 106 { set_max_cstate, "IBM ThinkPad R40e", {
107 DMI_MATCH(DMI_BIOS_VERSION, 107 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
108 "R01-A1J")}, (void *)1}, 108 DMI_MATCH(DMI_BIOS_VERSION,"1SET45WW") }, (void*)1},
109 {set_max_cstate, "Clevo 5600D", { 109 { set_max_cstate, "IBM ThinkPad R40e", {
110 DMI_MATCH(DMI_BIOS_VENDOR, 110 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
111 "Phoenix Technologies LTD"), 111 DMI_MATCH(DMI_BIOS_VERSION,"1SET47WW") }, (void*)1},
112 DMI_MATCH(DMI_BIOS_VERSION, 112 { set_max_cstate, "IBM ThinkPad R40e", {
113 "SHE845M0.86C.0013.D.0302131307")}, 113 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
114 DMI_MATCH(DMI_BIOS_VERSION,"1SET50WW") }, (void*)1},
115 { set_max_cstate, "IBM ThinkPad R40e", {
116 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
117 DMI_MATCH(DMI_BIOS_VERSION,"1SET52WW") }, (void*)1},
118 { set_max_cstate, "IBM ThinkPad R40e", {
119 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
120 DMI_MATCH(DMI_BIOS_VERSION,"1SET55WW") }, (void*)1},
121 { set_max_cstate, "IBM ThinkPad R40e", {
122 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
123 DMI_MATCH(DMI_BIOS_VERSION,"1SET56WW") }, (void*)1},
124 { set_max_cstate, "IBM ThinkPad R40e", {
125 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
126 DMI_MATCH(DMI_BIOS_VERSION,"1SET59WW") }, (void*)1},
127 { set_max_cstate, "IBM ThinkPad R40e", {
128 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
129 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW") }, (void*)1},
130 { set_max_cstate, "IBM ThinkPad R40e", {
131 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
132 DMI_MATCH(DMI_BIOS_VERSION,"1SET61WW") }, (void*)1},
133 { set_max_cstate, "IBM ThinkPad R40e", {
134 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
135 DMI_MATCH(DMI_BIOS_VERSION,"1SET62WW") }, (void*)1},
136 { set_max_cstate, "IBM ThinkPad R40e", {
137 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
138 DMI_MATCH(DMI_BIOS_VERSION,"1SET64WW") }, (void*)1},
139 { set_max_cstate, "IBM ThinkPad R40e", {
140 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
141 DMI_MATCH(DMI_BIOS_VERSION,"1SET65WW") }, (void*)1},
142 { set_max_cstate, "IBM ThinkPad R40e", {
143 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
144 DMI_MATCH(DMI_BIOS_VERSION,"1SET68WW") }, (void*)1},
145 { set_max_cstate, "Medion 41700", {
146 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
147 DMI_MATCH(DMI_BIOS_VERSION,"R01-A1J")}, (void *)1},
148 { set_max_cstate, "Clevo 5600D", {
149 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
150 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307")},
114 (void *)2}, 151 (void *)2},
115 {}, 152 {},
116}; 153};
@@ -550,18 +587,10 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
550 if (!pr->pblk) 587 if (!pr->pblk)
551 return_VALUE(-ENODEV); 588 return_VALUE(-ENODEV);
552 589
553 memset(pr->power.states, 0, sizeof(pr->power.states));
554
555 /* if info is obtained from pblk/fadt, type equals state */ 590 /* if info is obtained from pblk/fadt, type equals state */
556 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
557 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2; 591 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2;
558 pr->power.states[ACPI_STATE_C3].type = ACPI_STATE_C3; 592 pr->power.states[ACPI_STATE_C3].type = ACPI_STATE_C3;
559 593
560 /* the C0 state only exists as a filler in our array,
561 * and all processors need to support C1 */
562 pr->power.states[ACPI_STATE_C0].valid = 1;
563 pr->power.states[ACPI_STATE_C1].valid = 1;
564
565#ifndef CONFIG_HOTPLUG_CPU 594#ifndef CONFIG_HOTPLUG_CPU
566 /* 595 /*
567 * Check for P_LVL2_UP flag before entering C2 and above on 596 * Check for P_LVL2_UP flag before entering C2 and above on
@@ -591,12 +620,11 @@ static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
591{ 620{
592 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1"); 621 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
593 622
623 /* Zero initialize all the C-states info. */
594 memset(pr->power.states, 0, sizeof(pr->power.states)); 624 memset(pr->power.states, 0, sizeof(pr->power.states));
595 625
596 /* if info is obtained from pblk/fadt, type equals state */ 626 /* set the first C-State to C1 */
597 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1; 627 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
598 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2;
599 pr->power.states[ACPI_STATE_C3].type = ACPI_STATE_C3;
600 628
601 /* the C0 state only exists as a filler in our array, 629 /* the C0 state only exists as a filler in our array,
602 * and all processors need to support C1 */ 630 * and all processors need to support C1 */
@@ -610,6 +638,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
610{ 638{
611 acpi_status status = 0; 639 acpi_status status = 0;
612 acpi_integer count; 640 acpi_integer count;
641 int current_count;
613 int i; 642 int i;
614 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 643 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
615 union acpi_object *cst; 644 union acpi_object *cst;
@@ -619,10 +648,12 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
619 if (nocst) 648 if (nocst)
620 return_VALUE(-ENODEV); 649 return_VALUE(-ENODEV);
621 650
622 pr->power.count = 0; 651 current_count = 1;
623 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 652
624 memset(&(pr->power.states[i]), 0, 653 /* Zero initialize C2 onwards and prepare for fresh CST lookup */
625 sizeof(struct acpi_processor_cx)); 654 for (i = 2; i < ACPI_PROCESSOR_MAX_POWER; i++)
655 memset(&(pr->power.states[i]), 0,
656 sizeof(struct acpi_processor_cx));
626 657
627 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); 658 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
628 if (ACPI_FAILURE(status)) { 659 if (ACPI_FAILURE(status)) {
@@ -650,16 +681,6 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
650 goto end; 681 goto end;
651 } 682 }
652 683
653 /* We support up to ACPI_PROCESSOR_MAX_POWER. */
654 if (count > ACPI_PROCESSOR_MAX_POWER) {
655 printk(KERN_WARNING
656 "Limiting number of power states to max (%d)\n",
657 ACPI_PROCESSOR_MAX_POWER);
658 printk(KERN_WARNING
659 "Please increase ACPI_PROCESSOR_MAX_POWER if needed.\n");
660 count = ACPI_PROCESSOR_MAX_POWER;
661 }
662
663 /* Tell driver that at least _CST is supported. */ 684 /* Tell driver that at least _CST is supported. */
664 pr->flags.has_cst = 1; 685 pr->flags.has_cst = 1;
665 686
@@ -703,7 +724,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
703 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) 724 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO))
704 continue; 725 continue;
705 726
706 if ((cx.type < ACPI_STATE_C1) || (cx.type > ACPI_STATE_C3)) 727 if ((cx.type < ACPI_STATE_C2) || (cx.type > ACPI_STATE_C3))
707 continue; 728 continue;
708 729
709 obj = (union acpi_object *)&(element->package.elements[2]); 730 obj = (union acpi_object *)&(element->package.elements[2]);
@@ -718,15 +739,28 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
718 739
719 cx.power = obj->integer.value; 740 cx.power = obj->integer.value;
720 741
721 (pr->power.count)++; 742 current_count++;
722 memcpy(&(pr->power.states[pr->power.count]), &cx, sizeof(cx)); 743 memcpy(&(pr->power.states[current_count]), &cx, sizeof(cx));
744
745 /*
746 * We support total ACPI_PROCESSOR_MAX_POWER - 1
747 * (From 1 through ACPI_PROCESSOR_MAX_POWER - 1)
748 */
749 if (current_count >= (ACPI_PROCESSOR_MAX_POWER - 1)) {
750 printk(KERN_WARNING
751 "Limiting number of power states to max (%d)\n",
752 ACPI_PROCESSOR_MAX_POWER);
753 printk(KERN_WARNING
754 "Please increase ACPI_PROCESSOR_MAX_POWER if needed.\n");
755 break;
756 }
723 } 757 }
724 758
725 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d power states\n", 759 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d power states\n",
726 pr->power.count)); 760 current_count));
727 761
728 /* Validate number of power states discovered */ 762 /* Validate number of power states discovered */
729 if (pr->power.count < 2) 763 if (current_count < 2)
730 status = -EFAULT; 764 status = -EFAULT;
731 765
732 end: 766 end:
@@ -867,7 +901,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
867 case ACPI_STATE_C3: 901 case ACPI_STATE_C3:
868 acpi_processor_power_verify_c3(pr, cx); 902 acpi_processor_power_verify_c3(pr, cx);
869#ifdef ARCH_APICTIMER_STOPS_ON_C3 903#ifdef ARCH_APICTIMER_STOPS_ON_C3
870 if (c->x86_vendor == X86_VENDOR_INTEL) { 904 if (cx->valid && c->x86_vendor == X86_VENDOR_INTEL) {
871 on_each_cpu(switch_APIC_timer_to_ipi, 905 on_each_cpu(switch_APIC_timer_to_ipi,
872 &mask, 1, 1); 906 &mask, 1, 1);
873 } 907 }
@@ -892,12 +926,13 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
892 /* NOTE: the idle thread may not be running while calling 926 /* NOTE: the idle thread may not be running while calling
893 * this function */ 927 * this function */
894 928
929 /* Adding C1 state */
930 acpi_processor_get_power_info_default_c1(pr);
895 result = acpi_processor_get_power_info_cst(pr); 931 result = acpi_processor_get_power_info_cst(pr);
896 if (result == -ENODEV) 932 if (result == -ENODEV)
897 result = acpi_processor_get_power_info_fadt(pr); 933 acpi_processor_get_power_info_fadt(pr);
898 934
899 if ((result) || (acpi_processor_power_verify(pr) < 2)) 935 pr->power.count = acpi_processor_power_verify(pr);
900 result = acpi_processor_get_power_info_default_c1(pr);
901 936
902 /* 937 /*
903 * Set Default Policy 938 * Set Default Policy
@@ -1066,8 +1101,6 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1066 } 1101 }
1067 } 1102 }
1068 1103
1069 acpi_processor_power_init_pdc(&(pr->power), pr->id);
1070 acpi_processor_set_pdc(pr, pr->power.pdc);
1071 acpi_processor_get_power_info(pr); 1104 acpi_processor_get_power_info(pr);
1072 1105
1073 /* 1106 /*
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 22c7bb66c200..abbdb37a7f5f 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -315,8 +315,6 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
315 if (!pr || !pr->performance || !pr->handle) 315 if (!pr || !pr->performance || !pr->handle)
316 return_VALUE(-EINVAL); 316 return_VALUE(-EINVAL);
317 317
318 acpi_processor_set_pdc(pr, pr->performance->pdc);
319
320 status = acpi_get_handle(pr->handle, "_PCT", &handle); 318 status = acpi_get_handle(pr->handle, "_PCT", &handle);
321 if (ACPI_FAILURE(status)) { 319 if (ACPI_FAILURE(status)) {
322 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 320 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -520,8 +518,8 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
520 "Unable to create '%s' fs entry\n", 518 "Unable to create '%s' fs entry\n",
521 ACPI_PROCESSOR_FILE_PERFORMANCE)); 519 ACPI_PROCESSOR_FILE_PERFORMANCE));
522 else { 520 else {
521 acpi_processor_perf_fops.write = acpi_processor_write_performance;
523 entry->proc_fops = &acpi_processor_perf_fops; 522 entry->proc_fops = &acpi_processor_perf_fops;
524 entry->proc_fops->write = acpi_processor_write_performance;
525 entry->data = acpi_driver_data(device); 523 entry->data = acpi_driver_data(device);
526 entry->owner = THIS_MODULE; 524 entry->owner = THIS_MODULE;
527 } 525 }
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index dc9817cfb882..f99ad05cd6a2 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -348,9 +348,9 @@ static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file)
348 PDE(inode)->data); 348 PDE(inode)->data);
349} 349}
350 350
351ssize_t acpi_processor_write_limit(struct file * file, 351static ssize_t acpi_processor_write_limit(struct file * file,
352 const char __user * buffer, 352 const char __user * buffer,
353 size_t count, loff_t * data) 353 size_t count, loff_t * data)
354{ 354{
355 int result = 0; 355 int result = 0;
356 struct seq_file *m = (struct seq_file *)file->private_data; 356 struct seq_file *m = (struct seq_file *)file->private_data;
@@ -394,6 +394,7 @@ ssize_t acpi_processor_write_limit(struct file * file,
394struct file_operations acpi_processor_limit_fops = { 394struct file_operations acpi_processor_limit_fops = {
395 .open = acpi_processor_limit_open_fs, 395 .open = acpi_processor_limit_open_fs,
396 .read = seq_read, 396 .read = seq_read,
397 .write = acpi_processor_write_limit,
397 .llseek = seq_lseek, 398 .llseek = seq_lseek,
398 .release = single_release, 399 .release = single_release,
399}; 400};
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 74a52d4e79ae..b966549ec000 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -306,9 +306,9 @@ static int acpi_processor_throttling_open_fs(struct inode *inode,
306 PDE(inode)->data); 306 PDE(inode)->data);
307} 307}
308 308
309ssize_t acpi_processor_write_throttling(struct file * file, 309static ssize_t acpi_processor_write_throttling(struct file * file,
310 const char __user * buffer, 310 const char __user * buffer,
311 size_t count, loff_t * data) 311 size_t count, loff_t * data)
312{ 312{
313 int result = 0; 313 int result = 0;
314 struct seq_file *m = (struct seq_file *)file->private_data; 314 struct seq_file *m = (struct seq_file *)file->private_data;
@@ -337,6 +337,7 @@ ssize_t acpi_processor_write_throttling(struct file * file,
337struct file_operations acpi_processor_throttling_fops = { 337struct file_operations acpi_processor_throttling_fops = {
338 .open = acpi_processor_throttling_open_fs, 338 .open = acpi_processor_throttling_open_fs,
339 .read = seq_read, 339 .read = seq_read,
340 .write = acpi_processor_write_throttling,
340 .llseek = seq_lseek, 341 .llseek = seq_lseek,
341 .release = single_release, 342 .release = single_release,
342}; 343};
diff --git a/drivers/acpi/resources/Makefile b/drivers/acpi/resources/Makefile
index 2130b74170c3..8de4f69dfa09 100644
--- a/drivers/acpi/resources/Makefile
+++ b/drivers/acpi/resources/Makefile
@@ -2,7 +2,7 @@
2# Makefile for all Linux ACPI interpreter subdirectories 2# Makefile for all Linux ACPI interpreter subdirectories
3# 3#
4 4
5obj-y := rsaddr.o rscreate.o rsio.o rslist.o rsmisc.o rsxface.o \ 5obj-y := rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \
6 rscalc.o rsirq.o rsmemory.o rsutils.o 6 rscalc.o rsirq.o rsmemory.o rsutils.o
7 7
8obj-$(ACPI_FUTURE_USAGE) += rsdump.o 8obj-$(ACPI_FUTURE_USAGE) += rsdump.o
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c
index 23b54baa0cb2..8fa3213ce000 100644
--- a/drivers/acpi/resources/rsaddr.c
+++ b/drivers/acpi/resources/rsaddr.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,1072 +47,334 @@
47#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsaddr") 48ACPI_MODULE_NAME("rsaddr")
49 49
50/* Local prototypes */
51static void
52acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags);
53
54static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource);
55
56static void
57acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags);
58
59static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource);
60
61/******************************************************************************* 50/*******************************************************************************
62 * 51 *
63 * FUNCTION: acpi_rs_decode_general_flags 52 * acpi_rs_convert_address16 - All WORD (16-bit) address resources
64 *
65 * PARAMETERS: Resource - Address resource data struct
66 * Flags - Actual flag byte
67 *
68 * RETURN: Decoded flag bits in resource struct
69 *
70 * DESCRIPTION: Decode a general flag byte to an address resource struct
71 * 53 *
72 ******************************************************************************/ 54 ******************************************************************************/
55struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {
56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16,
57 ACPI_RS_SIZE(struct acpi_resource_address16),
58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address16)},
73 59
74static void 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16,
75acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags) 61 sizeof(struct aml_resource_address16),
76{ 62 0},
77 ACPI_FUNCTION_ENTRY();
78
79 /* Producer / Consumer - flag bit[0] */
80
81 resource->address.producer_consumer = (u32) (flags & 0x01);
82 63
83 /* Decode (_DEC) - flag bit[1] */ 64 /* Resource Type, General Flags, and Type-Specific Flags */
84 65
85 resource->address.decode = (u32) ((flags >> 1) & 0x01); 66 {ACPI_RSC_ADDRESS, 0, 0, 0},
86 67
87 /* Min Address Fixed (_MIF) - flag bit[2] */ 68 /*
69 * These fields are contiguous in both the source and destination:
70 * Address Granularity
71 * Address Range Minimum
72 * Address Range Maximum
73 * Address Translation Offset
74 * Address Length
75 */
76 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.address16.granularity),
77 AML_OFFSET(address16.granularity),
78 5},
88 79
89 resource->address.min_address_fixed = (u32) ((flags >> 2) & 0x01); 80 /* Optional resource_source (Index and String) */
90 81
91 /* Max Address Fixed (_MAF) - flag bit[3] */ 82 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address16.resource_source),
92 83 0,
93 resource->address.max_address_fixed = (u32) ((flags >> 3) & 0x01); 84 sizeof(struct aml_resource_address16)}
94} 85};
95 86
96/******************************************************************************* 87/*******************************************************************************
97 * 88 *
98 * FUNCTION: acpi_rs_encode_general_flags 89 * acpi_rs_convert_address32 - All DWORD (32-bit) address resources
99 *
100 * PARAMETERS: Resource - Address resource data struct
101 *
102 * RETURN: Encoded general flag byte
103 *
104 * DESCRIPTION: Construct a general flag byte from an address resource struct
105 * 90 *
106 ******************************************************************************/ 91 ******************************************************************************/
107 92
108static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) 93struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {
109{ 94 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32,
110 u8 flags; 95 ACPI_RS_SIZE(struct acpi_resource_address32),
111 96 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address32)},
112 ACPI_FUNCTION_ENTRY();
113
114 /* Producer / Consumer - flag bit[0] */
115
116 flags = (u8) (resource->address.producer_consumer & 0x01);
117
118 /* Decode (_DEC) - flag bit[1] */
119
120 flags |= (u8) ((resource->address.decode & 0x01) << 1);
121
122 /* Min Address Fixed (_MIF) - flag bit[2] */
123
124 flags |= (u8) ((resource->address.min_address_fixed & 0x01) << 2);
125 97
126 /* Max Address Fixed (_MAF) - flag bit[3] */ 98 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32,
99 sizeof(struct aml_resource_address32),
100 0},
127 101
128 flags |= (u8) ((resource->address.max_address_fixed & 0x01) << 3); 102 /* Resource Type, General Flags, and Type-Specific Flags */
129 103
130 return (flags); 104 {ACPI_RSC_ADDRESS, 0, 0, 0},
131}
132
133/*******************************************************************************
134 *
135 * FUNCTION: acpi_rs_decode_specific_flags
136 *
137 * PARAMETERS: Resource - Address resource data struct
138 * Flags - Actual flag byte
139 *
140 * RETURN: Decoded flag bits in attribute struct
141 *
142 * DESCRIPTION: Decode a type-specific flag byte to an attribute struct.
143 * Type-specific flags are only defined for the Memory and IO
144 * resource types.
145 *
146 ******************************************************************************/
147 105
148static void 106 /*
149acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags) 107 * These fields are contiguous in both the source and destination:
150{ 108 * Address Granularity
151 ACPI_FUNCTION_ENTRY(); 109 * Address Range Minimum
152 110 * Address Range Maximum
153 if (resource->address.resource_type == ACPI_MEMORY_RANGE) { 111 * Address Translation Offset
154 /* Write Status (_RW) - flag bit[0] */ 112 * Address Length
155 113 */
156 resource->address.attribute.memory.read_write_attribute = 114 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.address32.granularity),
157 (u16) (flags & 0x01); 115 AML_OFFSET(address32.granularity),
158 116 5},
159 /* Memory Attributes (_MEM) - flag bits[2:1] */
160
161 resource->address.attribute.memory.cache_attribute =
162 (u16) ((flags >> 1) & 0x03);
163 } else if (resource->address.resource_type == ACPI_IO_RANGE) {
164 /* Ranges (_RNG) - flag bits[1:0] */
165
166 resource->address.attribute.io.range_attribute =
167 (u16) (flags & 0x03);
168 117
169 /* Translations (_TTP and _TRS) - flag bits[5:4] */ 118 /* Optional resource_source (Index and String) */
170 119
171 resource->address.attribute.io.translation_attribute = 120 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address32.resource_source),
172 (u16) ((flags >> 4) & 0x03); 121 0,
173 } 122 sizeof(struct aml_resource_address32)}
174} 123};
175 124
176/******************************************************************************* 125/*******************************************************************************
177 * 126 *
178 * FUNCTION: acpi_rs_encode_specific_flags 127 * acpi_rs_convert_address64 - All QWORD (64-bit) address resources
179 *
180 * PARAMETERS: Resource - Address resource data struct
181 *
182 * RETURN: Encoded type-specific flag byte
183 *
184 * DESCRIPTION: Construct a type-specific flag byte from an attribute struct.
185 * Type-specific flags are only defined for the Memory and IO
186 * resource types.
187 * 128 *
188 ******************************************************************************/ 129 ******************************************************************************/
189 130
190static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource) 131struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {
191{ 132 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64,
192 u8 flags = 0; 133 ACPI_RS_SIZE(struct acpi_resource_address64),
193 134 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address64)},
194 ACPI_FUNCTION_ENTRY();
195
196 if (resource->address.resource_type == ACPI_MEMORY_RANGE) {
197 /* Write Status (_RW) - flag bit[0] */
198 135
199 flags = (u8) 136 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64,
200 (resource->address.attribute.memory. 137 sizeof(struct aml_resource_address64),
201 read_write_attribute & 0x01); 138 0},
202 139
203 /* Memory Attributes (_MEM) - flag bits[2:1] */ 140 /* Resource Type, General Flags, and Type-Specific Flags */
204 141
205 flags |= (u8) 142 {ACPI_RSC_ADDRESS, 0, 0, 0},
206 ((resource->address.attribute.memory.
207 cache_attribute & 0x03) << 1);
208 } else if (resource->address.resource_type == ACPI_IO_RANGE) {
209 /* Ranges (_RNG) - flag bits[1:0] */
210 143
211 flags = (u8) 144 /*
212 (resource->address.attribute.io.range_attribute & 0x03); 145 * These fields are contiguous in both the source and destination:
146 * Address Granularity
147 * Address Range Minimum
148 * Address Range Maximum
149 * Address Translation Offset
150 * Address Length
151 */
152 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.address64.granularity),
153 AML_OFFSET(address64.granularity),
154 5},
213 155
214 /* Translations (_TTP and _TRS) - flag bits[5:4] */ 156 /* Optional resource_source (Index and String) */
215 157
216 flags |= (u8) 158 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address64.resource_source),
217 ((resource->address.attribute.io. 159 0,
218 translation_attribute & 0x03) << 4); 160 sizeof(struct aml_resource_address64)}
219 } 161};
220
221 return (flags);
222}
223 162
224/******************************************************************************* 163/*******************************************************************************
225 * 164 *
226 * FUNCTION: acpi_rs_address16_resource 165 * acpi_rs_convert_ext_address64 - All Extended (64-bit) address resources
227 *
228 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
229 * stream
230 * bytes_consumed - Pointer to where the number of bytes
231 * consumed the byte_stream_buffer is
232 * returned
233 * output_buffer - Pointer to the return data buffer
234 * structure_size - Pointer to where the number of bytes
235 * in the return data struct is returned
236 *
237 * RETURN: Status
238 *
239 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
240 * structure pointed to by the output_buffer. Return the
241 * number of bytes consumed from the byte stream.
242 * 166 *
243 ******************************************************************************/ 167 ******************************************************************************/
244 168
245acpi_status 169struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {
246acpi_rs_address16_resource(u8 * byte_stream_buffer, 170 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
247 acpi_size * bytes_consumed, 171 ACPI_RS_SIZE(struct acpi_resource_extended_address64),
248 u8 ** output_buffer, acpi_size * structure_size) 172 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_address64)},
249{
250 u32 index;
251 u16 temp16;
252 u8 temp8;
253 u8 *temp_ptr;
254 u8 *buffer = byte_stream_buffer;
255 struct acpi_resource *output_struct = (void *)*output_buffer;
256 acpi_size struct_size =
257 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16);
258
259 ACPI_FUNCTION_TRACE("rs_address16_resource");
260
261 /* Get the Descriptor Length field */
262
263 buffer += 1;
264 ACPI_MOVE_16_TO_16(&temp16, buffer);
265
266 /* Validate minimum descriptor length */
267
268 if (temp16 < 13) {
269 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
270 }
271
272 *bytes_consumed = temp16 + 3;
273 output_struct->id = ACPI_RSTYPE_ADDRESS16;
274
275 /* Get the Resource Type (Byte3) */
276 173
277 buffer += 2; 174 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
278 temp8 = *buffer; 175 sizeof(struct aml_resource_extended_address64),
176 0},
279 177
280 /* Values 0-2 and 0xC0-0xFF are valid */ 178 /* Resource Type, General Flags, and Type-Specific Flags */
281 179
282 if ((temp8 > 2) && (temp8 < 0xC0)) { 180 {ACPI_RSC_ADDRESS, 0, 0, 0},
283 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
284 }
285
286 output_struct->data.address16.resource_type = temp8;
287
288 /* Get the General Flags (Byte4) */
289
290 buffer += 1;
291 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
292
293 /* Get the Type Specific Flags (Byte5) */
294
295 buffer += 1;
296 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
297
298 /* Get Granularity (Bytes 6-7) */
299
300 buffer += 1;
301 ACPI_MOVE_16_TO_32(&output_struct->data.address16.granularity, buffer);
302
303 /* Get min_address_range (Bytes 8-9) */
304 181
305 buffer += 2; 182 /* Revision ID */
306 ACPI_MOVE_16_TO_32(&output_struct->data.address16.min_address_range,
307 buffer);
308
309 /* Get max_address_range (Bytes 10-11) */
310
311 buffer += 2;
312 ACPI_MOVE_16_TO_32(&output_struct->data.address16.max_address_range,
313 buffer);
314
315 /* Get address_translation_offset (Bytes 12-13) */
316
317 buffer += 2;
318 ACPI_MOVE_16_TO_32(&output_struct->data.address16.
319 address_translation_offset, buffer);
320
321 /* Get address_length (Bytes 14-15) */
322
323 buffer += 2;
324 ACPI_MOVE_16_TO_32(&output_struct->data.address16.address_length,
325 buffer);
326
327 /* Resource Source Index (if present) */
328
329 buffer += 2;
330 183
184 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.ext_address64.revision_iD),
185 AML_OFFSET(ext_address64.revision_iD),
186 1},
331 /* 187 /*
332 * This will leave us pointing to the Resource Source Index 188 * These fields are contiguous in both the source and destination:
333 * If it is present, then save it off and calculate the 189 * Address Granularity
334 * pointer to where the null terminated string goes: 190 * Address Range Minimum
335 * Each Interrupt takes 32-bits + the 5 bytes of the 191 * Address Range Maximum
336 * stream that are default. 192 * Address Translation Offset
337 * 193 * Address Length
338 * Note: Some resource descriptors will have an additional null, so 194 * Type-Specific Attribute
339 * we add 1 to the length.
340 */ 195 */
341 if (*bytes_consumed > (16 + 1)) { 196 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.ext_address64.granularity),
342 /* Dereference the Index */ 197 AML_OFFSET(ext_address64.granularity),
343 198 6}
344 output_struct->data.address16.resource_source.index = 199};
345 (u32) * buffer;
346
347 /* Point to the String */
348
349 buffer += 1;
350
351 /* Point the String pointer to the end of this structure */
352
353 output_struct->data.address16.resource_source.string_ptr =
354 (char *)((u8 *) output_struct + struct_size);
355
356 temp_ptr = (u8 *)
357 output_struct->data.address16.resource_source.string_ptr;
358
359 /* Copy the resource_source string into the buffer */
360
361 index = 0;
362 while (*buffer) {
363 *temp_ptr = *buffer;
364
365 temp_ptr++;
366 buffer++;
367 index++;
368 }
369
370 /* Add the terminating null and set the string length */
371
372 *temp_ptr = 0;
373 output_struct->data.address16.resource_source.string_length =
374 index + 1;
375
376 /*
377 * In order for the struct_size to fall on a 32-bit boundary,
378 * calculate the length of the string and expand the
379 * struct_size to the next 32-bit boundary.
380 */
381 temp8 = (u8) (index + 1);
382 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
383 } else {
384 output_struct->data.address16.resource_source.index = 0;
385 output_struct->data.address16.resource_source.string_length = 0;
386 output_struct->data.address16.resource_source.string_ptr = NULL;
387 }
388
389 /* Set the Length parameter */
390
391 output_struct->length = (u32) struct_size;
392
393 /* Return the final size of the structure */
394
395 *structure_size = struct_size;
396 return_ACPI_STATUS(AE_OK);
397}
398 200
399/******************************************************************************* 201/*******************************************************************************
400 * 202 *
401 * FUNCTION: acpi_rs_address16_stream 203 * acpi_rs_convert_general_flags - Flags common to all address descriptors
402 *
403 * PARAMETERS: linked_list - Pointer to the resource linked list
404 * output_buffer - Pointer to the user's return buffer
405 * bytes_consumed - Pointer to where the number of bytes
406 * used in the output_buffer is returned
407 *
408 * RETURN: Status
409 *
410 * DESCRIPTION: Take the linked list resource structure and fills in the
411 * the appropriate bytes in a byte stream
412 * 204 *
413 ******************************************************************************/ 205 ******************************************************************************/
414 206
415acpi_status 207static struct acpi_rsconvert_info acpi_rs_convert_general_flags[6] = {
416acpi_rs_address16_stream(struct acpi_resource *linked_list, 208 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.flags),
417 u8 ** output_buffer, acpi_size * bytes_consumed) 209 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_general_flags)},
418{
419 u8 *buffer = *output_buffer;
420 u8 *length_field;
421 acpi_size actual_bytes;
422
423 ACPI_FUNCTION_TRACE("rs_address16_stream");
424
425 /* Set the Descriptor Type field */
426
427 *buffer = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE;
428 buffer += 1;
429
430 /* Save a pointer to the Length field - to be filled in later */
431
432 length_field = buffer;
433 buffer += 2;
434
435 /* Set the Resource Type (Memory, Io, bus_number) */
436
437 *buffer = (u8) (linked_list->data.address16.resource_type & 0x03);
438 buffer += 1;
439
440 /* Set the general flags */
441
442 *buffer = acpi_rs_encode_general_flags(&linked_list->data);
443 buffer += 1;
444
445 /* Set the type specific flags */
446
447 *buffer = acpi_rs_encode_specific_flags(&linked_list->data);
448 buffer += 1;
449
450 /* Set the address space granularity */
451
452 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.address16.granularity);
453 buffer += 2;
454
455 /* Set the address range minimum */
456 210
457 ACPI_MOVE_32_TO_16(buffer, 211 /* Resource Type (Memory, Io, bus_number, etc.) */
458 &linked_list->data.address16.min_address_range);
459 buffer += 2;
460 212
461 /* Set the address range maximum */ 213 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.address.resource_type),
214 AML_OFFSET(address.resource_type),
215 1},
462 216
463 ACPI_MOVE_32_TO_16(buffer, 217 /* General Flags - Consume, Decode, min_fixed, max_fixed */
464 &linked_list->data.address16.max_address_range);
465 buffer += 2;
466 218
467 /* Set the address translation offset */ 219 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.producer_consumer),
220 AML_OFFSET(address.flags),
221 0},
468 222
469 ACPI_MOVE_32_TO_16(buffer, 223 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.decode),
470 &linked_list->data.address16. 224 AML_OFFSET(address.flags),
471 address_translation_offset); 225 1},
472 buffer += 2;
473 226
474 /* Set the address length */ 227 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.min_address_fixed),
228 AML_OFFSET(address.flags),
229 2},
475 230
476 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.address16.address_length); 231 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.max_address_fixed),
477 buffer += 2; 232 AML_OFFSET(address.flags),
478 233 3}
479 /* Resource Source Index and Resource Source are optional */ 234};
480
481 if (linked_list->data.address16.resource_source.string_length) {
482 *buffer =
483 (u8) linked_list->data.address16.resource_source.index;
484 buffer += 1;
485
486 /* Copy the resource_source string */
487
488 ACPI_STRCPY((char *)buffer,
489 linked_list->data.address16.resource_source.
490 string_ptr);
491
492 /*
493 * Buffer needs to be set to the length of the string + one for the
494 * terminating null
495 */
496 buffer +=
497 (acpi_size) (ACPI_STRLEN
498 (linked_list->data.address16.resource_source.
499 string_ptr) + 1);
500 }
501
502 /* Return the number of bytes consumed in this operation */
503
504 actual_bytes = ACPI_PTR_DIFF(buffer, *output_buffer);
505 *bytes_consumed = actual_bytes;
506
507 /*
508 * Set the length field to the number of bytes consumed
509 * minus the header size (3 bytes)
510 */
511 actual_bytes -= 3;
512 ACPI_MOVE_SIZE_TO_16(length_field, &actual_bytes);
513 return_ACPI_STATUS(AE_OK);
514}
515 235
516/******************************************************************************* 236/*******************************************************************************
517 * 237 *
518 * FUNCTION: acpi_rs_address32_resource 238 * acpi_rs_convert_mem_flags - Flags common to Memory address descriptors
519 *
520 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
521 * stream
522 * bytes_consumed - Pointer to where the number of bytes
523 * consumed the byte_stream_buffer is
524 * returned
525 * output_buffer - Pointer to the return data buffer
526 * structure_size - Pointer to where the number of bytes
527 * in the return data struct is returned
528 *
529 * RETURN: Status
530 *
531 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
532 * structure pointed to by the output_buffer. Return the
533 * number of bytes consumed from the byte stream.
534 * 239 *
535 ******************************************************************************/ 240 ******************************************************************************/
536 241
537acpi_status 242static struct acpi_rsconvert_info acpi_rs_convert_mem_flags[5] = {
538acpi_rs_address32_resource(u8 * byte_stream_buffer, 243 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
539 acpi_size * bytes_consumed, 244 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_mem_flags)},
540 u8 ** output_buffer, acpi_size * structure_size)
541{
542 u16 temp16;
543 u8 temp8;
544 u8 *temp_ptr;
545 u32 index;
546 u8 *buffer = byte_stream_buffer;
547 struct acpi_resource *output_struct = (void *)*output_buffer;
548 acpi_size struct_size =
549 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32);
550 245
551 ACPI_FUNCTION_TRACE("rs_address32_resource"); 246 /* Memory-specific flags */
552 247
553 /* Get the Descriptor Length field */ 248 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.write_protect),
249 AML_OFFSET(address.specific_flags),
250 0},
554 251
555 buffer += 1; 252 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.caching),
556 ACPI_MOVE_16_TO_16(&temp16, buffer); 253 AML_OFFSET(address.specific_flags),
254 1},
557 255
558 /* Validate minimum descriptor length */ 256 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.range_type),
257 AML_OFFSET(address.specific_flags),
258 3},
559 259
560 if (temp16 < 23) { 260 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.translation),
561 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 261 AML_OFFSET(address.specific_flags),
562 } 262 5}
563 263};
564 *bytes_consumed = temp16 + 3;
565 output_struct->id = ACPI_RSTYPE_ADDRESS32;
566
567 /* Get the Resource Type (Byte3) */
568
569 buffer += 2;
570 temp8 = *buffer;
571
572 /* Values 0-2 and 0xC0-0xFF are valid */
573
574 if ((temp8 > 2) && (temp8 < 0xC0)) {
575 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
576 }
577
578 output_struct->data.address32.resource_type = temp8;
579
580 /* Get the General Flags (Byte4) */
581
582 buffer += 1;
583 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
584
585 /* Get the Type Specific Flags (Byte5) */
586
587 buffer += 1;
588 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
589
590 /* Get Granularity (Bytes 6-9) */
591
592 buffer += 1;
593 ACPI_MOVE_32_TO_32(&output_struct->data.address32.granularity, buffer);
594
595 /* Get min_address_range (Bytes 10-13) */
596
597 buffer += 4;
598 ACPI_MOVE_32_TO_32(&output_struct->data.address32.min_address_range,
599 buffer);
600
601 /* Get max_address_range (Bytes 14-17) */
602
603 buffer += 4;
604 ACPI_MOVE_32_TO_32(&output_struct->data.address32.max_address_range,
605 buffer);
606
607 /* Get address_translation_offset (Bytes 18-21) */
608
609 buffer += 4;
610 ACPI_MOVE_32_TO_32(&output_struct->data.address32.
611 address_translation_offset, buffer);
612
613 /* Get address_length (Bytes 22-25) */
614
615 buffer += 4;
616 ACPI_MOVE_32_TO_32(&output_struct->data.address32.address_length,
617 buffer);
618
619 /* Resource Source Index (if present) */
620
621 buffer += 4;
622
623 /*
624 * This will leave us pointing to the Resource Source Index
625 * If it is present, then save it off and calculate the
626 * pointer to where the null terminated string goes:
627 *
628 * Note: Some resource descriptors will have an additional null, so
629 * we add 1 to the length.
630 */
631 if (*bytes_consumed > (26 + 1)) {
632 /* Dereference the Index */
633
634 output_struct->data.address32.resource_source.index =
635 (u32) * buffer;
636
637 /* Point to the String */
638
639 buffer += 1;
640
641 /* Point the String pointer to the end of this structure */
642
643 output_struct->data.address32.resource_source.string_ptr =
644 (char *)((u8 *) output_struct + struct_size);
645
646 temp_ptr = (u8 *)
647 output_struct->data.address32.resource_source.string_ptr;
648
649 /* Copy the resource_source string into the buffer */
650
651 index = 0;
652 while (*buffer) {
653 *temp_ptr = *buffer;
654
655 temp_ptr++;
656 buffer++;
657 index++;
658 }
659
660 /* Add the terminating null and set the string length */
661
662 *temp_ptr = 0;
663 output_struct->data.address32.resource_source.string_length =
664 index + 1;
665
666 /*
667 * In order for the struct_size to fall on a 32-bit boundary,
668 * calculate the length of the string and expand the
669 * struct_size to the next 32-bit boundary.
670 */
671 temp8 = (u8) (index + 1);
672 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
673 } else {
674 output_struct->data.address32.resource_source.index = 0;
675 output_struct->data.address32.resource_source.string_length = 0;
676 output_struct->data.address32.resource_source.string_ptr = NULL;
677 }
678
679 /* Set the Length parameter */
680
681 output_struct->length = (u32) struct_size;
682
683 /* Return the final size of the structure */
684
685 *structure_size = struct_size;
686 return_ACPI_STATUS(AE_OK);
687}
688 264
689/******************************************************************************* 265/*******************************************************************************
690 * 266 *
691 * FUNCTION: acpi_rs_address32_stream 267 * acpi_rs_convert_io_flags - Flags common to I/O address descriptors
692 *
693 * PARAMETERS: linked_list - Pointer to the resource linked list
694 * output_buffer - Pointer to the user's return buffer
695 * bytes_consumed - Pointer to where the number of bytes
696 * used in the output_buffer is returned
697 *
698 * RETURN: Status
699 *
700 * DESCRIPTION: Take the linked list resource structure and fills in the
701 * the appropriate bytes in a byte stream
702 * 268 *
703 ******************************************************************************/ 269 ******************************************************************************/
704 270
705acpi_status 271static struct acpi_rsconvert_info acpi_rs_convert_io_flags[4] = {
706acpi_rs_address32_stream(struct acpi_resource *linked_list, 272 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
707 u8 ** output_buffer, acpi_size * bytes_consumed) 273 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io_flags)},
708{
709 u8 *buffer;
710 u16 *length_field;
711
712 ACPI_FUNCTION_TRACE("rs_address32_stream");
713
714 buffer = *output_buffer;
715
716 /* Set the Descriptor Type field */
717
718 *buffer = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE;
719 buffer += 1;
720
721 /* Save a pointer to the Length field - to be filled in later */
722
723 length_field = ACPI_CAST_PTR(u16, buffer);
724 buffer += 2;
725
726 /* Set the Resource Type (Memory, Io, bus_number) */
727
728 *buffer = (u8) (linked_list->data.address32.resource_type & 0x03);
729 buffer += 1;
730
731 /* Set the general flags */
732
733 *buffer = acpi_rs_encode_general_flags(&linked_list->data);
734 buffer += 1;
735
736 /* Set the type specific flags */
737
738 *buffer = acpi_rs_encode_specific_flags(&linked_list->data);
739 buffer += 1;
740
741 /* Set the address space granularity */
742
743 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.address32.granularity);
744 buffer += 4;
745
746 /* Set the address range minimum */
747
748 ACPI_MOVE_32_TO_32(buffer,
749 &linked_list->data.address32.min_address_range);
750 buffer += 4;
751
752 /* Set the address range maximum */
753
754 ACPI_MOVE_32_TO_32(buffer,
755 &linked_list->data.address32.max_address_range);
756 buffer += 4;
757
758 /* Set the address translation offset */
759
760 ACPI_MOVE_32_TO_32(buffer,
761 &linked_list->data.address32.
762 address_translation_offset);
763 buffer += 4;
764
765 /* Set the address length */
766
767 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.address32.address_length);
768 buffer += 4;
769 274
770 /* Resource Source Index and Resource Source are optional */ 275 /* I/O-specific flags */
771 276
772 if (linked_list->data.address32.resource_source.string_length) { 277 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.io.range_type),
773 *buffer = 278 AML_OFFSET(address.specific_flags),
774 (u8) linked_list->data.address32.resource_source.index; 279 0},
775 buffer += 1;
776 280
777 /* Copy the resource_source string */ 281 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.io.translation),
282 AML_OFFSET(address.specific_flags),
283 4},
778 284
779 ACPI_STRCPY((char *)buffer, 285 {ACPI_RSC_1BITFLAG,
780 linked_list->data.address32.resource_source. 286 ACPI_RS_OFFSET(data.address.info.io.translation_type),
781 string_ptr); 287 AML_OFFSET(address.specific_flags),
782 288 5}
783 /* 289};
784 * Buffer needs to be set to the length of the string + one for the
785 * terminating null
786 */
787 buffer +=
788 (acpi_size) (ACPI_STRLEN
789 (linked_list->data.address32.resource_source.
790 string_ptr) + 1);
791 }
792
793 /* Return the number of bytes consumed in this operation */
794
795 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
796
797 /*
798 * Set the length field to the number of bytes consumed
799 * minus the header size (3 bytes)
800 */
801 *length_field = (u16) (*bytes_consumed - 3);
802 return_ACPI_STATUS(AE_OK);
803}
804 290
805/******************************************************************************* 291/*******************************************************************************
806 * 292 *
807 * FUNCTION: acpi_rs_address64_resource 293 * FUNCTION: acpi_rs_get_address_common
808 * 294 *
809 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 295 * PARAMETERS: Resource - Pointer to the internal resource struct
810 * stream 296 * Aml - Pointer to the AML resource descriptor
811 * bytes_consumed - Pointer to where the number of bytes
812 * consumed the byte_stream_buffer is
813 * returned
814 * output_buffer - Pointer to the return data buffer
815 * structure_size - Pointer to where the number of bytes
816 * in the return data struct is returned
817 * 297 *
818 * RETURN: Status 298 * RETURN: TRUE if the resource_type field is OK, FALSE otherwise
819 * 299 *
820 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 300 * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
821 * structure pointed to by the output_buffer. Return the 301 * to an internal resource descriptor
822 * number of bytes consumed from the byte stream.
823 * 302 *
824 ******************************************************************************/ 303 ******************************************************************************/
825 304
826acpi_status 305u8
827acpi_rs_address64_resource(u8 * byte_stream_buffer, 306acpi_rs_get_address_common(struct acpi_resource *resource,
828 acpi_size * bytes_consumed, 307 union aml_resource *aml)
829 u8 ** output_buffer, acpi_size * structure_size)
830{ 308{
831 u16 temp16; 309 ACPI_FUNCTION_ENTRY();
832 u8 temp8;
833 u8 resource_type;
834 u8 *temp_ptr;
835 u32 index;
836 u8 *buffer = byte_stream_buffer;
837 struct acpi_resource *output_struct = (void *)*output_buffer;
838 acpi_size struct_size =
839 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64);
840
841 ACPI_FUNCTION_TRACE("rs_address64_resource");
842
843 /* Get the Descriptor Type */
844
845 resource_type = *buffer;
846
847 /* Get the Descriptor Length field */
848
849 buffer += 1;
850 ACPI_MOVE_16_TO_16(&temp16, buffer);
851
852 /* Validate minimum descriptor length */
853
854 if (temp16 < 43) {
855 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
856 }
857
858 *bytes_consumed = temp16 + 3;
859 output_struct->id = ACPI_RSTYPE_ADDRESS64;
860
861 /* Get the Resource Type (Byte3) */
862
863 buffer += 2;
864 temp8 = *buffer;
865
866 /* Values 0-2 and 0xC0-0xFF are valid */
867
868 if ((temp8 > 2) && (temp8 < 0xC0)) {
869 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
870 }
871
872 output_struct->data.address64.resource_type = temp8;
873
874 /* Get the General Flags (Byte4) */
875
876 buffer += 1;
877 acpi_rs_decode_general_flags(&output_struct->data, *buffer);
878
879 /* Get the Type Specific Flags (Byte5) */
880
881 buffer += 1;
882 acpi_rs_decode_specific_flags(&output_struct->data, *buffer);
883 310
884 if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { 311 /* Validate the Resource Type */
885 /* Move past revision_id and Reserved byte */
886 312
887 buffer += 2; 313 if ((aml->address.resource_type > 2)
314 && (aml->address.resource_type < 0xC0)) {
315 return (FALSE);
888 } 316 }
889 317
890 /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */ 318 /* Get the Resource Type and General Flags */
891
892 buffer += 1;
893 ACPI_MOVE_64_TO_64(&output_struct->data.address64.granularity, buffer);
894
895 /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */
896
897 buffer += 8;
898 ACPI_MOVE_64_TO_64(&output_struct->data.address64.min_address_range,
899 buffer);
900
901 /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */
902
903 buffer += 8;
904 ACPI_MOVE_64_TO_64(&output_struct->data.address64.max_address_range,
905 buffer);
906
907 /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */
908
909 buffer += 8;
910 ACPI_MOVE_64_TO_64(&output_struct->data.address64.
911 address_translation_offset, buffer);
912 319
913 /* Get address_length (Bytes 38-45) or (Bytes 40-47) */ 320 (void)acpi_rs_convert_aml_to_resource(resource, aml,
321 acpi_rs_convert_general_flags);
914 322
915 buffer += 8; 323 /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
916 ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length,
917 buffer);
918 324
919 output_struct->data.address64.resource_source.index = 0; 325 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
920 output_struct->data.address64.resource_source.string_length = 0; 326 (void)acpi_rs_convert_aml_to_resource(resource, aml,
921 output_struct->data.address64.resource_source.string_ptr = NULL; 327 acpi_rs_convert_mem_flags);
922 328 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
923 if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { 329 (void)acpi_rs_convert_aml_to_resource(resource, aml,
924 /* Get type_specific_attribute (Bytes 48-55) */ 330 acpi_rs_convert_io_flags);
925
926 buffer += 8;
927 ACPI_MOVE_64_TO_64(&output_struct->data.address64.
928 type_specific_attributes, buffer);
929 } else { 331 } else {
930 output_struct->data.address64.type_specific_attributes = 0; 332 /* Generic resource type, just grab the type_specific byte */
931
932 /* Resource Source Index (if present) */
933
934 buffer += 8;
935
936 /*
937 * This will leave us pointing to the Resource Source Index
938 * If it is present, then save it off and calculate the
939 * pointer to where the null terminated string goes:
940 * Each Interrupt takes 32-bits + the 5 bytes of the
941 * stream that are default.
942 *
943 * Note: Some resource descriptors will have an additional null, so
944 * we add 1 to the length.
945 */
946 if (*bytes_consumed > (46 + 1)) {
947 /* Dereference the Index */
948
949 output_struct->data.address64.resource_source.index =
950 (u32) * buffer;
951
952 /* Point to the String */
953
954 buffer += 1;
955
956 /* Point the String pointer to the end of this structure */
957
958 output_struct->data.address64.resource_source.
959 string_ptr =
960 (char *)((u8 *) output_struct + struct_size);
961
962 temp_ptr = (u8 *)
963 output_struct->data.address64.resource_source.
964 string_ptr;
965
966 /* Copy the resource_source string into the buffer */
967
968 index = 0;
969 while (*buffer) {
970 *temp_ptr = *buffer;
971
972 temp_ptr++;
973 buffer++;
974 index++;
975 }
976
977 /*
978 * Add the terminating null and set the string length
979 */
980 *temp_ptr = 0;
981 output_struct->data.address64.resource_source.
982 string_length = index + 1;
983
984 /*
985 * In order for the struct_size to fall on a 32-bit boundary,
986 * calculate the length of the string and expand the
987 * struct_size to the next 32-bit boundary.
988 */
989 temp8 = (u8) (index + 1);
990 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
991 }
992 }
993
994 /* Set the Length parameter */
995
996 output_struct->length = (u32) struct_size;
997 333
998 /* Return the final size of the structure */ 334 resource->data.address.info.type_specific =
335 aml->address.specific_flags;
336 }
999 337
1000 *structure_size = struct_size; 338 return (TRUE);
1001 return_ACPI_STATUS(AE_OK);
1002} 339}
1003 340
1004/******************************************************************************* 341/*******************************************************************************
1005 * 342 *
1006 * FUNCTION: acpi_rs_address64_stream 343 * FUNCTION: acpi_rs_set_address_common
1007 * 344 *
1008 * PARAMETERS: linked_list - Pointer to the resource linked list 345 * PARAMETERS: Aml - Pointer to the AML resource descriptor
1009 * output_buffer - Pointer to the user's return buffer 346 * Resource - Pointer to the internal resource struct
1010 * bytes_consumed - Pointer to where the number of bytes
1011 * used in the output_buffer is returned
1012 * 347 *
1013 * RETURN: Status 348 * RETURN: None
1014 * 349 *
1015 * DESCRIPTION: Take the linked list resource structure and fills in the 350 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
1016 * the appropriate bytes in a byte stream 351 * AML descriptor
1017 * 352 *
1018 ******************************************************************************/ 353 ******************************************************************************/
1019 354
1020acpi_status 355void
1021acpi_rs_address64_stream(struct acpi_resource *linked_list, 356acpi_rs_set_address_common(union aml_resource *aml,
1022 u8 ** output_buffer, acpi_size * bytes_consumed) 357 struct acpi_resource *resource)
1023{ 358{
1024 u8 *buffer; 359 ACPI_FUNCTION_ENTRY();
1025 u16 *length_field;
1026
1027 ACPI_FUNCTION_TRACE("rs_address64_stream");
1028
1029 buffer = *output_buffer;
1030
1031 /* Set the Descriptor Type field */
1032
1033 *buffer = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE;
1034 buffer += 1;
1035
1036 /* Save a pointer to the Length field - to be filled in later */
1037
1038 length_field = ACPI_CAST_PTR(u16, buffer);
1039 buffer += 2;
1040
1041 /* Set the Resource Type (Memory, Io, bus_number) */
1042
1043 *buffer = (u8) (linked_list->data.address64.resource_type & 0x03);
1044 buffer += 1;
1045
1046 /* Set the general flags */
1047
1048 *buffer = acpi_rs_encode_general_flags(&linked_list->data);
1049 buffer += 1;
1050
1051 /* Set the type specific flags */
1052
1053 *buffer = acpi_rs_encode_specific_flags(&linked_list->data);
1054 buffer += 1;
1055
1056 /* Set the address space granularity */
1057
1058 ACPI_MOVE_64_TO_64(buffer, &linked_list->data.address64.granularity);
1059 buffer += 8;
1060
1061 /* Set the address range minimum */
1062
1063 ACPI_MOVE_64_TO_64(buffer,
1064 &linked_list->data.address64.min_address_range);
1065 buffer += 8;
1066
1067 /* Set the address range maximum */
1068
1069 ACPI_MOVE_64_TO_64(buffer,
1070 &linked_list->data.address64.max_address_range);
1071 buffer += 8;
1072
1073 /* Set the address translation offset */
1074
1075 ACPI_MOVE_64_TO_64(buffer,
1076 &linked_list->data.address64.
1077 address_translation_offset);
1078 buffer += 8;
1079
1080 /* Set the address length */
1081
1082 ACPI_MOVE_64_TO_64(buffer, &linked_list->data.address64.address_length);
1083 buffer += 8;
1084 360
1085 /* Resource Source Index and Resource Source are optional */ 361 /* Set the Resource Type and General Flags */
1086 362
1087 if (linked_list->data.address64.resource_source.string_length) { 363 (void)acpi_rs_convert_resource_to_aml(resource, aml,
1088 *buffer = 364 acpi_rs_convert_general_flags);
1089 (u8) linked_list->data.address64.resource_source.index;
1090 buffer += 1;
1091 365
1092 /* Copy the resource_source string */ 366 /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
1093 367
1094 ACPI_STRCPY((char *)buffer, 368 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
1095 linked_list->data.address64.resource_source. 369 (void)acpi_rs_convert_resource_to_aml(resource, aml,
1096 string_ptr); 370 acpi_rs_convert_mem_flags);
371 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
372 (void)acpi_rs_convert_resource_to_aml(resource, aml,
373 acpi_rs_convert_io_flags);
374 } else {
375 /* Generic resource type, just copy the type_specific byte */
1097 376
1098 /* 377 aml->address.specific_flags =
1099 * Buffer needs to be set to the length of the string + one for the 378 resource->data.address.info.type_specific;
1100 * terminating null
1101 */
1102 buffer +=
1103 (acpi_size) (ACPI_STRLEN
1104 (linked_list->data.address64.resource_source.
1105 string_ptr) + 1);
1106 } 379 }
1107
1108 /* Return the number of bytes consumed in this operation */
1109
1110 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
1111
1112 /*
1113 * Set the length field to the number of bytes consumed
1114 * minus the header size (3 bytes)
1115 */
1116 *length_field = (u16) (*bytes_consumed - 3);
1117 return_ACPI_STATUS(AE_OK);
1118} 380}
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index 378f58390fc1..7d6481d9fbec 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,652 +49,433 @@
49#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
50ACPI_MODULE_NAME("rscalc") 50ACPI_MODULE_NAME("rscalc")
51 51
52/* Local prototypes */
53static u8 acpi_rs_count_set_bits(u16 bit_field);
54
55static acpi_rs_length
56acpi_rs_struct_option_length(struct acpi_resource_source *resource_source);
57
58static u32
59acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length);
60
52/******************************************************************************* 61/*******************************************************************************
53 * 62 *
54 * FUNCTION: acpi_rs_get_byte_stream_length 63 * FUNCTION: acpi_rs_count_set_bits
55 * 64 *
56 * PARAMETERS: linked_list - Pointer to the resource linked list 65 * PARAMETERS: bit_field - Field in which to count bits
57 * size_needed - u32 pointer of the size buffer needed
58 * to properly return the parsed data
59 * 66 *
60 * RETURN: Status 67 * RETURN: Number of bits set within the field
61 * 68 *
62 * DESCRIPTION: Takes the resource byte stream and parses it once, calculating 69 * DESCRIPTION: Count the number of bits set in a resource field. Used for
63 * the size buffer needed to hold the linked list that conveys 70 * (Short descriptor) interrupt and DMA lists.
64 * the resource data.
65 * 71 *
66 ******************************************************************************/ 72 ******************************************************************************/
67acpi_status
68acpi_rs_get_byte_stream_length(struct acpi_resource *linked_list,
69 acpi_size * size_needed)
70{
71 acpi_size byte_stream_size_needed = 0;
72 acpi_size segment_size;
73 u8 done = FALSE;
74
75 ACPI_FUNCTION_TRACE("rs_get_byte_stream_length");
76
77 while (!done) {
78 /* Init the variable that will hold the size to add to the total. */
79
80 segment_size = 0;
81
82 switch (linked_list->id) {
83 case ACPI_RSTYPE_IRQ:
84 /*
85 * IRQ Resource
86 * For an IRQ Resource, Byte 3, although optional, will always be
87 * created - it holds IRQ information.
88 */
89 segment_size = 4;
90 break;
91
92 case ACPI_RSTYPE_DMA:
93 /*
94 * DMA Resource
95 * For this resource the size is static
96 */
97 segment_size = 3;
98 break;
99
100 case ACPI_RSTYPE_START_DPF:
101 /*
102 * Start Dependent Functions Resource
103 * For a start_dependent_functions Resource, Byte 1, although
104 * optional, will always be created.
105 */
106 segment_size = 2;
107 break;
108
109 case ACPI_RSTYPE_END_DPF:
110 /*
111 * End Dependent Functions Resource
112 * For this resource the size is static
113 */
114 segment_size = 1;
115 break;
116
117 case ACPI_RSTYPE_IO:
118 /*
119 * IO Port Resource
120 * For this resource the size is static
121 */
122 segment_size = 8;
123 break;
124 73
125 case ACPI_RSTYPE_FIXED_IO: 74static u8 acpi_rs_count_set_bits(u16 bit_field)
126 /* 75{
127 * Fixed IO Port Resource 76 u8 bits_set;
128 * For this resource the size is static
129 */
130 segment_size = 4;
131 break;
132
133 case ACPI_RSTYPE_VENDOR:
134 /*
135 * Vendor Defined Resource
136 * For a Vendor Specific resource, if the Length is between 1 and 7
137 * it will be created as a Small Resource data type, otherwise it
138 * is a Large Resource data type.
139 */
140 if (linked_list->data.vendor_specific.length > 7) {
141 segment_size = 3;
142 } else {
143 segment_size = 1;
144 }
145 segment_size +=
146 linked_list->data.vendor_specific.length;
147 break;
148
149 case ACPI_RSTYPE_END_TAG:
150 /*
151 * End Tag
152 * For this resource the size is static
153 */
154 segment_size = 2;
155 done = TRUE;
156 break;
157
158 case ACPI_RSTYPE_MEM24:
159 /*
160 * 24-Bit Memory Resource
161 * For this resource the size is static
162 */
163 segment_size = 12;
164 break;
165 77
166 case ACPI_RSTYPE_MEM32: 78 ACPI_FUNCTION_ENTRY();
167 /*
168 * 32-Bit Memory Range Resource
169 * For this resource the size is static
170 */
171 segment_size = 20;
172 break;
173 79
174 case ACPI_RSTYPE_FIXED_MEM32: 80 for (bits_set = 0; bit_field; bits_set++) {
175 /* 81 /* Zero the least significant bit that is set */
176 * 32-Bit Fixed Memory Resource
177 * For this resource the size is static
178 */
179 segment_size = 12;
180 break;
181 82
182 case ACPI_RSTYPE_ADDRESS16: 83 bit_field &= (bit_field - 1);
183 /* 84 }
184 * 16-Bit Address Resource
185 * The base size of this byte stream is 16. If a Resource Source
186 * string is not NULL, add 1 for the Index + the length of the null
187 * terminated string Resource Source + 1 for the null.
188 */
189 segment_size = 16;
190
191 if (linked_list->data.address16.resource_source.
192 string_ptr) {
193 segment_size +=
194 linked_list->data.address16.resource_source.
195 string_length;
196 segment_size++;
197 }
198 break;
199 85
200 case ACPI_RSTYPE_ADDRESS32: 86 return (bits_set);
201 /* 87}
202 * 32-Bit Address Resource
203 * The base size of this byte stream is 26. If a Resource
204 * Source string is not NULL, add 1 for the Index + the
205 * length of the null terminated string Resource Source +
206 * 1 for the null.
207 */
208 segment_size = 26;
209
210 if (linked_list->data.address32.resource_source.
211 string_ptr) {
212 segment_size +=
213 linked_list->data.address32.resource_source.
214 string_length;
215 segment_size++;
216 }
217 break;
218 88
219 case ACPI_RSTYPE_ADDRESS64: 89/*******************************************************************************
220 /* 90 *
221 * 64-Bit Address Resource 91 * FUNCTION: acpi_rs_struct_option_length
222 * The base size of this byte stream is 46. If a resource_source 92 *
223 * string is not NULL, add 1 for the Index + the length of the null 93 * PARAMETERS: resource_source - Pointer to optional descriptor field
224 * terminated string Resource Source + 1 for the null. 94 *
225 */ 95 * RETURN: Status
226 segment_size = 46; 96 *
227 97 * DESCRIPTION: Common code to handle optional resource_source_index and
228 if (linked_list->data.address64.resource_source. 98 * resource_source fields in some Large descriptors. Used during
229 string_ptr) { 99 * list-to-stream conversion
230 segment_size += 100 *
231 linked_list->data.address64.resource_source. 101 ******************************************************************************/
232 string_length;
233 segment_size++;
234 }
235 break;
236 102
237 case ACPI_RSTYPE_EXT_IRQ: 103static acpi_rs_length
238 /* 104acpi_rs_struct_option_length(struct acpi_resource_source *resource_source)
239 * Extended IRQ Resource 105{
240 * The base size of this byte stream is 9. This is for an Interrupt 106 ACPI_FUNCTION_ENTRY();
241 * table length of 1. For each additional interrupt, add 4.
242 * If a Resource Source string is not NULL, add 1 for the
243 * Index + the length of the null terminated string
244 * Resource Source + 1 for the null.
245 */
246 segment_size = 9 + (((acpi_size)
247 linked_list->data.extended_irq.
248 number_of_interrupts - 1) * 4);
249
250 if (linked_list->data.extended_irq.resource_source.
251 string_ptr) {
252 segment_size +=
253 linked_list->data.extended_irq.
254 resource_source.string_length;
255 segment_size++;
256 }
257 break;
258 107
259 default: 108 /*
109 * If the resource_source string is valid, return the size of the string
110 * (string_length includes the NULL terminator) plus the size of the
111 * resource_source_index (1).
112 */
113 if (resource_source->string_ptr) {
114 return ((acpi_rs_length) (resource_source->string_length + 1));
115 }
260 116
261 /* If we get here, everything is out of sync, exit with error */ 117 return (0);
118}
262 119
263 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 120/*******************************************************************************
121 *
122 * FUNCTION: acpi_rs_stream_option_length
123 *
124 * PARAMETERS: resource_length - Length from the resource header
125 * minimum_total_length - Minimum length of this resource, before
126 * any optional fields. Includes header size
127 *
128 * RETURN: Length of optional string (0 if no string present)
129 *
130 * DESCRIPTION: Common code to handle optional resource_source_index and
131 * resource_source fields in some Large descriptors. Used during
132 * stream-to-list conversion
133 *
134 ******************************************************************************/
264 135
265 } /* switch (linked_list->Id) */ 136static u32
137acpi_rs_stream_option_length(u32 resource_length,
138 u32 minimum_aml_resource_length)
139{
140 u32 string_length = 0;
266 141
267 /* Update the total */ 142 ACPI_FUNCTION_ENTRY();
268 143
269 byte_stream_size_needed += segment_size; 144 /*
145 * The resource_source_index and resource_source are optional elements of some
146 * Large-type resource descriptors.
147 */
270 148
271 /* Point to the next object */ 149 /*
150 * If the length of the actual resource descriptor is greater than the ACPI
151 * spec-defined minimum length, it means that a resource_source_index exists
152 * and is followed by a (required) null terminated string. The string length
153 * (including the null terminator) is the resource length minus the minimum
154 * length, minus one byte for the resource_source_index itself.
155 */
156 if (resource_length > minimum_aml_resource_length) {
157 /* Compute the length of the optional string */
272 158
273 linked_list = ACPI_PTR_ADD(struct acpi_resource, 159 string_length =
274 linked_list, linked_list->length); 160 resource_length - minimum_aml_resource_length - 1;
275 } 161 }
276 162
277 /* This is the data the caller needs */ 163 /* Round up length to 32 bits for internal structure alignment */
278 164
279 *size_needed = byte_stream_size_needed; 165 return (ACPI_ROUND_UP_to_32_bITS(string_length));
280 return_ACPI_STATUS(AE_OK);
281} 166}
282 167
283/******************************************************************************* 168/*******************************************************************************
284 * 169 *
285 * FUNCTION: acpi_rs_get_list_length 170 * FUNCTION: acpi_rs_get_aml_length
286 * 171 *
287 * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream 172 * PARAMETERS: Resource - Pointer to the resource linked list
288 * byte_stream_buffer_length - Size of byte_stream_buffer 173 * size_needed - Where the required size is returned
289 * size_needed - u32 pointer of the size buffer
290 * needed to properly return the
291 * parsed data
292 * 174 *
293 * RETURN: Status 175 * RETURN: Status
294 * 176 *
295 * DESCRIPTION: Takes the resource byte stream and parses it once, calculating 177 * DESCRIPTION: Takes a linked list of internal resource descriptors and
296 * the size buffer needed to hold the linked list that conveys 178 * calculates the size buffer needed to hold the corresponding
297 * the resource data. 179 * external resource byte stream.
298 * 180 *
299 ******************************************************************************/ 181 ******************************************************************************/
300 182
301acpi_status 183acpi_status
302acpi_rs_get_list_length(u8 * byte_stream_buffer, 184acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
303 u32 byte_stream_buffer_length, acpi_size * size_needed)
304{ 185{
305 u32 buffer_size = 0; 186 acpi_size aml_size_needed = 0;
306 u32 bytes_parsed = 0; 187 acpi_rs_length total_size;
307 u8 number_of_interrupts = 0;
308 u8 number_of_channels = 0;
309 u8 resource_type;
310 u32 structure_size;
311 u32 bytes_consumed;
312 u8 *buffer;
313 u8 temp8;
314 u16 temp16;
315 u8 index;
316 u8 additional_bytes;
317
318 ACPI_FUNCTION_TRACE("rs_get_list_length");
319 188
320 while (bytes_parsed < byte_stream_buffer_length) { 189 ACPI_FUNCTION_TRACE("rs_get_aml_length");
321 /* The next byte in the stream is the resource type */
322 190
323 resource_type = acpi_rs_get_resource_type(*byte_stream_buffer); 191 /* Traverse entire list of internal resource descriptors */
324 192
325 switch (resource_type) { 193 while (resource) {
326 case ACPI_RDESC_TYPE_MEMORY_24: 194 /* Validate the descriptor type */
327 /*
328 * 24-Bit Memory Resource
329 */
330 bytes_consumed = 12;
331
332 structure_size =
333 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24);
334 break;
335 195
336 case ACPI_RDESC_TYPE_LARGE_VENDOR: 196 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
337 /* 197 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
338 * Vendor Defined Resource 198 }
339 */
340 buffer = byte_stream_buffer;
341 ++buffer;
342
343 ACPI_MOVE_16_TO_16(&temp16, buffer);
344 bytes_consumed = temp16 + 3;
345
346 /* Ensure a 32-bit boundary for the structure */
347 199
348 temp16 = (u16) ACPI_ROUND_UP_to_32_bITS(temp16); 200 /* Get the base size of the (external stream) resource descriptor */
349 201
350 structure_size = 202 total_size = acpi_gbl_aml_resource_sizes[resource->type];
351 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) +
352 (temp16 * sizeof(u8));
353 break;
354 203
355 case ACPI_RDESC_TYPE_MEMORY_32: 204 /*
205 * Augment the base size for descriptors with optional and/or
206 * variable-length fields
207 */
208 switch (resource->type) {
209 case ACPI_RESOURCE_TYPE_VENDOR:
356 /* 210 /*
357 * 32-Bit Memory Range Resource 211 * Vendor Defined Resource:
212 * For a Vendor Specific resource, if the Length is between 1 and 7
213 * it will be created as a Small Resource data type, otherwise it
214 * is a Large Resource data type.
358 */ 215 */
359 bytes_consumed = 20; 216 if (resource->data.vendor.byte_length > 7) {
217 /* Base size of a Large resource descriptor */
360 218
361 structure_size = 219 total_size =
362 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32); 220 sizeof(struct aml_resource_large_header);
363 break; 221 }
364 222
365 case ACPI_RDESC_TYPE_FIXED_MEMORY_32: 223 /* Add the size of the vendor-specific data */
366 /*
367 * 32-Bit Fixed Memory Resource
368 */
369 bytes_consumed = 12;
370 224
371 structure_size = 225 total_size = (acpi_rs_length)
372 ACPI_SIZEOF_RESOURCE(struct 226 (total_size + resource->data.vendor.byte_length);
373 acpi_resource_fixed_mem32);
374 break; 227 break;
375 228
376 case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE: 229 case ACPI_RESOURCE_TYPE_END_TAG:
377 /* 230 /*
378 * 64-Bit Address Resource 231 * End Tag:
232 * We are done -- return the accumulated total size.
379 */ 233 */
380 buffer = byte_stream_buffer; 234 *size_needed = aml_size_needed + total_size;
381 235
382 ++buffer; 236 /* Normal exit */
383 ACPI_MOVE_16_TO_16(&temp16, buffer);
384 237
385 bytes_consumed = temp16 + 3; 238 return_ACPI_STATUS(AE_OK);
386 structure_size =
387 ACPI_SIZEOF_RESOURCE(struct
388 acpi_resource_address64);
389 break;
390 239
391 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: 240 case ACPI_RESOURCE_TYPE_ADDRESS16:
392 /* 241 /*
393 * 64-Bit Address Resource 242 * 16-Bit Address Resource:
243 * Add the size of the optional resource_source info
394 */ 244 */
395 buffer = byte_stream_buffer; 245 total_size = (acpi_rs_length)
396 246 (total_size +
397 ++buffer; 247 acpi_rs_struct_option_length(&resource->data.
398 ACPI_MOVE_16_TO_16(&temp16, buffer); 248 address16.
399 249 resource_source));
400 bytes_consumed = temp16 + 3; 250 break;
401 251
252 case ACPI_RESOURCE_TYPE_ADDRESS32:
402 /* 253 /*
403 * Resource Source Index and Resource Source are optional elements. 254 * 32-Bit Address Resource:
404 * Check the length of the Bytestream. If it is greater than 43, 255 * Add the size of the optional resource_source info
405 * that means that an Index exists and is followed by a null
406 * terminated string. Therefore, set the temp variable to the
407 * length minus the minimum byte stream length plus the byte for
408 * the Index to determine the size of the NULL terminated string.
409 */ 256 */
410 if (43 < temp16) { 257 total_size = (acpi_rs_length)
411 temp8 = (u8) (temp16 - 44); 258 (total_size +
412 } else { 259 acpi_rs_struct_option_length(&resource->data.
413 temp8 = 0; 260 address32.
414 } 261 resource_source));
415
416 /* Ensure a 64-bit boundary for the structure */
417
418 temp8 = (u8) ACPI_ROUND_UP_to_64_bITS(temp8);
419
420 structure_size =
421 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)
422 + (temp8 * sizeof(u8));
423 break; 262 break;
424 263
425 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: 264 case ACPI_RESOURCE_TYPE_ADDRESS64:
426 /* 265 /*
427 * 32-Bit Address Resource 266 * 64-Bit Address Resource:
267 * Add the size of the optional resource_source info
428 */ 268 */
429 buffer = byte_stream_buffer; 269 total_size = (acpi_rs_length)
430 270 (total_size +
431 ++buffer; 271 acpi_rs_struct_option_length(&resource->data.
432 ACPI_MOVE_16_TO_16(&temp16, buffer); 272 address64.
433 273 resource_source));
434 bytes_consumed = temp16 + 3; 274 break;
435 275
276 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
436 /* 277 /*
437 * Resource Source Index and Resource Source are optional elements. 278 * Extended IRQ Resource:
438 * Check the length of the Bytestream. If it is greater than 23, 279 * Add the size of each additional optional interrupt beyond the
439 * that means that an Index exists and is followed by a null 280 * required 1 (4 bytes for each u32 interrupt number)
440 * terminated string. Therefore, set the temp variable to the
441 * length minus the minimum byte stream length plus the byte for
442 * the Index to determine the size of the NULL terminated string.
443 */ 281 */
444 if (23 < temp16) { 282 total_size = (acpi_rs_length)
445 temp8 = (u8) (temp16 - 24); 283 (total_size +
446 } else { 284 ((resource->data.extended_irq.interrupt_count -
447 temp8 = 0; 285 1) * 4) +
448 } 286 /* Add the size of the optional resource_source info */
449 287 acpi_rs_struct_option_length(&resource->data.
450 /* Ensure a 32-bit boundary for the structure */ 288 extended_irq.
451 289 resource_source));
452 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); 290 break;
453 291
454 structure_size = 292 default:
455 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)
456 + (temp8 * sizeof(u8));
457 break; 293 break;
294 }
458 295
459 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: 296 /* Update the total */
460 /*
461 * 16-Bit Address Resource
462 */
463 buffer = byte_stream_buffer;
464 297
465 ++buffer; 298 aml_size_needed += total_size;
466 ACPI_MOVE_16_TO_16(&temp16, buffer);
467 299
468 bytes_consumed = temp16 + 3; 300 /* Point to the next object */
469 301
470 /* 302 resource =
471 * Resource Source Index and Resource Source are optional elements. 303 ACPI_ADD_PTR(struct acpi_resource, resource,
472 * Check the length of the Bytestream. If it is greater than 13, 304 resource->length);
473 * that means that an Index exists and is followed by a null 305 }
474 * terminated string. Therefore, set the temp variable to the
475 * length minus the minimum byte stream length plus the byte for
476 * the Index to determine the size of the NULL terminated string.
477 */
478 if (13 < temp16) {
479 temp8 = (u8) (temp16 - 14);
480 } else {
481 temp8 = 0;
482 }
483 306
484 /* Ensure a 32-bit boundary for the structure */ 307 /* Did not find an end_tag resource descriptor */
485 308
486 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); 309 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
310}
487 311
488 structure_size = 312/*******************************************************************************
489 ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16) 313 *
490 + (temp8 * sizeof(u8)); 314 * FUNCTION: acpi_rs_get_list_length
491 break; 315 *
316 * PARAMETERS: aml_buffer - Pointer to the resource byte stream
317 * aml_buffer_length - Size of aml_buffer
318 * size_needed - Where the size needed is returned
319 *
320 * RETURN: Status
321 *
322 * DESCRIPTION: Takes an external resource byte stream and calculates the size
323 * buffer needed to hold the corresponding internal resource
324 * descriptor linked list.
325 *
326 ******************************************************************************/
492 327
493 case ACPI_RDESC_TYPE_EXTENDED_XRUPT: 328acpi_status
494 /* 329acpi_rs_get_list_length(u8 * aml_buffer,
495 * Extended IRQ 330 u32 aml_buffer_length, acpi_size * size_needed)
496 */ 331{
497 buffer = byte_stream_buffer; 332 acpi_status status;
333 u8 *end_aml;
334 u8 *buffer;
335 u32 buffer_size = 0;
336 u16 temp16;
337 u16 resource_length;
338 u32 extra_struct_bytes;
339 u8 resource_index;
340 u8 minimum_aml_resource_length;
498 341
499 ++buffer; 342 ACPI_FUNCTION_TRACE("rs_get_list_length");
500 ACPI_MOVE_16_TO_16(&temp16, buffer);
501 343
502 bytes_consumed = temp16 + 3; 344 end_aml = aml_buffer + aml_buffer_length;
503 345
504 /* 346 /* Walk the list of AML resource descriptors */
505 * Point past the length field and the Interrupt vector flags to
506 * save off the Interrupt table length to the Temp8 variable.
507 */
508 buffer += 3;
509 temp8 = *buffer;
510 347
511 /* 348 while (aml_buffer < end_aml) {
512 * To compensate for multiple interrupt numbers, add 4 bytes for 349 /* Validate the Resource Type and Resource Length */
513 * each additional interrupts greater than 1
514 */
515 additional_bytes = (u8) ((temp8 - 1) * 4);
516 350
517 /* 351 status = acpi_ut_validate_resource(aml_buffer, &resource_index);
518 * Resource Source Index and Resource Source are optional elements. 352 if (ACPI_FAILURE(status)) {
519 * Check the length of the Bytestream. If it is greater than 9, 353 return_ACPI_STATUS(status);
520 * that means that an Index exists and is followed by a null 354 }
521 * terminated string. Therefore, set the temp variable to the
522 * length minus the minimum byte stream length plus the byte for
523 * the Index to determine the size of the NULL terminated string.
524 */
525 if (9 + additional_bytes < temp16) {
526 temp8 = (u8) (temp16 - (9 + additional_bytes));
527 } else {
528 temp8 = 0;
529 }
530 355
531 /* Ensure a 32-bit boundary for the structure */ 356 /* Get the resource length and base (minimum) AML size */
532 357
533 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); 358 resource_length = acpi_ut_get_resource_length(aml_buffer);
359 minimum_aml_resource_length =
360 acpi_gbl_resource_aml_sizes[resource_index];
534 361
535 structure_size = 362 /*
536 ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq) + 363 * Augment the size for descriptors with optional
537 (additional_bytes * sizeof(u8)) + 364 * and/or variable length fields
538 (temp8 * sizeof(u8)); 365 */
539 break; 366 extra_struct_bytes = 0;
367 buffer =
368 aml_buffer + acpi_ut_get_resource_header_length(aml_buffer);
540 369
541 case ACPI_RDESC_TYPE_IRQ_FORMAT: 370 switch (acpi_ut_get_resource_type(aml_buffer)) {
371 case ACPI_RESOURCE_NAME_IRQ:
542 /* 372 /*
543 * IRQ Resource. 373 * IRQ Resource:
544 * Determine if it there are two or three trailing bytes 374 * Get the number of bits set in the 16-bit IRQ mask
545 */ 375 */
546 buffer = byte_stream_buffer;
547 temp8 = *buffer;
548
549 if (temp8 & 0x01) {
550 bytes_consumed = 4;
551 } else {
552 bytes_consumed = 3;
553 }
554
555 /* Point past the descriptor */
556
557 ++buffer;
558
559 /* Look at the number of bits set */
560
561 ACPI_MOVE_16_TO_16(&temp16, buffer); 376 ACPI_MOVE_16_TO_16(&temp16, buffer);
562 377 extra_struct_bytes = acpi_rs_count_set_bits(temp16);
563 for (index = 0; index < 16; index++) {
564 if (temp16 & 0x1) {
565 ++number_of_interrupts;
566 }
567
568 temp16 >>= 1;
569 }
570
571 structure_size =
572 ACPI_SIZEOF_RESOURCE(struct acpi_resource_io) +
573 (number_of_interrupts * sizeof(u32));
574 break; 378 break;
575 379
576 case ACPI_RDESC_TYPE_DMA_FORMAT: 380 case ACPI_RESOURCE_NAME_DMA:
577 /* 381 /*
578 * DMA Resource 382 * DMA Resource:
383 * Get the number of bits set in the 8-bit DMA mask
579 */ 384 */
580 buffer = byte_stream_buffer; 385 extra_struct_bytes = acpi_rs_count_set_bits(*buffer);
581 bytes_consumed = 3;
582
583 /* Point past the descriptor */
584
585 ++buffer;
586
587 /* Look at the number of bits set */
588
589 temp8 = *buffer;
590
591 for (index = 0; index < 8; index++) {
592 if (temp8 & 0x1) {
593 ++number_of_channels;
594 }
595
596 temp8 >>= 1;
597 }
598
599 structure_size =
600 ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma) +
601 (number_of_channels * sizeof(u32));
602 break; 386 break;
603 387
604 case ACPI_RDESC_TYPE_START_DEPENDENT: 388 case ACPI_RESOURCE_NAME_VENDOR_SMALL:
605 /* 389 /*
606 * Start Dependent Functions Resource 390 * Vendor Resource:
607 * Determine if it there are two or three trailing bytes 391 * Ensure a 32-bit boundary for the structure
608 */ 392 */
609 buffer = byte_stream_buffer; 393 extra_struct_bytes =
610 temp8 = *buffer; 394 ACPI_ROUND_UP_to_32_bITS(resource_length) -
611 395 resource_length;
612 if (temp8 & 0x01) {
613 bytes_consumed = 2;
614 } else {
615 bytes_consumed = 1;
616 }
617
618 structure_size =
619 ACPI_SIZEOF_RESOURCE(struct
620 acpi_resource_start_dpf);
621 break; 396 break;
622 397
623 case ACPI_RDESC_TYPE_END_DEPENDENT: 398 case ACPI_RESOURCE_NAME_END_TAG:
624 /* 399 /*
625 * End Dependent Functions Resource 400 * End Tag: This is the normal exit, add size of end_tag
626 */ 401 */
627 bytes_consumed = 1; 402 *size_needed = buffer_size + ACPI_RS_SIZE_MIN;
628 structure_size = ACPI_RESOURCE_LENGTH; 403 return_ACPI_STATUS(AE_OK);
629 break;
630 404
631 case ACPI_RDESC_TYPE_IO_PORT: 405 case ACPI_RESOURCE_NAME_VENDOR_LARGE:
632 /* 406 /*
633 * IO Port Resource 407 * Vendor Resource:
408 * Add vendor data and ensure a 32-bit boundary for the structure
634 */ 409 */
635 bytes_consumed = 8; 410 extra_struct_bytes =
636 structure_size = 411 ACPI_ROUND_UP_to_32_bITS(resource_length) -
637 ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); 412 resource_length;
638 break; 413 break;
639 414
640 case ACPI_RDESC_TYPE_FIXED_IO_PORT: 415 case ACPI_RESOURCE_NAME_ADDRESS32:
416 case ACPI_RESOURCE_NAME_ADDRESS16:
641 /* 417 /*
642 * Fixed IO Port Resource 418 * 32-Bit or 16-bit Address Resource:
419 * Add the size of any optional data (resource_source)
643 */ 420 */
644 bytes_consumed = 4; 421 extra_struct_bytes =
645 structure_size = 422 acpi_rs_stream_option_length(resource_length,
646 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); 423 minimum_aml_resource_length);
647 break; 424 break;
648 425
649 case ACPI_RDESC_TYPE_SMALL_VENDOR: 426 case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
650 /* 427 /*
651 * Vendor Specific Resource 428 * Extended IRQ:
429 * Point past the interrupt_vector_flags to get the
430 * interrupt_table_length.
652 */ 431 */
653 buffer = byte_stream_buffer; 432 buffer++;
654 433
655 temp8 = *buffer; 434 extra_struct_bytes =
656 temp8 = (u8) (temp8 & 0x7); 435 /*
657 bytes_consumed = temp8 + 1; 436 * Add 4 bytes for each additional interrupt. Note: at
658 437 * least one interrupt is required and is included in
659 /* Ensure a 32-bit boundary for the structure */ 438 * the minimum descriptor size
660 439 */
661 temp8 = (u8) ACPI_ROUND_UP_to_32_bITS(temp8); 440 ((*buffer - 1) * sizeof(u32)) +
662 structure_size = 441 /* Add the size of any optional data (resource_source) */
663 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) + 442 acpi_rs_stream_option_length(resource_length -
664 (temp8 * sizeof(u8)); 443 extra_struct_bytes,
444 minimum_aml_resource_length);
665 break; 445 break;
666 446
667 case ACPI_RDESC_TYPE_END_TAG: 447 case ACPI_RESOURCE_NAME_ADDRESS64:
668 /* 448 /*
669 * End Tag 449 * 64-Bit Address Resource:
450 * Add the size of any optional data (resource_source)
451 * Ensure a 64-bit boundary for the structure
670 */ 452 */
671 bytes_consumed = 2; 453 extra_struct_bytes =
672 structure_size = ACPI_RESOURCE_LENGTH; 454 ACPI_ROUND_UP_to_64_bITS
673 byte_stream_buffer_length = bytes_parsed; 455 (acpi_rs_stream_option_length
456 (resource_length, minimum_aml_resource_length));
674 break; 457 break;
675 458
676 default: 459 default:
677 /* 460 break;
678 * If we get here, everything is out of sync,
679 * exit with an error
680 */
681 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
682 } 461 }
683 462
684 /* Update the return value and counter */ 463 /* Update the required buffer size for the internal descriptor structs */
685
686 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(structure_size);
687 bytes_parsed += bytes_consumed;
688 464
689 /* Set the byte stream to point to the next resource */ 465 temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] +
466 extra_struct_bytes);
467 buffer_size += (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(temp16);
690 468
691 byte_stream_buffer += bytes_consumed; 469 /*
470 * Point to the next resource within the stream
471 * using the size of the header plus the length contained in the header
472 */
473 aml_buffer += acpi_ut_get_descriptor_length(aml_buffer);
692 } 474 }
693 475
694 /* This is the data the caller needs */ 476 /* Did not find an end_tag resource descriptor */
695 477
696 *size_needed = buffer_size; 478 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
697 return_ACPI_STATUS(AE_OK);
698} 479}
699 480
700/******************************************************************************* 481/*******************************************************************************
@@ -760,13 +541,13 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
760 541
761 for (table_index = 0; table_index < 4 && !name_found; 542 for (table_index = 0; table_index < 4 && !name_found;
762 table_index++) { 543 table_index++) {
763 if ((ACPI_TYPE_STRING == 544 if (*sub_object_list && /* Null object allowed */
764 ACPI_GET_OBJECT_TYPE(*sub_object_list)) 545 ((ACPI_TYPE_STRING ==
765 || 546 ACPI_GET_OBJECT_TYPE(*sub_object_list)) ||
766 ((ACPI_TYPE_LOCAL_REFERENCE == 547 ((ACPI_TYPE_LOCAL_REFERENCE ==
767 ACPI_GET_OBJECT_TYPE(*sub_object_list)) 548 ACPI_GET_OBJECT_TYPE(*sub_object_list)) &&
768 && ((*sub_object_list)->reference.opcode == 549 ((*sub_object_list)->reference.opcode ==
769 AML_INT_NAMEPATH_OP))) { 550 AML_INT_NAMEPATH_OP)))) {
770 name_found = TRUE; 551 name_found = TRUE;
771 } else { 552 } else {
772 /* Look at the next element */ 553 /* Look at the next element */
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c
index 0911526b7ad8..8c128dea3252 100644
--- a/drivers/acpi/resources/rscreate.c
+++ b/drivers/acpi/resources/rscreate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -53,10 +53,10 @@ ACPI_MODULE_NAME("rscreate")
53 * 53 *
54 * FUNCTION: acpi_rs_create_resource_list 54 * FUNCTION: acpi_rs_create_resource_list
55 * 55 *
56 * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream 56 * PARAMETERS: aml_buffer - Pointer to the resource byte stream
57 * output_buffer - Pointer to the user's buffer 57 * output_buffer - Pointer to the user's buffer
58 * 58 *
59 * RETURN: Status - AE_OK if okay, else a valid acpi_status code 59 * RETURN: Status: AE_OK if okay, else a valid acpi_status code
60 * If output_buffer is not large enough, output_buffer_length 60 * If output_buffer is not large enough, output_buffer_length
61 * indicates how large output_buffer should be, else it 61 * indicates how large output_buffer should be, else it
62 * indicates how may u8 elements of output_buffer are valid. 62 * indicates how may u8 elements of output_buffer are valid.
@@ -67,33 +67,30 @@ ACPI_MODULE_NAME("rscreate")
67 * 67 *
68 ******************************************************************************/ 68 ******************************************************************************/
69acpi_status 69acpi_status
70acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, 70acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
71 struct acpi_buffer *output_buffer) 71 struct acpi_buffer *output_buffer)
72{ 72{
73 73
74 acpi_status status; 74 acpi_status status;
75 u8 *byte_stream_start; 75 u8 *aml_start;
76 acpi_size list_size_needed = 0; 76 acpi_size list_size_needed = 0;
77 u32 byte_stream_buffer_length; 77 u32 aml_buffer_length;
78 78
79 ACPI_FUNCTION_TRACE("rs_create_resource_list"); 79 ACPI_FUNCTION_TRACE("rs_create_resource_list");
80 80
81 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_buffer = %p\n", 81 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_buffer = %p\n", aml_buffer));
82 byte_stream_buffer));
83 82
84 /* Params already validated, so we don't re-validate here */ 83 /* Params already validated, so we don't re-validate here */
85 84
86 byte_stream_buffer_length = byte_stream_buffer->buffer.length; 85 aml_buffer_length = aml_buffer->buffer.length;
87 byte_stream_start = byte_stream_buffer->buffer.pointer; 86 aml_start = aml_buffer->buffer.pointer;
88 87
89 /* 88 /*
90 * Pass the byte_stream_buffer into a module that can calculate 89 * Pass the aml_buffer into a module that can calculate
91 * the buffer size needed for the linked list 90 * the buffer size needed for the linked list
92 */ 91 */
93 status = 92 status = acpi_rs_get_list_length(aml_start, aml_buffer_length,
94 acpi_rs_get_list_length(byte_stream_start, 93 &list_size_needed);
95 byte_stream_buffer_length,
96 &list_size_needed);
97 94
98 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", 95 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n",
99 status, (u32) list_size_needed)); 96 status, (u32) list_size_needed));
@@ -110,10 +107,8 @@ acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer,
110 107
111 /* Do the conversion */ 108 /* Do the conversion */
112 109
113 status = 110 status = acpi_rs_convert_aml_to_resources(aml_start, aml_buffer_length,
114 acpi_rs_byte_stream_to_list(byte_stream_start, 111 output_buffer->pointer);
115 byte_stream_buffer_length,
116 output_buffer->pointer);
117 if (ACPI_FAILURE(status)) { 112 if (ACPI_FAILURE(status)) {
118 return_ACPI_STATUS(status); 113 return_ACPI_STATUS(status);
119 } 114 }
@@ -212,21 +207,20 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
212 /* Each element of the top-level package must also be a package */ 207 /* Each element of the top-level package must also be a package */
213 208
214 if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) { 209 if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) {
215 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 210 ACPI_ERROR((AE_INFO,
216 "(PRT[%X]) Need sub-package, found %s\n", 211 "(PRT[%X]) Need sub-package, found %s",
217 index, 212 index,
218 acpi_ut_get_object_type_name 213 acpi_ut_get_object_type_name
219 (*top_object_list))); 214 (*top_object_list)));
220 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 215 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
221 } 216 }
222 217
223 /* Each sub-package must be of length 4 */ 218 /* Each sub-package must be of length 4 */
224 219
225 if ((*top_object_list)->package.count != 4) { 220 if ((*top_object_list)->package.count != 4) {
226 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 221 ACPI_ERROR((AE_INFO,
227 "(PRT[%X]) Need package of length 4, found length %d\n", 222 "(PRT[%X]) Need package of length 4, found length %d",
228 index, 223 index, (*top_object_list)->package.count));
229 (*top_object_list)->package.count));
230 return_ACPI_STATUS(AE_AML_PACKAGE_LIMIT); 224 return_ACPI_STATUS(AE_AML_PACKAGE_LIMIT);
231 } 225 }
232 226
@@ -243,11 +237,10 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
243 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 237 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
244 user_prt->address = obj_desc->integer.value; 238 user_prt->address = obj_desc->integer.value;
245 } else { 239 } else {
246 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 240 ACPI_ERROR((AE_INFO,
247 "(PRT[%X].Address) Need Integer, found %s\n", 241 "(PRT[%X].Address) Need Integer, found %s",
248 index, 242 index,
249 acpi_ut_get_object_type_name 243 acpi_ut_get_object_type_name(obj_desc)));
250 (obj_desc)));
251 return_ACPI_STATUS(AE_BAD_DATA); 244 return_ACPI_STATUS(AE_BAD_DATA);
252 } 245 }
253 246
@@ -257,76 +250,83 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
257 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 250 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
258 user_prt->pin = (u32) obj_desc->integer.value; 251 user_prt->pin = (u32) obj_desc->integer.value;
259 } else { 252 } else {
260 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 253 ACPI_ERROR((AE_INFO,
261 "(PRT[%X].Pin) Need Integer, found %s\n", 254 "(PRT[%X].Pin) Need Integer, found %s",
262 index, 255 index,
263 acpi_ut_get_object_type_name 256 acpi_ut_get_object_type_name(obj_desc)));
264 (obj_desc)));
265 return_ACPI_STATUS(AE_BAD_DATA); 257 return_ACPI_STATUS(AE_BAD_DATA);
266 } 258 }
267 259
268 /* 3) Third subobject: Dereference the PRT.source_name */ 260 /*
269 261 * 3) Third subobject: Dereference the PRT.source_name
262 * The name may be unresolved (slack mode), so allow a null object
263 */
270 obj_desc = sub_object_list[2]; 264 obj_desc = sub_object_list[2];
271 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 265 if (obj_desc) {
272 case ACPI_TYPE_LOCAL_REFERENCE: 266 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
273 267 case ACPI_TYPE_LOCAL_REFERENCE:
274 if (obj_desc->reference.opcode != AML_INT_NAMEPATH_OP) { 268
275 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 269 if (obj_desc->reference.opcode !=
276 "(PRT[%X].Source) Need name, found reference op %X\n", 270 AML_INT_NAMEPATH_OP) {
277 index, 271 ACPI_ERROR((AE_INFO,
278 obj_desc->reference.opcode)); 272 "(PRT[%X].Source) Need name, found reference op %X",
273 index,
274 obj_desc->reference.
275 opcode));
276 return_ACPI_STATUS(AE_BAD_DATA);
277 }
278
279 node = obj_desc->reference.node;
280
281 /* Use *remaining* length of the buffer as max for pathname */
282
283 path_buffer.length = output_buffer->length -
284 (u32) ((u8 *) user_prt->source -
285 (u8 *) output_buffer->pointer);
286 path_buffer.pointer = user_prt->source;
287
288 status =
289 acpi_ns_handle_to_pathname((acpi_handle)
290 node,
291 &path_buffer);
292
293 /* +1 to include null terminator */
294
295 user_prt->length +=
296 (u32) ACPI_STRLEN(user_prt->source) + 1;
297 break;
298
299 case ACPI_TYPE_STRING:
300
301 ACPI_STRCPY(user_prt->source,
302 obj_desc->string.pointer);
303
304 /*
305 * Add to the Length field the length of the string
306 * (add 1 for terminator)
307 */
308 user_prt->length += obj_desc->string.length + 1;
309 break;
310
311 case ACPI_TYPE_INTEGER:
312 /*
313 * If this is a number, then the Source Name is NULL, since the
314 * entire buffer was zeroed out, we can leave this alone.
315 *
316 * Add to the Length field the length of the u32 NULL
317 */
318 user_prt->length += sizeof(u32);
319 break;
320
321 default:
322
323 ACPI_ERROR((AE_INFO,
324 "(PRT[%X].Source) Need Ref/String/Integer, found %s",
325 index,
326 acpi_ut_get_object_type_name
327 (obj_desc)));
279 return_ACPI_STATUS(AE_BAD_DATA); 328 return_ACPI_STATUS(AE_BAD_DATA);
280 } 329 }
281
282 node = obj_desc->reference.node;
283
284 /* Use *remaining* length of the buffer as max for pathname */
285
286 path_buffer.length = output_buffer->length -
287 (u32) ((u8 *) user_prt->source -
288 (u8 *) output_buffer->pointer);
289 path_buffer.pointer = user_prt->source;
290
291 status =
292 acpi_ns_handle_to_pathname((acpi_handle) node,
293 &path_buffer);
294
295 /* +1 to include null terminator */
296
297 user_prt->length +=
298 (u32) ACPI_STRLEN(user_prt->source) + 1;
299 break;
300
301 case ACPI_TYPE_STRING:
302
303 ACPI_STRCPY(user_prt->source, obj_desc->string.pointer);
304
305 /*
306 * Add to the Length field the length of the string
307 * (add 1 for terminator)
308 */
309 user_prt->length += obj_desc->string.length + 1;
310 break;
311
312 case ACPI_TYPE_INTEGER:
313 /*
314 * If this is a number, then the Source Name is NULL, since the
315 * entire buffer was zeroed out, we can leave this alone.
316 *
317 * Add to the Length field the length of the u32 NULL
318 */
319 user_prt->length += sizeof(u32);
320 break;
321
322 default:
323
324 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
325 "(PRT[%X].Source) Need Ref/String/Integer, found %s\n",
326 index,
327 acpi_ut_get_object_type_name
328 (obj_desc)));
329 return_ACPI_STATUS(AE_BAD_DATA);
330 } 330 }
331 331
332 /* Now align the current length */ 332 /* Now align the current length */
@@ -340,11 +340,10 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
340 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 340 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
341 user_prt->source_index = (u32) obj_desc->integer.value; 341 user_prt->source_index = (u32) obj_desc->integer.value;
342 } else { 342 } else {
343 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 343 ACPI_ERROR((AE_INFO,
344 "(PRT[%X].source_index) Need Integer, found %s\n", 344 "(PRT[%X].source_index) Need Integer, found %s",
345 index, 345 index,
346 acpi_ut_get_object_type_name 346 acpi_ut_get_object_type_name(obj_desc)));
347 (obj_desc)));
348 return_ACPI_STATUS(AE_BAD_DATA); 347 return_ACPI_STATUS(AE_BAD_DATA);
349 } 348 }
350 349
@@ -360,7 +359,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
360 359
361/******************************************************************************* 360/*******************************************************************************
362 * 361 *
363 * FUNCTION: acpi_rs_create_byte_stream 362 * FUNCTION: acpi_rs_create_aml_resources
364 * 363 *
365 * PARAMETERS: linked_list_buffer - Pointer to the resource linked list 364 * PARAMETERS: linked_list_buffer - Pointer to the resource linked list
366 * output_buffer - Pointer to the user's buffer 365 * output_buffer - Pointer to the user's buffer
@@ -377,13 +376,13 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
377 ******************************************************************************/ 376 ******************************************************************************/
378 377
379acpi_status 378acpi_status
380acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, 379acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
381 struct acpi_buffer *output_buffer) 380 struct acpi_buffer *output_buffer)
382{ 381{
383 acpi_status status; 382 acpi_status status;
384 acpi_size byte_stream_size_needed = 0; 383 acpi_size aml_size_needed = 0;
385 384
386 ACPI_FUNCTION_TRACE("rs_create_byte_stream"); 385 ACPI_FUNCTION_TRACE("rs_create_aml_resources");
387 386
388 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", 387 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n",
389 linked_list_buffer)); 388 linked_list_buffer));
@@ -394,11 +393,10 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
394 * Pass the linked_list_buffer into a module that calculates 393 * Pass the linked_list_buffer into a module that calculates
395 * the buffer size needed for the byte stream. 394 * the buffer size needed for the byte stream.
396 */ 395 */
397 status = acpi_rs_get_byte_stream_length(linked_list_buffer, 396 status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed);
398 &byte_stream_size_needed);
399 397
400 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n", 398 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_size_needed=%X, %s\n",
401 (u32) byte_stream_size_needed, 399 (u32) aml_size_needed,
402 acpi_format_exception(status))); 400 acpi_format_exception(status)));
403 if (ACPI_FAILURE(status)) { 401 if (ACPI_FAILURE(status)) {
404 return_ACPI_STATUS(status); 402 return_ACPI_STATUS(status);
@@ -406,8 +404,7 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
406 404
407 /* Validate/Allocate/Clear caller buffer */ 405 /* Validate/Allocate/Clear caller buffer */
408 406
409 status = 407 status = acpi_ut_initialize_buffer(output_buffer, aml_size_needed);
410 acpi_ut_initialize_buffer(output_buffer, byte_stream_size_needed);
411 if (ACPI_FAILURE(status)) { 408 if (ACPI_FAILURE(status)) {
412 return_ACPI_STATUS(status); 409 return_ACPI_STATUS(status);
413 } 410 }
@@ -415,9 +412,9 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer,
415 /* Do the conversion */ 412 /* Do the conversion */
416 413
417 status = 414 status =
418 acpi_rs_list_to_byte_stream(linked_list_buffer, 415 acpi_rs_convert_resources_to_aml(linked_list_buffer,
419 byte_stream_size_needed, 416 aml_size_needed,
420 output_buffer->pointer); 417 output_buffer->pointer);
421 if (ACPI_FAILURE(status)) { 418 if (ACPI_FAILURE(status)) {
422 return_ACPI_STATUS(status); 419 return_ACPI_STATUS(status);
423 } 420 }
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c
index 75bd34d1783f..e7de061cf883 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/resources/rsdump.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,1063 +49,720 @@ ACPI_MODULE_NAME("rsdump")
49 49
50#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 50#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
51/* Local prototypes */ 51/* Local prototypes */
52static void acpi_rs_dump_irq(union acpi_resource_data *data); 52static void acpi_rs_out_string(char *title, char *value);
53 53
54static void acpi_rs_dump_address16(union acpi_resource_data *data); 54static void acpi_rs_out_integer8(char *title, u8 value);
55 55
56static void acpi_rs_dump_address32(union acpi_resource_data *data); 56static void acpi_rs_out_integer16(char *title, u16 value);
57 57
58static void acpi_rs_dump_address64(union acpi_resource_data *data); 58static void acpi_rs_out_integer32(char *title, u32 value);
59 59
60static void acpi_rs_dump_dma(union acpi_resource_data *data); 60static void acpi_rs_out_integer64(char *title, u64 value);
61 61
62static void acpi_rs_dump_io(union acpi_resource_data *data); 62static void acpi_rs_out_title(char *title);
63 63
64static void acpi_rs_dump_extended_irq(union acpi_resource_data *data); 64static void acpi_rs_dump_byte_list(u16 length, u8 * data);
65 65
66static void acpi_rs_dump_fixed_io(union acpi_resource_data *data); 66static void acpi_rs_dump_dword_list(u8 length, u32 * data);
67 67
68static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *data); 68static void acpi_rs_dump_short_byte_list(u8 length, u8 * data);
69 69
70static void acpi_rs_dump_memory24(union acpi_resource_data *data); 70static void
71acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
71 72
72static void acpi_rs_dump_memory32(union acpi_resource_data *data); 73static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
73 74
74static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *data); 75static void
76acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table);
75 77
76static void acpi_rs_dump_vendor_specific(union acpi_resource_data *data); 78#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f)
79#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f)
80#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info))
77 81
78/******************************************************************************* 82/*******************************************************************************
79 * 83 *
80 * FUNCTION: acpi_rs_dump_irq 84 * Resource Descriptor info tables
81 * 85 *
82 * PARAMETERS: Data - pointer to the resource structure to dump. 86 * Note: The first table entry must be a Title or Literal and must contain
83 * 87 * the table length (number of table entries)
84 * RETURN: None
85 *
86 * DESCRIPTION: Prints out the various members of the Data structure type.
87 * 88 *
88 ******************************************************************************/ 89 ******************************************************************************/
89 90
90static void acpi_rs_dump_irq(union acpi_resource_data *data) 91struct acpi_rsdump_info acpi_rs_dump_irq[6] = {
91{ 92 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL},
92 struct acpi_resource_irq *irq_data = (struct acpi_resource_irq *)data; 93 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering",
93 u8 index = 0; 94 acpi_gbl_HEdecode},
94 95 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity",
95 ACPI_FUNCTION_ENTRY(); 96 acpi_gbl_LLdecode},
96 97 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing",
97 acpi_os_printf("IRQ Resource\n"); 98 acpi_gbl_SHRdecode},
99 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count),
100 "Interrupt Count", NULL},
101 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]),
102 "Interrupt List", NULL}
103};
104
105struct acpi_rsdump_info acpi_rs_dump_dma[6] = {
106 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL},
107 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed",
108 acpi_gbl_TYPdecode},
109 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering",
110 acpi_gbl_BMdecode},
111 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type",
112 acpi_gbl_SIZdecode},
113 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count",
114 NULL},
115 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List",
116 NULL}
117};
118
119struct acpi_rsdump_info acpi_rs_dump_start_dpf[3] = {
120 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf),
121 "Start-Dependent-Functions", NULL},
122 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.compatibility_priority),
123 "Compatibility Priority", acpi_gbl_config_decode},
124 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.performance_robustness),
125 "Performance/Robustness", acpi_gbl_config_decode}
126};
127
128struct acpi_rsdump_info acpi_rs_dump_end_dpf[1] = {
129 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_dpf),
130 "End-Dependent-Functions", NULL}
131};
132
133struct acpi_rsdump_info acpi_rs_dump_io[6] = {
134 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io), "I/O", NULL},
135 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(io.io_decode), "Address Decoding",
136 acpi_gbl_io_decode},
137 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.minimum), "Address Minimum", NULL},
138 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.maximum), "Address Maximum", NULL},
139 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.alignment), "Alignment", NULL},
140 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.address_length), "Address Length",
141 NULL}
142};
143
144struct acpi_rsdump_info acpi_rs_dump_fixed_io[3] = {
145 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_io),
146 "Fixed I/O", NULL},
147 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_io.address), "Address", NULL},
148 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_io.address_length),
149 "Address Length", NULL}
150};
151
152struct acpi_rsdump_info acpi_rs_dump_vendor[3] = {
153 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_vendor),
154 "Vendor Specific", NULL},
155 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(vendor.byte_length), "Length", NULL},
156 {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET(vendor.byte_data[0]), "Vendor Data",
157 NULL}
158};
159
160struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = {
161 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "end_tag",
162 NULL}
163};
164
165struct acpi_rsdump_info acpi_rs_dump_memory24[6] = {
166 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24),
167 "24-Bit Memory Range", NULL},
168 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect),
169 "Write Protect", acpi_gbl_RWdecode},
170 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum",
171 NULL},
172 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum",
173 NULL},
174 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.alignment), "Alignment",
175 NULL},
176 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.address_length),
177 "Address Length", NULL}
178};
179
180struct acpi_rsdump_info acpi_rs_dump_memory32[6] = {
181 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32),
182 "32-Bit Memory Range", NULL},
183 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect),
184 "Write Protect", acpi_gbl_RWdecode},
185 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum",
186 NULL},
187 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum",
188 NULL},
189 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.alignment), "Alignment",
190 NULL},
191 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.address_length),
192 "Address Length", NULL}
193};
194
195struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = {
196 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32),
197 "32-Bit Fixed Memory Range", NULL},
198 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect),
199 "Write Protect", acpi_gbl_RWdecode},
200 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address",
201 NULL},
202 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length),
203 "Address Length", NULL}
204};
205
206struct acpi_rsdump_info acpi_rs_dump_address16[8] = {
207 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address16),
208 "16-Bit WORD Address Space", NULL},
209 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
210 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity",
211 NULL},
212 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum",
213 NULL},
214 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum",
215 NULL},
216 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset),
217 "Translation Offset", NULL},
218 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length),
219 "Address Length", NULL},
220 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL}
221};
222
223struct acpi_rsdump_info acpi_rs_dump_address32[8] = {
224 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address32),
225 "32-Bit DWORD Address Space", NULL},
226 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
227 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity",
228 NULL},
229 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum",
230 NULL},
231 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum",
232 NULL},
233 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset),
234 "Translation Offset", NULL},
235 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length),
236 "Address Length", NULL},
237 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL}
238};
239
240struct acpi_rsdump_info acpi_rs_dump_address64[8] = {
241 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address64),
242 "64-Bit QWORD Address Space", NULL},
243 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
244 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity",
245 NULL},
246 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum",
247 NULL},
248 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum",
249 NULL},
250 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset),
251 "Translation Offset", NULL},
252 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length),
253 "Address Length", NULL},
254 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL}
255};
256
257struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = {
258 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_address64),
259 "64-Bit Extended Address Space", NULL},
260 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
261 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity),
262 "Granularity", NULL},
263 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum),
264 "Address Minimum", NULL},
265 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum),
266 "Address Maximum", NULL},
267 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset),
268 "Translation Offset", NULL},
269 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length),
270 "Address Length", NULL},
271 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific),
272 "Type-Specific Attribute", NULL}
273};
274
275struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = {
276 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_irq),
277 "Extended IRQ", NULL},
278 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer),
279 "Type", acpi_gbl_consume_decode},
280 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering),
281 "Triggering", acpi_gbl_HEdecode},
282 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity",
283 acpi_gbl_LLdecode},
284 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing",
285 acpi_gbl_SHRdecode},
286 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL,
287 NULL},
288 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count),
289 "Interrupt Count", NULL},
290 {ACPI_RSD_DWORDLIST, ACPI_RSD_OFFSET(extended_irq.interrupts[0]),
291 "Interrupt List", NULL}
292};
293
294struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = {
295 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_generic_reg),
296 "Generic Register", NULL},
297 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.space_id), "Space ID",
298 NULL},
299 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_width), "Bit Width",
300 NULL},
301 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_offset), "Bit Offset",
302 NULL},
303 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.access_size),
304 "Access Size", NULL},
305 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL}
306};
98 307
99 acpi_os_printf(" %s Triggered\n", 308/*
100 ACPI_LEVEL_SENSITIVE == 309 * Tables used for common address descriptor flag fields
101 irq_data->edge_level ? "Level" : "Edge"); 310 */
102 311static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = {
103 acpi_os_printf(" Active %s\n", 312 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_general_flags), NULL,
104 ACPI_ACTIVE_LOW == 313 NULL},
105 irq_data->active_high_low ? "Low" : "High"); 314 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer),
106 315 "Consumer/Producer", acpi_gbl_consume_decode},
107 acpi_os_printf(" %s\n", 316 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode",
108 ACPI_SHARED == 317 acpi_gbl_DECdecode},
109 irq_data->shared_exclusive ? "Shared" : "Exclusive"); 318 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed),
110 319 "Min Relocatability", acpi_gbl_min_decode},
111 acpi_os_printf(" %X Interrupts ( ", irq_data->number_of_interrupts); 320 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed),
112 321 "Max Relocatability", acpi_gbl_max_decode}
113 for (index = 0; index < irq_data->number_of_interrupts; index++) { 322};
114 acpi_os_printf("%X ", irq_data->interrupts[index]); 323
115 } 324static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
325 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags),
326 "Resource Type", (void *)"Memory Range"},
327 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
328 "Write Protect", acpi_gbl_RWdecode},
329 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
330 "Caching", acpi_gbl_MEMdecode},
331 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type),
332 "Range Type", acpi_gbl_MTPdecode},
333 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation),
334 "Translation", acpi_gbl_TTPdecode}
335};
336
337static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = {
338 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags),
339 "Resource Type", (void *)"I/O Range"},
340 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
341 "Range Type", acpi_gbl_RNGdecode},
342 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
343 "Translation", acpi_gbl_TTPdecode},
344 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type),
345 "Translation Type", acpi_gbl_TRSdecode}
346};
116 347
117 acpi_os_printf(")\n"); 348/*
118 return; 349 * Table used to dump _PRT contents
119} 350 */
351static struct acpi_rsdump_info acpi_rs_dump_prt[5] = {
352 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_prt), NULL, NULL},
353 {ACPI_RSD_UINT64, ACPI_PRT_OFFSET(address), "Address", NULL},
354 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(pin), "Pin", NULL},
355 {ACPI_RSD_STRING, ACPI_PRT_OFFSET(source[0]), "Source", NULL},
356 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(source_index), "Source Index", NULL}
357};
120 358
121/******************************************************************************* 359/*******************************************************************************
122 * 360 *
123 * FUNCTION: acpi_rs_dump_dma 361 * FUNCTION: acpi_rs_dump_descriptor
124 * 362 *
125 * PARAMETERS: Data - pointer to the resource structure to dump. 363 * PARAMETERS: Resource
126 * 364 *
127 * RETURN: None 365 * RETURN: None
128 * 366 *
129 * DESCRIPTION: Prints out the various members of the Data structure type. 367 * DESCRIPTION:
130 * 368 *
131 ******************************************************************************/ 369 ******************************************************************************/
132 370
133static void acpi_rs_dump_dma(union acpi_resource_data *data) 371static void
372acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
134{ 373{
135 struct acpi_resource_dma *dma_data = (struct acpi_resource_dma *)data; 374 u8 *target = NULL;
136 u8 index = 0; 375 u8 *previous_target;
137 376 char *name;
138 ACPI_FUNCTION_ENTRY(); 377 u8 count;
139 378
140 acpi_os_printf("DMA Resource\n"); 379 /* First table entry must contain the table length (# of table entries) */
141 380
142 switch (dma_data->type) { 381 count = table->offset;
143 case ACPI_COMPATIBILITY: 382
144 acpi_os_printf(" Compatibility mode\n"); 383 while (count) {
145 break; 384 previous_target = target;
146 385 target = ACPI_ADD_PTR(u8, resource, table->offset);
147 case ACPI_TYPE_A: 386 name = table->name;
148 acpi_os_printf(" Type A\n"); 387
149 break; 388 switch (table->opcode) {
150 389 case ACPI_RSD_TITLE:
151 case ACPI_TYPE_B: 390 /*
152 acpi_os_printf(" Type B\n"); 391 * Optional resource title
153 break; 392 */
154 393 if (table->name) {
155 case ACPI_TYPE_F: 394 acpi_os_printf("%s Resource\n", name);
156 acpi_os_printf(" Type F\n"); 395 }
157 break; 396 break;
158
159 default:
160 acpi_os_printf(" Invalid DMA type\n");
161 break;
162 }
163
164 acpi_os_printf(" %sBus Master\n",
165 ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
166
167 switch (dma_data->transfer) {
168 case ACPI_TRANSFER_8:
169 acpi_os_printf(" 8-bit only transfer\n");
170 break;
171 397
172 case ACPI_TRANSFER_8_16: 398 /* Strings */
173 acpi_os_printf(" 8 and 16-bit transfer\n");
174 break;
175 399
176 case ACPI_TRANSFER_16: 400 case ACPI_RSD_LITERAL:
177 acpi_os_printf(" 16 bit only transfer\n"); 401 acpi_rs_out_string(name,
178 break; 402 ACPI_CAST_PTR(char, table->pointer));
403 break;
179 404
180 default: 405 case ACPI_RSD_STRING:
181 acpi_os_printf(" Invalid transfer preference\n"); 406 acpi_rs_out_string(name, ACPI_CAST_PTR(char, target));
182 break; 407 break;
183 }
184 408
185 acpi_os_printf(" Number of Channels: %X ( ", 409 /* Data items, 8/16/32/64 bit */
186 dma_data->number_of_channels);
187 410
188 for (index = 0; index < dma_data->number_of_channels; index++) { 411 case ACPI_RSD_UINT8:
189 acpi_os_printf("%X ", dma_data->channels[index]); 412 acpi_rs_out_integer8(name, ACPI_GET8(target));
190 } 413 break;
191 414
192 acpi_os_printf(")\n"); 415 case ACPI_RSD_UINT16:
193 return; 416 acpi_rs_out_integer16(name, ACPI_GET16(target));
194} 417 break;
195 418
196/******************************************************************************* 419 case ACPI_RSD_UINT32:
197 * 420 acpi_rs_out_integer32(name, ACPI_GET32(target));
198 * FUNCTION: acpi_rs_dump_start_depend_fns 421 break;
199 *
200 * PARAMETERS: Data - pointer to the resource structure to dump.
201 *
202 * RETURN: None
203 *
204 * DESCRIPTION: Prints out the various members of the Data structure type.
205 *
206 ******************************************************************************/
207 422
208static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *data) 423 case ACPI_RSD_UINT64:
209{ 424 acpi_rs_out_integer64(name, ACPI_GET64(target));
210 struct acpi_resource_start_dpf *sdf_data = 425 break;
211 (struct acpi_resource_start_dpf *)data;
212 426
213 ACPI_FUNCTION_ENTRY(); 427 /* Flags: 1-bit and 2-bit flags supported */
214 428
215 acpi_os_printf("Start Dependent Functions Resource\n"); 429 case ACPI_RSD_1BITFLAG:
430 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
431 table->
432 pointer[*target &
433 0x01]));
434 break;
216 435
217 switch (sdf_data->compatibility_priority) { 436 case ACPI_RSD_2BITFLAG:
218 case ACPI_GOOD_CONFIGURATION: 437 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
219 acpi_os_printf(" Good configuration\n"); 438 table->
220 break; 439 pointer[*target &
440 0x03]));
441 break;
221 442
222 case ACPI_ACCEPTABLE_CONFIGURATION: 443 case ACPI_RSD_SHORTLIST:
223 acpi_os_printf(" Acceptable configuration\n"); 444 /*
224 break; 445 * Short byte list (single line output) for DMA and IRQ resources
446 * Note: The list length is obtained from the previous table entry
447 */
448 if (previous_target) {
449 acpi_rs_out_title(name);
450 acpi_rs_dump_short_byte_list(*previous_target,
451 target);
452 }
453 break;
225 454
226 case ACPI_SUB_OPTIMAL_CONFIGURATION: 455 case ACPI_RSD_LONGLIST:
227 acpi_os_printf(" Sub-optimal configuration\n"); 456 /*
228 break; 457 * Long byte list for Vendor resource data
458 * Note: The list length is obtained from the previous table entry
459 */
460 if (previous_target) {
461 acpi_rs_dump_byte_list(ACPI_GET16
462 (previous_target),
463 target);
464 }
465 break;
229 466
230 default: 467 case ACPI_RSD_DWORDLIST:
231 acpi_os_printf(" Invalid compatibility priority\n"); 468 /*
232 break; 469 * Dword list for Extended Interrupt resources
233 } 470 * Note: The list length is obtained from the previous table entry
471 */
472 if (previous_target) {
473 acpi_rs_dump_dword_list(*previous_target,
474 ACPI_CAST_PTR(u32,
475 target));
476 }
477 break;
234 478
235 switch (sdf_data->performance_robustness) { 479 case ACPI_RSD_ADDRESS:
236 case ACPI_GOOD_CONFIGURATION: 480 /*
237 acpi_os_printf(" Good configuration\n"); 481 * Common flags for all Address resources
238 break; 482 */
483 acpi_rs_dump_address_common(ACPI_CAST_PTR
484 (union acpi_resource_data,
485 target));
486 break;
239 487
240 case ACPI_ACCEPTABLE_CONFIGURATION: 488 case ACPI_RSD_SOURCE:
241 acpi_os_printf(" Acceptable configuration\n"); 489 /*
242 break; 490 * Optional resource_source for Address resources
491 */
492 acpi_rs_dump_resource_source(ACPI_CAST_PTR
493 (struct
494 acpi_resource_source,
495 target));
496 break;
243 497
244 case ACPI_SUB_OPTIMAL_CONFIGURATION: 498 default:
245 acpi_os_printf(" Sub-optimal configuration\n"); 499 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
246 break; 500 table->opcode);
501 return;
502 }
247 503
248 default: 504 table++;
249 acpi_os_printf(" Invalid performance robustness preference\n"); 505 count--;
250 break;
251 } 506 }
252
253 return;
254}
255
256/*******************************************************************************
257 *
258 * FUNCTION: acpi_rs_dump_io
259 *
260 * PARAMETERS: Data - pointer to the resource structure to dump.
261 *
262 * RETURN: None
263 *
264 * DESCRIPTION: Prints out the various members of the Data structure type.
265 *
266 ******************************************************************************/
267
268static void acpi_rs_dump_io(union acpi_resource_data *data)
269{
270 struct acpi_resource_io *io_data = (struct acpi_resource_io *)data;
271
272 ACPI_FUNCTION_ENTRY();
273
274 acpi_os_printf("Io Resource\n");
275
276 acpi_os_printf(" %d bit decode\n",
277 ACPI_DECODE_16 == io_data->io_decode ? 16 : 10);
278
279 acpi_os_printf(" Range minimum base: %08X\n",
280 io_data->min_base_address);
281
282 acpi_os_printf(" Range maximum base: %08X\n",
283 io_data->max_base_address);
284
285 acpi_os_printf(" Alignment: %08X\n", io_data->alignment);
286
287 acpi_os_printf(" Range Length: %08X\n", io_data->range_length);
288
289 return;
290}
291
292/*******************************************************************************
293 *
294 * FUNCTION: acpi_rs_dump_fixed_io
295 *
296 * PARAMETERS: Data - pointer to the resource structure to dump.
297 *
298 * RETURN: None
299 *
300 * DESCRIPTION: Prints out the various members of the Data structure type.
301 *
302 ******************************************************************************/
303
304static void acpi_rs_dump_fixed_io(union acpi_resource_data *data)
305{
306 struct acpi_resource_fixed_io *fixed_io_data =
307 (struct acpi_resource_fixed_io *)data;
308
309 ACPI_FUNCTION_ENTRY();
310
311 acpi_os_printf("Fixed Io Resource\n");
312 acpi_os_printf(" Range base address: %08X",
313 fixed_io_data->base_address);
314
315 acpi_os_printf(" Range length: %08X", fixed_io_data->range_length);
316
317 return;
318} 507}
319 508
320/******************************************************************************* 509/*******************************************************************************
321 * 510 *
322 * FUNCTION: acpi_rs_dump_vendor_specific 511 * FUNCTION: acpi_rs_dump_resource_source
323 * 512 *
324 * PARAMETERS: Data - pointer to the resource structure to dump. 513 * PARAMETERS: resource_source - Pointer to a Resource Source struct
325 * 514 *
326 * RETURN: None 515 * RETURN: None
327 * 516 *
328 * DESCRIPTION: Prints out the various members of the Data structure type. 517 * DESCRIPTION: Common routine for dumping the optional resource_source and the
518 * corresponding resource_source_index.
329 * 519 *
330 ******************************************************************************/ 520 ******************************************************************************/
331 521
332static void acpi_rs_dump_vendor_specific(union acpi_resource_data *data) 522static void
523acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
333{ 524{
334 struct acpi_resource_vendor *vendor_data =
335 (struct acpi_resource_vendor *)data;
336 u16 index = 0;
337
338 ACPI_FUNCTION_ENTRY(); 525 ACPI_FUNCTION_ENTRY();
339 526
340 acpi_os_printf("Vendor Specific Resource\n"); 527 if (resource_source->index == 0xFF) {
341 528 return;
342 acpi_os_printf(" Length: %08X\n", vendor_data->length);
343
344 for (index = 0; index < vendor_data->length; index++) {
345 acpi_os_printf(" Byte %X: %08X\n",
346 index, vendor_data->reserved[index]);
347 } 529 }
348 530
349 return; 531 acpi_rs_out_integer8("Resource Source Index", resource_source->index);
350}
351
352/*******************************************************************************
353 *
354 * FUNCTION: acpi_rs_dump_memory24
355 *
356 * PARAMETERS: Data - pointer to the resource structure to dump.
357 *
358 * RETURN: None
359 *
360 * DESCRIPTION: Prints out the various members of the Data structure type.
361 *
362 ******************************************************************************/
363
364static void acpi_rs_dump_memory24(union acpi_resource_data *data)
365{
366 struct acpi_resource_mem24 *memory24_data =
367 (struct acpi_resource_mem24 *)data;
368
369 ACPI_FUNCTION_ENTRY();
370
371 acpi_os_printf("24-Bit Memory Range Resource\n");
372
373 acpi_os_printf(" Read%s\n",
374 ACPI_READ_WRITE_MEMORY ==
375 memory24_data->read_write_attribute ?
376 "/Write" : " only");
377
378 acpi_os_printf(" Range minimum base: %08X\n",
379 memory24_data->min_base_address);
380
381 acpi_os_printf(" Range maximum base: %08X\n",
382 memory24_data->max_base_address);
383
384 acpi_os_printf(" Alignment: %08X\n", memory24_data->alignment);
385
386 acpi_os_printf(" Range length: %08X\n", memory24_data->range_length);
387
388 return;
389}
390
391/*******************************************************************************
392 *
393 * FUNCTION: acpi_rs_dump_memory32
394 *
395 * PARAMETERS: Data - pointer to the resource structure to dump.
396 *
397 * RETURN: None
398 *
399 * DESCRIPTION: Prints out the various members of the Data structure type.
400 *
401 ******************************************************************************/
402
403static void acpi_rs_dump_memory32(union acpi_resource_data *data)
404{
405 struct acpi_resource_mem32 *memory32_data =
406 (struct acpi_resource_mem32 *)data;
407
408 ACPI_FUNCTION_ENTRY();
409
410 acpi_os_printf("32-Bit Memory Range Resource\n");
411
412 acpi_os_printf(" Read%s\n",
413 ACPI_READ_WRITE_MEMORY ==
414 memory32_data->read_write_attribute ?
415 "/Write" : " only");
416
417 acpi_os_printf(" Range minimum base: %08X\n",
418 memory32_data->min_base_address);
419
420 acpi_os_printf(" Range maximum base: %08X\n",
421 memory32_data->max_base_address);
422
423 acpi_os_printf(" Alignment: %08X\n", memory32_data->alignment);
424
425 acpi_os_printf(" Range length: %08X\n", memory32_data->range_length);
426 532
427 return; 533 acpi_rs_out_string("Resource Source",
534 resource_source->string_ptr ?
535 resource_source->string_ptr : "[Not Specified]");
428} 536}
429 537
430/******************************************************************************* 538/*******************************************************************************
431 * 539 *
432 * FUNCTION: acpi_rs_dump_fixed_memory32 540 * FUNCTION: acpi_rs_dump_address_common
433 * 541 *
434 * PARAMETERS: Data - pointer to the resource structure to dump. 542 * PARAMETERS: Resource - Pointer to an internal resource descriptor
435 *
436 * RETURN:
437 *
438 * DESCRIPTION: Prints out the various members of the Data structure type.
439 *
440 ******************************************************************************/
441
442static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *data)
443{
444 struct acpi_resource_fixed_mem32 *fixed_memory32_data =
445 (struct acpi_resource_fixed_mem32 *)data;
446
447 ACPI_FUNCTION_ENTRY();
448
449 acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n");
450
451 acpi_os_printf(" Read%s\n",
452 ACPI_READ_WRITE_MEMORY ==
453 fixed_memory32_data->
454 read_write_attribute ? "/Write" : " Only");
455
456 acpi_os_printf(" Range base address: %08X\n",
457 fixed_memory32_data->range_base_address);
458
459 acpi_os_printf(" Range length: %08X\n",
460 fixed_memory32_data->range_length);
461
462 return;
463}
464
465/*******************************************************************************
466 *
467 * FUNCTION: acpi_rs_dump_address16
468 *
469 * PARAMETERS: Data - pointer to the resource structure to dump.
470 * 543 *
471 * RETURN: None 544 * RETURN: None
472 * 545 *
473 * DESCRIPTION: Prints out the various members of the Data structure type. 546 * DESCRIPTION: Dump the fields that are common to all Address resource
547 * descriptors
474 * 548 *
475 ******************************************************************************/ 549 ******************************************************************************/
476 550
477static void acpi_rs_dump_address16(union acpi_resource_data *data) 551static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
478{ 552{
479 struct acpi_resource_address16 *address16_data =
480 (struct acpi_resource_address16 *)data;
481
482 ACPI_FUNCTION_ENTRY(); 553 ACPI_FUNCTION_ENTRY();
483 554
484 acpi_os_printf("16-Bit Address Space Resource\n"); 555 /* Decode the type-specific flags */
485 acpi_os_printf(" Resource Type: ");
486 556
487 switch (address16_data->resource_type) { 557 switch (resource->address.resource_type) {
488 case ACPI_MEMORY_RANGE: 558 case ACPI_MEMORY_RANGE:
489 559
490 acpi_os_printf("Memory Range\n"); 560 acpi_rs_dump_descriptor(resource, acpi_rs_dump_memory_flags);
491
492 switch (address16_data->attribute.memory.cache_attribute) {
493 case ACPI_NON_CACHEABLE_MEMORY:
494 acpi_os_printf
495 (" Type Specific: Noncacheable memory\n");
496 break;
497
498 case ACPI_CACHABLE_MEMORY:
499 acpi_os_printf(" Type Specific: Cacheable memory\n");
500 break;
501
502 case ACPI_WRITE_COMBINING_MEMORY:
503 acpi_os_printf
504 (" Type Specific: Write-combining memory\n");
505 break;
506
507 case ACPI_PREFETCHABLE_MEMORY:
508 acpi_os_printf
509 (" Type Specific: Prefetchable memory\n");
510 break;
511
512 default:
513 acpi_os_printf
514 (" Type Specific: Invalid cache attribute\n");
515 break;
516 }
517
518 acpi_os_printf(" Type Specific: Read%s\n",
519 ACPI_READ_WRITE_MEMORY ==
520 address16_data->attribute.memory.
521 read_write_attribute ? "/Write" : " Only");
522 break; 561 break;
523 562
524 case ACPI_IO_RANGE: 563 case ACPI_IO_RANGE:
525 564
526 acpi_os_printf("I/O Range\n"); 565 acpi_rs_dump_descriptor(resource, acpi_rs_dump_io_flags);
527
528 switch (address16_data->attribute.io.range_attribute) {
529 case ACPI_NON_ISA_ONLY_RANGES:
530 acpi_os_printf
531 (" Type Specific: Non-ISA Io Addresses\n");
532 break;
533
534 case ACPI_ISA_ONLY_RANGES:
535 acpi_os_printf(" Type Specific: ISA Io Addresses\n");
536 break;
537
538 case ACPI_ENTIRE_RANGE:
539 acpi_os_printf
540 (" Type Specific: ISA and non-ISA Io Addresses\n");
541 break;
542
543 default:
544 acpi_os_printf
545 (" Type Specific: Invalid range attribute\n");
546 break;
547 }
548
549 acpi_os_printf(" Type Specific: %s Translation\n",
550 ACPI_SPARSE_TRANSLATION ==
551 address16_data->attribute.io.
552 translation_attribute ? "Sparse" : "Dense");
553 break; 566 break;
554 567
555 case ACPI_BUS_NUMBER_RANGE: 568 case ACPI_BUS_NUMBER_RANGE:
556 569
557 acpi_os_printf("Bus Number Range\n"); 570 acpi_rs_out_string("Resource Type", "Bus Number Range");
558 break; 571 break;
559 572
560 default: 573 default:
561 574
562 acpi_os_printf("0x%2.2X\n", address16_data->resource_type); 575 acpi_rs_out_integer8("Resource Type",
576 (u8) resource->address.resource_type);
563 break; 577 break;
564 } 578 }
565 579
566 acpi_os_printf(" Resource %s\n", 580 /* Decode the general flags */
567 ACPI_CONSUMER == address16_data->producer_consumer ?
568 "Consumer" : "Producer");
569
570 acpi_os_printf(" %s decode\n",
571 ACPI_SUB_DECODE == address16_data->decode ?
572 "Subtractive" : "Positive");
573 581
574 acpi_os_printf(" Min address is %s fixed\n", 582 acpi_rs_dump_descriptor(resource, acpi_rs_dump_general_flags);
575 ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ?
576 "" : "not");
577
578 acpi_os_printf(" Max address is %s fixed\n",
579 ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ?
580 "" : "not");
581
582 acpi_os_printf(" Granularity: %08X\n", address16_data->granularity);
583
584 acpi_os_printf(" Address range min: %08X\n",
585 address16_data->min_address_range);
586
587 acpi_os_printf(" Address range max: %08X\n",
588 address16_data->max_address_range);
589
590 acpi_os_printf(" Address translation offset: %08X\n",
591 address16_data->address_translation_offset);
592
593 acpi_os_printf(" Address Length: %08X\n",
594 address16_data->address_length);
595
596 if (0xFF != address16_data->resource_source.index) {
597 acpi_os_printf(" Resource Source Index: %X\n",
598 address16_data->resource_source.index);
599
600 acpi_os_printf(" Resource Source: %s\n",
601 address16_data->resource_source.string_ptr);
602 }
603
604 return;
605} 583}
606 584
607/******************************************************************************* 585/*******************************************************************************
608 * 586 *
609 * FUNCTION: acpi_rs_dump_address32 587 * FUNCTION: acpi_rs_dump_resource_list
610 * 588 *
611 * PARAMETERS: Data - pointer to the resource structure to dump. 589 * PARAMETERS: resource_list - Pointer to a resource descriptor list
612 * 590 *
613 * RETURN: None 591 * RETURN: None
614 * 592 *
615 * DESCRIPTION: Prints out the various members of the Data structure type. 593 * DESCRIPTION: Dispatches the structure to the correct dump routine.
616 * 594 *
617 ******************************************************************************/ 595 ******************************************************************************/
618 596
619static void acpi_rs_dump_address32(union acpi_resource_data *data) 597void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
620{ 598{
621 struct acpi_resource_address32 *address32_data = 599 u32 count = 0;
622 (struct acpi_resource_address32 *)data; 600 u32 type;
623 601
624 ACPI_FUNCTION_ENTRY(); 602 ACPI_FUNCTION_ENTRY();
625 603
626 acpi_os_printf("32-Bit Address Space Resource\n"); 604 if (!(acpi_dbg_level & ACPI_LV_RESOURCES)
627 605 || !(_COMPONENT & acpi_dbg_layer)) {
628 switch (address32_data->resource_type) { 606 return;
629 case ACPI_MEMORY_RANGE: 607 }
630
631 acpi_os_printf(" Resource Type: Memory Range\n");
632
633 switch (address32_data->attribute.memory.cache_attribute) {
634 case ACPI_NON_CACHEABLE_MEMORY:
635 acpi_os_printf
636 (" Type Specific: Noncacheable memory\n");
637 break;
638
639 case ACPI_CACHABLE_MEMORY:
640 acpi_os_printf(" Type Specific: Cacheable memory\n");
641 break;
642
643 case ACPI_WRITE_COMBINING_MEMORY:
644 acpi_os_printf
645 (" Type Specific: Write-combining memory\n");
646 break;
647
648 case ACPI_PREFETCHABLE_MEMORY:
649 acpi_os_printf
650 (" Type Specific: Prefetchable memory\n");
651 break;
652
653 default:
654 acpi_os_printf
655 (" Type Specific: Invalid cache attribute\n");
656 break;
657 }
658
659 acpi_os_printf(" Type Specific: Read%s\n",
660 ACPI_READ_WRITE_MEMORY ==
661 address32_data->attribute.memory.
662 read_write_attribute ? "/Write" : " Only");
663 break;
664
665 case ACPI_IO_RANGE:
666
667 acpi_os_printf(" Resource Type: Io Range\n");
668 608
669 switch (address32_data->attribute.io.range_attribute) { 609 /* Walk list and dump all resource descriptors (END_TAG terminates) */
670 case ACPI_NON_ISA_ONLY_RANGES:
671 acpi_os_printf
672 (" Type Specific: Non-ISA Io Addresses\n");
673 break;
674 610
675 case ACPI_ISA_ONLY_RANGES: 611 do {
676 acpi_os_printf(" Type Specific: ISA Io Addresses\n"); 612 acpi_os_printf("\n[%02X] ", count);
677 break; 613 count++;
678 614
679 case ACPI_ENTIRE_RANGE: 615 /* Validate Type before dispatch */
680 acpi_os_printf
681 (" Type Specific: ISA and non-ISA Io Addresses\n");
682 break;
683 616
684 default: 617 type = resource_list->type;
618 if (type > ACPI_RESOURCE_TYPE_MAX) {
685 acpi_os_printf 619 acpi_os_printf
686 (" Type Specific: Invalid Range attribute"); 620 ("Invalid descriptor type (%X) in resource list\n",
687 break; 621 resource_list->type);
622 return;
688 } 623 }
689 624
690 acpi_os_printf(" Type Specific: %s Translation\n", 625 /* Dump the resource descriptor */
691 ACPI_SPARSE_TRANSLATION ==
692 address32_data->attribute.io.
693 translation_attribute ? "Sparse" : "Dense");
694 break;
695
696 case ACPI_BUS_NUMBER_RANGE:
697
698 acpi_os_printf(" Resource Type: Bus Number Range\n");
699 break;
700
701 default:
702
703 acpi_os_printf(" Resource Type: 0x%2.2X\n",
704 address32_data->resource_type);
705 break;
706 }
707
708 acpi_os_printf(" Resource %s\n",
709 ACPI_CONSUMER == address32_data->producer_consumer ?
710 "Consumer" : "Producer");
711
712 acpi_os_printf(" %s decode\n",
713 ACPI_SUB_DECODE == address32_data->decode ?
714 "Subtractive" : "Positive");
715
716 acpi_os_printf(" Min address is %s fixed\n",
717 ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ?
718 "" : "not ");
719
720 acpi_os_printf(" Max address is %s fixed\n",
721 ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ?
722 "" : "not ");
723 626
724 acpi_os_printf(" Granularity: %08X\n", address32_data->granularity); 627 acpi_rs_dump_descriptor(&resource_list->data,
628 acpi_gbl_dump_resource_dispatch[type]);
725 629
726 acpi_os_printf(" Address range min: %08X\n", 630 /* Point to the next resource structure */
727 address32_data->min_address_range);
728 631
729 acpi_os_printf(" Address range max: %08X\n", 632 resource_list =
730 address32_data->max_address_range); 633 ACPI_ADD_PTR(struct acpi_resource, resource_list,
634 resource_list->length);
731 635
732 acpi_os_printf(" Address translation offset: %08X\n", 636 /* Exit when END_TAG descriptor is reached */
733 address32_data->address_translation_offset);
734 637
735 acpi_os_printf(" Address Length: %08X\n", 638 } while (type != ACPI_RESOURCE_TYPE_END_TAG);
736 address32_data->address_length);
737
738 if (0xFF != address32_data->resource_source.index) {
739 acpi_os_printf(" Resource Source Index: %X\n",
740 address32_data->resource_source.index);
741
742 acpi_os_printf(" Resource Source: %s\n",
743 address32_data->resource_source.string_ptr);
744 }
745
746 return;
747} 639}
748 640
749/******************************************************************************* 641/*******************************************************************************
750 * 642 *
751 * FUNCTION: acpi_rs_dump_address64 643 * FUNCTION: acpi_rs_dump_irq_list
752 * 644 *
753 * PARAMETERS: Data - pointer to the resource structure to dump. 645 * PARAMETERS: route_table - Pointer to the routing table to dump.
754 * 646 *
755 * RETURN: None 647 * RETURN: None
756 * 648 *
757 * DESCRIPTION: Prints out the various members of the Data structure type. 649 * DESCRIPTION: Print IRQ routing table
758 * 650 *
759 ******************************************************************************/ 651 ******************************************************************************/
760 652
761static void acpi_rs_dump_address64(union acpi_resource_data *data) 653void acpi_rs_dump_irq_list(u8 * route_table)
762{ 654{
763 struct acpi_resource_address64 *address64_data = 655 struct acpi_pci_routing_table *prt_element;
764 (struct acpi_resource_address64 *)data; 656 u8 count;
765 657
766 ACPI_FUNCTION_ENTRY(); 658 ACPI_FUNCTION_ENTRY();
767 659
768 acpi_os_printf("64-Bit Address Space Resource\n"); 660 if (!(acpi_dbg_level & ACPI_LV_RESOURCES)
769 661 || !(_COMPONENT & acpi_dbg_layer)) {
770 switch (address64_data->resource_type) { 662 return;
771 case ACPI_MEMORY_RANGE:
772
773 acpi_os_printf(" Resource Type: Memory Range\n");
774
775 switch (address64_data->attribute.memory.cache_attribute) {
776 case ACPI_NON_CACHEABLE_MEMORY:
777 acpi_os_printf
778 (" Type Specific: Noncacheable memory\n");
779 break;
780
781 case ACPI_CACHABLE_MEMORY:
782 acpi_os_printf(" Type Specific: Cacheable memory\n");
783 break;
784
785 case ACPI_WRITE_COMBINING_MEMORY:
786 acpi_os_printf
787 (" Type Specific: Write-combining memory\n");
788 break;
789
790 case ACPI_PREFETCHABLE_MEMORY:
791 acpi_os_printf
792 (" Type Specific: Prefetchable memory\n");
793 break;
794
795 default:
796 acpi_os_printf
797 (" Type Specific: Invalid cache attribute\n");
798 break;
799 }
800
801 acpi_os_printf(" Type Specific: Read%s\n",
802 ACPI_READ_WRITE_MEMORY ==
803 address64_data->attribute.memory.
804 read_write_attribute ? "/Write" : " Only");
805 break;
806
807 case ACPI_IO_RANGE:
808
809 acpi_os_printf(" Resource Type: Io Range\n");
810
811 switch (address64_data->attribute.io.range_attribute) {
812 case ACPI_NON_ISA_ONLY_RANGES:
813 acpi_os_printf
814 (" Type Specific: Non-ISA Io Addresses\n");
815 break;
816
817 case ACPI_ISA_ONLY_RANGES:
818 acpi_os_printf(" Type Specific: ISA Io Addresses\n");
819 break;
820
821 case ACPI_ENTIRE_RANGE:
822 acpi_os_printf
823 (" Type Specific: ISA and non-ISA Io Addresses\n");
824 break;
825
826 default:
827 acpi_os_printf
828 (" Type Specific: Invalid Range attribute");
829 break;
830 }
831
832 acpi_os_printf(" Type Specific: %s Translation\n",
833 ACPI_SPARSE_TRANSLATION ==
834 address64_data->attribute.io.
835 translation_attribute ? "Sparse" : "Dense");
836 break;
837
838 case ACPI_BUS_NUMBER_RANGE:
839
840 acpi_os_printf(" Resource Type: Bus Number Range\n");
841 break;
842
843 default:
844
845 acpi_os_printf(" Resource Type: 0x%2.2X\n",
846 address64_data->resource_type);
847 break;
848 } 663 }
849 664
850 acpi_os_printf(" Resource %s\n", 665 prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, route_table);
851 ACPI_CONSUMER == address64_data->producer_consumer ?
852 "Consumer" : "Producer");
853
854 acpi_os_printf(" %s decode\n",
855 ACPI_SUB_DECODE == address64_data->decode ?
856 "Subtractive" : "Positive");
857
858 acpi_os_printf(" Min address is %s fixed\n",
859 ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ?
860 "" : "not ");
861
862 acpi_os_printf(" Max address is %s fixed\n",
863 ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ?
864 "" : "not ");
865 666
866 acpi_os_printf(" Granularity: %8.8X%8.8X\n", 667 /* Dump all table elements, Exit on zero length element */
867 ACPI_FORMAT_UINT64(address64_data->granularity));
868 668
869 acpi_os_printf(" Address range min: %8.8X%8.8X\n", 669 for (count = 0; prt_element->length; count++) {
870 ACPI_FORMAT_UINT64(address64_data->min_address_range)); 670 acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
671 count);
672 acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
871 673
872 acpi_os_printf(" Address range max: %8.8X%8.8X\n", 674 prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
873 ACPI_FORMAT_UINT64(address64_data->max_address_range)); 675 prt_element, prt_element->length);
874
875 acpi_os_printf(" Address translation offset: %8.8X%8.8X\n",
876 ACPI_FORMAT_UINT64(address64_data->
877 address_translation_offset));
878
879 acpi_os_printf(" Address Length: %8.8X%8.8X\n",
880 ACPI_FORMAT_UINT64(address64_data->address_length));
881
882 acpi_os_printf(" Type Specific Attributes: %8.8X%8.8X\n",
883 ACPI_FORMAT_UINT64(address64_data->
884 type_specific_attributes));
885
886 if (0xFF != address64_data->resource_source.index) {
887 acpi_os_printf(" Resource Source Index: %X\n",
888 address64_data->resource_source.index);
889
890 acpi_os_printf(" Resource Source: %s\n",
891 address64_data->resource_source.string_ptr);
892 } 676 }
893
894 return;
895} 677}
896 678
897/******************************************************************************* 679/*******************************************************************************
898 * 680 *
899 * FUNCTION: acpi_rs_dump_extended_irq 681 * FUNCTION: acpi_rs_out*
900 * 682 *
901 * PARAMETERS: Data - pointer to the resource structure to dump. 683 * PARAMETERS: Title - Name of the resource field
684 * Value - Value of the resource field
902 * 685 *
903 * RETURN: None 686 * RETURN: None
904 * 687 *
905 * DESCRIPTION: Prints out the various members of the Data structure type. 688 * DESCRIPTION: Miscellaneous helper functions to consistently format the
689 * output of the resource dump routines
906 * 690 *
907 ******************************************************************************/ 691 ******************************************************************************/
908 692
909static void acpi_rs_dump_extended_irq(union acpi_resource_data *data) 693static void acpi_rs_out_string(char *title, char *value)
910{ 694{
911 struct acpi_resource_ext_irq *ext_irq_data = 695 acpi_os_printf("%27s : %s", title, value);
912 (struct acpi_resource_ext_irq *)data; 696 if (!*value) {
913 u8 index = 0; 697 acpi_os_printf("[NULL NAMESTRING]");
914
915 ACPI_FUNCTION_ENTRY();
916
917 acpi_os_printf("Extended IRQ Resource\n");
918
919 acpi_os_printf(" Resource %s\n",
920 ACPI_CONSUMER == ext_irq_data->producer_consumer ?
921 "Consumer" : "Producer");
922
923 acpi_os_printf(" %s\n",
924 ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ?
925 "Level" : "Edge");
926
927 acpi_os_printf(" Active %s\n",
928 ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ?
929 "low" : "high");
930
931 acpi_os_printf(" %s\n",
932 ACPI_SHARED == ext_irq_data->shared_exclusive ?
933 "Shared" : "Exclusive");
934
935 acpi_os_printf(" Interrupts : %X ( ",
936 ext_irq_data->number_of_interrupts);
937
938 for (index = 0; index < ext_irq_data->number_of_interrupts; index++) {
939 acpi_os_printf("%X ", ext_irq_data->interrupts[index]);
940 }
941
942 acpi_os_printf(")\n");
943
944 if (0xFF != ext_irq_data->resource_source.index) {
945 acpi_os_printf(" Resource Source Index: %X",
946 ext_irq_data->resource_source.index);
947
948 acpi_os_printf(" Resource Source: %s",
949 ext_irq_data->resource_source.string_ptr);
950 } 698 }
951 699 acpi_os_printf("\n");
952 return;
953} 700}
954 701
955/******************************************************************************* 702static void acpi_rs_out_integer8(char *title, u8 value)
956 *
957 * FUNCTION: acpi_rs_dump_resource_list
958 *
959 * PARAMETERS: Resource - pointer to the resource structure to dump.
960 *
961 * RETURN: None
962 *
963 * DESCRIPTION: Dispatches the structure to the correct dump routine.
964 *
965 ******************************************************************************/
966
967void acpi_rs_dump_resource_list(struct acpi_resource *resource)
968{ 703{
969 u8 count = 0; 704 acpi_os_printf("%27s : %2.2X\n", title, value);
970 u8 done = FALSE; 705}
971
972 ACPI_FUNCTION_ENTRY();
973
974 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) {
975 while (!done) {
976 acpi_os_printf("Resource structure %X.\n", count++);
977
978 switch (resource->id) {
979 case ACPI_RSTYPE_IRQ:
980 acpi_rs_dump_irq(&resource->data);
981 break;
982
983 case ACPI_RSTYPE_DMA:
984 acpi_rs_dump_dma(&resource->data);
985 break;
986
987 case ACPI_RSTYPE_START_DPF:
988 acpi_rs_dump_start_depend_fns(&resource->data);
989 break;
990
991 case ACPI_RSTYPE_END_DPF:
992 acpi_os_printf
993 ("end_dependent_functions Resource\n");
994 /* acpi_rs_dump_end_dependent_functions (Resource->Data); */
995 break;
996
997 case ACPI_RSTYPE_IO:
998 acpi_rs_dump_io(&resource->data);
999 break;
1000
1001 case ACPI_RSTYPE_FIXED_IO:
1002 acpi_rs_dump_fixed_io(&resource->data);
1003 break;
1004
1005 case ACPI_RSTYPE_VENDOR:
1006 acpi_rs_dump_vendor_specific(&resource->data);
1007 break;
1008
1009 case ACPI_RSTYPE_END_TAG:
1010 /*rs_dump_end_tag (Resource->Data); */
1011 acpi_os_printf("end_tag Resource\n");
1012 done = TRUE;
1013 break;
1014
1015 case ACPI_RSTYPE_MEM24:
1016 acpi_rs_dump_memory24(&resource->data);
1017 break;
1018
1019 case ACPI_RSTYPE_MEM32:
1020 acpi_rs_dump_memory32(&resource->data);
1021 break;
1022
1023 case ACPI_RSTYPE_FIXED_MEM32:
1024 acpi_rs_dump_fixed_memory32(&resource->data);
1025 break;
1026
1027 case ACPI_RSTYPE_ADDRESS16:
1028 acpi_rs_dump_address16(&resource->data);
1029 break;
1030
1031 case ACPI_RSTYPE_ADDRESS32:
1032 acpi_rs_dump_address32(&resource->data);
1033 break;
1034
1035 case ACPI_RSTYPE_ADDRESS64:
1036 acpi_rs_dump_address64(&resource->data);
1037 break;
1038
1039 case ACPI_RSTYPE_EXT_IRQ:
1040 acpi_rs_dump_extended_irq(&resource->data);
1041 break;
1042 706
1043 default: 707static void acpi_rs_out_integer16(char *title, u16 value)
1044 acpi_os_printf("Invalid resource type\n"); 708{
1045 break; 709 acpi_os_printf("%27s : %4.4X\n", title, value);
710}
1046 711
1047 } 712static void acpi_rs_out_integer32(char *title, u32 value)
713{
714 acpi_os_printf("%27s : %8.8X\n", title, value);
715}
1048 716
1049 resource = 717static void acpi_rs_out_integer64(char *title, u64 value)
1050 ACPI_PTR_ADD(struct acpi_resource, resource, 718{
1051 resource->length); 719 acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
1052 } 720}
1053 }
1054 721
1055 return; 722static void acpi_rs_out_title(char *title)
723{
724 acpi_os_printf("%27s : ", title);
1056} 725}
1057 726
1058/******************************************************************************* 727/*******************************************************************************
1059 * 728 *
1060 * FUNCTION: acpi_rs_dump_irq_list 729 * FUNCTION: acpi_rs_dump*List
1061 * 730 *
1062 * PARAMETERS: route_table - pointer to the routing table to dump. 731 * PARAMETERS: Length - Number of elements in the list
732 * Data - Start of the list
1063 * 733 *
1064 * RETURN: None 734 * RETURN: None
1065 * 735 *
1066 * DESCRIPTION: Dispatches the structures to the correct dump routine. 736 * DESCRIPTION: Miscellaneous functions to dump lists of raw data
1067 * 737 *
1068 ******************************************************************************/ 738 ******************************************************************************/
1069 739
1070void acpi_rs_dump_irq_list(u8 * route_table) 740static void acpi_rs_dump_byte_list(u16 length, u8 * data)
1071{ 741{
1072 u8 *buffer = route_table; 742 u8 i;
1073 u8 count = 0;
1074 u8 done = FALSE;
1075 struct acpi_pci_routing_table *prt_element;
1076 743
1077 ACPI_FUNCTION_ENTRY(); 744 for (i = 0; i < length; i++) {
1078 745 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
1079 if (acpi_dbg_level & ACPI_LV_RESOURCES && _COMPONENT & acpi_dbg_layer) { 746 }
1080 prt_element = 747}
1081 ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer);
1082
1083 while (!done) {
1084 acpi_os_printf("PCI IRQ Routing Table structure %X.\n",
1085 count++);
1086
1087 acpi_os_printf(" Address: %8.8X%8.8X\n",
1088 ACPI_FORMAT_UINT64(prt_element->
1089 address));
1090 748
1091 acpi_os_printf(" Pin: %X\n", prt_element->pin); 749static void acpi_rs_dump_short_byte_list(u8 length, u8 * data)
750{
751 u8 i;
1092 752
1093 acpi_os_printf(" Source: %s\n", prt_element->source); 753 for (i = 0; i < length; i++) {
754 acpi_os_printf("%X ", data[i]);
755 }
756 acpi_os_printf("\n");
757}
1094 758
1095 acpi_os_printf(" source_index: %X\n", 759static void acpi_rs_dump_dword_list(u8 length, u32 * data)
1096 prt_element->source_index); 760{
761 u8 i;
1097 762
1098 buffer += prt_element->length; 763 for (i = 0; i < length; i++) {
1099 prt_element = 764 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
1100 ACPI_CAST_PTR(struct acpi_pci_routing_table,
1101 buffer);
1102 if (0 == prt_element->length) {
1103 done = TRUE;
1104 }
1105 }
1106 } 765 }
1107
1108 return;
1109} 766}
1110 767
1111#endif 768#endif
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c
new file mode 100644
index 000000000000..d9ae64b77bd9
--- /dev/null
+++ b/drivers/acpi/resources/rsinfo.c
@@ -0,0 +1,204 @@
1/*******************************************************************************
2 *
3 * Module Name: rsinfo - Dispatch and Info tables
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/acresrc.h>
46
47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsinfo")
49
50/*
51 * Resource dispatch and information tables. Any new resource types (either
52 * Large or Small) must be reflected in each of these tables, so they are here
53 * in one place.
54 *
55 * The tables for Large descriptors are indexed by bits 6:0 of the AML
56 * descriptor type byte. The tables for Small descriptors are indexed by
57 * bits 6:3 of the descriptor byte. The tables for internal resource
58 * descriptors are indexed by the acpi_resource_type field.
59 */
60/* Dispatch table for resource-to-AML (Set Resource) conversion functions */
61struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[] = {
62 acpi_rs_set_irq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
63 acpi_rs_convert_dma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */
64 acpi_rs_set_start_dpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
65 acpi_rs_convert_end_dpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
66 acpi_rs_convert_io, /* 0x04, ACPI_RESOURCE_TYPE_IO */
67 acpi_rs_convert_fixed_io, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
68 acpi_rs_set_vendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
69 acpi_rs_convert_end_tag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
70 acpi_rs_convert_memory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
71 acpi_rs_convert_memory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
72 acpi_rs_convert_fixed_memory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
73 acpi_rs_convert_address16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
74 acpi_rs_convert_address32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
75 acpi_rs_convert_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
76 acpi_rs_convert_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
77 acpi_rs_convert_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
78 acpi_rs_convert_generic_reg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
79};
80
81/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
82
83struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = {
84 /* Small descriptors */
85
86 NULL, /* 0x00, Reserved */
87 NULL, /* 0x01, Reserved */
88 NULL, /* 0x02, Reserved */
89 NULL, /* 0x03, Reserved */
90 acpi_rs_get_irq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */
91 acpi_rs_convert_dma, /* 0x05, ACPI_RESOURCE_NAME_DMA */
92 acpi_rs_get_start_dpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
93 acpi_rs_convert_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
94 acpi_rs_convert_io, /* 0x08, ACPI_RESOURCE_NAME_IO */
95 acpi_rs_convert_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
96 NULL, /* 0x0A, Reserved */
97 NULL, /* 0x0B, Reserved */
98 NULL, /* 0x0C, Reserved */
99 NULL, /* 0x0D, Reserved */
100 acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
101 acpi_rs_convert_end_tag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
102
103 /* Large descriptors */
104
105 NULL, /* 0x00, Reserved */
106 acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
107 acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
108 NULL, /* 0x03, Reserved */
109 acpi_rs_get_vendor_large, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
110 acpi_rs_convert_memory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
111 acpi_rs_convert_fixed_memory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
112 acpi_rs_convert_address32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
113 acpi_rs_convert_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
114 acpi_rs_convert_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
115 acpi_rs_convert_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
116 acpi_rs_convert_ext_address64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
117};
118
119#ifdef ACPI_FUTURE_USAGE
120#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
121
122/* Dispatch table for resource dump functions */
123
124struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = {
125 acpi_rs_dump_irq, /* ACPI_RESOURCE_TYPE_IRQ */
126 acpi_rs_dump_dma, /* ACPI_RESOURCE_TYPE_DMA */
127 acpi_rs_dump_start_dpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
128 acpi_rs_dump_end_dpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
129 acpi_rs_dump_io, /* ACPI_RESOURCE_TYPE_IO */
130 acpi_rs_dump_fixed_io, /* ACPI_RESOURCE_TYPE_FIXED_IO */
131 acpi_rs_dump_vendor, /* ACPI_RESOURCE_TYPE_VENDOR */
132 acpi_rs_dump_end_tag, /* ACPI_RESOURCE_TYPE_END_TAG */
133 acpi_rs_dump_memory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */
134 acpi_rs_dump_memory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */
135 acpi_rs_dump_fixed_memory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
136 acpi_rs_dump_address16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */
137 acpi_rs_dump_address32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */
138 acpi_rs_dump_address64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */
139 acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
140 acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
141 acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
142};
143#endif
144#endif /* ACPI_FUTURE_USAGE */
145/*
146 * Base sizes for external AML resource descriptors, indexed by internal type.
147 * Includes size of the descriptor header (1 byte for small descriptors,
148 * 3 bytes for large descriptors)
149 */
150const u8 acpi_gbl_aml_resource_sizes[] = {
151 sizeof(struct aml_resource_irq), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
152 sizeof(struct aml_resource_dma), /* ACPI_RESOURCE_TYPE_DMA */
153 sizeof(struct aml_resource_start_dependent), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
154 sizeof(struct aml_resource_end_dependent), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
155 sizeof(struct aml_resource_io), /* ACPI_RESOURCE_TYPE_IO */
156 sizeof(struct aml_resource_fixed_io), /* ACPI_RESOURCE_TYPE_FIXED_IO */
157 sizeof(struct aml_resource_vendor_small), /* ACPI_RESOURCE_TYPE_VENDOR */
158 sizeof(struct aml_resource_end_tag), /* ACPI_RESOURCE_TYPE_END_TAG */
159 sizeof(struct aml_resource_memory24), /* ACPI_RESOURCE_TYPE_MEMORY24 */
160 sizeof(struct aml_resource_memory32), /* ACPI_RESOURCE_TYPE_MEMORY32 */
161 sizeof(struct aml_resource_fixed_memory32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
162 sizeof(struct aml_resource_address16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */
163 sizeof(struct aml_resource_address32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */
164 sizeof(struct aml_resource_address64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */
165 sizeof(struct aml_resource_extended_address64), /*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
166 sizeof(struct aml_resource_extended_irq), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
167 sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
168};
169
170const u8 acpi_gbl_resource_struct_sizes[] = {
171 /* Small descriptors */
172
173 0,
174 0,
175 0,
176 0,
177 ACPI_RS_SIZE(struct acpi_resource_irq),
178 ACPI_RS_SIZE(struct acpi_resource_dma),
179 ACPI_RS_SIZE(struct acpi_resource_start_dependent),
180 ACPI_RS_SIZE_MIN,
181 ACPI_RS_SIZE(struct acpi_resource_io),
182 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
183 0,
184 0,
185 0,
186 0,
187 ACPI_RS_SIZE(struct acpi_resource_vendor),
188 ACPI_RS_SIZE_MIN,
189
190 /* Large descriptors */
191
192 0,
193 ACPI_RS_SIZE(struct acpi_resource_memory24),
194 ACPI_RS_SIZE(struct acpi_resource_generic_register),
195 0,
196 ACPI_RS_SIZE(struct acpi_resource_vendor),
197 ACPI_RS_SIZE(struct acpi_resource_memory32),
198 ACPI_RS_SIZE(struct acpi_resource_fixed_memory32),
199 ACPI_RS_SIZE(struct acpi_resource_address32),
200 ACPI_RS_SIZE(struct acpi_resource_address16),
201 ACPI_RS_SIZE(struct acpi_resource_extended_irq),
202 ACPI_RS_SIZE(struct acpi_resource_address64),
203 ACPI_RS_SIZE(struct acpi_resource_extended_address64)
204};
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c
index d53bbe89e851..ea567167c4f2 100644
--- a/drivers/acpi/resources/rsio.c
+++ b/drivers/acpi/resources/rsio.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,428 +49,206 @@ ACPI_MODULE_NAME("rsio")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_io_resource 52 * acpi_rs_convert_io
53 * 53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 54 ******************************************************************************/
55 * stream 55struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
56 * bytes_consumed - Pointer to where the number of bytes 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
57 * consumed the byte_stream_buffer is 57 ACPI_RS_SIZE(struct acpi_resource_io),
58 * returned 58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
59 * output_buffer - Pointer to the return data buffer 59
60 * structure_size - Pointer to where the number of bytes 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
61 * in the return data struct is returned 61 sizeof(struct aml_resource_io),
62 * 62 0},
63 * RETURN: Status 63
64 /* Decode flag */
65
66 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
67 AML_OFFSET(io.flags),
68 0},
69 /*
70 * These fields are contiguous in both the source and destination:
71 * Address Alignment
72 * Length
73 * Minimum Base Address
74 * Maximum Base Address
75 */
76 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
77 AML_OFFSET(io.alignment),
78 2},
79
80 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
81 AML_OFFSET(io.minimum),
82 2}
83};
84
85/*******************************************************************************
64 * 86 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 87 * acpi_rs_convert_fixed_io
66 * structure pointed to by the output_buffer. Return the
67 * number of bytes consumed from the byte stream.
68 * 88 *
69 ******************************************************************************/ 89 ******************************************************************************/
70acpi_status
71acpi_rs_io_resource(u8 * byte_stream_buffer,
72 acpi_size * bytes_consumed,
73 u8 ** output_buffer, acpi_size * structure_size)
74{
75 u8 *buffer = byte_stream_buffer;
76 struct acpi_resource *output_struct = (void *)*output_buffer;
77 u16 temp16 = 0;
78 u8 temp8 = 0;
79 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io);
80
81 ACPI_FUNCTION_TRACE("rs_io_resource");
82
83 /* The number of bytes consumed are Constant */
84
85 *bytes_consumed = 8;
86
87 output_struct->id = ACPI_RSTYPE_IO;
88
89 /* Check Decode */
90
91 buffer += 1;
92 temp8 = *buffer;
93
94 output_struct->data.io.io_decode = temp8 & 0x01;
95
96 /* Check min_base Address */
97
98 buffer += 1;
99 ACPI_MOVE_16_TO_16(&temp16, buffer);
100
101 output_struct->data.io.min_base_address = temp16;
102
103 /* Check max_base Address */
104 90
105 buffer += 2; 91struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
106 ACPI_MOVE_16_TO_16(&temp16, buffer); 92 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
107 93 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
108 output_struct->data.io.max_base_address = temp16; 94 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
109 95
110 /* Check Base alignment */ 96 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
111 97 sizeof(struct aml_resource_fixed_io),
112 buffer += 2; 98 0},
113 temp8 = *buffer; 99 /*
114 100 * These fields are contiguous in both the source and destination:
115 output_struct->data.io.alignment = temp8; 101 * Base Address
116 102 * Length
117 /* Check range_length */ 103 */
118 104 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
119 buffer += 1; 105 AML_OFFSET(fixed_io.address_length),
120 temp8 = *buffer; 106 1},
121 107
122 output_struct->data.io.range_length = temp8; 108 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
123 109 AML_OFFSET(fixed_io.address),
124 /* Set the Length parameter */ 110 1}
125 111};
126 output_struct->length = (u32) struct_size;
127
128 /* Return the final size of the structure */
129
130 *structure_size = struct_size;
131 return_ACPI_STATUS(AE_OK);
132}
133 112
134/******************************************************************************* 113/*******************************************************************************
135 * 114 *
136 * FUNCTION: acpi_rs_fixed_io_resource 115 * acpi_rs_convert_generic_reg
137 *
138 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
139 * stream
140 * bytes_consumed - Pointer to where the number of bytes
141 * consumed the byte_stream_buffer is
142 * returned
143 * output_buffer - Pointer to the return data buffer
144 * structure_size - Pointer to where the number of bytes
145 * in the return data struct is returned
146 *
147 * RETURN: Status
148 *
149 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
150 * structure pointed to by the output_buffer. Return the
151 * number of bytes consumed from the byte stream.
152 * 116 *
153 ******************************************************************************/ 117 ******************************************************************************/
154 118
155acpi_status 119struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
156acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, 120 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
157 acpi_size * bytes_consumed, 121 ACPI_RS_SIZE(struct acpi_resource_generic_register),
158 u8 ** output_buffer, acpi_size * structure_size) 122 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
159{ 123
160 u8 *buffer = byte_stream_buffer; 124 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
161 struct acpi_resource *output_struct = (void *)*output_buffer; 125 sizeof(struct aml_resource_generic_register),
162 u16 temp16 = 0; 126 0},
163 u8 temp8 = 0; 127 /*
164 acpi_size struct_size = 128 * These fields are contiguous in both the source and destination:
165 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); 129 * Address Space ID
166 130 * Register Bit Width
167 ACPI_FUNCTION_TRACE("rs_fixed_io_resource"); 131 * Register Bit Offset
168 132 * Access Size
169 /* The number of bytes consumed are Constant */ 133 */
170 134 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
171 *bytes_consumed = 4; 135 AML_OFFSET(generic_reg.address_space_id),
172 136 4},
173 output_struct->id = ACPI_RSTYPE_FIXED_IO; 137
174 138 /* Get the Register Address */
175 /* Check Range Base Address */ 139
176 140 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
177 buffer += 1; 141 AML_OFFSET(generic_reg.address),
178 ACPI_MOVE_16_TO_16(&temp16, buffer); 142 1}
179 143};
180 output_struct->data.fixed_io.base_address = temp16;
181
182 /* Check range_length */
183
184 buffer += 2;
185 temp8 = *buffer;
186
187 output_struct->data.fixed_io.range_length = temp8;
188
189 /* Set the Length parameter */
190
191 output_struct->length = (u32) struct_size;
192
193 /* Return the final size of the structure */
194
195 *structure_size = struct_size;
196 return_ACPI_STATUS(AE_OK);
197}
198 144
199/******************************************************************************* 145/*******************************************************************************
200 * 146 *
201 * FUNCTION: acpi_rs_io_stream 147 * acpi_rs_convert_end_dpf
202 *
203 * PARAMETERS: linked_list - Pointer to the resource linked list
204 * output_buffer - Pointer to the user's return buffer
205 * bytes_consumed - Pointer to where the number of bytes
206 * used in the output_buffer is returned
207 *
208 * RETURN: Status
209 *
210 * DESCRIPTION: Take the linked list resource structure and fills in the
211 * the appropriate bytes in a byte stream
212 * 148 *
213 ******************************************************************************/ 149 ******************************************************************************/
214 150
215acpi_status 151struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
216acpi_rs_io_stream(struct acpi_resource *linked_list, 152 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
217 u8 ** output_buffer, acpi_size * bytes_consumed) 153 ACPI_RS_SIZE_MIN,
218{ 154 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
219 u8 *buffer = *output_buffer;
220 u16 temp16 = 0;
221 u8 temp8 = 0;
222
223 ACPI_FUNCTION_TRACE("rs_io_stream");
224
225 /* The descriptor field is static */
226
227 *buffer = 0x47;
228 buffer += 1;
229
230 /* Io Information Byte */
231
232 temp8 = (u8) (linked_list->data.io.io_decode & 0x01);
233
234 *buffer = temp8;
235 buffer += 1;
236
237 /* Set the Range minimum base address */
238
239 temp16 = (u16) linked_list->data.io.min_base_address;
240
241 ACPI_MOVE_16_TO_16(buffer, &temp16);
242 buffer += 2;
243
244 /* Set the Range maximum base address */
245
246 temp16 = (u16) linked_list->data.io.max_base_address;
247 155
248 ACPI_MOVE_16_TO_16(buffer, &temp16); 156 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
249 buffer += 2; 157 sizeof(struct aml_resource_end_dependent),
250 158 0}
251 /* Set the base alignment */ 159};
252
253 temp8 = (u8) linked_list->data.io.alignment;
254
255 *buffer = temp8;
256 buffer += 1;
257
258 /* Set the range length */
259
260 temp8 = (u8) linked_list->data.io.range_length;
261
262 *buffer = temp8;
263 buffer += 1;
264
265 /* Return the number of bytes consumed in this operation */
266
267 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
268 return_ACPI_STATUS(AE_OK);
269}
270 160
271/******************************************************************************* 161/*******************************************************************************
272 * 162 *
273 * FUNCTION: acpi_rs_fixed_io_stream 163 * acpi_rs_convert_end_tag
274 *
275 * PARAMETERS: linked_list - Pointer to the resource linked list
276 * output_buffer - Pointer to the user's return buffer
277 * bytes_consumed - Pointer to where the number of bytes
278 * used in the output_buffer is returned
279 *
280 * RETURN: Status
281 *
282 * DESCRIPTION: Take the linked list resource structure and fills in the
283 * the appropriate bytes in a byte stream
284 * 164 *
285 ******************************************************************************/ 165 ******************************************************************************/
286 166
287acpi_status 167struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
288acpi_rs_fixed_io_stream(struct acpi_resource *linked_list, 168 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
289 u8 ** output_buffer, acpi_size * bytes_consumed) 169 ACPI_RS_SIZE_MIN,
290{ 170 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
291 u8 *buffer = *output_buffer; 171
292 u16 temp16 = 0; 172 /*
293 u8 temp8 = 0; 173 * Note: The checksum field is set to zero, meaning that the resource
294 174 * data is treated as if the checksum operation succeeded.
295 ACPI_FUNCTION_TRACE("rs_fixed_io_stream"); 175 * (ACPI Spec 1.0b Section 6.4.2.8)
296 176 */
297 /* The descriptor field is static */ 177 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
298 178 sizeof(struct aml_resource_end_tag),
299 *buffer = 0x4B; 179 0}
300 180};
301 buffer += 1;
302
303 /* Set the Range base address */
304
305 temp16 = (u16) linked_list->data.fixed_io.base_address;
306
307 ACPI_MOVE_16_TO_16(buffer, &temp16);
308 buffer += 2;
309
310 /* Set the range length */
311
312 temp8 = (u8) linked_list->data.fixed_io.range_length;
313
314 *buffer = temp8;
315 buffer += 1;
316
317 /* Return the number of bytes consumed in this operation */
318
319 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
320 return_ACPI_STATUS(AE_OK);
321}
322 181
323/******************************************************************************* 182/*******************************************************************************
324 * 183 *
325 * FUNCTION: acpi_rs_dma_resource 184 * acpi_rs_get_start_dpf
326 *
327 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
328 * stream
329 * bytes_consumed - Pointer to where the number of bytes
330 * consumed the byte_stream_buffer is
331 * returned
332 * output_buffer - Pointer to the return data buffer
333 * structure_size - Pointer to where the number of bytes
334 * in the return data struct is returned
335 *
336 * RETURN: Status
337 *
338 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
339 * structure pointed to by the output_buffer. Return the
340 * number of bytes consumed from the byte stream.
341 * 185 *
342 ******************************************************************************/ 186 ******************************************************************************/
343 187
344acpi_status 188struct acpi_rsconvert_info acpi_rs_get_start_dpf[5] = {
345acpi_rs_dma_resource(u8 * byte_stream_buffer, 189 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
346 acpi_size * bytes_consumed, 190 ACPI_RS_SIZE(struct acpi_resource_start_dependent),
347 u8 ** output_buffer, acpi_size * structure_size) 191 ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
348{
349 u8 *buffer = byte_stream_buffer;
350 struct acpi_resource *output_struct = (void *)*output_buffer;
351 u8 temp8 = 0;
352 u8 index;
353 u8 i;
354 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma);
355
356 ACPI_FUNCTION_TRACE("rs_dma_resource");
357
358 /* The number of bytes consumed are Constant */
359 192
360 *bytes_consumed = 3; 193 /* Defaults for Compatibility and Performance priorities */
361 output_struct->id = ACPI_RSTYPE_DMA;
362 194
363 /* Point to the 8-bits of Byte 1 */ 195 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
196 ACPI_ACCEPTABLE_CONFIGURATION,
197 2},
364 198
365 buffer += 1; 199 /* All done if there is no flag byte present in the descriptor */
366 temp8 = *buffer;
367 200
368 /* Decode the DMA channel bits */ 201 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
369 202
370 for (i = 0, index = 0; index < 8; index++) { 203 /* Flag byte is present, get the flags */
371 if ((temp8 >> index) & 0x01) {
372 output_struct->data.dma.channels[i] = index;
373 i++;
374 }
375 }
376 204
377 /* Zero DMA channels is valid */ 205 {ACPI_RSC_2BITFLAG,
206 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
207 AML_OFFSET(start_dpf.flags),
208 0},
378 209
379 output_struct->data.dma.number_of_channels = i; 210 {ACPI_RSC_2BITFLAG,
380 if (i > 0) { 211 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
381 /* Calculate the structure size based upon the number of interrupts */ 212 AML_OFFSET(start_dpf.flags),
382 213 2}
383 struct_size += ((acpi_size) i - 1) * 4; 214};
384 }
385
386 /* Point to Byte 2 */
387
388 buffer += 1;
389 temp8 = *buffer;
390
391 /* Check for transfer preference (Bits[1:0]) */
392
393 output_struct->data.dma.transfer = temp8 & 0x03;
394
395 if (0x03 == output_struct->data.dma.transfer) {
396 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
397 "Invalid DMA.Transfer preference (3)\n"));
398 return_ACPI_STATUS(AE_BAD_DATA);
399 }
400
401 /* Get bus master preference (Bit[2]) */
402
403 output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01;
404
405 /* Get channel speed support (Bits[6:5]) */
406
407 output_struct->data.dma.type = (temp8 >> 5) & 0x03;
408
409 /* Set the Length parameter */
410
411 output_struct->length = (u32) struct_size;
412
413 /* Return the final size of the structure */
414
415 *structure_size = struct_size;
416 return_ACPI_STATUS(AE_OK);
417}
418 215
419/******************************************************************************* 216/*******************************************************************************
420 * 217 *
421 * FUNCTION: acpi_rs_dma_stream 218 * acpi_rs_set_start_dpf
422 *
423 * PARAMETERS: linked_list - Pointer to the resource linked list
424 * output_buffer - Pointer to the user's return buffer
425 * bytes_consumed - Pointer to where the number of bytes
426 * used in the output_buffer is returned
427 *
428 * RETURN: Status
429 *
430 * DESCRIPTION: Take the linked list resource structure and fills in the
431 * the appropriate bytes in a byte stream
432 * 219 *
433 ******************************************************************************/ 220 ******************************************************************************/
434 221
435acpi_status 222struct acpi_rsconvert_info acpi_rs_set_start_dpf[6] = {
436acpi_rs_dma_stream(struct acpi_resource *linked_list, 223 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
437 u8 ** output_buffer, acpi_size * bytes_consumed) 224 sizeof(struct aml_resource_start_dependent),
438{ 225 ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
439 u8 *buffer = *output_buffer; 226
440 u16 temp16 = 0; 227 /* Set the default flag values */
441 u8 temp8 = 0; 228
442 u8 index; 229 {ACPI_RSC_2BITFLAG,
443 230 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
444 ACPI_FUNCTION_TRACE("rs_dma_stream"); 231 AML_OFFSET(start_dpf.flags),
445 232 0},
446 /* The descriptor field is static */ 233
447 234 {ACPI_RSC_2BITFLAG,
448 *buffer = 0x2A; 235 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
449 buffer += 1; 236 AML_OFFSET(start_dpf.flags),
450 temp8 = 0; 237 2},
451 238 /*
452 /* Loop through all of the Channels and set the mask bits */ 239 * All done if flags byte is necessary -- if either priority value
453 240 * is not ACPI_ACCEPTABLE_CONFIGURATION
454 for (index = 0; 241 */
455 index < linked_list->data.dma.number_of_channels; index++) { 242 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
456 temp16 = (u16) linked_list->data.dma.channels[index]; 243 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
457 temp8 |= 0x1 << temp16; 244 ACPI_ACCEPTABLE_CONFIGURATION},
458 } 245
459 246 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
460 *buffer = temp8; 247 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
461 buffer += 1; 248 ACPI_ACCEPTABLE_CONFIGURATION},
462 249
463 /* Set the DMA Info */ 250 /* Flag byte is not necessary */
464 251
465 temp8 = (u8) ((linked_list->data.dma.type & 0x03) << 5); 252 {ACPI_RSC_LENGTH, 0, 0,
466 temp8 |= ((linked_list->data.dma.bus_master & 0x01) << 2); 253 sizeof(struct aml_resource_start_dependent_noprio)}
467 temp8 |= (linked_list->data.dma.transfer & 0x03); 254};
468
469 *buffer = temp8;
470 buffer += 1;
471
472 /* Return the number of bytes consumed in this operation */
473
474 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
475 return_ACPI_STATUS(AE_OK);
476}
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c
index 56043fee96cb..1fa63bc2e36f 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/resources/rsirq.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,504 +49,182 @@ ACPI_MODULE_NAME("rsirq")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_irq_resource 52 * acpi_rs_get_irq
53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
55 * stream
56 * bytes_consumed - Pointer to where the number of bytes
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
66 * structure pointed to by the output_buffer. Return the
67 * number of bytes consumed from the byte stream.
68 * 53 *
69 ******************************************************************************/ 54 ******************************************************************************/
70acpi_status 55struct acpi_rsconvert_info acpi_rs_get_irq[7] = {
71acpi_rs_irq_resource(u8 * byte_stream_buffer, 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
72 acpi_size * bytes_consumed, 57 ACPI_RS_SIZE(struct acpi_resource_irq),
73 u8 ** output_buffer, acpi_size * structure_size) 58 ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)},
74{
75 u8 *buffer = byte_stream_buffer;
76 struct acpi_resource *output_struct = (void *)*output_buffer;
77 u16 temp16 = 0;
78 u8 temp8 = 0;
79 u8 index;
80 u8 i;
81 acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq);
82
83 ACPI_FUNCTION_TRACE("rs_irq_resource");
84
85 /*
86 * The number of bytes consumed are contained in the descriptor
87 * (Bits:0-1)
88 */
89 temp8 = *buffer;
90 *bytes_consumed = (temp8 & 0x03) + 1;
91 output_struct->id = ACPI_RSTYPE_IRQ;
92
93 /* Point to the 16-bits of Bytes 1 and 2 */
94
95 buffer += 1;
96 ACPI_MOVE_16_TO_16(&temp16, buffer);
97
98 output_struct->data.irq.number_of_interrupts = 0;
99
100 /* Decode the IRQ bits */
101
102 for (i = 0, index = 0; index < 16; index++) {
103 if ((temp16 >> index) & 0x01) {
104 output_struct->data.irq.interrupts[i] = index;
105 i++;
106 }
107 }
108 59
109 /* Zero interrupts is valid */ 60 /* Get the IRQ mask (bytes 1:2) */
110 61
111 output_struct->data.irq.number_of_interrupts = i; 62 {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
112 if (i > 0) { 63 AML_OFFSET(irq.irq_mask),
113 /* Calculate the structure size based upon the number of interrupts */ 64 ACPI_RS_OFFSET(data.irq.interrupt_count)},
114 65
115 struct_size += ((acpi_size) i - 1) * 4; 66 /* Set default flags (others are zero) */
116 }
117 67
118 /* Point to Byte 3 if it is used */ 68 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.irq.triggering),
69 ACPI_EDGE_SENSITIVE,
70 1},
119 71
120 if (4 == *bytes_consumed) { 72 /* All done if no flag byte present in descriptor */
121 buffer += 2;
122 temp8 = *buffer;
123 73
124 /* Check for HE, LL interrupts */ 74 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
125 75
126 switch (temp8 & 0x09) { 76 /* Get flags: Triggering[0], Polarity[3], Sharing[4] */
127 case 0x01: /* HE */
128 output_struct->data.irq.edge_level =
129 ACPI_EDGE_SENSITIVE;
130 output_struct->data.irq.active_high_low =
131 ACPI_ACTIVE_HIGH;
132 break;
133 77
134 case 0x08: /* LL */ 78 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
135 output_struct->data.irq.edge_level = 79 AML_OFFSET(irq.flags),
136 ACPI_LEVEL_SENSITIVE; 80 0},
137 output_struct->data.irq.active_high_low =
138 ACPI_ACTIVE_LOW;
139 break;
140 81
141 default: 82 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
142 /* 83 AML_OFFSET(irq.flags),
143 * Only _LL and _HE polarity/trigger interrupts 84 3},
144 * are allowed (ACPI spec, section "IRQ Format")
145 * so 0x00 and 0x09 are illegal.
146 */
147 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
148 "Invalid interrupt polarity/trigger in resource list, %X\n",
149 temp8));
150 return_ACPI_STATUS(AE_BAD_DATA);
151 }
152 85
153 /* Check for sharable */ 86 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
154 87 AML_OFFSET(irq.flags),
155 output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; 88 4}
156 } else { 89};
157 /*
158 * Assume Edge Sensitive, Active High, Non-Sharable
159 * per ACPI Specification
160 */
161 output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE;
162 output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH;
163 output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
164 }
165
166 /* Set the Length parameter */
167
168 output_struct->length = (u32) struct_size;
169
170 /* Return the final size of the structure */
171
172 *structure_size = struct_size;
173 return_ACPI_STATUS(AE_OK);
174}
175 90
176/******************************************************************************* 91/*******************************************************************************
177 * 92 *
178 * FUNCTION: acpi_rs_irq_stream 93 * acpi_rs_set_irq
179 *
180 * PARAMETERS: linked_list - Pointer to the resource linked list
181 * output_buffer - Pointer to the user's return buffer
182 * bytes_consumed - Pointer to where the number of bytes
183 * used in the output_buffer is returned
184 *
185 * RETURN: Status
186 *
187 * DESCRIPTION: Take the linked list resource structure and fills in the
188 * the appropriate bytes in a byte stream
189 * 94 *
190 ******************************************************************************/ 95 ******************************************************************************/
191 96
192acpi_status 97struct acpi_rsconvert_info acpi_rs_set_irq[9] = {
193acpi_rs_irq_stream(struct acpi_resource *linked_list, 98 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
194 u8 ** output_buffer, acpi_size * bytes_consumed) 99 sizeof(struct aml_resource_irq),
195{ 100 ACPI_RSC_TABLE_SIZE(acpi_rs_set_irq)},
196 u8 *buffer = *output_buffer;
197 u16 temp16 = 0;
198 u8 temp8 = 0;
199 u8 index;
200 u8 IRqinfo_byte_needed;
201
202 ACPI_FUNCTION_TRACE("rs_irq_stream");
203
204 /*
205 * The descriptor field is set based upon whether a third byte is
206 * needed to contain the IRQ Information.
207 */
208 if (ACPI_EDGE_SENSITIVE == linked_list->data.irq.edge_level &&
209 ACPI_ACTIVE_HIGH == linked_list->data.irq.active_high_low &&
210 ACPI_EXCLUSIVE == linked_list->data.irq.shared_exclusive) {
211 *buffer = 0x22;
212 IRqinfo_byte_needed = FALSE;
213 } else {
214 *buffer = 0x23;
215 IRqinfo_byte_needed = TRUE;
216 }
217
218 buffer += 1;
219 temp16 = 0;
220
221 /* Loop through all of the interrupts and set the mask bits */
222
223 for (index = 0;
224 index < linked_list->data.irq.number_of_interrupts; index++) {
225 temp8 = (u8) linked_list->data.irq.interrupts[index];
226 temp16 |= 0x1 << temp8;
227 }
228
229 ACPI_MOVE_16_TO_16(buffer, &temp16);
230 buffer += 2;
231
232 /* Set the IRQ Info byte if needed. */
233
234 if (IRqinfo_byte_needed) {
235 temp8 = 0;
236 temp8 = (u8) ((linked_list->data.irq.shared_exclusive &
237 0x01) << 4);
238
239 if (ACPI_LEVEL_SENSITIVE == linked_list->data.irq.edge_level &&
240 ACPI_ACTIVE_LOW == linked_list->data.irq.active_high_low) {
241 temp8 |= 0x08;
242 } else {
243 temp8 |= 0x01;
244 }
245
246 *buffer = temp8;
247 buffer += 1;
248 }
249
250 /* Return the number of bytes consumed in this operation */
251
252 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
253 return_ACPI_STATUS(AE_OK);
254}
255
256/*******************************************************************************
257 *
258 * FUNCTION: acpi_rs_extended_irq_resource
259 *
260 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
261 * stream
262 * bytes_consumed - Pointer to where the number of bytes
263 * consumed the byte_stream_buffer is
264 * returned
265 * output_buffer - Pointer to the return data buffer
266 * structure_size - Pointer to where the number of bytes
267 * in the return data struct is returned
268 *
269 * RETURN: Status
270 *
271 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
272 * structure pointed to by the output_buffer. Return the
273 * number of bytes consumed from the byte stream.
274 *
275 ******************************************************************************/
276
277acpi_status
278acpi_rs_extended_irq_resource(u8 * byte_stream_buffer,
279 acpi_size * bytes_consumed,
280 u8 ** output_buffer, acpi_size * structure_size)
281{
282 u8 *buffer = byte_stream_buffer;
283 struct acpi_resource *output_struct = (void *)*output_buffer;
284 u16 temp16 = 0;
285 u8 temp8 = 0;
286 u8 *temp_ptr;
287 u8 index;
288 acpi_size struct_size =
289 ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq);
290
291 ACPI_FUNCTION_TRACE("rs_extended_irq_resource");
292
293 /* Get the Descriptor Length field */
294
295 buffer += 1;
296 ACPI_MOVE_16_TO_16(&temp16, buffer);
297
298 /* Validate minimum descriptor length */
299
300 if (temp16 < 6) {
301 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
302 }
303
304 *bytes_consumed = temp16 + 3;
305 output_struct->id = ACPI_RSTYPE_EXT_IRQ;
306
307 /* Point to the Byte3 */
308
309 buffer += 2;
310 temp8 = *buffer;
311
312 output_struct->data.extended_irq.producer_consumer = temp8 & 0x01;
313 101
314 /* 102 /* Convert interrupt list to 16-bit IRQ bitmask */
315 * Check for Interrupt Mode
316 *
317 * The definition of an Extended IRQ changed between ACPI spec v1.0b
318 * and ACPI spec 2.0 (section 6.4.3.6 in both).
319 *
320 * - Edge/Level are defined opposite in the table vs the headers
321 */
322 output_struct->data.extended_irq.edge_level =
323 (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
324
325 /* Check Interrupt Polarity */
326
327 output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1;
328
329 /* Check for sharable */
330
331 output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01;
332 103
333 /* Point to Byte4 (IRQ Table length) */ 104 {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
105 AML_OFFSET(irq.irq_mask),
106 ACPI_RS_OFFSET(data.irq.interrupt_count)},
334 107
335 buffer += 1; 108 /* Set the flags byte by default */
336 temp8 = *buffer;
337 109
338 /* Must have at least one IRQ */ 110 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
111 AML_OFFSET(irq.flags),
112 0},
339 113
340 if (temp8 < 1) { 114 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
341 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); 115 AML_OFFSET(irq.flags),
342 } 116 3},
343
344 output_struct->data.extended_irq.number_of_interrupts = temp8;
345 117
118 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
119 AML_OFFSET(irq.flags),
120 4},
346 /* 121 /*
347 * Add any additional structure size to properly calculate 122 * Check if the flags byte is necessary. Not needed if the flags are:
348 * the next pointer at the end of this function 123 * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
349 */ 124 */
350 struct_size += (temp8 - 1) * 4; 125 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
351 126 ACPI_RS_OFFSET(data.irq.triggering),
352 /* Point to Byte5 (First IRQ Number) */ 127 ACPI_EDGE_SENSITIVE},
353
354 buffer += 1;
355
356 /* Cycle through every IRQ in the table */
357
358 for (index = 0; index < temp8; index++) {
359 ACPI_MOVE_32_TO_32(&output_struct->data.extended_irq.
360 interrupts[index], buffer);
361
362 /* Point to the next IRQ */
363
364 buffer += 4;
365 }
366
367 /*
368 * This will leave us pointing to the Resource Source Index
369 * If it is present, then save it off and calculate the
370 * pointer to where the null terminated string goes:
371 * Each Interrupt takes 32-bits + the 5 bytes of the
372 * stream that are default.
373 *
374 * Note: Some resource descriptors will have an additional null, so
375 * we add 1 to the length.
376 */
377 if (*bytes_consumed >
378 ((acpi_size) output_struct->data.extended_irq.number_of_interrupts *
379 4) + (5 + 1)) {
380 /* Dereference the Index */
381
382 temp8 = *buffer;
383 output_struct->data.extended_irq.resource_source.index =
384 (u32) temp8;
385
386 /* Point to the String */
387
388 buffer += 1;
389
390 /* Point the String pointer to the end of this structure. */
391
392 output_struct->data.extended_irq.resource_source.string_ptr =
393 (char *)((char *)output_struct + struct_size);
394 128
395 temp_ptr = (u8 *) 129 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
396 output_struct->data.extended_irq.resource_source.string_ptr; 130 ACPI_RS_OFFSET(data.irq.polarity),
131 ACPI_ACTIVE_HIGH},
397 132
398 /* Copy the string into the buffer */ 133 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
134 ACPI_RS_OFFSET(data.irq.sharable),
135 ACPI_EXCLUSIVE},
399 136
400 index = 0; 137 /* irq_no_flags() descriptor can be used */
401 while (*buffer) {
402 *temp_ptr = *buffer;
403 138
404 temp_ptr += 1; 139 {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq_noflags)}
405 buffer += 1; 140};
406 index += 1;
407 }
408
409 /* Add the terminating null */
410
411 *temp_ptr = 0;
412 output_struct->data.extended_irq.resource_source.string_length =
413 index + 1;
414
415 /*
416 * In order for the struct_size to fall on a 32-bit boundary,
417 * calculate the length of the string and expand the
418 * struct_size to the next 32-bit boundary.
419 */
420 temp8 = (u8) (index + 1);
421 struct_size += ACPI_ROUND_UP_to_32_bITS(temp8);
422 } else {
423 output_struct->data.extended_irq.resource_source.index = 0;
424 output_struct->data.extended_irq.resource_source.string_length =
425 0;
426 output_struct->data.extended_irq.resource_source.string_ptr =
427 NULL;
428 }
429
430 /* Set the Length parameter */
431
432 output_struct->length = (u32) struct_size;
433
434 /* Return the final size of the structure */
435
436 *structure_size = struct_size;
437 return_ACPI_STATUS(AE_OK);
438}
439 141
440/******************************************************************************* 142/*******************************************************************************
441 * 143 *
442 * FUNCTION: acpi_rs_extended_irq_stream 144 * acpi_rs_convert_ext_irq
443 *
444 * PARAMETERS: linked_list - Pointer to the resource linked list
445 * output_buffer - Pointer to the user's return buffer
446 * bytes_consumed - Pointer to where the number of bytes
447 * used in the output_buffer is returned
448 *
449 * RETURN: Status
450 *
451 * DESCRIPTION: Take the linked list resource structure and fills in the
452 * the appropriate bytes in a byte stream
453 * 145 *
454 ******************************************************************************/ 146 ******************************************************************************/
455 147
456acpi_status 148struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = {
457acpi_rs_extended_irq_stream(struct acpi_resource *linked_list, 149 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
458 u8 ** output_buffer, acpi_size * bytes_consumed) 150 ACPI_RS_SIZE(struct acpi_resource_extended_irq),
459{ 151 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)},
460 u8 *buffer = *output_buffer;
461 u16 *length_field;
462 u8 temp8 = 0;
463 u8 index;
464 152
465 ACPI_FUNCTION_TRACE("rs_extended_irq_stream"); 153 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ,
154 sizeof(struct aml_resource_extended_irq),
155 0},
466 156
467 /* Set the Descriptor Type field */ 157 /* Flag bits */
468 158
469 *buffer = ACPI_RDESC_TYPE_EXTENDED_XRUPT; 159 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer),
470 buffer += 1; 160 AML_OFFSET(extended_irq.flags),
161 0},
471 162
472 /* Save a pointer to the Length field - to be filled in later */ 163 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.triggering),
164 AML_OFFSET(extended_irq.flags),
165 1},
473 166
474 length_field = ACPI_CAST_PTR(u16, buffer); 167 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.polarity),
475 buffer += 2; 168 AML_OFFSET(extended_irq.flags),
169 2},
476 170
477 /* Set the Interrupt vector flags */ 171 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.sharable),
172 AML_OFFSET(extended_irq.flags),
173 3},
478 174
479 temp8 = (u8) (linked_list->data.extended_irq.producer_consumer & 0x01); 175 /* IRQ Table length (Byte4) */
480 temp8 |=
481 ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3);
482 176
483 /* 177 {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count),
484 * Set the Interrupt Mode 178 AML_OFFSET(extended_irq.interrupt_count),
485 * 179 sizeof(u32)}
486 * The definition of an Extended IRQ changed between ACPI spec v1.0b 180 ,
487 * and ACPI spec 2.0 (section 6.4.3.6 in both). This code does not
488 * implement the more restrictive definition of 1.0b
489 *
490 * - Edge/Level are defined opposite in the table vs the headers
491 */
492 if (ACPI_EDGE_SENSITIVE == linked_list->data.extended_irq.edge_level) {
493 temp8 |= 0x2;
494 }
495
496 /* Set the Interrupt Polarity */
497 181
498 temp8 |= ((linked_list->data.extended_irq.active_high_low & 0x1) << 2); 182 /* Copy every IRQ in the table, each is 32 bits */
499 183
500 *buffer = temp8; 184 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
501 buffer += 1; 185 AML_OFFSET(extended_irq.interrupts[0]),
186 0}
187 ,
502 188
503 /* Set the Interrupt table length */ 189 /* Optional resource_source (Index and String) */
504 190
505 temp8 = (u8) linked_list->data.extended_irq.number_of_interrupts; 191 {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET(data.extended_irq.resource_source),
192 ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
193 sizeof(struct aml_resource_extended_irq)}
194};
506 195
507 *buffer = temp8; 196/*******************************************************************************
508 buffer += 1; 197 *
509 198 * acpi_rs_convert_dma
510 for (index = 0; 199 *
511 index < linked_list->data.extended_irq.number_of_interrupts; 200 ******************************************************************************/
512 index++) {
513 ACPI_MOVE_32_TO_32(buffer,
514 &linked_list->data.extended_irq.
515 interrupts[index]);
516 buffer += 4;
517 }
518 201
519 /* Resource Source Index and Resource Source are optional */ 202struct acpi_rsconvert_info acpi_rs_convert_dma[6] = {
203 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA,
204 ACPI_RS_SIZE(struct acpi_resource_dma),
205 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_dma)},
520 206
521 if (0 != linked_list->data.extended_irq.resource_source.string_length) { 207 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA,
522 *buffer = 208 sizeof(struct aml_resource_dma),
523 (u8) linked_list->data.extended_irq.resource_source.index; 209 0},
524 buffer += 1;
525 210
526 /* Copy the string */ 211 /* Flags: transfer preference, bus mastering, channel speed */
527 212
528 ACPI_STRCPY((char *)buffer, 213 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.transfer),
529 linked_list->data.extended_irq.resource_source. 214 AML_OFFSET(dma.flags),
530 string_ptr); 215 0},
531 216
532 /* 217 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.dma.bus_master),
533 * Buffer needs to be set to the length of the string + one for the 218 AML_OFFSET(dma.flags),
534 * terminating null 219 2},
535 */
536 buffer +=
537 (acpi_size) (ACPI_STRLEN
538 (linked_list->data.extended_irq.
539 resource_source.string_ptr) + 1);
540 }
541 220
542 /* Return the number of bytes consumed in this operation */ 221 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.type),
222 AML_OFFSET(dma.flags),
223 5},
543 224
544 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 225 /* DMA channel mask bits */
545 226
546 /* 227 {ACPI_RSC_BITMASK, ACPI_RS_OFFSET(data.dma.channels[0]),
547 * Set the length field to the number of bytes consumed 228 AML_OFFSET(dma.dma_channel_mask),
548 * minus the header size (3 bytes) 229 ACPI_RS_OFFSET(data.dma.channel_count)}
549 */ 230};
550 *length_field = (u16) (*bytes_consumed - 3);
551 return_ACPI_STATUS(AE_OK);
552}
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index 103eb31c284e..1434e786477e 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,52 +49,12 @@ ACPI_MODULE_NAME("rslist")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_get_resource_type 52 * FUNCTION: acpi_rs_convert_aml_to_resources
53 * 53 *
54 * PARAMETERS: resource_start_byte - Byte 0 of a resource descriptor 54 * PARAMETERS: Aml - Pointer to the resource byte stream
55 * 55 * aml_length - Length of Aml
56 * RETURN: The Resource Type with no extraneous bits 56 * output_buffer - Pointer to the buffer that will
57 * 57 * contain the output structures
58 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
59 * a resource descriptor.
60 *
61 ******************************************************************************/
62u8 acpi_rs_get_resource_type(u8 resource_start_byte)
63{
64
65 ACPI_FUNCTION_ENTRY();
66
67 /* Determine if this is a small or large resource */
68
69 switch (resource_start_byte & ACPI_RDESC_TYPE_MASK) {
70 case ACPI_RDESC_TYPE_SMALL:
71
72 /* Small Resource Type -- Only bits 6:3 are valid */
73
74 return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK));
75
76 case ACPI_RDESC_TYPE_LARGE:
77
78 /* Large Resource Type -- All bits are valid */
79
80 return (resource_start_byte);
81
82 default:
83 /* Invalid type */
84 break;
85 }
86
87 return (0xFF);
88}
89
90/*******************************************************************************
91 *
92 * FUNCTION: acpi_rs_byte_stream_to_list
93 *
94 * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream
95 * byte_stream_buffer_length - Length of byte_stream_buffer
96 * output_buffer - Pointer to the buffer that will
97 * contain the output structures
98 * 58 *
99 * RETURN: Status 59 * RETURN: Status
100 * 60 *
@@ -102,241 +62,78 @@ u8 acpi_rs_get_resource_type(u8 resource_start_byte)
102 * linked list of resources in the caller's output buffer 62 * linked list of resources in the caller's output buffer
103 * 63 *
104 ******************************************************************************/ 64 ******************************************************************************/
105
106acpi_status 65acpi_status
107acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, 66acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer)
108 u32 byte_stream_buffer_length, u8 * output_buffer)
109{ 67{
68 struct acpi_resource *resource = (void *)output_buffer;
110 acpi_status status; 69 acpi_status status;
111 acpi_size bytes_parsed = 0; 70 u8 resource_index;
112 u8 resource_type = 0; 71 u8 *end_aml;
113 acpi_size bytes_consumed = 0; 72
114 u8 *buffer = output_buffer; 73 ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources");
115 acpi_size structure_size = 0;
116 u8 end_tag_processed = FALSE;
117 struct acpi_resource *resource;
118
119 ACPI_FUNCTION_TRACE("rs_byte_stream_to_list");
120
121 while (bytes_parsed < byte_stream_buffer_length && !end_tag_processed) {
122 /* The next byte in the stream is the resource type */
123
124 resource_type = acpi_rs_get_resource_type(*byte_stream_buffer);
125
126 switch (resource_type) {
127 case ACPI_RDESC_TYPE_MEMORY_24:
128 /*
129 * 24-Bit Memory Resource
130 */
131 status = acpi_rs_memory24_resource(byte_stream_buffer,
132 &bytes_consumed,
133 &buffer,
134 &structure_size);
135 break;
136
137 case ACPI_RDESC_TYPE_LARGE_VENDOR:
138 /*
139 * Vendor Defined Resource
140 */
141 status = acpi_rs_vendor_resource(byte_stream_buffer,
142 &bytes_consumed,
143 &buffer,
144 &structure_size);
145 break;
146
147 case ACPI_RDESC_TYPE_MEMORY_32:
148 /*
149 * 32-Bit Memory Range Resource
150 */
151 status =
152 acpi_rs_memory32_range_resource(byte_stream_buffer,
153 &bytes_consumed,
154 &buffer,
155 &structure_size);
156 break;
157
158 case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
159 /*
160 * 32-Bit Fixed Memory Resource
161 */
162 status =
163 acpi_rs_fixed_memory32_resource(byte_stream_buffer,
164 &bytes_consumed,
165 &buffer,
166 &structure_size);
167 break;
168
169 case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
170 case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE:
171 /*
172 * 64-Bit Address Resource
173 */
174 status = acpi_rs_address64_resource(byte_stream_buffer,
175 &bytes_consumed,
176 &buffer,
177 &structure_size);
178 break;
179
180 case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
181 /*
182 * 32-Bit Address Resource
183 */
184 status = acpi_rs_address32_resource(byte_stream_buffer,
185 &bytes_consumed,
186 &buffer,
187 &structure_size);
188 break;
189
190 case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
191 /*
192 * 16-Bit Address Resource
193 */
194 status = acpi_rs_address16_resource(byte_stream_buffer,
195 &bytes_consumed,
196 &buffer,
197 &structure_size);
198 break;
199
200 case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
201 /*
202 * Extended IRQ
203 */
204 status =
205 acpi_rs_extended_irq_resource(byte_stream_buffer,
206 &bytes_consumed,
207 &buffer,
208 &structure_size);
209 break;
210
211 case ACPI_RDESC_TYPE_IRQ_FORMAT:
212 /*
213 * IRQ Resource
214 */
215 status = acpi_rs_irq_resource(byte_stream_buffer,
216 &bytes_consumed, &buffer,
217 &structure_size);
218 break;
219
220 case ACPI_RDESC_TYPE_DMA_FORMAT:
221 /*
222 * DMA Resource
223 */
224 status = acpi_rs_dma_resource(byte_stream_buffer,
225 &bytes_consumed, &buffer,
226 &structure_size);
227 break;
228
229 case ACPI_RDESC_TYPE_START_DEPENDENT:
230 /*
231 * Start Dependent Functions Resource
232 */
233 status =
234 acpi_rs_start_depend_fns_resource
235 (byte_stream_buffer, &bytes_consumed, &buffer,
236 &structure_size);
237 break;
238
239 case ACPI_RDESC_TYPE_END_DEPENDENT:
240 /*
241 * End Dependent Functions Resource
242 */
243 status =
244 acpi_rs_end_depend_fns_resource(byte_stream_buffer,
245 &bytes_consumed,
246 &buffer,
247 &structure_size);
248 break;
249
250 case ACPI_RDESC_TYPE_IO_PORT:
251 /*
252 * IO Port Resource
253 */
254 status = acpi_rs_io_resource(byte_stream_buffer,
255 &bytes_consumed, &buffer,
256 &structure_size);
257 break;
258
259 case ACPI_RDESC_TYPE_FIXED_IO_PORT:
260 /*
261 * Fixed IO Port Resource
262 */
263 status = acpi_rs_fixed_io_resource(byte_stream_buffer,
264 &bytes_consumed,
265 &buffer,
266 &structure_size);
267 break;
268
269 case ACPI_RDESC_TYPE_SMALL_VENDOR:
270 /*
271 * Vendor Specific Resource
272 */
273 status = acpi_rs_vendor_resource(byte_stream_buffer,
274 &bytes_consumed,
275 &buffer,
276 &structure_size);
277 break;
278
279 case ACPI_RDESC_TYPE_END_TAG:
280 /*
281 * End Tag
282 */
283 end_tag_processed = TRUE;
284 status = acpi_rs_end_tag_resource(byte_stream_buffer,
285 &bytes_consumed,
286 &buffer,
287 &structure_size);
288 break;
289
290 default:
291 /*
292 * Invalid/Unknown resource type
293 */
294 status = AE_AML_INVALID_RESOURCE_TYPE;
295 break;
296 }
297 74
75 end_aml = aml + aml_length;
76
77 /* Loop until end-of-buffer or an end_tag is found */
78
79 while (aml < end_aml) {
80 /* Validate the Resource Type and Resource Length */
81
82 status = acpi_ut_validate_resource(aml, &resource_index);
298 if (ACPI_FAILURE(status)) { 83 if (ACPI_FAILURE(status)) {
299 return_ACPI_STATUS(status); 84 return_ACPI_STATUS(status);
300 } 85 }
301 86
302 /* Update the return value and counter */ 87 /* Convert the AML byte stream resource to a local resource struct */
303 88
304 bytes_parsed += bytes_consumed; 89 status =
90 acpi_rs_convert_aml_to_resource(resource,
91 ACPI_CAST_PTR(union
92 aml_resource,
93 aml),
94 acpi_gbl_get_resource_dispatch
95 [resource_index]);
96 if (ACPI_FAILURE(status)) {
97 ACPI_EXCEPTION((AE_INFO, status,
98 "Could not convert AML resource (Type %X)",
99 *aml));
100 return_ACPI_STATUS(status);
101 }
305 102
306 /* Set the byte stream to point to the next resource */ 103 /* Normal exit on completion of an end_tag resource descriptor */
307 104
308 byte_stream_buffer += bytes_consumed; 105 if (acpi_ut_get_resource_type(aml) ==
106 ACPI_RESOURCE_NAME_END_TAG) {
107 return_ACPI_STATUS(AE_OK);
108 }
309 109
310 /* Set the Buffer to the next structure */ 110 /* Point to the next input AML resource */
311 111
312 resource = ACPI_CAST_PTR(struct acpi_resource, buffer); 112 aml += acpi_ut_get_descriptor_length(aml);
313 resource->length =
314 (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length);
315 buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size);
316 }
317 113
318 /* Check the reason for exiting the while loop */ 114 /* Point to the next structure in the output buffer */
319 115
320 if (!end_tag_processed) { 116 resource =
321 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); 117 ACPI_ADD_PTR(struct acpi_resource, resource,
118 resource->length);
322 } 119 }
323 120
324 return_ACPI_STATUS(AE_OK); 121 /* Did not find an end_tag resource descriptor */
122
123 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
325} 124}
326 125
327/******************************************************************************* 126/*******************************************************************************
328 * 127 *
329 * FUNCTION: acpi_rs_list_to_byte_stream 128 * FUNCTION: acpi_rs_convert_resources_to_aml
330 * 129 *
331 * PARAMETERS: linked_list - Pointer to the resource linked list 130 * PARAMETERS: Resource - Pointer to the resource linked list
332 * byte_steam_size_needed - Calculated size of the byte stream 131 * aml_size_needed - Calculated size of the byte stream
333 * needed from calling 132 * needed from calling acpi_rs_get_aml_length()
334 * acpi_rs_get_byte_stream_length() 133 * The size of the output_buffer is
335 * The size of the output_buffer is 134 * guaranteed to be >= aml_size_needed
336 * guaranteed to be >= 135 * output_buffer - Pointer to the buffer that will
337 * byte_stream_size_needed 136 * contain the byte stream
338 * output_buffer - Pointer to the buffer that will
339 * contain the byte stream
340 * 137 *
341 * RETURN: Status 138 * RETURN: Status
342 * 139 *
@@ -346,180 +143,73 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
346 ******************************************************************************/ 143 ******************************************************************************/
347 144
348acpi_status 145acpi_status
349acpi_rs_list_to_byte_stream(struct acpi_resource *linked_list, 146acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
350 acpi_size byte_stream_size_needed, 147 acpi_size aml_size_needed, u8 * output_buffer)
351 u8 * output_buffer)
352{ 148{
149 u8 *aml = output_buffer;
150 u8 *end_aml = output_buffer + aml_size_needed;
353 acpi_status status; 151 acpi_status status;
354 u8 *buffer = output_buffer; 152
355 acpi_size bytes_consumed = 0; 153 ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml");
356 u8 done = FALSE; 154
357 155 /* Walk the resource descriptor list, convert each descriptor */
358 ACPI_FUNCTION_TRACE("rs_list_to_byte_stream"); 156
359 157 while (aml < end_aml) {
360 while (!done) { 158 /* Validate the (internal) Resource Type */
361 switch (linked_list->id) { 159
362 case ACPI_RSTYPE_IRQ: 160 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
363 /* 161 ACPI_ERROR((AE_INFO,
364 * IRQ Resource 162 "Invalid descriptor type (%X) in resource list",
365 */ 163 resource->type));
366 status = 164 return_ACPI_STATUS(AE_BAD_DATA);
367 acpi_rs_irq_stream(linked_list, &buffer,
368 &bytes_consumed);
369 break;
370
371 case ACPI_RSTYPE_DMA:
372 /*
373 * DMA Resource
374 */
375 status =
376 acpi_rs_dma_stream(linked_list, &buffer,
377 &bytes_consumed);
378 break;
379
380 case ACPI_RSTYPE_START_DPF:
381 /*
382 * Start Dependent Functions Resource
383 */
384 status = acpi_rs_start_depend_fns_stream(linked_list,
385 &buffer,
386 &bytes_consumed);
387 break;
388
389 case ACPI_RSTYPE_END_DPF:
390 /*
391 * End Dependent Functions Resource
392 */
393 status = acpi_rs_end_depend_fns_stream(linked_list,
394 &buffer,
395 &bytes_consumed);
396 break;
397
398 case ACPI_RSTYPE_IO:
399 /*
400 * IO Port Resource
401 */
402 status =
403 acpi_rs_io_stream(linked_list, &buffer,
404 &bytes_consumed);
405 break;
406
407 case ACPI_RSTYPE_FIXED_IO:
408 /*
409 * Fixed IO Port Resource
410 */
411 status =
412 acpi_rs_fixed_io_stream(linked_list, &buffer,
413 &bytes_consumed);
414 break;
415
416 case ACPI_RSTYPE_VENDOR:
417 /*
418 * Vendor Defined Resource
419 */
420 status =
421 acpi_rs_vendor_stream(linked_list, &buffer,
422 &bytes_consumed);
423 break;
424
425 case ACPI_RSTYPE_END_TAG:
426 /*
427 * End Tag
428 */
429 status =
430 acpi_rs_end_tag_stream(linked_list, &buffer,
431 &bytes_consumed);
432
433 /* An End Tag indicates the end of the Resource Template */
434
435 done = TRUE;
436 break;
437
438 case ACPI_RSTYPE_MEM24:
439 /*
440 * 24-Bit Memory Resource
441 */
442 status =
443 acpi_rs_memory24_stream(linked_list, &buffer,
444 &bytes_consumed);
445 break;
446
447 case ACPI_RSTYPE_MEM32:
448 /*
449 * 32-Bit Memory Range Resource
450 */
451 status =
452 acpi_rs_memory32_range_stream(linked_list, &buffer,
453 &bytes_consumed);
454 break;
455
456 case ACPI_RSTYPE_FIXED_MEM32:
457 /*
458 * 32-Bit Fixed Memory Resource
459 */
460 status =
461 acpi_rs_fixed_memory32_stream(linked_list, &buffer,
462 &bytes_consumed);
463 break;
464
465 case ACPI_RSTYPE_ADDRESS16:
466 /*
467 * 16-Bit Address Descriptor Resource
468 */
469 status = acpi_rs_address16_stream(linked_list, &buffer,
470 &bytes_consumed);
471 break;
472
473 case ACPI_RSTYPE_ADDRESS32:
474 /*
475 * 32-Bit Address Descriptor Resource
476 */
477 status = acpi_rs_address32_stream(linked_list, &buffer,
478 &bytes_consumed);
479 break;
480
481 case ACPI_RSTYPE_ADDRESS64:
482 /*
483 * 64-Bit Address Descriptor Resource
484 */
485 status = acpi_rs_address64_stream(linked_list, &buffer,
486 &bytes_consumed);
487 break;
488
489 case ACPI_RSTYPE_EXT_IRQ:
490 /*
491 * Extended IRQ Resource
492 */
493 status =
494 acpi_rs_extended_irq_stream(linked_list, &buffer,
495 &bytes_consumed);
496 break;
497
498 default:
499 /*
500 * If we get here, everything is out of sync,
501 * so exit with an error
502 */
503 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
504 "Invalid descriptor type (%X) in resource list\n",
505 linked_list->id));
506 status = AE_BAD_DATA;
507 break;
508 } 165 }
509 166
167 /* Perform the conversion */
168
169 status = acpi_rs_convert_resource_to_aml(resource,
170 ACPI_CAST_PTR(union
171 aml_resource,
172 aml),
173 acpi_gbl_set_resource_dispatch
174 [resource->type]);
510 if (ACPI_FAILURE(status)) { 175 if (ACPI_FAILURE(status)) {
176 ACPI_EXCEPTION((AE_INFO, status,
177 "Could not convert resource (type %X) to AML",
178 resource->type));
511 return_ACPI_STATUS(status); 179 return_ACPI_STATUS(status);
512 } 180 }
513 181
514 /* Set the Buffer to point to the open byte */ 182 /* Perform final sanity check on the new AML resource descriptor */
183
184 status =
185 acpi_ut_validate_resource(ACPI_CAST_PTR
186 (union aml_resource, aml), NULL);
187 if (ACPI_FAILURE(status)) {
188 return_ACPI_STATUS(status);
189 }
515 190
516 buffer += bytes_consumed; 191 /* Check for end-of-list, normal exit */
517 192
518 /* Point to the next object */ 193 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
194 /* An End Tag indicates the end of the input Resource Template */
519 195
520 linked_list = ACPI_PTR_ADD(struct acpi_resource, 196 return_ACPI_STATUS(AE_OK);
521 linked_list, linked_list->length); 197 }
198
199 /*
200 * Extract the total length of the new descriptor and set the
201 * Aml to point to the next (output) resource descriptor
202 */
203 aml += acpi_ut_get_descriptor_length(aml);
204
205 /* Point to the next input resource descriptor */
206
207 resource =
208 ACPI_ADD_PTR(struct acpi_resource, resource,
209 resource->length);
522 } 210 }
523 211
524 return_ACPI_STATUS(AE_OK); 212 /* Completed buffer, but did not find an end_tag resource descriptor */
213
214 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
525} 215}
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c
index daba1a1ed46d..a5131936d690 100644
--- a/drivers/acpi/resources/rsmemory.c
+++ b/drivers/acpi/resources/rsmemory.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,454 +49,187 @@ ACPI_MODULE_NAME("rsmemory")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_memory24_resource 52 * acpi_rs_convert_memory24
53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
55 * stream
56 * bytes_consumed - Pointer to where the number of bytes
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
66 * structure pointed to by the output_buffer. Return the
67 * number of bytes consumed from the byte stream.
68 * 53 *
69 ******************************************************************************/ 54 ******************************************************************************/
70acpi_status 55struct acpi_rsconvert_info acpi_rs_convert_memory24[4] = {
71acpi_rs_memory24_resource(u8 * byte_stream_buffer, 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24,
72 acpi_size * bytes_consumed, 57 ACPI_RS_SIZE(struct acpi_resource_memory24),
73 u8 ** output_buffer, acpi_size * structure_size) 58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory24)},
74{
75 u8 *buffer = byte_stream_buffer;
76 struct acpi_resource *output_struct = (void *)*output_buffer;
77 u16 temp16 = 0;
78 u8 temp8 = 0;
79 acpi_size struct_size =
80 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24);
81
82 ACPI_FUNCTION_TRACE("rs_memory24_resource");
83
84 /* Point past the Descriptor to get the number of bytes consumed */
85
86 buffer += 1;
87
88 ACPI_MOVE_16_TO_16(&temp16, buffer);
89 buffer += 2;
90 *bytes_consumed = (acpi_size) temp16 + 3;
91 output_struct->id = ACPI_RSTYPE_MEM24;
92
93 /* Check Byte 3 the Read/Write bit */
94
95 temp8 = *buffer;
96 buffer += 1;
97 output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
98
99 /* Get min_base_address (Bytes 4-5) */
100
101 ACPI_MOVE_16_TO_16(&temp16, buffer);
102 buffer += 2;
103 output_struct->data.memory24.min_base_address = temp16;
104
105 /* Get max_base_address (Bytes 6-7) */
106
107 ACPI_MOVE_16_TO_16(&temp16, buffer);
108 buffer += 2;
109 output_struct->data.memory24.max_base_address = temp16;
110 59
111 /* Get Alignment (Bytes 8-9) */ 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24,
61 sizeof(struct aml_resource_memory24),
62 0},
112 63
113 ACPI_MOVE_16_TO_16(&temp16, buffer); 64 /* Read/Write bit */
114 buffer += 2;
115 output_struct->data.memory24.alignment = temp16;
116 65
117 /* Get range_length (Bytes 10-11) */ 66 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory24.write_protect),
118 67 AML_OFFSET(memory24.flags),
119 ACPI_MOVE_16_TO_16(&temp16, buffer); 68 0},
120 output_struct->data.memory24.range_length = temp16; 69 /*
121 70 * These fields are contiguous in both the source and destination:
122 /* Set the Length parameter */ 71 * Minimum Base Address
123 72 * Maximum Base Address
124 output_struct->length = (u32) struct_size; 73 * Address Base Alignment
125 74 * Range Length
126 /* Return the final size of the structure */ 75 */
127 76 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.memory24.minimum),
128 *structure_size = struct_size; 77 AML_OFFSET(memory24.minimum),
129 return_ACPI_STATUS(AE_OK); 78 4}
130} 79};
131 80
132/******************************************************************************* 81/*******************************************************************************
133 * 82 *
134 * FUNCTION: acpi_rs_memory24_stream 83 * acpi_rs_convert_memory32
135 *
136 * PARAMETERS: linked_list - Pointer to the resource linked list
137 * output_buffer - Pointer to the user's return buffer
138 * bytes_consumed - Pointer to where the number of bytes
139 * used in the output_buffer is returned
140 *
141 * RETURN: Status
142 *
143 * DESCRIPTION: Take the linked list resource structure and fills in the
144 * the appropriate bytes in a byte stream
145 * 84 *
146 ******************************************************************************/ 85 ******************************************************************************/
147 86
148acpi_status 87struct acpi_rsconvert_info acpi_rs_convert_memory32[4] = {
149acpi_rs_memory24_stream(struct acpi_resource *linked_list, 88 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32,
150 u8 ** output_buffer, acpi_size * bytes_consumed) 89 ACPI_RS_SIZE(struct acpi_resource_memory32),
151{ 90 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory32)},
152 u8 *buffer = *output_buffer;
153 u16 temp16 = 0;
154 u8 temp8 = 0;
155
156 ACPI_FUNCTION_TRACE("rs_memory24_stream");
157
158 /* The descriptor field is static */
159
160 *buffer = 0x81;
161 buffer += 1;
162 91
163 /* The length field is static */ 92 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32,
93 sizeof(struct aml_resource_memory32),
94 0},
164 95
165 temp16 = 0x09; 96 /* Read/Write bit */
166 ACPI_MOVE_16_TO_16(buffer, &temp16);
167 buffer += 2;
168 97
169 /* Set the Information Byte */ 98 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory32.write_protect),
170 99 AML_OFFSET(memory32.flags),
171 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01); 100 0},
172 *buffer = temp8; 101 /*
173 buffer += 1; 102 * These fields are contiguous in both the source and destination:
174 103 * Minimum Base Address
175 /* Set the Range minimum base address */ 104 * Maximum Base Address
176 105 * Address Base Alignment
177 ACPI_MOVE_32_TO_16(buffer, 106 * Range Length
178 &linked_list->data.memory24.min_base_address); 107 */
179 buffer += 2; 108 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.memory32.minimum),
180 109 AML_OFFSET(memory32.minimum),
181 /* Set the Range maximum base address */ 110 4}
182 111};
183 ACPI_MOVE_32_TO_16(buffer,
184 &linked_list->data.memory24.max_base_address);
185 buffer += 2;
186
187 /* Set the base alignment */
188
189 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.alignment);
190 buffer += 2;
191
192 /* Set the range length */
193
194 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.range_length);
195 buffer += 2;
196
197 /* Return the number of bytes consumed in this operation */
198
199 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
200 return_ACPI_STATUS(AE_OK);
201}
202 112
203/******************************************************************************* 113/*******************************************************************************
204 * 114 *
205 * FUNCTION: acpi_rs_memory32_range_resource 115 * acpi_rs_convert_fixed_memory32
206 *
207 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
208 * stream
209 * bytes_consumed - Pointer to where the number of bytes
210 * consumed the byte_stream_buffer is
211 * returned
212 * output_buffer - Pointer to the return data buffer
213 * structure_size - Pointer to where the number of bytes
214 * in the return data struct is returned
215 *
216 * RETURN: Status
217 *
218 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
219 * structure pointed to by the output_buffer. Return the
220 * number of bytes consumed from the byte stream.
221 * 116 *
222 ******************************************************************************/ 117 ******************************************************************************/
223 118
224acpi_status 119struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[4] = {
225acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, 120 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32,
226 acpi_size * bytes_consumed, 121 ACPI_RS_SIZE(struct acpi_resource_fixed_memory32),
227 u8 ** output_buffer, acpi_size * structure_size) 122 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_memory32)},
228{
229 u8 *buffer = byte_stream_buffer;
230 struct acpi_resource *output_struct = (void *)*output_buffer;
231 u16 temp16 = 0;
232 u8 temp8 = 0;
233 acpi_size struct_size =
234 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32);
235
236 ACPI_FUNCTION_TRACE("rs_memory32_range_resource");
237
238 /* Point past the Descriptor to get the number of bytes consumed */
239
240 buffer += 1;
241 123
242 ACPI_MOVE_16_TO_16(&temp16, buffer); 124 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32,
243 buffer += 2; 125 sizeof(struct aml_resource_fixed_memory32),
244 *bytes_consumed = (acpi_size) temp16 + 3; 126 0},
245 127
246 output_struct->id = ACPI_RSTYPE_MEM32; 128 /* Read/Write bit */
247 129
130 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.fixed_memory32.write_protect),
131 AML_OFFSET(fixed_memory32.flags),
132 0},
248 /* 133 /*
249 * Point to the place in the output buffer where the data portion will 134 * These fields are contiguous in both the source and destination:
250 * begin. 135 * Base Address
251 * 1. Set the RESOURCE_DATA * Data to point to its own address, then 136 * Range Length
252 * 2. Set the pointer to the next address.
253 *
254 * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds
255 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
256 */ 137 */
257 138 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.fixed_memory32.address),
258 /* Check Byte 3 the Read/Write bit */ 139 AML_OFFSET(fixed_memory32.address),
259 140 2}
260 temp8 = *buffer; 141};
261 buffer += 1;
262
263 output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
264
265 /* Get min_base_address (Bytes 4-7) */
266
267 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.min_base_address,
268 buffer);
269 buffer += 4;
270
271 /* Get max_base_address (Bytes 8-11) */
272
273 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.max_base_address,
274 buffer);
275 buffer += 4;
276
277 /* Get Alignment (Bytes 12-15) */
278
279 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.alignment, buffer);
280 buffer += 4;
281
282 /* Get range_length (Bytes 16-19) */
283
284 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.range_length, buffer);
285
286 /* Set the Length parameter */
287
288 output_struct->length = (u32) struct_size;
289
290 /* Return the final size of the structure */
291
292 *structure_size = struct_size;
293 return_ACPI_STATUS(AE_OK);
294}
295 142
296/******************************************************************************* 143/*******************************************************************************
297 * 144 *
298 * FUNCTION: acpi_rs_fixed_memory32_resource 145 * acpi_rs_get_vendor_small
299 *
300 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
301 * stream
302 * bytes_consumed - Pointer to where the number of bytes
303 * consumed the byte_stream_buffer is
304 * returned
305 * output_buffer - Pointer to the return data buffer
306 * structure_size - Pointer to where the number of bytes
307 * in the return data struct is returned
308 *
309 * RETURN: Status
310 *
311 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
312 * structure pointed to by the output_buffer. Return the
313 * number of bytes consumed from the byte stream.
314 * 146 *
315 ******************************************************************************/ 147 ******************************************************************************/
316 148
317acpi_status 149struct acpi_rsconvert_info acpi_rs_get_vendor_small[3] = {
318acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, 150 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
319 acpi_size * bytes_consumed, 151 ACPI_RS_SIZE(struct acpi_resource_vendor),
320 u8 ** output_buffer, acpi_size * structure_size) 152 ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_small)},
321{
322 u8 *buffer = byte_stream_buffer;
323 struct acpi_resource *output_struct = (void *)*output_buffer;
324 u16 temp16 = 0;
325 u8 temp8 = 0;
326 acpi_size struct_size =
327 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32);
328
329 ACPI_FUNCTION_TRACE("rs_fixed_memory32_resource");
330 153
331 /* Point past the Descriptor to get the number of bytes consumed */ 154 /* Length of the vendor data (byte count) */
332 155
333 buffer += 1; 156 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
334 ACPI_MOVE_16_TO_16(&temp16, buffer); 157 0,
158 sizeof(u8)}
159 ,
335 160
336 buffer += 2; 161 /* Vendor data */
337 *bytes_consumed = (acpi_size) temp16 + 3;
338 162
339 output_struct->id = ACPI_RSTYPE_FIXED_MEM32; 163 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
340 164 sizeof(struct aml_resource_small_header),
341 /* Check Byte 3 the Read/Write bit */ 165 0}
342 166};
343 temp8 = *buffer;
344 buffer += 1;
345 output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
346
347 /* Get range_base_address (Bytes 4-7) */
348
349 ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.
350 range_base_address, buffer);
351 buffer += 4;
352
353 /* Get range_length (Bytes 8-11) */
354
355 ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.range_length,
356 buffer);
357
358 /* Set the Length parameter */
359
360 output_struct->length = (u32) struct_size;
361
362 /* Return the final size of the structure */
363
364 *structure_size = struct_size;
365 return_ACPI_STATUS(AE_OK);
366}
367 167
368/******************************************************************************* 168/*******************************************************************************
369 * 169 *
370 * FUNCTION: acpi_rs_memory32_range_stream 170 * acpi_rs_get_vendor_large
371 *
372 * PARAMETERS: linked_list - Pointer to the resource linked list
373 * output_buffer - Pointer to the user's return buffer
374 * bytes_consumed - Pointer to where the number of bytes
375 * used in the output_buffer is returned
376 *
377 * RETURN: Status
378 *
379 * DESCRIPTION: Take the linked list resource structure and fills in the
380 * the appropriate bytes in a byte stream
381 * 171 *
382 ******************************************************************************/ 172 ******************************************************************************/
383 173
384acpi_status 174struct acpi_rsconvert_info acpi_rs_get_vendor_large[3] = {
385acpi_rs_memory32_range_stream(struct acpi_resource *linked_list, 175 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
386 u8 ** output_buffer, acpi_size * bytes_consumed) 176 ACPI_RS_SIZE(struct acpi_resource_vendor),
387{ 177 ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_large)},
388 u8 *buffer = *output_buffer;
389 u16 temp16 = 0;
390 u8 temp8 = 0;
391
392 ACPI_FUNCTION_TRACE("rs_memory32_range_stream");
393
394 /* The descriptor field is static */
395
396 *buffer = 0x85;
397 buffer += 1;
398
399 /* The length field is static */
400
401 temp16 = 0x11;
402
403 ACPI_MOVE_16_TO_16(buffer, &temp16);
404 buffer += 2;
405
406 /* Set the Information Byte */
407
408 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01);
409 *buffer = temp8;
410 buffer += 1;
411
412 /* Set the Range minimum base address */
413
414 ACPI_MOVE_32_TO_32(buffer,
415 &linked_list->data.memory32.min_base_address);
416 buffer += 4;
417
418 /* Set the Range maximum base address */
419
420 ACPI_MOVE_32_TO_32(buffer,
421 &linked_list->data.memory32.max_base_address);
422 buffer += 4;
423 178
424 /* Set the base alignment */ 179 /* Length of the vendor data (byte count) */
425 180
426 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.alignment); 181 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
427 buffer += 4; 182 0,
183 sizeof(u8)}
184 ,
428 185
429 /* Set the range length */ 186 /* Vendor data */
430 187
431 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.range_length); 188 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
432 buffer += 4; 189 sizeof(struct aml_resource_large_header),
433 190 0}
434 /* Return the number of bytes consumed in this operation */ 191};
435
436 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
437 return_ACPI_STATUS(AE_OK);
438}
439 192
440/******************************************************************************* 193/*******************************************************************************
441 * 194 *
442 * FUNCTION: acpi_rs_fixed_memory32_stream 195 * acpi_rs_set_vendor
443 *
444 * PARAMETERS: linked_list - Pointer to the resource linked list
445 * output_buffer - Pointer to the user's return buffer
446 * bytes_consumed - Pointer to where the number of bytes
447 * used in the output_buffer is returned
448 *
449 * RETURN: Status
450 *
451 * DESCRIPTION: Take the linked list resource structure and fills in the
452 * the appropriate bytes in a byte stream
453 * 196 *
454 ******************************************************************************/ 197 ******************************************************************************/
455 198
456acpi_status 199struct acpi_rsconvert_info acpi_rs_set_vendor[7] = {
457acpi_rs_fixed_memory32_stream(struct acpi_resource *linked_list, 200 /* Default is a small vendor descriptor */
458 u8 ** output_buffer, acpi_size * bytes_consumed)
459{
460 u8 *buffer = *output_buffer;
461 u16 temp16 = 0;
462 u8 temp8 = 0;
463
464 ACPI_FUNCTION_TRACE("rs_fixed_memory32_stream");
465 201
466 /* The descriptor field is static */ 202 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL,
203 sizeof(struct aml_resource_small_header),
204 ACPI_RSC_TABLE_SIZE(acpi_rs_set_vendor)},
467 205
468 *buffer = 0x86; 206 /* Get the length and copy the data */
469 buffer += 1;
470 207
471 /* The length field is static */ 208 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
209 0,
210 0},
472 211
473 temp16 = 0x09; 212 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
213 sizeof(struct aml_resource_small_header),
214 0},
474 215
475 ACPI_MOVE_16_TO_16(buffer, &temp16); 216 /*
476 buffer += 2; 217 * All done if the Vendor byte length is 7 or less, meaning that it will
477 218 * fit within a small descriptor
478 /* Set the Information Byte */ 219 */
479 220 {ACPI_RSC_EXIT_LE, 0, 0, 7},
480 temp8 =
481 (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
482 *buffer = temp8;
483 buffer += 1;
484
485 /* Set the Range base address */
486
487 ACPI_MOVE_32_TO_32(buffer,
488 &linked_list->data.fixed_memory32.
489 range_base_address);
490 buffer += 4;
491 221
492 /* Set the range length */ 222 /* Must create a large vendor descriptor */
493 223
494 ACPI_MOVE_32_TO_32(buffer, 224 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE,
495 &linked_list->data.fixed_memory32.range_length); 225 sizeof(struct aml_resource_large_header),
496 buffer += 4; 226 0},
497 227
498 /* Return the number of bytes consumed in this operation */ 228 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
229 0,
230 0},
499 231
500 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 232 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
501 return_ACPI_STATUS(AE_OK); 233 sizeof(struct aml_resource_large_header),
502} 234 0}
235};
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c
index 7a8a34e757f5..ed866cf1c6d2 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/resources/rsmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,481 +47,501 @@
47#define _COMPONENT ACPI_RESOURCES 47#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsmisc") 48ACPI_MODULE_NAME("rsmisc")
49 49
50#define INIT_RESOURCE_TYPE(i) i->resource_offset
51#define INIT_RESOURCE_LENGTH(i) i->aml_offset
52#define INIT_TABLE_LENGTH(i) i->value
53#define COMPARE_OPCODE(i) i->resource_offset
54#define COMPARE_TARGET(i) i->aml_offset
55#define COMPARE_VALUE(i) i->value
50/******************************************************************************* 56/*******************************************************************************
51 * 57 *
52 * FUNCTION: acpi_rs_end_tag_resource 58 * FUNCTION: acpi_rs_convert_aml_to_resource
53 * 59 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 60 * PARAMETERS: Resource - Pointer to the resource descriptor
55 * stream 61 * Aml - Where the AML descriptor is returned
56 * bytes_consumed - Pointer to where the number of bytes 62 * Info - Pointer to appropriate conversion table
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 * 63 *
63 * RETURN: Status 64 * RETURN: Status
64 * 65 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 66 * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
66 * structure pointed to by the output_buffer. Return the 67 * internal resource descriptor
67 * number of bytes consumed from the byte stream.
68 * 68 *
69 ******************************************************************************/ 69 ******************************************************************************/
70acpi_status 70acpi_status
71acpi_rs_end_tag_resource(u8 * byte_stream_buffer, 71acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
72 acpi_size * bytes_consumed, 72 union aml_resource *aml,
73 u8 ** output_buffer, acpi_size * structure_size) 73 struct acpi_rsconvert_info *info)
74{ 74{
75 struct acpi_resource *output_struct = (void *)*output_buffer; 75 acpi_rs_length aml_resource_length;
76 acpi_size struct_size = ACPI_RESOURCE_LENGTH; 76 void *source;
77 77 void *destination;
78 ACPI_FUNCTION_TRACE("rs_end_tag_resource"); 78 char *target;
79 79 u8 count;
80 /* The number of bytes consumed is static */ 80 u8 flags_mode = FALSE;
81 81 u16 item_count = 0;
82 *bytes_consumed = 2;
83
84 /* Fill out the structure */
85
86 output_struct->id = ACPI_RSTYPE_END_TAG;
87
88 /* Set the Length parameter */
89
90 output_struct->length = 0;
91
92 /* Return the final size of the structure */
93
94 *structure_size = struct_size;
95 return_ACPI_STATUS(AE_OK);
96}
97
98/*******************************************************************************
99 *
100 * FUNCTION: acpi_rs_end_tag_stream
101 *
102 * PARAMETERS: linked_list - Pointer to the resource linked list
103 * output_buffer - Pointer to the user's return buffer
104 * bytes_consumed - Pointer to where the number of bytes
105 * used in the output_buffer is returned
106 *
107 * RETURN: Status
108 *
109 * DESCRIPTION: Take the linked list resource structure and fills in the
110 * the appropriate bytes in a byte stream
111 *
112 ******************************************************************************/
113
114acpi_status
115acpi_rs_end_tag_stream(struct acpi_resource *linked_list,
116 u8 ** output_buffer, acpi_size * bytes_consumed)
117{
118 u8 *buffer = *output_buffer;
119 u8 temp8 = 0;
120
121 ACPI_FUNCTION_TRACE("rs_end_tag_stream");
122
123 /* The descriptor field is static */
124
125 *buffer = 0x79;
126 buffer += 1;
127
128 /*
129 * Set the Checksum - zero means that the resource data is treated as if
130 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
131 */
132 temp8 = 0;
133
134 *buffer = temp8;
135 buffer += 1;
136
137 /* Return the number of bytes consumed in this operation */
138
139 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
140 return_ACPI_STATUS(AE_OK);
141}
142
143/*******************************************************************************
144 *
145 * FUNCTION: acpi_rs_vendor_resource
146 *
147 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
148 * stream
149 * bytes_consumed - Pointer to where the number of bytes
150 * consumed the byte_stream_buffer is
151 * returned
152 * output_buffer - Pointer to the return data buffer
153 * structure_size - Pointer to where the number of bytes
154 * in the return data struct is returned
155 *
156 * RETURN: Status
157 *
158 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
159 * structure pointed to by the output_buffer. Return the
160 * number of bytes consumed from the byte stream.
161 *
162 ******************************************************************************/
163
164acpi_status
165acpi_rs_vendor_resource(u8 * byte_stream_buffer,
166 acpi_size * bytes_consumed,
167 u8 ** output_buffer, acpi_size * structure_size)
168{
169 u8 *buffer = byte_stream_buffer;
170 struct acpi_resource *output_struct = (void *)*output_buffer;
171 u16 temp16 = 0; 82 u16 temp16 = 0;
172 u8 temp8 = 0;
173 u8 index;
174 acpi_size struct_size =
175 ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor);
176
177 ACPI_FUNCTION_TRACE("rs_vendor_resource");
178
179 /* Dereference the Descriptor to find if this is a large or small item. */
180
181 temp8 = *buffer;
182
183 if (temp8 & 0x80) {
184 /* Large Item, point to the length field */
185
186 buffer += 1;
187 83
188 /* Dereference */ 84 ACPI_FUNCTION_TRACE("rs_get_resource");
189 85
190 ACPI_MOVE_16_TO_16(&temp16, buffer); 86 if (((acpi_native_uint) resource) & 0x3) {
87 /* Each internal resource struct is expected to be 32-bit aligned */
191 88
192 /* Calculate bytes consumed */ 89 ACPI_WARNING((AE_INFO,
193 90 "Misaligned resource pointer (get): %p Type %2.2X Len %X",
194 *bytes_consumed = (acpi_size) temp16 + 3; 91 resource, resource->type, resource->length));
195
196 /* Point to the first vendor byte */
197
198 buffer += 2;
199 } else {
200 /* Small Item, dereference the size */
201
202 temp16 = (u8) (*buffer & 0x07);
203
204 /* Calculate bytes consumed */
205
206 *bytes_consumed = (acpi_size) temp16 + 1;
207
208 /* Point to the first vendor byte */
209
210 buffer += 1;
211 } 92 }
212 93
213 output_struct->id = ACPI_RSTYPE_VENDOR; 94 /* Extract the resource Length field (does not include header length) */
214 output_struct->data.vendor_specific.length = temp16;
215 95
216 for (index = 0; index < temp16; index++) { 96 aml_resource_length = acpi_ut_get_resource_length(aml);
217 output_struct->data.vendor_specific.reserved[index] = *buffer;
218 buffer += 1;
219 }
220 97
221 /* 98 /*
222 * In order for the struct_size to fall on a 32-bit boundary, 99 * First table entry must be ACPI_RSC_INITxxx and must contain the
223 * calculate the length of the vendor string and expand the 100 * table length (# of table entries)
224 * struct_size to the next 32-bit boundary.
225 */ 101 */
226 struct_size += ACPI_ROUND_UP_to_32_bITS(temp16); 102 count = INIT_TABLE_LENGTH(info);
227 103
228 /* Set the Length parameter */ 104 while (count) {
229 105 /*
230 output_struct->length = (u32) struct_size; 106 * Source is the external AML byte stream buffer,
231 107 * destination is the internal resource descriptor
232 /* Return the final size of the structure */ 108 */
233 109 source = ACPI_ADD_PTR(void, aml, info->aml_offset);
234 *structure_size = struct_size; 110 destination =
235 return_ACPI_STATUS(AE_OK); 111 ACPI_ADD_PTR(void, resource, info->resource_offset);
236} 112
237 113 switch (info->opcode) {
238/******************************************************************************* 114 case ACPI_RSC_INITGET:
239 * 115 /*
240 * FUNCTION: acpi_rs_vendor_stream 116 * Get the resource type and the initial (minimum) length
241 * 117 */
242 * PARAMETERS: linked_list - Pointer to the resource linked list 118 ACPI_MEMSET(resource, 0, INIT_RESOURCE_LENGTH(info));
243 * output_buffer - Pointer to the user's return buffer 119 resource->type = INIT_RESOURCE_TYPE(info);
244 * bytes_consumed - Pointer to where the number of bytes 120 resource->length = INIT_RESOURCE_LENGTH(info);
245 * used in the output_buffer is returned 121 break;
246 * 122
247 * RETURN: Status 123 case ACPI_RSC_INITSET:
248 * 124 break;
249 * DESCRIPTION: Take the linked list resource structure and fills in the 125
250 * the appropriate bytes in a byte stream 126 case ACPI_RSC_FLAGINIT:
251 * 127
252 ******************************************************************************/ 128 flags_mode = TRUE;
253 129 break;
254acpi_status 130
255acpi_rs_vendor_stream(struct acpi_resource *linked_list, 131 case ACPI_RSC_1BITFLAG:
256 u8 ** output_buffer, acpi_size * bytes_consumed) 132 /*
257{ 133 * Mask and shift the flag bit
258 u8 *buffer = *output_buffer; 134 */
259 u16 temp16 = 0; 135 ACPI_SET8(destination) = (u8)
260 u8 temp8 = 0; 136 ((ACPI_GET8(source) >> info->value) & 0x01);
261 u8 index; 137 break;
262 138
263 ACPI_FUNCTION_TRACE("rs_vendor_stream"); 139 case ACPI_RSC_2BITFLAG:
264 140 /*
265 /* Dereference the length to find if this is a large or small item. */ 141 * Mask and shift the flag bits
266 142 */
267 if (linked_list->data.vendor_specific.length > 7) { 143 ACPI_SET8(destination) = (u8)
268 /* Large Item, Set the descriptor field and length bytes */ 144 ((ACPI_GET8(source) >> info->value) & 0x03);
269 145 break;
270 *buffer = 0x84; 146
271 buffer += 1; 147 case ACPI_RSC_COUNT:
272 148
273 temp16 = (u16) linked_list->data.vendor_specific.length; 149 item_count = ACPI_GET8(source);
274 150 ACPI_SET8(destination) = (u8) item_count;
275 ACPI_MOVE_16_TO_16(buffer, &temp16); 151
276 buffer += 2; 152 resource->length = resource->length +
277 } else { 153 (info->value * (item_count - 1));
278 /* Small Item, Set the descriptor field */ 154 break;
279 155
280 temp8 = 0x70; 156 case ACPI_RSC_COUNT16:
281 temp8 |= (u8) linked_list->data.vendor_specific.length; 157
158 item_count = aml_resource_length;
159 ACPI_SET16(destination) = item_count;
160
161 resource->length = resource->length +
162 (info->value * (item_count - 1));
163 break;
164
165 case ACPI_RSC_LENGTH:
166
167 resource->length = resource->length + info->value;
168 break;
169
170 case ACPI_RSC_MOVE8:
171 case ACPI_RSC_MOVE16:
172 case ACPI_RSC_MOVE32:
173 case ACPI_RSC_MOVE64:
174 /*
175 * Raw data move. Use the Info value field unless item_count has
176 * been previously initialized via a COUNT opcode
177 */
178 if (info->value) {
179 item_count = info->value;
180 }
181 acpi_rs_move_data(destination, source, item_count,
182 info->opcode);
183 break;
184
185 case ACPI_RSC_SET8:
186
187 ACPI_MEMSET(destination, info->aml_offset, info->value);
188 break;
189
190 case ACPI_RSC_DATA8:
191
192 target = ACPI_ADD_PTR(char, resource, info->value);
193 ACPI_MEMCPY(destination, source, ACPI_GET16(target));
194 break;
195
196 case ACPI_RSC_ADDRESS:
197 /*
198 * Common handler for address descriptor flags
199 */
200 if (!acpi_rs_get_address_common(resource, aml)) {
201 return_ACPI_STATUS
202 (AE_AML_INVALID_RESOURCE_TYPE);
203 }
204 break;
205
206 case ACPI_RSC_SOURCE:
207 /*
208 * Optional resource_source (Index and String)
209 */
210 resource->length +=
211 acpi_rs_get_resource_source(aml_resource_length,
212 info->value,
213 destination, aml, NULL);
214 break;
215
216 case ACPI_RSC_SOURCEX:
217 /*
218 * Optional resource_source (Index and String). This is the more
219 * complicated case used by the Interrupt() macro
220 */
221 target =
222 ACPI_ADD_PTR(char, resource,
223 info->aml_offset + (item_count * 4));
224
225 resource->length +=
226 acpi_rs_get_resource_source(aml_resource_length,
227 (acpi_rs_length) (((item_count - 1) * sizeof(u32)) + info->value), destination, aml, target);
228 break;
229
230 case ACPI_RSC_BITMASK:
231 /*
232 * 8-bit encoded bitmask (DMA macro)
233 */
234 item_count =
235 acpi_rs_decode_bitmask(ACPI_GET8(source),
236 destination);
237 if (item_count) {
238 resource->length += (item_count - 1);
239 }
240
241 target = ACPI_ADD_PTR(char, resource, info->value);
242 ACPI_SET8(target) = (u8) item_count;
243 break;
244
245 case ACPI_RSC_BITMASK16:
246 /*
247 * 16-bit encoded bitmask (IRQ macro)
248 */
249 ACPI_MOVE_16_TO_16(&temp16, source);
250
251 item_count =
252 acpi_rs_decode_bitmask(temp16, destination);
253 if (item_count) {
254 resource->length += (item_count - 1);
255 }
256
257 target = ACPI_ADD_PTR(char, resource, info->value);
258 ACPI_SET8(target) = (u8) item_count;
259 break;
260
261 case ACPI_RSC_EXIT_NE:
262 /*
263 * Control - Exit conversion if not equal
264 */
265 switch (info->resource_offset) {
266 case ACPI_RSC_COMPARE_AML_LENGTH:
267 if (aml_resource_length != info->value) {
268 goto exit;
269 }
270 break;
271
272 case ACPI_RSC_COMPARE_VALUE:
273 if (ACPI_GET8(source) != info->value) {
274 goto exit;
275 }
276 break;
277
278 default:
279
280 ACPI_ERROR((AE_INFO,
281 "Invalid conversion sub-opcode"));
282 return_ACPI_STATUS(AE_BAD_PARAMETER);
283 }
284 break;
285
286 default:
287
288 ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
289 return_ACPI_STATUS(AE_BAD_PARAMETER);
290 }
282 291
283 *buffer = temp8; 292 count--;
284 buffer += 1; 293 info++;
285 } 294 }
286 295
287 /* Loop through all of the Vendor Specific fields */ 296 exit:
297 if (!flags_mode) {
298 /* Round the resource struct length up to the next 32-bit boundary */
288 299
289 for (index = 0; index < linked_list->data.vendor_specific.length; 300 resource->length = ACPI_ROUND_UP_to_32_bITS(resource->length);
290 index++) {
291 temp8 = linked_list->data.vendor_specific.reserved[index];
292
293 *buffer = temp8;
294 buffer += 1;
295 } 301 }
296
297 /* Return the number of bytes consumed in this operation */
298
299 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
300 return_ACPI_STATUS(AE_OK); 302 return_ACPI_STATUS(AE_OK);
301} 303}
302 304
303/******************************************************************************* 305/*******************************************************************************
304 * 306 *
305 * FUNCTION: acpi_rs_start_depend_fns_resource 307 * FUNCTION: acpi_rs_convert_resource_to_aml
306 * 308 *
307 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte 309 * PARAMETERS: Resource - Pointer to the resource descriptor
308 * stream 310 * Aml - Where the AML descriptor is returned
309 * bytes_consumed - Pointer to where the number of bytes 311 * Info - Pointer to appropriate conversion table
310 * consumed the byte_stream_buffer is
311 * returned
312 * output_buffer - Pointer to the return data buffer
313 * structure_size - Pointer to where the number of bytes
314 * in the return data struct is returned
315 * 312 *
316 * RETURN: Status 313 * RETURN: Status
317 * 314 *
318 * DESCRIPTION: Take the resource byte stream and fill out the appropriate 315 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
319 * structure pointed to by the output_buffer. Return the 316 * external AML resource descriptor.
320 * number of bytes consumed from the byte stream.
321 * 317 *
322 ******************************************************************************/ 318 ******************************************************************************/
323 319
324acpi_status 320acpi_status
325acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, 321acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
326 acpi_size * bytes_consumed, 322 union aml_resource *aml,
327 u8 ** output_buffer, 323 struct acpi_rsconvert_info *info)
328 acpi_size * structure_size)
329{ 324{
330 u8 *buffer = byte_stream_buffer; 325 void *source = NULL;
331 struct acpi_resource *output_struct = (void *)*output_buffer; 326 void *destination;
332 u8 temp8 = 0; 327 acpi_rsdesc_size aml_length = 0;
333 acpi_size struct_size = 328 u8 count;
334 ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf); 329 u16 temp16 = 0;
335 330 u16 item_count = 0;
336 ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource");
337
338 /* The number of bytes consumed are found in the descriptor (Bits:0-1) */
339
340 temp8 = *buffer;
341
342 *bytes_consumed = (temp8 & 0x01) + 1;
343
344 output_struct->id = ACPI_RSTYPE_START_DPF;
345
346 /* Point to Byte 1 if it is used */
347
348 if (2 == *bytes_consumed) {
349 buffer += 1;
350 temp8 = *buffer;
351
352 /* Check Compatibility priority */
353
354 output_struct->data.start_dpf.compatibility_priority =
355 temp8 & 0x03;
356
357 if (3 == output_struct->data.start_dpf.compatibility_priority) {
358 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
359 }
360
361 /* Check Performance/Robustness preference */
362 331
363 output_struct->data.start_dpf.performance_robustness = 332 ACPI_FUNCTION_TRACE("rs_convert_resource_to_aml");
364 (temp8 >> 2) & 0x03;
365 333
366 if (3 == output_struct->data.start_dpf.performance_robustness) { 334 /*
367 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); 335 * First table entry must be ACPI_RSC_INITxxx and must contain the
336 * table length (# of table entries)
337 */
338 count = INIT_TABLE_LENGTH(info);
339
340 while (count) {
341 /*
342 * Source is the internal resource descriptor,
343 * destination is the external AML byte stream buffer
344 */
345 source = ACPI_ADD_PTR(void, resource, info->resource_offset);
346 destination = ACPI_ADD_PTR(void, aml, info->aml_offset);
347
348 switch (info->opcode) {
349 case ACPI_RSC_INITSET:
350
351 ACPI_MEMSET(aml, 0, INIT_RESOURCE_LENGTH(info));
352 aml_length = INIT_RESOURCE_LENGTH(info);
353 acpi_rs_set_resource_header(INIT_RESOURCE_TYPE(info),
354 aml_length, aml);
355 break;
356
357 case ACPI_RSC_INITGET:
358 break;
359
360 case ACPI_RSC_FLAGINIT:
361 /*
362 * Clear the flag byte
363 */
364 ACPI_SET8(destination) = 0;
365 break;
366
367 case ACPI_RSC_1BITFLAG:
368 /*
369 * Mask and shift the flag bit
370 */
371 ACPI_SET8(destination) |= (u8)
372 ((ACPI_GET8(source) & 0x01) << info->value);
373 break;
374
375 case ACPI_RSC_2BITFLAG:
376 /*
377 * Mask and shift the flag bits
378 */
379 ACPI_SET8(destination) |= (u8)
380 ((ACPI_GET8(source) & 0x03) << info->value);
381 break;
382
383 case ACPI_RSC_COUNT:
384
385 item_count = ACPI_GET8(source);
386 ACPI_SET8(destination) = (u8) item_count;
387
388 aml_length =
389 (u16) (aml_length +
390 (info->value * (item_count - 1)));
391 break;
392
393 case ACPI_RSC_COUNT16:
394
395 item_count = ACPI_GET16(source);
396 aml_length = (u16) (aml_length + item_count);
397 acpi_rs_set_resource_length(aml_length, aml);
398 break;
399
400 case ACPI_RSC_LENGTH:
401
402 acpi_rs_set_resource_length(info->value, aml);
403 break;
404
405 case ACPI_RSC_MOVE8:
406 case ACPI_RSC_MOVE16:
407 case ACPI_RSC_MOVE32:
408 case ACPI_RSC_MOVE64:
409
410 if (info->value) {
411 item_count = info->value;
412 }
413 acpi_rs_move_data(destination, source, item_count,
414 info->opcode);
415 break;
416
417 case ACPI_RSC_ADDRESS:
418
419 /* Set the Resource Type, General Flags, and Type-Specific Flags */
420
421 acpi_rs_set_address_common(aml, resource);
422 break;
423
424 case ACPI_RSC_SOURCEX:
425 /*
426 * Optional resource_source (Index and String)
427 */
428 aml_length =
429 acpi_rs_set_resource_source(aml,
430 (acpi_rs_length)
431 aml_length, source);
432 acpi_rs_set_resource_length(aml_length, aml);
433 break;
434
435 case ACPI_RSC_SOURCE:
436 /*
437 * Optional resource_source (Index and String). This is the more
438 * complicated case used by the Interrupt() macro
439 */
440 aml_length =
441 acpi_rs_set_resource_source(aml, info->value,
442 source);
443 acpi_rs_set_resource_length(aml_length, aml);
444 break;
445
446 case ACPI_RSC_BITMASK:
447 /*
448 * 8-bit encoded bitmask (DMA macro)
449 */
450 ACPI_SET8(destination) = (u8)
451 acpi_rs_encode_bitmask(source,
452 *ACPI_ADD_PTR(u8, resource,
453 info->value));
454 break;
455
456 case ACPI_RSC_BITMASK16:
457 /*
458 * 16-bit encoded bitmask (IRQ macro)
459 */
460 temp16 = acpi_rs_encode_bitmask(source,
461 *ACPI_ADD_PTR(u8,
462 resource,
463 info->
464 value));
465 ACPI_MOVE_16_TO_16(destination, &temp16);
466 break;
467
468 case ACPI_RSC_EXIT_LE:
469 /*
470 * Control - Exit conversion if less than or equal
471 */
472 if (item_count <= info->value) {
473 goto exit;
474 }
475 break;
476
477 case ACPI_RSC_EXIT_NE:
478 /*
479 * Control - Exit conversion if not equal
480 */
481 switch (COMPARE_OPCODE(info)) {
482 case ACPI_RSC_COMPARE_VALUE:
483
484 if (*ACPI_ADD_PTR(u8, resource,
485 COMPARE_TARGET(info)) !=
486 COMPARE_VALUE(info)) {
487 goto exit;
488 }
489 break;
490
491 default:
492
493 ACPI_ERROR((AE_INFO,
494 "Invalid conversion sub-opcode"));
495 return_ACPI_STATUS(AE_BAD_PARAMETER);
496 }
497 break;
498
499 default:
500
501 ACPI_ERROR((AE_INFO, "Invalid conversion opcode"));
502 return_ACPI_STATUS(AE_BAD_PARAMETER);
368 } 503 }
369 } else {
370 output_struct->data.start_dpf.compatibility_priority =
371 ACPI_ACCEPTABLE_CONFIGURATION;
372 504
373 output_struct->data.start_dpf.performance_robustness = 505 count--;
374 ACPI_ACCEPTABLE_CONFIGURATION; 506 info++;
375 } 507 }
376 508
377 /* Set the Length parameter */ 509 exit:
378
379 output_struct->length = (u32) struct_size;
380
381 /* Return the final size of the structure */
382
383 *structure_size = struct_size;
384 return_ACPI_STATUS(AE_OK); 510 return_ACPI_STATUS(AE_OK);
385} 511}
386 512
387/******************************************************************************* 513#if 0
388 * 514/* Previous resource validations */
389 * FUNCTION: acpi_rs_end_depend_fns_resource
390 *
391 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
392 * stream
393 * bytes_consumed - Pointer to where the number of bytes
394 * consumed the byte_stream_buffer is
395 * returned
396 * output_buffer - Pointer to the return data buffer
397 * structure_size - Pointer to where the number of bytes
398 * in the return data struct is returned
399 *
400 * RETURN: Status
401 *
402 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
403 * structure pointed to by the output_buffer. Return the
404 * number of bytes consumed from the byte stream.
405 *
406 ******************************************************************************/
407
408acpi_status
409acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer,
410 acpi_size * bytes_consumed,
411 u8 ** output_buffer, acpi_size * structure_size)
412{
413 struct acpi_resource *output_struct = (void *)*output_buffer;
414 acpi_size struct_size = ACPI_RESOURCE_LENGTH;
415
416 ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource");
417
418 /* The number of bytes consumed is static */
419
420 *bytes_consumed = 1;
421 515
422 /* Fill out the structure */ 516if (aml->ext_address64.revision_iD != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) {
423 517 return_ACPI_STATUS(AE_SUPPORT);
424 output_struct->id = ACPI_RSTYPE_END_DPF;
425
426 /* Set the Length parameter */
427
428 output_struct->length = (u32) struct_size;
429
430 /* Return the final size of the structure */
431
432 *structure_size = struct_size;
433 return_ACPI_STATUS(AE_OK);
434} 518}
435 519
436/******************************************************************************* 520if (resource->data.start_dpf.performance_robustness >= 3) {
437 * 521 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE);
438 * FUNCTION: acpi_rs_start_depend_fns_stream 522}
439 *
440 * PARAMETERS: linked_list - Pointer to the resource linked list
441 * output_buffer - Pointer to the user's return buffer
442 * bytes_consumed - u32 pointer that is filled with
443 * the number of bytes of the
444 * output_buffer used
445 *
446 * RETURN: Status
447 *
448 * DESCRIPTION: Take the linked list resource structure and fills in the
449 * the appropriate bytes in a byte stream
450 *
451 ******************************************************************************/
452
453acpi_status
454acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list,
455 u8 ** output_buffer, acpi_size * bytes_consumed)
456{
457 u8 *buffer = *output_buffer;
458 u8 temp8 = 0;
459
460 ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream");
461 523
524if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) {
462 /* 525 /*
463 * The descriptor field is set based upon whether a byte is needed 526 * Only [active_high, edge_sensitive] or [active_low, level_sensitive]
464 * to contain Priority data. 527 * polarity/trigger interrupts are allowed (ACPI spec, section
528 * "IRQ Format"), so 0x00 and 0x09 are illegal.
465 */ 529 */
466 if (ACPI_ACCEPTABLE_CONFIGURATION == 530 ACPI_ERROR((AE_INFO,
467 linked_list->data.start_dpf.compatibility_priority && 531 "Invalid interrupt polarity/trigger in resource list, %X",
468 ACPI_ACCEPTABLE_CONFIGURATION == 532 aml->irq.flags));
469 linked_list->data.start_dpf.performance_robustness) { 533 return_ACPI_STATUS(AE_BAD_DATA);
470 *buffer = 0x30;
471 } else {
472 *buffer = 0x31;
473 buffer += 1;
474
475 /* Set the Priority Byte Definition */
476
477 temp8 = 0;
478 temp8 =
479 (u8) ((linked_list->data.start_dpf.
480 performance_robustness & 0x03) << 2);
481 temp8 |=
482 (linked_list->data.start_dpf.compatibility_priority & 0x03);
483 *buffer = temp8;
484 }
485
486 buffer += 1;
487
488 /* Return the number of bytes consumed in this operation */
489
490 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
491 return_ACPI_STATUS(AE_OK);
492} 534}
493 535
494/******************************************************************************* 536resource->data.extended_irq.interrupt_count = temp8;
495 * 537if (temp8 < 1) {
496 * FUNCTION: acpi_rs_end_depend_fns_stream 538 /* Must have at least one IRQ */
497 *
498 * PARAMETERS: linked_list - Pointer to the resource linked list
499 * output_buffer - Pointer to the user's return buffer
500 * bytes_consumed - Pointer to where the number of bytes
501 * used in the output_buffer is returned
502 *
503 * RETURN: Status
504 *
505 * DESCRIPTION: Take the linked list resource structure and fills in the
506 * the appropriate bytes in a byte stream
507 *
508 ******************************************************************************/
509
510acpi_status
511acpi_rs_end_depend_fns_stream(struct acpi_resource *linked_list,
512 u8 ** output_buffer, acpi_size * bytes_consumed)
513{
514 u8 *buffer = *output_buffer;
515
516 ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream");
517
518 /* The descriptor field is static */
519
520 *buffer = 0x38;
521 buffer += 1;
522 539
523 /* Return the number of bytes consumed in this operation */ 540 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
541}
524 542
525 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 543if (resource->data.dma.transfer == 0x03) {
526 return_ACPI_STATUS(AE_OK); 544 ACPI_ERROR((AE_INFO, "Invalid DMA.Transfer preference (3)"));
545 return_ACPI_STATUS(AE_BAD_DATA);
527} 546}
547#endif
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
index 4446778eaf79..25b5aedd6612 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/resources/rsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -50,6 +50,389 @@ ACPI_MODULE_NAME("rsutils")
50 50
51/******************************************************************************* 51/*******************************************************************************
52 * 52 *
53 * FUNCTION: acpi_rs_decode_bitmask
54 *
55 * PARAMETERS: Mask - Bitmask to decode
56 * List - Where the converted list is returned
57 *
58 * RETURN: Count of bits set (length of list)
59 *
60 * DESCRIPTION: Convert a bit mask into a list of values
61 *
62 ******************************************************************************/
63u8 acpi_rs_decode_bitmask(u16 mask, u8 * list)
64{
65 acpi_native_uint i;
66 u8 bit_count;
67
68 ACPI_FUNCTION_ENTRY();
69
70 /* Decode the mask bits */
71
72 for (i = 0, bit_count = 0; mask; i++) {
73 if (mask & 0x0001) {
74 list[bit_count] = (u8) i;
75 bit_count++;
76 }
77
78 mask >>= 1;
79 }
80
81 return (bit_count);
82}
83
84/*******************************************************************************
85 *
86 * FUNCTION: acpi_rs_encode_bitmask
87 *
88 * PARAMETERS: List - List of values to encode
89 * Count - Length of list
90 *
91 * RETURN: Encoded bitmask
92 *
93 * DESCRIPTION: Convert a list of values to an encoded bitmask
94 *
95 ******************************************************************************/
96
97u16 acpi_rs_encode_bitmask(u8 * list, u8 count)
98{
99 acpi_native_uint i;
100 u16 mask;
101
102 ACPI_FUNCTION_ENTRY();
103
104 /* Encode the list into a single bitmask */
105
106 for (i = 0, mask = 0; i < count; i++) {
107 mask |= (0x0001 << list[i]);
108 }
109
110 return (mask);
111}
112
113/*******************************************************************************
114 *
115 * FUNCTION: acpi_rs_move_data
116 *
117 * PARAMETERS: Destination - Pointer to the destination descriptor
118 * Source - Pointer to the source descriptor
119 * item_count - How many items to move
120 * move_type - Byte width
121 *
122 * RETURN: None
123 *
124 * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
125 * alignment issues and endian issues if necessary, as configured
126 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
127 *
128 ******************************************************************************/
129
130void
131acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
132{
133 acpi_native_uint i;
134
135 ACPI_FUNCTION_ENTRY();
136
137 /* One move per item */
138
139 for (i = 0; i < item_count; i++) {
140 switch (move_type) {
141 /*
142 * For the 8-bit case, we can perform the move all at once
143 * since there are no alignment or endian issues
144 */
145 case ACPI_RSC_MOVE8:
146 ACPI_MEMCPY(destination, source, item_count);
147 return;
148
149 /*
150 * 16-, 32-, and 64-bit cases must use the move macros that perform
151 * endian conversion and/or accomodate hardware that cannot perform
152 * misaligned memory transfers
153 */
154 case ACPI_RSC_MOVE16:
155 ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
156 &ACPI_CAST_PTR(u16, source)[i]);
157 break;
158
159 case ACPI_RSC_MOVE32:
160 ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i],
161 &ACPI_CAST_PTR(u32, source)[i]);
162 break;
163
164 case ACPI_RSC_MOVE64:
165 ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i],
166 &ACPI_CAST_PTR(u64, source)[i]);
167 break;
168
169 default:
170 return;
171 }
172 }
173}
174
175/*******************************************************************************
176 *
177 * FUNCTION: acpi_rs_set_resource_length
178 *
179 * PARAMETERS: total_length - Length of the AML descriptor, including
180 * the header and length fields.
181 * Aml - Pointer to the raw AML descriptor
182 *
183 * RETURN: None
184 *
185 * DESCRIPTION: Set the resource_length field of an AML
186 * resource descriptor, both Large and Small descriptors are
187 * supported automatically. Note: Descriptor Type field must
188 * be valid.
189 *
190 ******************************************************************************/
191
192void
193acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
194 union aml_resource *aml)
195{
196 acpi_rs_length resource_length;
197
198 ACPI_FUNCTION_ENTRY();
199
200 /* Length is the total descriptor length minus the header length */
201
202 resource_length = (acpi_rs_length)
203 (total_length - acpi_ut_get_resource_header_length(aml));
204
205 /* Length is stored differently for large and small descriptors */
206
207 if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
208 /* Large descriptor -- bytes 1-2 contain the 16-bit length */
209
210 ACPI_MOVE_16_TO_16(&aml->large_header.resource_length,
211 &resource_length);
212 } else {
213 /* Small descriptor -- bits 2:0 of byte 0 contain the length */
214
215 aml->small_header.descriptor_type = (u8)
216
217 /* Clear any existing length, preserving descriptor type bits */
218 ((aml->small_header.
219 descriptor_type & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
220
221 | resource_length);
222 }
223}
224
225/*******************************************************************************
226 *
227 * FUNCTION: acpi_rs_set_resource_header
228 *
229 * PARAMETERS: descriptor_type - Byte to be inserted as the type
230 * total_length - Length of the AML descriptor, including
231 * the header and length fields.
232 * Aml - Pointer to the raw AML descriptor
233 *
234 * RETURN: None
235 *
236 * DESCRIPTION: Set the descriptor_type and resource_length fields of an AML
237 * resource descriptor, both Large and Small descriptors are
238 * supported automatically
239 *
240 ******************************************************************************/
241
242void
243acpi_rs_set_resource_header(u8 descriptor_type,
244 acpi_rsdesc_size total_length,
245 union aml_resource *aml)
246{
247 ACPI_FUNCTION_ENTRY();
248
249 /* Set the Resource Type */
250
251 aml->small_header.descriptor_type = descriptor_type;
252
253 /* Set the Resource Length */
254
255 acpi_rs_set_resource_length(total_length, aml);
256}
257
258/*******************************************************************************
259 *
260 * FUNCTION: acpi_rs_strcpy
261 *
262 * PARAMETERS: Destination - Pointer to the destination string
263 * Source - Pointer to the source string
264 *
265 * RETURN: String length, including NULL terminator
266 *
267 * DESCRIPTION: Local string copy that returns the string length, saving a
268 * strcpy followed by a strlen.
269 *
270 ******************************************************************************/
271
272static u16 acpi_rs_strcpy(char *destination, char *source)
273{
274 u16 i;
275
276 ACPI_FUNCTION_ENTRY();
277
278 for (i = 0; source[i]; i++) {
279 destination[i] = source[i];
280 }
281
282 destination[i] = 0;
283
284 /* Return string length including the NULL terminator */
285
286 return ((u16) (i + 1));
287}
288
289/*******************************************************************************
290 *
291 * FUNCTION: acpi_rs_get_resource_source
292 *
293 * PARAMETERS: resource_length - Length field of the descriptor
294 * minimum_length - Minimum length of the descriptor (minus
295 * any optional fields)
296 * resource_source - Where the resource_source is returned
297 * Aml - Pointer to the raw AML descriptor
298 * string_ptr - (optional) where to store the actual
299 * resource_source string
300 *
301 * RETURN: Length of the string plus NULL terminator, rounded up to 32 bit
302 *
303 * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor
304 * to an internal resource descriptor
305 *
306 ******************************************************************************/
307
308acpi_rs_length
309acpi_rs_get_resource_source(acpi_rs_length resource_length,
310 acpi_rs_length minimum_length,
311 struct acpi_resource_source * resource_source,
312 union aml_resource * aml, char *string_ptr)
313{
314 acpi_rsdesc_size total_length;
315 u8 *aml_resource_source;
316
317 ACPI_FUNCTION_ENTRY();
318
319 total_length =
320 resource_length + sizeof(struct aml_resource_large_header);
321 aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
322
323 /*
324 * resource_source is present if the length of the descriptor is longer than
325 * the minimum length.
326 *
327 * Note: Some resource descriptors will have an additional null, so
328 * we add 1 to the minimum length.
329 */
330 if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) {
331 /* Get the resource_source_index */
332
333 resource_source->index = aml_resource_source[0];
334
335 resource_source->string_ptr = string_ptr;
336 if (!string_ptr) {
337 /*
338 * String destination pointer is not specified; Set the String
339 * pointer to the end of the current resource_source structure.
340 */
341 resource_source->string_ptr =
342 ACPI_ADD_PTR(char, resource_source,
343 sizeof(struct acpi_resource_source));
344 }
345
346 /*
347 * In order for the struct_size to fall on a 32-bit boundary, calculate
348 * the length of the string (+1 for the NULL terminator) and expand the
349 * struct_size to the next 32-bit boundary.
350 *
351 * Zero the entire area of the buffer.
352 */
353 total_length =
354 ACPI_ROUND_UP_to_32_bITS(ACPI_STRLEN
355 ((char *)&aml_resource_source[1]) +
356 1);
357 ACPI_MEMSET(resource_source->string_ptr, 0, total_length);
358
359 /* Copy the resource_source string to the destination */
360
361 resource_source->string_length =
362 acpi_rs_strcpy(resource_source->string_ptr,
363 (char *)&aml_resource_source[1]);
364
365 return ((acpi_rs_length) total_length);
366 }
367
368 /* resource_source is not present */
369
370 resource_source->index = 0;
371 resource_source->string_length = 0;
372 resource_source->string_ptr = NULL;
373 return (0);
374}
375
376/*******************************************************************************
377 *
378 * FUNCTION: acpi_rs_set_resource_source
379 *
380 * PARAMETERS: Aml - Pointer to the raw AML descriptor
381 * minimum_length - Minimum length of the descriptor (minus
382 * any optional fields)
383 * resource_source - Internal resource_source
384
385 *
386 * RETURN: Total length of the AML descriptor
387 *
388 * DESCRIPTION: Convert an optional resource_source from internal format to a
389 * raw AML resource descriptor
390 *
391 ******************************************************************************/
392
393acpi_rsdesc_size
394acpi_rs_set_resource_source(union aml_resource * aml,
395 acpi_rs_length minimum_length,
396 struct acpi_resource_source * resource_source)
397{
398 u8 *aml_resource_source;
399 acpi_rsdesc_size descriptor_length;
400
401 ACPI_FUNCTION_ENTRY();
402
403 descriptor_length = minimum_length;
404
405 /* Non-zero string length indicates presence of a resource_source */
406
407 if (resource_source->string_length) {
408 /* Point to the end of the AML descriptor */
409
410 aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
411
412 /* Copy the resource_source_index */
413
414 aml_resource_source[0] = (u8) resource_source->index;
415
416 /* Copy the resource_source string */
417
418 ACPI_STRCPY((char *)&aml_resource_source[1],
419 resource_source->string_ptr);
420
421 /*
422 * Add the length of the string (+ 1 for null terminator) to the
423 * final descriptor length
424 */
425 descriptor_length +=
426 ((acpi_rsdesc_size) resource_source->string_length + 1);
427 }
428
429 /* Return the new total length of the AML descriptor */
430
431 return (descriptor_length);
432}
433
434/*******************************************************************************
435 *
53 * FUNCTION: acpi_rs_get_prt_method_data 436 * FUNCTION: acpi_rs_get_prt_method_data
54 * 437 *
55 * PARAMETERS: Handle - a handle to the containing object 438 * PARAMETERS: Handle - a handle to the containing object
@@ -65,8 +448,9 @@ ACPI_MODULE_NAME("rsutils")
65 * and the contents of the callers buffer is undefined. 448 * and the contents of the callers buffer is undefined.
66 * 449 *
67 ******************************************************************************/ 450 ******************************************************************************/
451
68acpi_status 452acpi_status
69acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) 453acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer)
70{ 454{
71 union acpi_operand_object *obj_desc; 455 union acpi_operand_object *obj_desc;
72 acpi_status status; 456 acpi_status status;
@@ -284,7 +668,7 @@ acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer)
284 * Convert the linked list into a byte stream 668 * Convert the linked list into a byte stream
285 */ 669 */
286 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 670 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
287 status = acpi_rs_create_byte_stream(in_buffer->pointer, &buffer); 671 status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer);
288 if (ACPI_FAILURE(status)) { 672 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status); 673 return_ACPI_STATUS(status);
290 } 674 }
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
index ee5a5c509199..88b67077aeeb 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/resources/rsxface.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -57,13 +57,17 @@ ACPI_MODULE_NAME("rsxface")
57 ACPI_COPY_FIELD(out, in, decode); \ 57 ACPI_COPY_FIELD(out, in, decode); \
58 ACPI_COPY_FIELD(out, in, min_address_fixed); \ 58 ACPI_COPY_FIELD(out, in, min_address_fixed); \
59 ACPI_COPY_FIELD(out, in, max_address_fixed); \ 59 ACPI_COPY_FIELD(out, in, max_address_fixed); \
60 ACPI_COPY_FIELD(out, in, attribute); \ 60 ACPI_COPY_FIELD(out, in, info); \
61 ACPI_COPY_FIELD(out, in, granularity); \ 61 ACPI_COPY_FIELD(out, in, granularity); \
62 ACPI_COPY_FIELD(out, in, min_address_range); \ 62 ACPI_COPY_FIELD(out, in, minimum); \
63 ACPI_COPY_FIELD(out, in, max_address_range); \ 63 ACPI_COPY_FIELD(out, in, maximum); \
64 ACPI_COPY_FIELD(out, in, address_translation_offset); \ 64 ACPI_COPY_FIELD(out, in, translation_offset); \
65 ACPI_COPY_FIELD(out, in, address_length); \ 65 ACPI_COPY_FIELD(out, in, address_length); \
66 ACPI_COPY_FIELD(out, in, resource_source); 66 ACPI_COPY_FIELD(out, in, resource_source);
67/* Local prototypes */
68static acpi_status
69acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context);
70
67/******************************************************************************* 71/*******************************************************************************
68 * 72 *
69 * FUNCTION: acpi_get_irq_routing_table 73 * FUNCTION: acpi_get_irq_routing_table
@@ -86,6 +90,7 @@ ACPI_MODULE_NAME("rsxface")
86 * the object indicated by the passed device_handle. 90 * the object indicated by the passed device_handle.
87 * 91 *
88 ******************************************************************************/ 92 ******************************************************************************/
93
89acpi_status 94acpi_status
90acpi_get_irq_routing_table(acpi_handle device_handle, 95acpi_get_irq_routing_table(acpi_handle device_handle,
91 struct acpi_buffer *ret_buffer) 96 struct acpi_buffer *ret_buffer)
@@ -222,12 +227,12 @@ EXPORT_SYMBOL(acpi_get_possible_resources);
222 * 227 *
223 * FUNCTION: acpi_walk_resources 228 * FUNCTION: acpi_walk_resources
224 * 229 *
225 * PARAMETERS: device_handle - a handle to the device object for the 230 * PARAMETERS: device_handle - Handle to the device object for the
226 * device we are querying 231 * device we are querying
227 * Path - method name of the resources we want 232 * Name - Method name of the resources we want
228 * (METHOD_NAME__CRS or METHOD_NAME__PRS) 233 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
229 * user_function - called for each resource 234 * user_function - Called for each resource
230 * Context - passed to user_function 235 * Context - Passed to user_function
231 * 236 *
232 * RETURN: Status 237 * RETURN: Status
233 * 238 *
@@ -239,79 +244,74 @@ EXPORT_SYMBOL(acpi_get_possible_resources);
239 244
240acpi_status 245acpi_status
241acpi_walk_resources(acpi_handle device_handle, 246acpi_walk_resources(acpi_handle device_handle,
242 char *path, 247 char *name,
243 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context) 248 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context)
244{ 249{
245 acpi_status status; 250 acpi_status status;
246 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 251 struct acpi_buffer buffer;
247 struct acpi_resource *resource; 252 struct acpi_resource *resource;
248 struct acpi_resource *buffer_end; 253 struct acpi_resource *resource_end;
249 254
250 ACPI_FUNCTION_TRACE("acpi_walk_resources"); 255 ACPI_FUNCTION_TRACE("acpi_walk_resources");
251 256
252 if (!device_handle || 257 /* Parameter validation */
253 (ACPI_STRNCMP(path, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) && 258
254 ACPI_STRNCMP(path, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) { 259 if (!device_handle || !user_function || !name ||
260 (ACPI_STRNCMP(name, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) &&
261 ACPI_STRNCMP(name, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) {
255 return_ACPI_STATUS(AE_BAD_PARAMETER); 262 return_ACPI_STATUS(AE_BAD_PARAMETER);
256 } 263 }
257 264
258 status = acpi_rs_get_method_data(device_handle, path, &buffer); 265 /* Get the _CRS or _PRS resource list */
266
267 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
268 status = acpi_rs_get_method_data(device_handle, name, &buffer);
259 if (ACPI_FAILURE(status)) { 269 if (ACPI_FAILURE(status)) {
260 return_ACPI_STATUS(status); 270 return_ACPI_STATUS(status);
261 } 271 }
262 272
263 /* Setup pointers */ 273 /* Buffer now contains the resource list */
264 274
265 resource = (struct acpi_resource *)buffer.pointer; 275 resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer);
266 buffer_end = ACPI_CAST_PTR(struct acpi_resource, 276 resource_end =
267 ((u8 *) buffer.pointer + buffer.length)); 277 ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length);
268 278
269 /* Walk the resource list */ 279 /* Walk the resource list until the end_tag is found (or buffer end) */
270 280
271 for (;;) { 281 while (resource < resource_end) {
272 if (!resource || resource->id == ACPI_RSTYPE_END_TAG) { 282 /* Sanity check the resource */
283
284 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
285 status = AE_AML_INVALID_RESOURCE_TYPE;
273 break; 286 break;
274 } 287 }
275 288
276 status = user_function(resource, context); 289 /* Invoke the user function, abort on any error returned */
277
278 switch (status) {
279 case AE_OK:
280 case AE_CTRL_DEPTH:
281 290
282 /* Just keep going */ 291 status = user_function(resource, context);
292 if (ACPI_FAILURE(status)) {
293 if (status == AE_CTRL_TERMINATE) {
294 /* This is an OK termination by the user function */
283 295
284 status = AE_OK; 296 status = AE_OK;
297 }
285 break; 298 break;
299 }
286 300
287 case AE_CTRL_TERMINATE: 301 /* end_tag indicates end-of-list */
288
289 /* Exit now, with OK stats */
290
291 status = AE_OK;
292 goto cleanup;
293
294 default:
295
296 /* All others are valid exceptions */
297 302
298 goto cleanup; 303 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
304 break;
299 } 305 }
300 306
301 /* Get the next resource descriptor */ 307 /* Get the next resource descriptor */
302 308
303 resource = ACPI_NEXT_RESOURCE(resource); 309 resource =
304 310 ACPI_ADD_PTR(struct acpi_resource, resource,
305 /* Check for end-of-buffer */ 311 resource->length);
306
307 if (resource >= buffer_end) {
308 goto cleanup;
309 }
310 } 312 }
311 313
312 cleanup: 314 ACPI_MEM_FREE(buffer.pointer);
313
314 acpi_os_free(buffer.pointer);
315 return_ACPI_STATUS(status); 315 return_ACPI_STATUS(status);
316} 316}
317 317
@@ -360,8 +360,8 @@ EXPORT_SYMBOL(acpi_set_current_resources);
360 * 360 *
361 * FUNCTION: acpi_resource_to_address64 361 * FUNCTION: acpi_resource_to_address64
362 * 362 *
363 * PARAMETERS: resource - Pointer to a resource 363 * PARAMETERS: Resource - Pointer to a resource
364 * out - Pointer to the users's return 364 * Out - Pointer to the users's return
365 * buffer (a struct 365 * buffer (a struct
366 * struct acpi_resource_address64) 366 * struct acpi_resource_address64)
367 * 367 *
@@ -381,20 +381,26 @@ acpi_resource_to_address64(struct acpi_resource *resource,
381 struct acpi_resource_address16 *address16; 381 struct acpi_resource_address16 *address16;
382 struct acpi_resource_address32 *address32; 382 struct acpi_resource_address32 *address32;
383 383
384 switch (resource->id) { 384 if (!resource || !out) {
385 case ACPI_RSTYPE_ADDRESS16: 385 return (AE_BAD_PARAMETER);
386 }
387
388 /* Convert 16 or 32 address descriptor to 64 */
389
390 switch (resource->type) {
391 case ACPI_RESOURCE_TYPE_ADDRESS16:
386 392
387 address16 = (struct acpi_resource_address16 *)&resource->data; 393 address16 = (struct acpi_resource_address16 *)&resource->data;
388 ACPI_COPY_ADDRESS(out, address16); 394 ACPI_COPY_ADDRESS(out, address16);
389 break; 395 break;
390 396
391 case ACPI_RSTYPE_ADDRESS32: 397 case ACPI_RESOURCE_TYPE_ADDRESS32:
392 398
393 address32 = (struct acpi_resource_address32 *)&resource->data; 399 address32 = (struct acpi_resource_address32 *)&resource->data;
394 ACPI_COPY_ADDRESS(out, address32); 400 ACPI_COPY_ADDRESS(out, address32);
395 break; 401 break;
396 402
397 case ACPI_RSTYPE_ADDRESS64: 403 case ACPI_RESOURCE_TYPE_ADDRESS64:
398 404
399 /* Simple copy for 64 bit source */ 405 /* Simple copy for 64 bit source */
400 406
@@ -410,3 +416,113 @@ acpi_resource_to_address64(struct acpi_resource *resource,
410} 416}
411 417
412EXPORT_SYMBOL(acpi_resource_to_address64); 418EXPORT_SYMBOL(acpi_resource_to_address64);
419
420/*******************************************************************************
421 *
422 * FUNCTION: acpi_get_vendor_resource
423 *
424 * PARAMETERS: device_handle - Handle for the parent device object
425 * Name - Method name for the parent resource
426 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
427 * Uuid - Pointer to the UUID to be matched.
428 * includes both subtype and 16-byte UUID
429 * ret_buffer - Where the vendor resource is returned
430 *
431 * RETURN: Status
432 *
433 * DESCRIPTION: Walk a resource template for the specified evice to find a
434 * vendor-defined resource that matches the supplied UUID and
435 * UUID subtype. Returns a struct acpi_resource of type Vendor.
436 *
437 ******************************************************************************/
438
439acpi_status
440acpi_get_vendor_resource(acpi_handle device_handle,
441 char *name,
442 struct acpi_vendor_uuid * uuid,
443 struct acpi_buffer * ret_buffer)
444{
445 struct acpi_vendor_walk_info info;
446 acpi_status status;
447
448 /* Other parameters are validated by acpi_walk_resources */
449
450 if (!uuid || !ret_buffer) {
451 return (AE_BAD_PARAMETER);
452 }
453
454 info.uuid = uuid;
455 info.buffer = ret_buffer;
456 info.status = AE_NOT_EXIST;
457
458 /* Walk the _CRS or _PRS resource list for this device */
459
460 status =
461 acpi_walk_resources(device_handle, name,
462 acpi_rs_match_vendor_resource, &info);
463 if (ACPI_FAILURE(status)) {
464 return (status);
465 }
466
467 return (info.status);
468}
469
470/*******************************************************************************
471 *
472 * FUNCTION: acpi_rs_match_vendor_resource
473 *
474 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
475 *
476 * RETURN: Status
477 *
478 * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
479 *
480 ******************************************************************************/
481
482static acpi_status
483acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
484{
485 struct acpi_vendor_walk_info *info = context;
486 struct acpi_resource_vendor_typed *vendor;
487 struct acpi_buffer *buffer;
488 acpi_status status;
489
490 /* Ignore all descriptors except Vendor */
491
492 if (resource->type != ACPI_RESOURCE_TYPE_VENDOR) {
493 return (AE_OK);
494 }
495
496 vendor = &resource->data.vendor_typed;
497
498 /*
499 * For a valid match, these conditions must hold:
500 *
501 * 1) Length of descriptor data must be at least as long as a UUID struct
502 * 2) The UUID subtypes must match
503 * 3) The UUID data must match
504 */
505 if ((vendor->byte_length < (ACPI_UUID_LENGTH + 1)) ||
506 (vendor->uuid_subtype != info->uuid->subtype) ||
507 (ACPI_MEMCMP(vendor->uuid, info->uuid->data, ACPI_UUID_LENGTH))) {
508 return (AE_OK);
509 }
510
511 /* Validate/Allocate/Clear caller buffer */
512
513 buffer = info->buffer;
514 status = acpi_ut_initialize_buffer(buffer, resource->length);
515 if (ACPI_FAILURE(status)) {
516 return (status);
517 }
518
519 /* Found the correct resource, copy and return it */
520
521 ACPI_MEMCPY(buffer->pointer, resource, resource->length);
522 buffer->length = resource->length;
523
524 /* Found the desired descriptor, terminate resource walk */
525
526 info->status = AE_OK;
527 return (AE_CTRL_TERMINATE);
528}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 3b26a7104363..9271e5209ac1 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -851,7 +851,7 @@ static void acpi_device_set_id(struct acpi_device *device,
851 * ---- 851 * ----
852 * Fix for the system root bus device -- the only root-level device. 852 * Fix for the system root bus device -- the only root-level device.
853 */ 853 */
854 if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { 854 if (((acpi_handle)parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) {
855 hid = ACPI_BUS_HID; 855 hid = ACPI_BUS_HID;
856 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); 856 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
857 strcpy(device->pnp.device_class, ACPI_BUS_CLASS); 857 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
index af7935a95bcc..47fb4b394eec 100644
--- a/drivers/acpi/sleep/poweroff.c
+++ b/drivers/acpi/sleep/poweroff.c
@@ -33,9 +33,7 @@ int acpi_sleep_prepare(u32 acpi_state)
33 ACPI_FLUSH_CPU_CACHE(); 33 ACPI_FLUSH_CPU_CACHE();
34 acpi_enable_wakeup_device_prep(acpi_state); 34 acpi_enable_wakeup_device_prep(acpi_state);
35#endif 35#endif
36 if (acpi_state == ACPI_STATE_S5) { 36 acpi_gpe_sleep_prepare(acpi_state);
37 acpi_wakeup_gpe_poweroff_prepare();
38 }
39 acpi_enter_sleep_state_prep(acpi_state); 37 acpi_enter_sleep_state_prep(acpi_state);
40 return 0; 38 return 0;
41} 39}
@@ -53,11 +51,16 @@ void acpi_power_off(void)
53 51
54static int acpi_shutdown(struct sys_device *x) 52static int acpi_shutdown(struct sys_device *x)
55{ 53{
56 if (system_state == SYSTEM_POWER_OFF) { 54 switch (system_state) {
57 /* Prepare if we are going to power off the system */ 55 case SYSTEM_POWER_OFF:
56 /* Prepare to power off the system */
58 return acpi_sleep_prepare(ACPI_STATE_S5); 57 return acpi_sleep_prepare(ACPI_STATE_S5);
58 case SYSTEM_SUSPEND_DISK:
59 /* Prepare to suspend the system to disk */
60 return acpi_sleep_prepare(ACPI_STATE_S4);
61 default:
62 return 0;
59 } 63 }
60 return 0;
61} 64}
62 65
63static struct sysdev_class acpi_sysclass = { 66static struct sysdev_class acpi_sysclass = {
diff --git a/drivers/acpi/sleep/sleep.h b/drivers/acpi/sleep/sleep.h
index efd0001c6f05..f3e70397a7d6 100644
--- a/drivers/acpi/sleep/sleep.h
+++ b/drivers/acpi/sleep/sleep.h
@@ -5,4 +5,4 @@ extern int acpi_suspend (u32 state);
5extern void acpi_enable_wakeup_device_prep(u8 sleep_state); 5extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
6extern void acpi_enable_wakeup_device(u8 sleep_state); 6extern void acpi_enable_wakeup_device(u8 sleep_state);
7extern void acpi_disable_wakeup_device(u8 sleep_state); 7extern void acpi_disable_wakeup_device(u8 sleep_state);
8extern void acpi_wakeup_gpe_poweroff_prepare(void); 8extern void acpi_gpe_sleep_prepare(u32 sleep_state);
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c
index 4134ed43d026..85df0ceda2a9 100644
--- a/drivers/acpi/sleep/wakeup.c
+++ b/drivers/acpi/sleep/wakeup.c
@@ -192,7 +192,7 @@ late_initcall(acpi_wakeup_device_init);
192 * RUNTIME GPEs, we simply mark all GPES that 192 * RUNTIME GPEs, we simply mark all GPES that
193 * are not enabled for wakeup from S5 as RUNTIME. 193 * are not enabled for wakeup from S5 as RUNTIME.
194 */ 194 */
195void acpi_wakeup_gpe_poweroff_prepare(void) 195void acpi_gpe_sleep_prepare(u32 sleep_state)
196{ 196{
197 struct list_head *node, *next; 197 struct list_head *node, *next;
198 198
@@ -201,8 +201,8 @@ void acpi_wakeup_gpe_poweroff_prepare(void)
201 struct acpi_device, 201 struct acpi_device,
202 wakeup_list); 202 wakeup_list);
203 203
204 /* The GPE can wakeup system from S5, don't touch it */ 204 /* The GPE can wakeup system from this state, don't touch it */
205 if ((u32) dev->wakeup.sleep_state == ACPI_STATE_S5) 205 if ((u32) dev->wakeup.sleep_state >= sleep_state)
206 continue; 206 continue;
207 /* acpi_set_gpe_type will automatically disable GPE */ 207 /* acpi_set_gpe_type will automatically disable GPE */
208 acpi_set_gpe_type(dev->wakeup.gpe_device, 208 acpi_set_gpe_type(dev->wakeup.gpe_device,
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
index a03939399fa9..03b37d2223bc 100644
--- a/drivers/acpi/tables/tbconvrt.c
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -501,8 +501,8 @@ acpi_status acpi_tb_convert_table_fadt(void)
501 * at least as long as the version 1.0 FADT 501 * at least as long as the version 1.0 FADT
502 */ 502 */
503 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) { 503 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) {
504 ACPI_REPORT_ERROR(("FADT is invalid, too short: 0x%X\n", 504 ACPI_ERROR((AE_INFO, "FADT is invalid, too short: 0x%X",
505 acpi_gbl_FADT->length)); 505 acpi_gbl_FADT->length));
506 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); 506 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
507 } 507 }
508 508
@@ -517,7 +517,10 @@ acpi_status acpi_tb_convert_table_fadt(void)
517 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) { 517 if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) {
518 /* Length is too short to be a V2.0 table */ 518 /* Length is too short to be a V2.0 table */
519 519
520 ACPI_REPORT_WARNING(("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", acpi_gbl_FADT->length, acpi_gbl_FADT->revision)); 520 ACPI_WARNING((AE_INFO,
521 "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table",
522 acpi_gbl_FADT->length,
523 acpi_gbl_FADT->revision));
521 524
522 acpi_tb_convert_fadt1(local_fadt, 525 acpi_tb_convert_fadt1(local_fadt,
523 (void *)acpi_gbl_FADT); 526 (void *)acpi_gbl_FADT);
@@ -554,7 +557,9 @@ acpi_status acpi_tb_convert_table_fadt(void)
554 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, 557 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
555 "Hex dump of common internal FADT, size %d (%X)\n", 558 "Hex dump of common internal FADT, size %d (%X)\n",
556 acpi_gbl_FADT->length, acpi_gbl_FADT->length)); 559 acpi_gbl_FADT->length, acpi_gbl_FADT->length));
557 ACPI_DUMP_BUFFER((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length); 560
561 ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_FADT),
562 acpi_gbl_FADT->length);
558 563
559 return_ACPI_STATUS(AE_OK); 564 return_ACPI_STATUS(AE_OK);
560} 565}
@@ -580,13 +585,15 @@ acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info)
580 /* Absolute minimum length is 24, but the ACPI spec says 64 */ 585 /* Absolute minimum length is 24, but the ACPI spec says 64 */
581 586
582 if (acpi_gbl_FACS->length < 24) { 587 if (acpi_gbl_FACS->length < 24) {
583 ACPI_REPORT_ERROR(("Invalid FACS table length: 0x%X\n", 588 ACPI_ERROR((AE_INFO, "Invalid FACS table length: 0x%X",
584 acpi_gbl_FACS->length)); 589 acpi_gbl_FACS->length));
585 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); 590 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
586 } 591 }
587 592
588 if (acpi_gbl_FACS->length < 64) { 593 if (acpi_gbl_FACS->length < 64) {
589 ACPI_REPORT_WARNING(("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", acpi_gbl_FACS->length)); 594 ACPI_WARNING((AE_INFO,
595 "FACS is shorter than the ACPI specification allows: 0x%X, using anyway",
596 acpi_gbl_FACS->length));
590 } 597 }
591 598
592 /* Copy fields to the new FACS */ 599 /* Copy fields to the new FACS */
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 6acd5aeb093e..09b4ee6dfd60 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -91,9 +91,9 @@ acpi_tb_get_table(struct acpi_pointer *address,
91 91
92 status = acpi_tb_get_table_body(address, &header, table_info); 92 status = acpi_tb_get_table_body(address, &header, table_info);
93 if (ACPI_FAILURE(status)) { 93 if (ACPI_FAILURE(status)) {
94 ACPI_REPORT_ERROR(("Could not get ACPI table (size %X), %s\n", 94 ACPI_EXCEPTION((AE_INFO, status,
95 header.length, 95 "Could not get ACPI table (size %X)",
96 acpi_format_exception(status))); 96 header.length));
97 return_ACPI_STATUS(status); 97 return_ACPI_STATUS(status);
98 } 98 }
99 99
@@ -148,7 +148,6 @@ acpi_tb_get_table_header(struct acpi_pointer *address,
148 sizeof(struct acpi_table_header), 148 sizeof(struct acpi_table_header),
149 (void *)&header); 149 (void *)&header);
150 if (ACPI_FAILURE(status)) { 150 if (ACPI_FAILURE(status)) {
151 ACPI_REPORT_ERROR(("Could not map memory at %8.8X%8.8X for length %X\n", ACPI_FORMAT_UINT64(address->pointer.physical), sizeof(struct acpi_table_header)));
152 return_ACPI_STATUS(status); 151 return_ACPI_STATUS(status);
153 } 152 }
154 153
@@ -161,8 +160,8 @@ acpi_tb_get_table_header(struct acpi_pointer *address,
161 160
162 default: 161 default:
163 162
164 ACPI_REPORT_ERROR(("Invalid address flags %X\n", 163 ACPI_ERROR((AE_INFO, "Invalid address flags %X",
165 address->pointer_type)); 164 address->pointer_type));
166 return_ACPI_STATUS(AE_BAD_PARAMETER); 165 return_ACPI_STATUS(AE_BAD_PARAMETER);
167 } 166 }
168 167
@@ -253,8 +252,8 @@ acpi_tb_table_override(struct acpi_table_header *header,
253 if (ACPI_FAILURE(status)) { 252 if (ACPI_FAILURE(status)) {
254 /* Some severe error from the OSL, but we basically ignore it */ 253 /* Some severe error from the OSL, but we basically ignore it */
255 254
256 ACPI_REPORT_ERROR(("Could not override ACPI table, %s\n", 255 ACPI_EXCEPTION((AE_INFO, status,
257 acpi_format_exception(status))); 256 "Could not override ACPI table"));
258 return_ACPI_STATUS(status); 257 return_ACPI_STATUS(status);
259 } 258 }
260 259
@@ -273,15 +272,14 @@ acpi_tb_table_override(struct acpi_table_header *header,
273 272
274 status = acpi_tb_get_this_table(&address, new_table, table_info); 273 status = acpi_tb_get_this_table(&address, new_table, table_info);
275 if (ACPI_FAILURE(status)) { 274 if (ACPI_FAILURE(status)) {
276 ACPI_REPORT_ERROR(("Could not copy override ACPI table, %s\n", 275 ACPI_EXCEPTION((AE_INFO, status, "Could not copy ACPI table"));
277 acpi_format_exception(status)));
278 return_ACPI_STATUS(status); 276 return_ACPI_STATUS(status);
279 } 277 }
280 278
281 /* Copy the table info */ 279 /* Copy the table info */
282 280
283 ACPI_REPORT_INFO(("Table [%4.4s] replaced by host OS\n", 281 ACPI_INFO((AE_INFO, "Table [%4.4s] replaced by host OS",
284 table_info->pointer->signature)); 282 table_info->pointer->signature));
285 283
286 return_ACPI_STATUS(AE_OK); 284 return_ACPI_STATUS(AE_OK);
287} 285}
@@ -327,7 +325,9 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
327 325
328 full_table = ACPI_MEM_ALLOCATE(header->length); 326 full_table = ACPI_MEM_ALLOCATE(header->length);
329 if (!full_table) { 327 if (!full_table) {
330 ACPI_REPORT_ERROR(("Could not allocate table memory for [%4.4s] length %X\n", header->signature, header->length)); 328 ACPI_ERROR((AE_INFO,
329 "Could not allocate table memory for [%4.4s] length %X",
330 header->signature, header->length));
331 return_ACPI_STATUS(AE_NO_MEMORY); 331 return_ACPI_STATUS(AE_NO_MEMORY);
332 } 332 }
333 333
@@ -351,7 +351,12 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
351 (acpi_size) header->length, 351 (acpi_size) header->length,
352 (void *)&full_table); 352 (void *)&full_table);
353 if (ACPI_FAILURE(status)) { 353 if (ACPI_FAILURE(status)) {
354 ACPI_REPORT_ERROR(("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", header->signature, ACPI_FORMAT_UINT64(address->pointer.physical), header->length)); 354 ACPI_ERROR((AE_INFO,
355 "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X",
356 header->signature,
357 ACPI_FORMAT_UINT64(address->pointer.
358 physical),
359 header->length));
355 return (status); 360 return (status);
356 } 361 }
357 362
@@ -362,8 +367,8 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
362 367
363 default: 368 default:
364 369
365 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid address flags %X\n", 370 ACPI_ERROR((AE_INFO, "Invalid address flags %X",
366 address->pointer_type)); 371 address->pointer_type));
367 return_ACPI_STATUS(AE_BAD_PARAMETER); 372 return_ACPI_STATUS(AE_BAD_PARAMETER);
368 } 373 }
369 374
diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c
index 8d72343537e7..134e5dce0bc1 100644
--- a/drivers/acpi/tables/tbgetall.c
+++ b/drivers/acpi/tables/tbgetall.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -152,7 +152,9 @@ acpi_tb_get_secondary_table(struct acpi_pointer *address,
152 /* Signature must match request */ 152 /* Signature must match request */
153 153
154 if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) { 154 if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) {
155 ACPI_REPORT_ERROR(("Incorrect table signature - wanted [%s] found [%4.4s]\n", signature, header.signature)); 155 ACPI_ERROR((AE_INFO,
156 "Incorrect table signature - wanted [%s] found [%4.4s]",
157 signature, header.signature));
156 return_ACPI_STATUS(AE_BAD_SIGNATURE); 158 return_ACPI_STATUS(AE_BAD_SIGNATURE);
157 } 159 }
158 160
@@ -231,14 +233,18 @@ acpi_status acpi_tb_get_required_tables(void)
231 */ 233 */
232 status = acpi_tb_get_primary_table(&address, &table_info); 234 status = acpi_tb_get_primary_table(&address, &table_info);
233 if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) { 235 if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) {
234 ACPI_REPORT_WARNING(("%s, while getting table at %8.8X%8.8X\n", acpi_format_exception(status), ACPI_FORMAT_UINT64(address.pointer.value))); 236 ACPI_WARNING((AE_INFO,
237 "%s, while getting table at %8.8X%8.8X",
238 acpi_format_exception(status),
239 ACPI_FORMAT_UINT64(address.pointer.
240 value)));
235 } 241 }
236 } 242 }
237 243
238 /* We must have a FADT to continue */ 244 /* We must have a FADT to continue */
239 245
240 if (!acpi_gbl_FADT) { 246 if (!acpi_gbl_FADT) {
241 ACPI_REPORT_ERROR(("No FADT present in RSDT/XSDT\n")); 247 ACPI_ERROR((AE_INFO, "No FADT present in RSDT/XSDT"));
242 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 248 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
243 } 249 }
244 250
@@ -248,7 +254,8 @@ acpi_status acpi_tb_get_required_tables(void)
248 */ 254 */
249 status = acpi_tb_convert_table_fadt(); 255 status = acpi_tb_convert_table_fadt();
250 if (ACPI_FAILURE(status)) { 256 if (ACPI_FAILURE(status)) {
251 ACPI_REPORT_ERROR(("Could not convert FADT to internal common format\n")); 257 ACPI_ERROR((AE_INFO,
258 "Could not convert FADT to internal common format"));
252 return_ACPI_STATUS(status); 259 return_ACPI_STATUS(status);
253 } 260 }
254 261
@@ -258,8 +265,8 @@ acpi_status acpi_tb_get_required_tables(void)
258 265
259 status = acpi_tb_get_secondary_table(&address, FACS_SIG, &table_info); 266 status = acpi_tb_get_secondary_table(&address, FACS_SIG, &table_info);
260 if (ACPI_FAILURE(status)) { 267 if (ACPI_FAILURE(status)) {
261 ACPI_REPORT_ERROR(("Could not get/install the FACS, %s\n", 268 ACPI_EXCEPTION((AE_INFO, status,
262 acpi_format_exception(status))); 269 "Could not get/install the FACS"));
263 return_ACPI_STATUS(status); 270 return_ACPI_STATUS(status);
264 } 271 }
265 272
@@ -278,7 +285,7 @@ acpi_status acpi_tb_get_required_tables(void)
278 285
279 status = acpi_tb_get_secondary_table(&address, DSDT_SIG, &table_info); 286 status = acpi_tb_get_secondary_table(&address, DSDT_SIG, &table_info);
280 if (ACPI_FAILURE(status)) { 287 if (ACPI_FAILURE(status)) {
281 ACPI_REPORT_ERROR(("Could not get/install the DSDT\n")); 288 ACPI_ERROR((AE_INFO, "Could not get/install the DSDT"));
282 return_ACPI_STATUS(status); 289 return_ACPI_STATUS(status);
283 } 290 }
284 291
@@ -292,7 +299,9 @@ acpi_status acpi_tb_get_required_tables(void)
292 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", 299 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n",
293 acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, 300 acpi_gbl_DSDT->length, acpi_gbl_DSDT->length,
294 acpi_gbl_integer_bit_width)); 301 acpi_gbl_integer_bit_width));
295 ACPI_DUMP_BUFFER((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length); 302
303 ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_DSDT),
304 acpi_gbl_DSDT->length);
296 305
297 /* Always delete the RSDP mapping, we are done with it */ 306 /* Always delete the RSDP mapping, we are done with it */
298 307
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index 10db8484e462..7ffd0fddb4e5 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -128,8 +128,8 @@ acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info)
128 128
129 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 129 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
130 if (ACPI_FAILURE(status)) { 130 if (ACPI_FAILURE(status)) {
131 ACPI_REPORT_ERROR(("Could not acquire table mutex, %s\n", 131 ACPI_EXCEPTION((AE_INFO, status,
132 acpi_format_exception(status))); 132 "Could not acquire table mutex"));
133 return_ACPI_STATUS(status); 133 return_ACPI_STATUS(status);
134 } 134 }
135 135
@@ -146,9 +146,9 @@ acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info)
146 146
147 status = acpi_tb_init_table_descriptor(table_info->type, table_info); 147 status = acpi_tb_init_table_descriptor(table_info->type, table_info);
148 if (ACPI_FAILURE(status)) { 148 if (ACPI_FAILURE(status)) {
149 ACPI_REPORT_ERROR(("Could not install table [%4.4s], %s\n", 149 ACPI_EXCEPTION((AE_INFO, status,
150 table_info->pointer->signature, 150 "Could not install table [%4.4s]",
151 acpi_format_exception(status))); 151 table_info->pointer->signature));
152 } 152 }
153 153
154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n", 154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n",
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index ad0252c2f7db..4d308220225d 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -176,7 +176,7 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
176{ 176{
177 int no_match; 177 int no_match;
178 178
179 ACPI_FUNCTION_NAME("tb_validate_rsdt"); 179 ACPI_FUNCTION_ENTRY();
180 180
181 /* 181 /*
182 * Search for appropriate signature, RSDT or XSDT 182 * Search for appropriate signature, RSDT or XSDT
@@ -192,24 +192,24 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
192 if (no_match) { 192 if (no_match) {
193 /* Invalid RSDT or XSDT signature */ 193 /* Invalid RSDT or XSDT signature */
194 194
195 ACPI_REPORT_ERROR(("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); 195 ACPI_ERROR((AE_INFO,
196 "Invalid signature where RSDP indicates RSDT/XSDT should be located. RSDP:"));
196 197
197 ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20); 198 ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20);
198 199
199 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, 200 ACPI_ERROR((AE_INFO,
200 "RSDT/XSDT signature at %X (%p) is invalid\n", 201 "RSDT/XSDT signature at %X (%p) is invalid",
201 acpi_gbl_RSDP->rsdt_physical_address, 202 acpi_gbl_RSDP->rsdt_physical_address,
202 (void *)(acpi_native_uint) acpi_gbl_RSDP-> 203 (void *)(acpi_native_uint) acpi_gbl_RSDP->
203 rsdt_physical_address)); 204 rsdt_physical_address));
204 205
205 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { 206 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
206 ACPI_REPORT_ERROR(("Looking for RSDT\n")) 207 ACPI_ERROR((AE_INFO, "Looking for RSDT"));
207 } else { 208 } else {
208 ACPI_REPORT_ERROR(("Looking for XSDT\n")) 209 ACPI_ERROR((AE_INFO, "Looking for XSDT"));
209 } 210 }
210 211
211 ACPI_DUMP_BUFFER((char *)table_ptr, 48); 212 ACPI_DUMP_BUFFER((char *)table_ptr, 48);
212
213 return (AE_BAD_SIGNATURE); 213 return (AE_BAD_SIGNATURE);
214 } 214 }
215 215
@@ -243,15 +243,13 @@ acpi_status acpi_tb_get_table_rsdt(void)
243 table_info.type = ACPI_TABLE_XSDT; 243 table_info.type = ACPI_TABLE_XSDT;
244 status = acpi_tb_get_table(&address, &table_info); 244 status = acpi_tb_get_table(&address, &table_info);
245 if (ACPI_FAILURE(status)) { 245 if (ACPI_FAILURE(status)) {
246 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 246 ACPI_EXCEPTION((AE_INFO, status,
247 "Could not get the RSDT/XSDT, %s\n", 247 "Could not get the RSDT/XSDT"));
248 acpi_format_exception(status)));
249
250 return_ACPI_STATUS(status); 248 return_ACPI_STATUS(status);
251 } 249 }
252 250
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 251 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
254 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", 252 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X\n",
255 acpi_gbl_RSDP, 253 acpi_gbl_RSDP,
256 ACPI_FORMAT_UINT64(address.pointer.value))); 254 ACPI_FORMAT_UINT64(address.pointer.value)));
257 255
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index 4b2fbb592f49..bc571592f087 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -94,9 +94,8 @@ acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc)
94 new_table_desc->pointer->length) 94 new_table_desc->pointer->length)
95 && 95 &&
96 (!ACPI_MEMCMP 96 (!ACPI_MEMCMP
97 ((const char *)table_desc->pointer, 97 (table_desc->pointer, new_table_desc->pointer,
98 (const char *)new_table_desc->pointer, 98 new_table_desc->pointer->length))) {
99 (acpi_size) new_table_desc->pointer->length))) {
100 /* Match: this table is already installed */ 99 /* Match: this table is already installed */
101 100
102 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, 101 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
@@ -145,14 +144,13 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
145{ 144{
146 acpi_name signature; 145 acpi_name signature;
147 146
148 ACPI_FUNCTION_NAME("tb_validate_table_header"); 147 ACPI_FUNCTION_ENTRY();
149 148
150 /* Verify that this is a valid address */ 149 /* Verify that this is a valid address */
151 150
152 if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) { 151 if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) {
153 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 152 ACPI_ERROR((AE_INFO,
154 "Cannot read table header at %p\n", 153 "Cannot read table header at %p", table_header));
155 table_header));
156 154
157 return (AE_BAD_ADDRESS); 155 return (AE_BAD_ADDRESS);
158 } 156 }
@@ -161,12 +159,12 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
161 159
162 ACPI_MOVE_32_TO_32(&signature, table_header->signature); 160 ACPI_MOVE_32_TO_32(&signature, table_header->signature);
163 if (!acpi_ut_valid_acpi_name(signature)) { 161 if (!acpi_ut_valid_acpi_name(signature)) {
164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 162 ACPI_ERROR((AE_INFO,
165 "Table signature at %p [%p] has invalid characters\n", 163 "Table signature at %p [%p] has invalid characters",
166 table_header, &signature)); 164 table_header, &signature));
167 165
168 ACPI_REPORT_WARNING(("Invalid table signature found: [%4.4s]\n", 166 ACPI_WARNING((AE_INFO, "Invalid table signature found: [%4.4s]",
169 (char *)&signature)); 167 ACPI_CAST_PTR(char, &signature)));
170 168
171 ACPI_DUMP_BUFFER(table_header, 169 ACPI_DUMP_BUFFER(table_header,
172 sizeof(struct acpi_table_header)); 170 sizeof(struct acpi_table_header));
@@ -176,11 +174,13 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header)
176 /* Validate the table length */ 174 /* Validate the table length */
177 175
178 if (table_header->length < sizeof(struct acpi_table_header)) { 176 if (table_header->length < sizeof(struct acpi_table_header)) {
179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 177 ACPI_ERROR((AE_INFO,
180 "Invalid length in table header %p name %4.4s\n", 178 "Invalid length in table header %p name %4.4s",
181 table_header, (char *)&signature)); 179 table_header, (char *)&signature));
182 180
183 ACPI_REPORT_WARNING(("Invalid table header length (0x%X) found\n", (u32) table_header->length)); 181 ACPI_WARNING((AE_INFO,
182 "Invalid table header length (0x%X) found",
183 (u32) table_header->length));
184 184
185 ACPI_DUMP_BUFFER(table_header, 185 ACPI_DUMP_BUFFER(table_header,
186 sizeof(struct acpi_table_header)); 186 sizeof(struct acpi_table_header));
@@ -219,7 +219,10 @@ acpi_tb_verify_table_checksum(struct acpi_table_header * table_header)
219 /* Return the appropriate exception */ 219 /* Return the appropriate exception */
220 220
221 if (checksum) { 221 if (checksum) {
222 ACPI_REPORT_WARNING(("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", table_header->signature, (u32) table_header->checksum, (u32) checksum)); 222 ACPI_WARNING((AE_INFO,
223 "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)",
224 table_header->signature,
225 (u32) table_header->checksum, (u32) checksum));
223 226
224 status = AE_BAD_CHECKSUM; 227 status = AE_BAD_CHECKSUM;
225 } 228 }
@@ -241,16 +244,16 @@ acpi_tb_verify_table_checksum(struct acpi_table_header * table_header)
241 244
242u8 acpi_tb_generate_checksum(void *buffer, u32 length) 245u8 acpi_tb_generate_checksum(void *buffer, u32 length)
243{ 246{
244 const u8 *limit; 247 u8 *end_buffer;
245 const u8 *rover; 248 u8 *rover;
246 u8 sum = 0; 249 u8 sum = 0;
247 250
248 if (buffer && length) { 251 if (buffer && length) {
249 /* Buffer and Length are valid */ 252 /* Buffer and Length are valid */
250 253
251 limit = (u8 *) buffer + length; 254 end_buffer = ACPI_ADD_PTR(u8, buffer, length);
252 255
253 for (rover = buffer; rover < limit; rover++) { 256 for (rover = buffer; rover < end_buffer; rover++) {
254 sum = (u8) (sum + *rover); 257 sum = (u8) (sum + *rover);
255 } 258 }
256 } 259 }
@@ -292,8 +295,7 @@ acpi_tb_handle_to_object(u16 table_id,
292 } 295 }
293 } 296 }
294 297
295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "table_id=%X does not exist\n", 298 ACPI_ERROR((AE_INFO, "table_id=%X does not exist", table_id));
296 table_id));
297 return (AE_BAD_PARAMETER); 299 return (AE_BAD_PARAMETER);
298} 300}
299#endif 301#endif
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index 3f96a4909aad..9fe53c9d5b9a 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -75,8 +75,7 @@ acpi_status acpi_load_tables(void)
75 status = acpi_os_get_root_pointer(ACPI_LOGICAL_ADDRESSING, 75 status = acpi_os_get_root_pointer(ACPI_LOGICAL_ADDRESSING,
76 &rsdp_address); 76 &rsdp_address);
77 if (ACPI_FAILURE(status)) { 77 if (ACPI_FAILURE(status)) {
78 ACPI_REPORT_ERROR(("acpi_load_tables: Could not get RSDP, %s\n", 78 ACPI_EXCEPTION((AE_INFO, status, "Could not get the RSDP"));
79 acpi_format_exception(status)));
80 goto error_exit; 79 goto error_exit;
81 } 80 }
82 81
@@ -86,7 +85,7 @@ acpi_status acpi_load_tables(void)
86 85
87 status = acpi_tb_verify_rsdp(&rsdp_address); 86 status = acpi_tb_verify_rsdp(&rsdp_address);
88 if (ACPI_FAILURE(status)) { 87 if (ACPI_FAILURE(status)) {
89 ACPI_REPORT_ERROR(("acpi_load_tables: RSDP Failed validation: %s\n", acpi_format_exception(status))); 88 ACPI_EXCEPTION((AE_INFO, status, "During RSDP validation"));
90 goto error_exit; 89 goto error_exit;
91 } 90 }
92 91
@@ -94,7 +93,7 @@ acpi_status acpi_load_tables(void)
94 93
95 status = acpi_tb_get_table_rsdt(); 94 status = acpi_tb_get_table_rsdt();
96 if (ACPI_FAILURE(status)) { 95 if (ACPI_FAILURE(status)) {
97 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load RSDT: %s\n", acpi_format_exception(status))); 96 ACPI_EXCEPTION((AE_INFO, status, "Could not load RSDT"));
98 goto error_exit; 97 goto error_exit;
99 } 98 }
100 99
@@ -102,7 +101,8 @@ acpi_status acpi_load_tables(void)
102 101
103 status = acpi_tb_get_required_tables(); 102 status = acpi_tb_get_required_tables();
104 if (ACPI_FAILURE(status)) { 103 if (ACPI_FAILURE(status)) {
105 ACPI_REPORT_ERROR(("acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n", acpi_format_exception(status))); 104 ACPI_EXCEPTION((AE_INFO, status,
105 "Could not get all required tables (DSDT/FADT/FACS)"));
106 goto error_exit; 106 goto error_exit;
107 } 107 }
108 108
@@ -112,16 +112,14 @@ acpi_status acpi_load_tables(void)
112 112
113 status = acpi_ns_load_namespace(); 113 status = acpi_ns_load_namespace();
114 if (ACPI_FAILURE(status)) { 114 if (ACPI_FAILURE(status)) {
115 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load namespace: %s\n", acpi_format_exception(status))); 115 ACPI_EXCEPTION((AE_INFO, status, "Could not load namespace"));
116 goto error_exit; 116 goto error_exit;
117 } 117 }
118 118
119 return_ACPI_STATUS(AE_OK); 119 return_ACPI_STATUS(AE_OK);
120 120
121 error_exit: 121 error_exit:
122 ACPI_REPORT_ERROR(("acpi_load_tables: Could not load tables: %s\n", 122 ACPI_EXCEPTION((AE_INFO, status, "Could not load tables"));
123 acpi_format_exception(status)));
124
125 return_ACPI_STATUS(status); 123 return_ACPI_STATUS(status);
126} 124}
127 125
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index 3b8a7e063e8a..a62db6af83c9 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -251,7 +251,7 @@ acpi_get_firmware_table(acpi_string signature,
251 251
252 acpi_tb_get_rsdt_address(&address); 252 acpi_tb_get_rsdt_address(&address);
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
254 "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", 254 "RSDP located at %p, RSDT physical=%8.8X%8.8X\n",
255 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
256 ACPI_FORMAT_UINT64(address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
257 257
@@ -396,9 +396,8 @@ acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address)
396 396
397 status = acpi_tb_find_rsdp(&table_info, flags); 397 status = acpi_tb_find_rsdp(&table_info, flags);
398 if (ACPI_FAILURE(status)) { 398 if (ACPI_FAILURE(status)) {
399 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 399 ACPI_EXCEPTION((AE_INFO, status,
400 "RSDP structure not found, %s Flags=%X\n", 400 "RSDP structure not found - Flags=%X", flags));
401 acpi_format_exception(status), flags));
402 401
403 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 402 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
404 } 403 }
@@ -503,10 +502,10 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
503 ACPI_EBDA_PTR_LENGTH, 502 ACPI_EBDA_PTR_LENGTH,
504 (void *)&table_ptr); 503 (void *)&table_ptr);
505 if (ACPI_FAILURE(status)) { 504 if (ACPI_FAILURE(status)) {
506 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 505 ACPI_ERROR((AE_INFO,
507 "Could not map memory at %8.8X for length %X\n", 506 "Could not map memory at %8.8X for length %X",
508 ACPI_EBDA_PTR_LOCATION, 507 ACPI_EBDA_PTR_LOCATION,
509 ACPI_EBDA_PTR_LENGTH)); 508 ACPI_EBDA_PTR_LENGTH));
510 509
511 return_ACPI_STATUS(status); 510 return_ACPI_STATUS(status);
512 } 511 }
@@ -530,10 +529,10 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
530 ACPI_EBDA_WINDOW_SIZE, 529 ACPI_EBDA_WINDOW_SIZE,
531 (void *)&table_ptr); 530 (void *)&table_ptr);
532 if (ACPI_FAILURE(status)) { 531 if (ACPI_FAILURE(status)) {
533 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 532 ACPI_ERROR((AE_INFO,
534 "Could not map memory at %8.8X for length %X\n", 533 "Could not map memory at %8.8X for length %X",
535 physical_address, 534 physical_address,
536 ACPI_EBDA_WINDOW_SIZE)); 535 ACPI_EBDA_WINDOW_SIZE));
537 536
538 return_ACPI_STATUS(status); 537 return_ACPI_STATUS(status);
539 } 538 }
@@ -563,10 +562,10 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
563 (void *)&table_ptr); 562 (void *)&table_ptr);
564 563
565 if (ACPI_FAILURE(status)) { 564 if (ACPI_FAILURE(status)) {
566 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 565 ACPI_ERROR((AE_INFO,
567 "Could not map memory at %8.8X for length %X\n", 566 "Could not map memory at %8.8X for length %X",
568 ACPI_HI_RSDP_WINDOW_BASE, 567 ACPI_HI_RSDP_WINDOW_BASE,
569 ACPI_HI_RSDP_WINDOW_SIZE)); 568 ACPI_HI_RSDP_WINDOW_SIZE));
570 569
571 return_ACPI_STATUS(status); 570 return_ACPI_STATUS(status);
572 } 571 }
@@ -635,7 +634,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags)
635 634
636 /* A valid RSDP was not found */ 635 /* A valid RSDP was not found */
637 636
638 ACPI_REPORT_ERROR(("No valid RSDP was found\n")); 637 ACPI_ERROR((AE_INFO, "No valid RSDP was found"));
639 return_ACPI_STATUS(AE_NOT_FOUND); 638 return_ACPI_STATUS(AE_NOT_FOUND);
640} 639}
641 640
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
index e87108b7338a..88eff14c4894 100644
--- a/drivers/acpi/utilities/Makefile
+++ b/drivers/acpi/utilities/Makefile
@@ -2,7 +2,8 @@
2# Makefile for all Linux ACPI interpreter subdirectories 2# Makefile for all Linux ACPI interpreter subdirectories
3# 3#
4 4
5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o 6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
7 utstate.o utmutex.o utobject.o utcache.o utresrc.o
7 8
8EXTRA_CFLAGS += $(ACPI_CFLAGS) 9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 068450b36475..03b0044974c2 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,7 @@
47ACPI_MODULE_NAME("utalloc") 47ACPI_MODULE_NAME("utalloc")
48 48
49/* Local prototypes */ 49/* Local prototypes */
50#ifdef ACPI_DBG_TRACK_ALLOCATIONS 50#ifdef ACPI_DBG_TRACK_ALLOCATIONS
51static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation); 51static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation);
52 52
53static acpi_status 53static acpi_status
@@ -58,9 +58,7 @@ acpi_ut_track_allocation(struct acpi_debug_mem_block *address,
58static acpi_status 58static acpi_status
59acpi_ut_remove_allocation(struct acpi_debug_mem_block *address, 59acpi_ut_remove_allocation(struct acpi_debug_mem_block *address,
60 u32 component, char *module, u32 line); 60 u32 component, char *module, u32 line);
61#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
62 61
63#ifdef ACPI_DBG_TRACK_ALLOCATIONS
64static acpi_status 62static acpi_status
65acpi_ut_create_list(char *list_name, 63acpi_ut_create_list(char *list_name,
66 u16 object_size, struct acpi_memory_list **return_cache); 64 u16 object_size, struct acpi_memory_list **return_cache);
@@ -303,8 +301,8 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
303 /* Check for an inadvertent size of zero bytes */ 301 /* Check for an inadvertent size of zero bytes */
304 302
305 if (!size) { 303 if (!size) {
306 _ACPI_REPORT_ERROR(module, line, component, 304 ACPI_ERROR((module, line,
307 ("ut_allocate: Attempt to allocate zero bytes\n")); 305 "ut_allocate: Attempt to allocate zero bytes, allocating 1 byte"));
308 size = 1; 306 size = 1;
309 } 307 }
310 308
@@ -312,9 +310,9 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line)
312 if (!allocation) { 310 if (!allocation) {
313 /* Report allocation error */ 311 /* Report allocation error */
314 312
315 _ACPI_REPORT_ERROR(module, line, component, 313 ACPI_ERROR((module, line,
316 ("ut_allocate: Could not allocate size %X\n", 314 "ut_allocate: Could not allocate size %X",
317 (u32) size)); 315 (u32) size));
318 316
319 return_PTR(NULL); 317 return_PTR(NULL);
320 } 318 }
@@ -346,18 +344,17 @@ void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line)
346 /* Check for an inadvertent size of zero bytes */ 344 /* Check for an inadvertent size of zero bytes */
347 345
348 if (!size) { 346 if (!size) {
349 _ACPI_REPORT_ERROR(module, line, component, 347 ACPI_ERROR((module, line,
350 ("ut_callocate: Attempt to allocate zero bytes\n")); 348 "Attempt to allocate zero bytes, allocating 1 byte"));
351 return_PTR(NULL); 349 size = 1;
352 } 350 }
353 351
354 allocation = acpi_os_allocate(size); 352 allocation = acpi_os_allocate(size);
355 if (!allocation) { 353 if (!allocation) {
356 /* Report allocation error */ 354 /* Report allocation error */
357 355
358 _ACPI_REPORT_ERROR(module, line, component, 356 ACPI_ERROR((module, line,
359 ("ut_callocate: Could not allocate size %X\n", 357 "Could not allocate size %X", (u32) size));
360 (u32) size));
361 return_PTR(NULL); 358 return_PTR(NULL);
362 } 359 }
363 360
@@ -482,9 +479,8 @@ void *acpi_ut_callocate_and_track(acpi_size size,
482 if (!allocation) { 479 if (!allocation) {
483 /* Report allocation error */ 480 /* Report allocation error */
484 481
485 _ACPI_REPORT_ERROR(module, line, component, 482 ACPI_ERROR((module, line,
486 ("ut_callocate: Could not allocate size %X\n", 483 "Could not allocate size %X", (u32) size));
487 (u32) size));
488 return (NULL); 484 return (NULL);
489 } 485 }
490 486
@@ -526,8 +522,7 @@ acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line)
526 ACPI_FUNCTION_TRACE_PTR("ut_free", allocation); 522 ACPI_FUNCTION_TRACE_PTR("ut_free", allocation);
527 523
528 if (NULL == allocation) { 524 if (NULL == allocation) {
529 _ACPI_REPORT_ERROR(module, line, component, 525 ACPI_ERROR((module, line, "Attempt to delete a NULL address"));
530 ("acpi_ut_free: Attempt to delete a NULL address\n"));
531 526
532 return_VOID; 527 return_VOID;
533 } 528 }
@@ -542,14 +537,11 @@ acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line)
542 status = acpi_ut_remove_allocation(debug_block, 537 status = acpi_ut_remove_allocation(debug_block,
543 component, module, line); 538 component, module, line);
544 if (ACPI_FAILURE(status)) { 539 if (ACPI_FAILURE(status)) {
545 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Could not free memory, %s\n", 540 ACPI_EXCEPTION((AE_INFO, status, "Could not free memory"));
546 acpi_format_exception(status)));
547 } 541 }
548 542
549 acpi_os_free(debug_block); 543 acpi_os_free(debug_block);
550
551 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); 544 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
552
553 return_VOID; 545 return_VOID;
554} 546}
555 547
@@ -626,10 +618,12 @@ acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
626 */ 618 */
627 element = acpi_ut_find_allocation(allocation); 619 element = acpi_ut_find_allocation(allocation);
628 if (element) { 620 if (element) {
629 ACPI_REPORT_ERROR(("ut_track_allocation: Allocation already present in list! (%p)\n", allocation)); 621 ACPI_ERROR((AE_INFO,
622 "ut_track_allocation: Allocation already present in list! (%p)",
623 allocation));
630 624
631 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Element %p Address %p\n", 625 ACPI_ERROR((AE_INFO, "Element %p Address %p",
632 element, allocation)); 626 element, allocation));
633 627
634 goto unlock_and_exit; 628 goto unlock_and_exit;
635 } 629 }
@@ -689,8 +683,8 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
689 if (NULL == mem_list->list_head) { 683 if (NULL == mem_list->list_head) {
690 /* No allocations! */ 684 /* No allocations! */
691 685
692 _ACPI_REPORT_ERROR(module, line, component, 686 ACPI_ERROR((module, line,
693 ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); 687 "Empty allocation list, nothing to free!"));
694 688
695 return_ACPI_STATUS(AE_OK); 689 return_ACPI_STATUS(AE_OK);
696 } 690 }
@@ -865,12 +859,11 @@ void acpi_ut_dump_allocations(u32 component, char *module)
865 /* Print summary */ 859 /* Print summary */
866 860
867 if (!num_outstanding) { 861 if (!num_outstanding) {
868 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 862 ACPI_INFO((AE_INFO, "No outstanding allocations"));
869 "No outstanding allocations.\n"));
870 } else { 863 } else {
871 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 864 ACPI_ERROR((AE_INFO,
872 "%d(%X) Outstanding allocations\n", 865 "%d(%X) Outstanding allocations",
873 num_outstanding, num_outstanding)); 866 num_outstanding, num_outstanding));
874 } 867 }
875 868
876 return_VOID; 869 return_VOID;
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
index 93d48681d276..2177cb1ef2c4 100644
--- a/drivers/acpi/utilities/utcache.c
+++ b/drivers/acpi/utilities/utcache.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 5442b32de611..df2d32096b72 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/utilities/utcopy.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -398,14 +398,17 @@ acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
398 * Build a simple object (no nested objects) 398 * Build a simple object (no nested objects)
399 */ 399 */
400 status = acpi_ut_copy_isimple_to_esimple(internal_object, 400 status = acpi_ut_copy_isimple_to_esimple(internal_object,
401 (union acpi_object *) 401 ACPI_CAST_PTR(union
402 ret_buffer->pointer, 402 acpi_object,
403 ((u8 *) ret_buffer-> 403 ret_buffer->
404 pointer + 404 pointer),
405 ACPI_ROUND_UP_TO_NATIVE_WORD 405 ACPI_ADD_PTR(u8,
406 (sizeof 406 ret_buffer->
407 (union 407 pointer,
408 acpi_object))), 408 ACPI_ROUND_UP_TO_NATIVE_WORD
409 (sizeof
410 (union
411 acpi_object))),
409 &ret_buffer->length); 412 &ret_buffer->length);
410 /* 413 /*
411 * build simple does not include the object size in the length 414 * build simple does not include the object size in the length
@@ -603,8 +606,8 @@ acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
603 /* 606 /*
604 * Packages as external input to control methods are not supported, 607 * Packages as external input to control methods are not supported,
605 */ 608 */
606 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 609 ACPI_ERROR((AE_INFO,
607 "Packages as parameters not implemented!\n")); 610 "Packages as parameters not implemented!"));
608 611
609 return_ACPI_STATUS(AE_NOT_IMPLEMENTED); 612 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
610 } 613 }
@@ -867,7 +870,7 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
867 count + 870 count +
868 1) * sizeof(void *)); 871 1) * sizeof(void *));
869 if (!dest_obj->package.elements) { 872 if (!dest_obj->package.elements) {
870 ACPI_REPORT_ERROR(("aml_build_copy_internal_package_object: Package allocation failure\n")); 873 ACPI_ERROR((AE_INFO, "Package allocation failure"));
871 return_ACPI_STATUS(AE_NO_MEMORY); 874 return_ACPI_STATUS(AE_NO_MEMORY);
872 } 875 }
873 876
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index d80e92639932..35f3d581e034 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 2bc878f7a127..1db9695b0029 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -363,8 +363,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
363 363
364 default: 364 default:
365 365
366 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown action (%X)\n", 366 ACPI_ERROR((AE_INFO, "Unknown action (%X)", action));
367 action));
368 break; 367 break;
369 } 368 }
370 369
@@ -374,9 +373,9 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
374 */ 373 */
375 if (count > ACPI_MAX_REFERENCE_COUNT) { 374 if (count > ACPI_MAX_REFERENCE_COUNT) {
376 375
377 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 376 ACPI_WARNING((AE_INFO,
378 "**** Warning **** Large Reference Count (%X) in object %p\n\n", 377 "Large Reference Count (%X) in object %p",
379 count, object)); 378 count, object));
380 } 379 }
381 380
382 return; 381 return;
@@ -535,8 +534,8 @@ acpi_ut_update_object_reference(union acpi_operand_object * object, u16 action)
535 534
536 error_exit: 535 error_exit:
537 536
538 ACPI_REPORT_ERROR(("Could not update object reference count, %s\n", 537 ACPI_EXCEPTION((AE_INFO, status,
539 acpi_format_exception(status))); 538 "Could not update object reference count"));
540 539
541 return_ACPI_STATUS(status); 540 return_ACPI_STATUS(status);
542} 541}
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
index 7b81d5ef3c32..106cc97cb4af 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/utilities/uteval.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -95,7 +95,9 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
95 95
96 for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) { 96 for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) {
97 if (!ACPI_STRCMP(string_desc->string.pointer, 97 if (!ACPI_STRCMP(string_desc->string.pointer,
98 (char *)acpi_gbl_valid_osi_strings[i])) { 98 ACPI_CAST_PTR(char,
99 acpi_gbl_valid_osi_strings[i])))
100 {
99 /* This string is supported */ 101 /* This string is supported */
100 102
101 return_desc->integer.value = 0xFFFFFFFF; 103 return_desc->integer.value = 0xFFFFFFFF;
@@ -152,8 +154,8 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
152 acpi_ut_get_node_name(prefix_node), 154 acpi_ut_get_node_name(prefix_node),
153 path)); 155 path));
154 } else { 156 } else {
155 ACPI_REPORT_METHOD_ERROR("Method execution failed", 157 ACPI_ERROR_METHOD("Method execution failed",
156 prefix_node, path, status); 158 prefix_node, path, status);
157 } 159 }
158 160
159 return_ACPI_STATUS(status); 161 return_ACPI_STATUS(status);
@@ -163,9 +165,8 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
163 165
164 if (!info.return_object) { 166 if (!info.return_object) {
165 if (expected_return_btypes) { 167 if (expected_return_btypes) {
166 ACPI_REPORT_METHOD_ERROR("No object was returned from", 168 ACPI_ERROR_METHOD("No object was returned from",
167 prefix_node, path, 169 prefix_node, path, AE_NOT_EXIST);
168 AE_NOT_EXIST);
169 170
170 return_ACPI_STATUS(AE_NOT_EXIST); 171 return_ACPI_STATUS(AE_NOT_EXIST);
171 } 172 }
@@ -210,15 +211,14 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
210 /* Is the return object one of the expected types? */ 211 /* Is the return object one of the expected types? */
211 212
212 if (!(expected_return_btypes & return_btype)) { 213 if (!(expected_return_btypes & return_btype)) {
213 ACPI_REPORT_METHOD_ERROR("Return object type is incorrect", 214 ACPI_ERROR_METHOD("Return object type is incorrect",
214 prefix_node, path, AE_TYPE); 215 prefix_node, path, AE_TYPE);
215 216
216 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 217 ACPI_ERROR((AE_INFO,
217 "Type returned from %s was incorrect: %s, expected Btypes: %X\n", 218 "Type returned from %s was incorrect: %s, expected Btypes: %X",
218 path, 219 path,
219 acpi_ut_get_object_type_name(info. 220 acpi_ut_get_object_type_name(info.return_object),
220 return_object), 221 expected_return_btypes));
221 expected_return_btypes));
222 222
223 /* On error exit, we must delete the return object */ 223 /* On error exit, we must delete the return object */
224 224
@@ -592,7 +592,7 @@ acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
592 "_STA on %4.4s was not found, assuming device is present\n", 592 "_STA on %4.4s was not found, assuming device is present\n",
593 acpi_ut_get_node_name(device_node))); 593 acpi_ut_get_node_name(device_node)));
594 594
595 *flags = 0x0F; 595 *flags = ACPI_UINT32_MAX;
596 status = AE_OK; 596 status = AE_OK;
597 } 597 }
598 598
@@ -637,17 +637,17 @@ acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest)
637 for (i = 0; i < 4; i++) { 637 for (i = 0; i < 4; i++) {
638 highest[i] = 0xFF; 638 highest[i] = 0xFF;
639 status = acpi_ut_evaluate_object(device_node, 639 status = acpi_ut_evaluate_object(device_node,
640 (char *) 640 ACPI_CAST_PTR(char,
641 acpi_gbl_highest_dstate_names 641 acpi_gbl_highest_dstate_names
642 [i], ACPI_BTYPE_INTEGER, 642 [i]),
643 &obj_desc); 643 ACPI_BTYPE_INTEGER, &obj_desc);
644 if (ACPI_FAILURE(status)) { 644 if (ACPI_FAILURE(status)) {
645 if (status != AE_NOT_FOUND) { 645 if (status != AE_NOT_FOUND) {
646 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 646 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
647 "%s on Device %4.4s, %s\n", 647 "%s on Device %4.4s, %s\n",
648 (char *) 648 ACPI_CAST_PTR(char,
649 acpi_gbl_highest_dstate_names 649 acpi_gbl_highest_dstate_names
650 [i], 650 [i]),
651 acpi_ut_get_node_name 651 acpi_ut_get_node_name
652 (device_node), 652 (device_node),
653 acpi_format_exception 653 acpi_format_exception
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 399e64b51886..ffd13383a325 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -67,8 +67,11 @@ const char *acpi_format_exception(acpi_status status)
67 acpi_status sub_status; 67 acpi_status sub_status;
68 const char *exception = NULL; 68 const char *exception = NULL;
69 69
70 ACPI_FUNCTION_NAME("format_exception"); 70 ACPI_FUNCTION_ENTRY();
71 71
72 /*
73 * Status is composed of two parts, a "type" and an actual code
74 */
72 sub_status = (status & ~AE_CODE_MASK); 75 sub_status = (status & ~AE_CODE_MASK);
73 76
74 switch (status & AE_CODE_MASK) { 77 switch (status & AE_CODE_MASK) {
@@ -118,13 +121,13 @@ const char *acpi_format_exception(acpi_status status)
118 if (!exception) { 121 if (!exception) {
119 /* Exception code was not recognized */ 122 /* Exception code was not recognized */
120 123
121 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 124 ACPI_ERROR((AE_INFO,
122 "Unknown exception code: 0x%8.8X\n", status)); 125 "Unknown exception code: 0x%8.8X", status));
123 126
124 return ((const char *)"UNKNOWN_STATUS_CODE"); 127 exception = "UNKNOWN_STATUS_CODE";
125 } 128 }
126 129
127 return ((const char *)exception); 130 return (ACPI_CAST_PTR(const char, exception));
128} 131}
129 132
130/******************************************************************************* 133/*******************************************************************************
@@ -217,23 +220,23 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = {
217 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to 220 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
218 * perform a Notify() operation on it. 221 * perform a Notify() operation on it.
219 */ 222 */
220const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = 223const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
221 { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, 224 {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
222{"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 225 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
223{"_SB_", ACPI_TYPE_DEVICE, NULL}, 226 {"_SB_", ACPI_TYPE_DEVICE, NULL},
224{"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 227 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
225{"_TZ_", ACPI_TYPE_THERMAL, NULL}, 228 {"_TZ_", ACPI_TYPE_THERMAL, NULL},
226{"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL}, 229 {"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
227{"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 230 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
228{"_GL_", ACPI_TYPE_MUTEX, (char *)1}, 231 {"_GL_", ACPI_TYPE_MUTEX, (char *)1},
229 232
230#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 233#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
231{"_OSI", ACPI_TYPE_METHOD, (char *)1}, 234 {"_OSI", ACPI_TYPE_METHOD, (char *)1},
232#endif 235#endif
233 236
234 /* Table terminator */ 237 /* Table terminator */
235 238
236{NULL, ACPI_TYPE_ANY, NULL} 239 {NULL, ACPI_TYPE_ANY, NULL}
237}; 240};
238 241
239/* 242/*
@@ -485,7 +488,7 @@ char *acpi_ut_get_region_name(u8 space_id)
485 return ("invalid_space_id"); 488 return ("invalid_space_id");
486 } 489 }
487 490
488 return ((char *)acpi_gbl_region_types[space_id]); 491 return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
489} 492}
490 493
491/******************************************************************************* 494/*******************************************************************************
@@ -503,11 +506,13 @@ char *acpi_ut_get_region_name(u8 space_id)
503/* Event type decoding */ 506/* Event type decoding */
504 507
505static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = { 508static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
509/*! [Begin] no source code translation (keep these strings as-is) */
506 "PM_Timer", 510 "PM_Timer",
507 "global_lock", 511 "GlobalLock",
508 "power_button", 512 "PowerButton",
509 "sleep_button", 513 "SleepButton",
510 "real_time_clock", 514 "RealTimeClock",
515/*! [End] no source code translation !*/
511}; 516};
512 517
513char *acpi_ut_get_event_name(u32 event_id) 518char *acpi_ut_get_event_name(u32 event_id)
@@ -517,7 +522,7 @@ char *acpi_ut_get_event_name(u32 event_id)
517 return ("invalid_event_iD"); 522 return ("invalid_event_iD");
518 } 523 }
519 524
520 return ((char *)acpi_gbl_event_types[event_id]); 525 return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
521} 526}
522 527
523/******************************************************************************* 528/*******************************************************************************
@@ -545,12 +550,13 @@ static const char acpi_gbl_bad_type[] = "UNDEFINED";
545/* Printable names of the ACPI object types */ 550/* Printable names of the ACPI object types */
546 551
547static const char *acpi_gbl_ns_type_names[] = { 552static const char *acpi_gbl_ns_type_names[] = {
553/*! [Begin] no source code translation (keep these strings as-is) */
548 /* 00 */ "Untyped", 554 /* 00 */ "Untyped",
549 /* 01 */ "Integer", 555 /* 01 */ "Integer",
550 /* 02 */ "String", 556 /* 02 */ "String",
551 /* 03 */ "Buffer", 557 /* 03 */ "Buffer",
552 /* 04 */ "Package", 558 /* 04 */ "Package",
553 /* 05 */ "field_unit", 559 /* 05 */ "FieldUnit",
554 /* 06 */ "Device", 560 /* 06 */ "Device",
555 /* 07 */ "Event", 561 /* 07 */ "Event",
556 /* 08 */ "Method", 562 /* 08 */ "Method",
@@ -559,33 +565,34 @@ static const char *acpi_gbl_ns_type_names[] = {
559 /* 11 */ "Power", 565 /* 11 */ "Power",
560 /* 12 */ "Processor", 566 /* 12 */ "Processor",
561 /* 13 */ "Thermal", 567 /* 13 */ "Thermal",
562 /* 14 */ "buffer_field", 568 /* 14 */ "BufferField",
563 /* 15 */ "ddb_handle", 569 /* 15 */ "DdbHandle",
564 /* 16 */ "debug_object", 570 /* 16 */ "DebugObject",
565 /* 17 */ "region_field", 571 /* 17 */ "RegionField",
566 /* 18 */ "bank_field", 572 /* 18 */ "BankField",
567 /* 19 */ "index_field", 573 /* 19 */ "IndexField",
568 /* 20 */ "Reference", 574 /* 20 */ "Reference",
569 /* 21 */ "Alias", 575 /* 21 */ "Alias",
570 /* 22 */ "method_alias", 576 /* 22 */ "MethodAlias",
571 /* 23 */ "Notify", 577 /* 23 */ "Notify",
572 /* 24 */ "addr_handler", 578 /* 24 */ "AddrHandler",
573 /* 25 */ "resource_desc", 579 /* 25 */ "ResourceDesc",
574 /* 26 */ "resource_fld", 580 /* 26 */ "ResourceFld",
575 /* 27 */ "Scope", 581 /* 27 */ "Scope",
576 /* 28 */ "Extra", 582 /* 28 */ "Extra",
577 /* 29 */ "Data", 583 /* 29 */ "Data",
578 /* 30 */ "Invalid" 584 /* 30 */ "Invalid"
585/*! [End] no source code translation !*/
579}; 586};
580 587
581char *acpi_ut_get_type_name(acpi_object_type type) 588char *acpi_ut_get_type_name(acpi_object_type type)
582{ 589{
583 590
584 if (type > ACPI_TYPE_INVALID) { 591 if (type > ACPI_TYPE_INVALID) {
585 return ((char *)acpi_gbl_bad_type); 592 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
586 } 593 }
587 594
588 return ((char *)acpi_gbl_ns_type_names[type]); 595 return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
589} 596}
590 597
591char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc) 598char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
@@ -634,7 +641,7 @@ char *acpi_ut_get_node_name(void *object)
634 641
635 /* Name must be a valid ACPI name */ 642 /* Name must be a valid ACPI name */
636 643
637 if (!acpi_ut_valid_acpi_name(*(u32 *) node->name.ascii)) { 644 if (!acpi_ut_valid_acpi_name(node->name.integer)) {
638 return ("????"); 645 return ("????");
639 } 646 }
640 647
@@ -658,15 +665,16 @@ char *acpi_ut_get_node_name(void *object)
658/* Printable names of object descriptor types */ 665/* Printable names of object descriptor types */
659 666
660static const char *acpi_gbl_desc_type_names[] = { 667static const char *acpi_gbl_desc_type_names[] = {
668/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
661 /* 00 */ "Invalid", 669 /* 00 */ "Invalid",
662 /* 01 */ "Cached", 670 /* 01 */ "Cached",
663 /* 02 */ "State-Generic", 671 /* 02 */ "State-Generic",
664 /* 03 */ "State-Update", 672 /* 03 */ "State-Update",
665 /* 04 */ "State-Package", 673 /* 04 */ "State-Package",
666 /* 05 */ "State-Control", 674 /* 05 */ "State-Control",
667 /* 06 */ "State-root_parse_scope", 675 /* 06 */ "State-RootParseScope",
668 /* 07 */ "State-parse_scope", 676 /* 07 */ "State-ParseScope",
669 /* 08 */ "State-walk_scope", 677 /* 08 */ "State-WalkScope",
670 /* 09 */ "State-Result", 678 /* 09 */ "State-Result",
671 /* 10 */ "State-Notify", 679 /* 10 */ "State-Notify",
672 /* 11 */ "State-Thread", 680 /* 11 */ "State-Thread",
@@ -674,6 +682,7 @@ static const char *acpi_gbl_desc_type_names[] = {
674 /* 13 */ "Parser", 682 /* 13 */ "Parser",
675 /* 14 */ "Operand", 683 /* 14 */ "Operand",
676 /* 15 */ "Node" 684 /* 15 */ "Node"
685/*! [End] no source code translation !*/
677}; 686};
678 687
679char *acpi_ut_get_descriptor_name(void *object) 688char *acpi_ut_get_descriptor_name(void *object)
@@ -684,11 +693,12 @@ char *acpi_ut_get_descriptor_name(void *object)
684 } 693 }
685 694
686 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) { 695 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
687 return ((char *)acpi_gbl_bad_type); 696 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
688 } 697 }
689 698
690 return ((char *) 699 return (ACPI_CAST_PTR(char,
691 acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE(object)]); 700 acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
701 (object)]));
692 702
693} 703}
694 704
@@ -787,6 +797,11 @@ void acpi_ut_init_globals(void)
787 acpi_gbl_mutex_info[i].use_count = 0; 797 acpi_gbl_mutex_info[i].use_count = 0;
788 } 798 }
789 799
800 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
801 acpi_gbl_owner_id_mask[i] = 0;
802 }
803 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */
804
790 /* GPE support */ 805 /* GPE support */
791 806
792 acpi_gbl_gpe_xrupt_list_head = NULL; 807 acpi_gbl_gpe_xrupt_list_head = NULL;
@@ -824,7 +839,11 @@ void acpi_ut_init_globals(void)
824 acpi_gbl_ns_lookup_count = 0; 839 acpi_gbl_ns_lookup_count = 0;
825 acpi_gbl_ps_find_count = 0; 840 acpi_gbl_ps_find_count = 0;
826 acpi_gbl_acpi_hardware_present = TRUE; 841 acpi_gbl_acpi_hardware_present = TRUE;
827 acpi_gbl_owner_id_mask = 0; 842 acpi_gbl_last_owner_id_index = 0;
843 acpi_gbl_next_owner_id_offset = 0;
844 acpi_gbl_trace_method_name = 0;
845 acpi_gbl_trace_dbg_level = 0;
846 acpi_gbl_trace_dbg_layer = 0;
828 acpi_gbl_debugger_configuration = DEBUGGER_THREADING; 847 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
829 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; 848 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
830 849
@@ -836,7 +855,6 @@ void acpi_ut_init_globals(void)
836 /* Namespace */ 855 /* Namespace */
837 856
838 acpi_gbl_root_node = NULL; 857 acpi_gbl_root_node = NULL;
839
840 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; 858 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
841 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; 859 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
842 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; 860 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c
index 9dde82b0beaf..ba771b4f39bc 100644
--- a/drivers/acpi/utilities/utinit.c
+++ b/drivers/acpi/utilities/utinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -72,9 +72,9 @@ static void
72acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset) 72acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset)
73{ 73{
74 74
75 ACPI_REPORT_WARNING(("Invalid FADT value %s=%X at offset %X FADT=%p\n", 75 ACPI_WARNING((AE_INFO,
76 register_name, value, (u32) offset, 76 "Invalid FADT value %s=%X at offset %X FADT=%p",
77 acpi_gbl_FADT)); 77 register_name, value, (u32) offset, acpi_gbl_FADT));
78} 78}
79 79
80/****************************************************************************** 80/******************************************************************************
@@ -221,15 +221,14 @@ void acpi_ut_subsystem_shutdown(void)
221 /* Just exit if subsystem is already shutdown */ 221 /* Just exit if subsystem is already shutdown */
222 222
223 if (acpi_gbl_shutdown) { 223 if (acpi_gbl_shutdown) {
224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 224 ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
225 "ACPI Subsystem is already terminated\n"));
226 return_VOID; 225 return_VOID;
227 } 226 }
228 227
229 /* Subsystem appears active, go ahead and shut it down */ 228 /* Subsystem appears active, go ahead and shut it down */
230 229
231 acpi_gbl_shutdown = TRUE; 230 acpi_gbl_shutdown = TRUE;
232 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n")); 231 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
233 232
234 /* Close the acpi_event Handling */ 233 /* Close the acpi_event Handling */
235 234
diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c
index 68a0a6f94129..4a3360484e72 100644
--- a/drivers/acpi/utilities/utmath.c
+++ b/drivers/acpi/utilities/utmath.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -82,7 +82,7 @@ acpi_ut_short_divide(acpi_integer dividend,
82 /* Always check for a zero divisor */ 82 /* Always check for a zero divisor */
83 83
84 if (divisor == 0) { 84 if (divisor == 0) {
85 ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n")); 85 ACPI_ERROR((AE_INFO, "Divide by zero"));
86 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); 86 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
87 } 87 }
88 88
@@ -144,7 +144,7 @@ acpi_ut_divide(acpi_integer in_dividend,
144 /* Always check for a zero divisor */ 144 /* Always check for a zero divisor */
145 145
146 if (in_divisor == 0) { 146 if (in_divisor == 0) {
147 ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n")); 147 ACPI_ERROR((AE_INFO, "Divide by zero"));
148 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); 148 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
149 } 149 }
150 150
@@ -266,7 +266,7 @@ acpi_ut_short_divide(acpi_integer in_dividend,
266 /* Always check for a zero divisor */ 266 /* Always check for a zero divisor */
267 267
268 if (divisor == 0) { 268 if (divisor == 0) {
269 ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n")); 269 ACPI_ERROR((AE_INFO, "Divide by zero"));
270 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); 270 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
271 } 271 }
272 272
@@ -292,7 +292,7 @@ acpi_ut_divide(acpi_integer in_dividend,
292 /* Always check for a zero divisor */ 292 /* Always check for a zero divisor */
293 293
294 if (in_divisor == 0) { 294 if (in_divisor == 0) {
295 ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n")); 295 ACPI_ERROR((AE_INFO, "Divide by zero"));
296 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); 296 return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
297 } 297 }
298 298
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 2ce872d75890..7364f5f8c9cd 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -63,6 +63,8 @@ ACPI_MODULE_NAME("utmisc")
63acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) 63acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
64{ 64{
65 acpi_native_uint i; 65 acpi_native_uint i;
66 acpi_native_uint j;
67 acpi_native_uint k;
66 acpi_status status; 68 acpi_status status;
67 69
68 ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); 70 ACPI_FUNCTION_TRACE("ut_allocate_owner_id");
@@ -70,8 +72,8 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
70 /* Guard against multiple allocations of ID to the same location */ 72 /* Guard against multiple allocations of ID to the same location */
71 73
72 if (*owner_id) { 74 if (*owner_id) {
73 ACPI_REPORT_ERROR(("Owner ID [%2.2X] already exists\n", 75 ACPI_ERROR((AE_INFO, "Owner ID [%2.2X] already exists",
74 *owner_id)); 76 *owner_id));
75 return_ACPI_STATUS(AE_ALREADY_EXISTS); 77 return_ACPI_STATUS(AE_ALREADY_EXISTS);
76 } 78 }
77 79
@@ -82,31 +84,67 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
82 return_ACPI_STATUS(status); 84 return_ACPI_STATUS(status);
83 } 85 }
84 86
85 /* Find a free owner ID */ 87 /*
88 * Find a free owner ID, cycle through all possible IDs on repeated
89 * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
90 * to be scanned twice.
91 */
92 for (i = 0, j = acpi_gbl_last_owner_id_index;
93 i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) {
94 if (j >= ACPI_NUM_OWNERID_MASKS) {
95 j = 0; /* Wraparound to start of mask array */
96 }
97
98 for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) {
99 if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) {
100 /* There are no free IDs in this mask */
86 101
87 for (i = 0; i < 64; i++) { 102 break;
88 if (!(acpi_gbl_owner_id_mask & (1ULL << i))) { 103 }
89 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
90 "Current owner_id mask: %16.16LX New ID: %2.2X\n",
91 acpi_gbl_owner_id_mask,
92 (unsigned int)(i + 1)));
93 104
94 acpi_gbl_owner_id_mask |= (1ULL << i); 105 if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) {
95 *owner_id = (acpi_owner_id) (i + 1); 106 /*
96 goto exit; 107 * Found a free ID. The actual ID is the bit index plus one,
108 * making zero an invalid Owner ID. Save this as the last ID
109 * allocated and update the global ID mask.
110 */
111 acpi_gbl_owner_id_mask[j] |= (1 << k);
112
113 acpi_gbl_last_owner_id_index = (u8) j;
114 acpi_gbl_next_owner_id_offset = (u8) (k + 1);
115
116 /*
117 * Construct encoded ID from the index and bit position
118 *
119 * Note: Last [j].k (bit 255) is never used and is marked
120 * permanently allocated (prevents +1 overflow)
121 */
122 *owner_id =
123 (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j));
124
125 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
126 "Allocated owner_id: %2.2X\n",
127 (unsigned int)*owner_id));
128 goto exit;
129 }
97 } 130 }
131
132 acpi_gbl_next_owner_id_offset = 0;
98 } 133 }
99 134
100 /* 135 /*
101 * If we are here, all owner_ids have been allocated. This probably should 136 * All owner_ids have been allocated. This typically should
102 * not happen since the IDs are reused after deallocation. The IDs are 137 * not happen since the IDs are reused after deallocation. The IDs are
103 * allocated upon table load (one per table) and method execution, and 138 * allocated upon table load (one per table) and method execution, and
104 * they are released when a table is unloaded or a method completes 139 * they are released when a table is unloaded or a method completes
105 * execution. 140 * execution.
141 *
142 * If this error happens, there may be very deep nesting of invoked control
143 * methods, or there may be a bug where the IDs are not released.
106 */ 144 */
107 *owner_id = 0;
108 status = AE_OWNER_ID_LIMIT; 145 status = AE_OWNER_ID_LIMIT;
109 ACPI_REPORT_ERROR(("Could not allocate new owner_id (64 max), AE_OWNER_ID_LIMIT\n")); 146 ACPI_ERROR((AE_INFO,
147 "Could not allocate new owner_id (255 max), AE_OWNER_ID_LIMIT"));
110 148
111 exit: 149 exit:
112 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); 150 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
@@ -123,7 +161,7 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
123 * control method or unloading a table. Either way, we would 161 * control method or unloading a table. Either way, we would
124 * ignore any error anyway. 162 * ignore any error anyway.
125 * 163 *
126 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 64 164 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255
127 * 165 *
128 ******************************************************************************/ 166 ******************************************************************************/
129 167
@@ -131,6 +169,8 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
131{ 169{
132 acpi_owner_id owner_id = *owner_id_ptr; 170 acpi_owner_id owner_id = *owner_id_ptr;
133 acpi_status status; 171 acpi_status status;
172 acpi_native_uint index;
173 u32 bit;
134 174
135 ACPI_FUNCTION_TRACE_U32("ut_release_owner_id", owner_id); 175 ACPI_FUNCTION_TRACE_U32("ut_release_owner_id", owner_id);
136 176
@@ -140,8 +180,8 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
140 180
141 /* Zero is not a valid owner_iD */ 181 /* Zero is not a valid owner_iD */
142 182
143 if ((owner_id == 0) || (owner_id > 64)) { 183 if (owner_id == 0) {
144 ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id)); 184 ACPI_ERROR((AE_INFO, "Invalid owner_id: %2.2X", owner_id));
145 return_VOID; 185 return_VOID;
146 } 186 }
147 187
@@ -156,10 +196,19 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
156 196
157 owner_id--; 197 owner_id--;
158 198
199 /* Decode ID to index/offset pair */
200
201 index = ACPI_DIV_32(owner_id);
202 bit = 1 << ACPI_MOD_32(owner_id);
203
159 /* Free the owner ID only if it is valid */ 204 /* Free the owner ID only if it is valid */
160 205
161 if (acpi_gbl_owner_id_mask & (1ULL << owner_id)) { 206 if (acpi_gbl_owner_id_mask[index] & bit) {
162 acpi_gbl_owner_id_mask ^= (1ULL << owner_id); 207 acpi_gbl_owner_id_mask[index] ^= bit;
208 } else {
209 ACPI_ERROR((AE_INFO,
210 "Release of non-allocated owner_id: %2.2X",
211 owner_id + 1));
163 } 212 }
164 213
165 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); 214 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
@@ -790,109 +839,97 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length)
790 839
791/******************************************************************************* 840/*******************************************************************************
792 * 841 *
793 * FUNCTION: acpi_ut_get_resource_end_tag 842 * FUNCTION: acpi_ut_error, acpi_ut_warning, acpi_ut_info
794 * 843 *
795 * PARAMETERS: obj_desc - The resource template buffer object 844 * PARAMETERS: module_name - Caller's module name (for error output)
845 * line_number - Caller's line number (for error output)
846 * Format - Printf format string + additional args
796 * 847 *
797 * RETURN: Pointer to the end tag 848 * RETURN: None
798 * 849 *
799 * DESCRIPTION: Find the END_TAG resource descriptor in a resource template 850 * DESCRIPTION: Print message with module/line/version info
800 * 851 *
801 ******************************************************************************/ 852 ******************************************************************************/
802 853
803u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) 854void ACPI_INTERNAL_VAR_XFACE
855acpi_ut_error(char *module_name, u32 line_number, char *format, ...)
804{ 856{
805 u8 buffer_byte; 857 va_list args;
806 u8 *buffer;
807 u8 *end_buffer;
808 858
809 buffer = obj_desc->buffer.pointer; 859 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
810 end_buffer = buffer + obj_desc->buffer.length;
811 860
812 while (buffer < end_buffer) { 861 va_start(args, format);
813 buffer_byte = *buffer; 862 acpi_os_vprintf(format, args);
814 if (buffer_byte & ACPI_RDESC_TYPE_MASK) { 863 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
815 /* Large Descriptor - Length is next 2 bytes */ 864}
816 865
817 buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3); 866void ACPI_INTERNAL_VAR_XFACE
818 } else { 867acpi_ut_exception(char *module_name,
819 /* Small Descriptor. End Tag will be found here */ 868 u32 line_number, acpi_status status, char *format, ...)
869{
870 va_list args;
820 871
821 if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == 872 acpi_os_printf("ACPI Exception (%s-%04d): %s, ", module_name,
822 ACPI_RDESC_TYPE_END_TAG) { 873 line_number, acpi_format_exception(status));
823 /* Found the end tag descriptor, all done. */
824 874
825 return (buffer); 875 va_start(args, format);
826 } 876 acpi_os_vprintf(format, args);
877 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
878}
827 879
828 /* Length is in the header */ 880void ACPI_INTERNAL_VAR_XFACE
881acpi_ut_warning(char *module_name, u32 line_number, char *format, ...)
882{
883 va_list args;
829 884
830 buffer += ((buffer_byte & 0x07) + 1); 885 acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
831 } 886
832 } 887 va_start(args, format);
888 acpi_os_vprintf(format, args);
889 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
890}
891
892void ACPI_INTERNAL_VAR_XFACE
893acpi_ut_info(char *module_name, u32 line_number, char *format, ...)
894{
895 va_list args;
833 896
834 /* End tag not found */ 897 acpi_os_printf("ACPI (%s-%04d): ", module_name, line_number);
835 898
836 return (NULL); 899 va_start(args, format);
900 acpi_os_vprintf(format, args);
901 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
837} 902}
838 903
839/******************************************************************************* 904/*******************************************************************************
840 * 905 *
841 * FUNCTION: acpi_ut_report_error 906 * FUNCTION: acpi_ut_report_error, Warning, Info
842 * 907 *
843 * PARAMETERS: module_name - Caller's module name (for error output) 908 * PARAMETERS: module_name - Caller's module name (for error output)
844 * line_number - Caller's line number (for error output) 909 * line_number - Caller's line number (for error output)
845 * component_id - Caller's component ID (for error output)
846 * 910 *
847 * RETURN: None 911 * RETURN: None
848 * 912 *
849 * DESCRIPTION: Print error message 913 * DESCRIPTION: Print error message
850 * 914 *
915 * Note: Legacy only, should be removed when no longer used by drivers.
916 *
851 ******************************************************************************/ 917 ******************************************************************************/
852 918
853void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id) 919void acpi_ut_report_error(char *module_name, u32 line_number)
854{ 920{
855 921
856 acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number); 922 acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number);
857} 923}
858 924
859/******************************************************************************* 925void acpi_ut_report_warning(char *module_name, u32 line_number)
860 *
861 * FUNCTION: acpi_ut_report_warning
862 *
863 * PARAMETERS: module_name - Caller's module name (for error output)
864 * line_number - Caller's line number (for error output)
865 * component_id - Caller's component ID (for error output)
866 *
867 * RETURN: None
868 *
869 * DESCRIPTION: Print warning message
870 *
871 ******************************************************************************/
872
873void
874acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id)
875{ 926{
876 927
877 acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number); 928 acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number);
878} 929}
879 930
880/******************************************************************************* 931void acpi_ut_report_info(char *module_name, u32 line_number)
881 *
882 * FUNCTION: acpi_ut_report_info
883 *
884 * PARAMETERS: module_name - Caller's module name (for error output)
885 * line_number - Caller's line number (for error output)
886 * component_id - Caller's component ID (for error output)
887 *
888 * RETURN: None
889 *
890 * DESCRIPTION: Print information message
891 *
892 ******************************************************************************/
893
894void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id)
895{ 932{
896 933
897 acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number); 934 acpi_os_printf("ACPI (%s-%04d): ", module_name, line_number);
898} 935}
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
index 90134c56ece9..45a7244df924 100644
--- a/drivers/acpi/utilities/utmutex.c
+++ b/drivers/acpi/utilities/utmutex.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -214,23 +214,22 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
214 * the ACPI subsystem code. 214 * the ACPI subsystem code.
215 */ 215 */
216 for (i = mutex_id; i < MAX_MUTEX; i++) { 216 for (i = mutex_id; i < MAX_MUTEX; i++) {
217 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { 217 if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
218 if (i == mutex_id) { 218 if (i == mutex_id) {
219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 219 ACPI_ERROR((AE_INFO,
220 "Mutex [%s] already acquired by this thread [%X]\n", 220 "Mutex [%s] already acquired by this thread [%X]",
221 acpi_ut_get_mutex_name 221 acpi_ut_get_mutex_name
222 (mutex_id), 222 (mutex_id),
223 this_thread_id)); 223 this_thread_id));
224 224
225 return (AE_ALREADY_ACQUIRED); 225 return (AE_ALREADY_ACQUIRED);
226 } 226 }
227 227
228 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 228 ACPI_ERROR((AE_INFO,
229 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", 229 "Invalid acquire order: Thread %X owns [%s], wants [%s]",
230 this_thread_id, 230 this_thread_id,
231 acpi_ut_get_mutex_name(i), 231 acpi_ut_get_mutex_name(i),
232 acpi_ut_get_mutex_name 232 acpi_ut_get_mutex_name(mutex_id)));
233 (mutex_id)));
234 233
235 return (AE_ACQUIRE_DEADLOCK); 234 return (AE_ACQUIRE_DEADLOCK);
236 } 235 }
@@ -253,11 +252,9 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
253 acpi_gbl_mutex_info[mutex_id].use_count++; 252 acpi_gbl_mutex_info[mutex_id].use_count++;
254 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; 253 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
255 } else { 254 } else {
256 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 255 ACPI_EXCEPTION((AE_INFO, status,
257 "Thread %X could not acquire Mutex [%s] %s\n", 256 "Thread %X could not acquire Mutex [%X]",
258 this_thread_id, 257 this_thread_id, mutex_id));
259 acpi_ut_get_mutex_name(mutex_id),
260 acpi_format_exception(status)));
261 } 258 }
262 259
263 return (status); 260 return (status);
@@ -295,9 +292,9 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
295 * Mutex must be acquired in order to release it! 292 * Mutex must be acquired in order to release it!
296 */ 293 */
297 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) { 294 if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) {
298 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 295 ACPI_ERROR((AE_INFO,
299 "Mutex [%s] is not acquired, cannot release\n", 296 "Mutex [%X] is not acquired, cannot release",
300 acpi_ut_get_mutex_name(mutex_id))); 297 mutex_id));
301 298
302 return (AE_NOT_ACQUIRED); 299 return (AE_NOT_ACQUIRED);
303 } 300 }
@@ -313,16 +310,15 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
313 * the ACPI subsystem code. 310 * the ACPI subsystem code.
314 */ 311 */
315 for (i = mutex_id; i < MAX_MUTEX; i++) { 312 for (i = mutex_id; i < MAX_MUTEX; i++) {
316 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { 313 if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
317 if (i == mutex_id) { 314 if (i == mutex_id) {
318 continue; 315 continue;
319 } 316 }
320 317
321 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 318 ACPI_ERROR((AE_INFO,
322 "Invalid release order: owns [%s], releasing [%s]\n", 319 "Invalid release order: owns [%s], releasing [%s]",
323 acpi_ut_get_mutex_name(i), 320 acpi_ut_get_mutex_name(i),
324 acpi_ut_get_mutex_name 321 acpi_ut_get_mutex_name(mutex_id)));
325 (mutex_id)));
326 322
327 return (AE_RELEASE_DEADLOCK); 323 return (AE_RELEASE_DEADLOCK);
328 } 324 }
@@ -338,11 +334,9 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
338 acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1); 334 acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1);
339 335
340 if (ACPI_FAILURE(status)) { 336 if (ACPI_FAILURE(status)) {
341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 337 ACPI_EXCEPTION((AE_INFO, status,
342 "Thread %X could not release Mutex [%s] %s\n", 338 "Thread %X could not release Mutex [%X]",
343 this_thread_id, 339 this_thread_id, mutex_id));
344 acpi_ut_get_mutex_name(mutex_id),
345 acpi_format_exception(status)));
346 } else { 340 } else {
347 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 341 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
348 "Thread %X released Mutex [%s]\n", 342 "Thread %X released Mutex [%s]\n",
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
index 3015e1540053..7ee2d1d98071 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/utilities/utobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -177,7 +177,8 @@ union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size)
177 177
178 buffer = ACPI_MEM_CALLOCATE(buffer_size); 178 buffer = ACPI_MEM_CALLOCATE(buffer_size);
179 if (!buffer) { 179 if (!buffer) {
180 ACPI_REPORT_ERROR(("create_buffer: could not allocate size %X\n", (u32) buffer_size)); 180 ACPI_ERROR((AE_INFO, "Could not allocate size %X",
181 (u32) buffer_size));
181 acpi_ut_remove_reference(buffer_desc); 182 acpi_ut_remove_reference(buffer_desc);
182 return_PTR(NULL); 183 return_PTR(NULL);
183 } 184 }
@@ -228,7 +229,8 @@ union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size)
228 */ 229 */
229 string = ACPI_MEM_CALLOCATE(string_size + 1); 230 string = ACPI_MEM_CALLOCATE(string_size + 1);
230 if (!string) { 231 if (!string) {
231 ACPI_REPORT_ERROR(("create_string: could not allocate size %X\n", (u32) string_size)); 232 ACPI_ERROR((AE_INFO, "Could not allocate size %X",
233 (u32) string_size));
232 acpi_ut_remove_reference(string_desc); 234 acpi_ut_remove_reference(string_desc);
233 return_PTR(NULL); 235 return_PTR(NULL);
234 } 236 }
@@ -310,8 +312,8 @@ void *acpi_ut_allocate_object_desc_dbg(char *module_name,
310 312
311 object = acpi_os_acquire_object(acpi_gbl_operand_cache); 313 object = acpi_os_acquire_object(acpi_gbl_operand_cache);
312 if (!object) { 314 if (!object) {
313 _ACPI_REPORT_ERROR(module_name, line_number, component_id, 315 ACPI_ERROR((module_name, line_number,
314 ("Could not allocate an object descriptor\n")); 316 "Could not allocate an object descriptor"));
315 317
316 return_PTR(NULL); 318 return_PTR(NULL);
317 } 319 }
@@ -345,9 +347,9 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object)
345 /* Object must be an union acpi_operand_object */ 347 /* Object must be an union acpi_operand_object */
346 348
347 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { 349 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
348 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 350 ACPI_ERROR((AE_INFO,
349 "%p is not an ACPI Operand object [%s]\n", 351 "%p is not an ACPI Operand object [%s]", object,
350 object, acpi_ut_get_descriptor_name(object))); 352 acpi_ut_get_descriptor_name(object)));
351 return_VOID; 353 return_VOID;
352 } 354 }
353 355
@@ -449,10 +451,10 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
449 * Notably, Locals and Args are not supported, but this may be 451 * Notably, Locals and Args are not supported, but this may be
450 * required eventually. 452 * required eventually.
451 */ 453 */
452 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 454 ACPI_ERROR((AE_INFO,
453 "Unsupported Reference opcode=%X in object %p\n", 455 "Unsupported Reference opcode=%X in object %p",
454 internal_object->reference.opcode, 456 internal_object->reference.opcode,
455 internal_object)); 457 internal_object));
456 status = AE_TYPE; 458 status = AE_TYPE;
457 break; 459 break;
458 } 460 }
@@ -460,10 +462,9 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
460 462
461 default: 463 default:
462 464
463 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 465 ACPI_ERROR((AE_INFO, "Unsupported type=%X in object %p",
464 "Unsupported type=%X in object %p\n", 466 ACPI_GET_OBJECT_TYPE(internal_object),
465 ACPI_GET_OBJECT_TYPE(internal_object), 467 internal_object));
466 internal_object));
467 status = AE_TYPE; 468 status = AE_TYPE;
468 break; 469 break;
469 } 470 }
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c
new file mode 100644
index 000000000000..16461317113f
--- /dev/null
+++ b/drivers/acpi/utilities/utresrc.c
@@ -0,0 +1,554 @@
1/*******************************************************************************
2 *
3 * Module Name: utresrc - Resource managment utilities
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <acpi/amlresrc.h>
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utmisc")
49
50#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
51/*
52 * Strings used to decode resource descriptors.
53 * Used by both the disasssembler and the debugger resource dump routines
54 */
55const char *acpi_gbl_BMdecode[2] = {
56 "not_bus_master",
57 "bus_master"
58};
59
60const char *acpi_gbl_config_decode[4] = {
61 "0 - Good Configuration",
62 "1 - Acceptable Configuration",
63 "2 - Suboptimal Configuration",
64 "3 - ***Invalid Configuration***",
65};
66
67const char *acpi_gbl_consume_decode[2] = {
68 "resource_producer",
69 "resource_consumer"
70};
71
72const char *acpi_gbl_DECdecode[2] = {
73 "pos_decode",
74 "sub_decode"
75};
76
77const char *acpi_gbl_HEdecode[2] = {
78 "Level",
79 "Edge"
80};
81
82const char *acpi_gbl_io_decode[2] = {
83 "Decode10",
84 "Decode16"
85};
86
87const char *acpi_gbl_LLdecode[2] = {
88 "active_high",
89 "active_low"
90};
91
92const char *acpi_gbl_max_decode[2] = {
93 "max_not_fixed",
94 "max_fixed"
95};
96
97const char *acpi_gbl_MEMdecode[4] = {
98 "non_cacheable",
99 "Cacheable",
100 "write_combining",
101 "Prefetchable"
102};
103
104const char *acpi_gbl_min_decode[2] = {
105 "min_not_fixed",
106 "min_fixed"
107};
108
109const char *acpi_gbl_MTPdecode[4] = {
110 "address_range_memory",
111 "address_range_reserved",
112 "address_range_aCPI",
113 "address_range_nVS"
114};
115
116const char *acpi_gbl_RNGdecode[4] = {
117 "invalid_ranges",
118 "non_iSAonly_ranges",
119 "ISAonly_ranges",
120 "entire_range"
121};
122
123const char *acpi_gbl_RWdecode[2] = {
124 "read_only",
125 "read_write"
126};
127
128const char *acpi_gbl_SHRdecode[2] = {
129 "Exclusive",
130 "Shared"
131};
132
133const char *acpi_gbl_SIZdecode[4] = {
134 "Transfer8",
135 "Transfer8_16",
136 "Transfer16",
137 "invalid_size"
138};
139
140const char *acpi_gbl_TRSdecode[2] = {
141 "dense_translation",
142 "sparse_translation"
143};
144
145const char *acpi_gbl_TTPdecode[2] = {
146 "type_static",
147 "type_translation"
148};
149
150const char *acpi_gbl_TYPdecode[4] = {
151 "Compatibility",
152 "type_a",
153 "type_b",
154 "type_f"
155};
156
157#endif
158
159/*
160 * Base sizes of the raw AML resource descriptors, indexed by resource type.
161 * Zero indicates a reserved (and therefore invalid) resource type.
162 */
163const u8 acpi_gbl_resource_aml_sizes[] = {
164 /* Small descriptors */
165
166 0,
167 0,
168 0,
169 0,
170 ACPI_AML_SIZE_SMALL(struct aml_resource_irq),
171 ACPI_AML_SIZE_SMALL(struct aml_resource_dma),
172 ACPI_AML_SIZE_SMALL(struct aml_resource_start_dependent),
173 ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent),
174 ACPI_AML_SIZE_SMALL(struct aml_resource_io),
175 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io),
176 0,
177 0,
178 0,
179 0,
180 ACPI_AML_SIZE_SMALL(struct aml_resource_vendor_small),
181 ACPI_AML_SIZE_SMALL(struct aml_resource_end_tag),
182
183 /* Large descriptors */
184
185 0,
186 ACPI_AML_SIZE_LARGE(struct aml_resource_memory24),
187 ACPI_AML_SIZE_LARGE(struct aml_resource_generic_register),
188 0,
189 ACPI_AML_SIZE_LARGE(struct aml_resource_vendor_large),
190 ACPI_AML_SIZE_LARGE(struct aml_resource_memory32),
191 ACPI_AML_SIZE_LARGE(struct aml_resource_fixed_memory32),
192 ACPI_AML_SIZE_LARGE(struct aml_resource_address32),
193 ACPI_AML_SIZE_LARGE(struct aml_resource_address16),
194 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq),
195 ACPI_AML_SIZE_LARGE(struct aml_resource_address64),
196 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64)
197};
198
199/*
200 * Resource types, used to validate the resource length field.
201 * The length of fixed-length types must match exactly, variable
202 * lengths must meet the minimum required length, etc.
203 * Zero indicates a reserved (and therefore invalid) resource type.
204 */
205static const u8 acpi_gbl_resource_types[] = {
206 /* Small descriptors */
207
208 0,
209 0,
210 0,
211 0,
212 ACPI_SMALL_VARIABLE_LENGTH,
213 ACPI_FIXED_LENGTH,
214 ACPI_SMALL_VARIABLE_LENGTH,
215 ACPI_FIXED_LENGTH,
216 ACPI_FIXED_LENGTH,
217 ACPI_FIXED_LENGTH,
218 0,
219 0,
220 0,
221 0,
222 ACPI_VARIABLE_LENGTH,
223 ACPI_FIXED_LENGTH,
224
225 /* Large descriptors */
226
227 0,
228 ACPI_FIXED_LENGTH,
229 ACPI_FIXED_LENGTH,
230 0,
231 ACPI_VARIABLE_LENGTH,
232 ACPI_FIXED_LENGTH,
233 ACPI_FIXED_LENGTH,
234 ACPI_VARIABLE_LENGTH,
235 ACPI_VARIABLE_LENGTH,
236 ACPI_VARIABLE_LENGTH,
237 ACPI_VARIABLE_LENGTH,
238 ACPI_FIXED_LENGTH
239};
240
241/*******************************************************************************
242 *
243 * FUNCTION: acpi_ut_validate_resource
244 *
245 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
246 * return_index - Where the resource index is returned. NULL
247 * if the index is not required.
248 *
249 * RETURN: Status, and optionally the Index into the global resource tables
250 *
251 * DESCRIPTION: Validate an AML resource descriptor by checking the Resource
252 * Type and Resource Length. Returns an index into the global
253 * resource information/dispatch tables for later use.
254 *
255 ******************************************************************************/
256
257acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
258{
259 u8 resource_type;
260 u8 resource_index;
261 acpi_rs_length resource_length;
262 acpi_rs_length minimum_resource_length;
263
264 ACPI_FUNCTION_ENTRY();
265
266 /*
267 * 1) Validate the resource_type field (Byte 0)
268 */
269 resource_type = ACPI_GET8(aml);
270
271 /*
272 * Byte 0 contains the descriptor name (Resource Type)
273 * Examine the large/small bit in the resource header
274 */
275 if (resource_type & ACPI_RESOURCE_NAME_LARGE) {
276 /* Verify the large resource type (name) against the max */
277
278 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
279 return (AE_AML_INVALID_RESOURCE_TYPE);
280 }
281
282 /*
283 * Large Resource Type -- bits 6:0 contain the name
284 * Translate range 0x80-0x8B to index range 0x10-0x1B
285 */
286 resource_index = (u8) (resource_type - 0x70);
287 } else {
288 /*
289 * Small Resource Type -- bits 6:3 contain the name
290 * Shift range to index range 0x00-0x0F
291 */
292 resource_index = (u8)
293 ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
294 }
295
296 /* Check validity of the resource type, zero indicates name is invalid */
297
298 if (!acpi_gbl_resource_types[resource_index]) {
299 return (AE_AML_INVALID_RESOURCE_TYPE);
300 }
301
302 /*
303 * 2) Validate the resource_length field. This ensures that the length
304 * is at least reasonable, and guarantees that it is non-zero.
305 */
306 resource_length = acpi_ut_get_resource_length(aml);
307 minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index];
308
309 /* Validate based upon the type of resource - fixed length or variable */
310
311 switch (acpi_gbl_resource_types[resource_index]) {
312 case ACPI_FIXED_LENGTH:
313
314 /* Fixed length resource, length must match exactly */
315
316 if (resource_length != minimum_resource_length) {
317 return (AE_AML_BAD_RESOURCE_LENGTH);
318 }
319 break;
320
321 case ACPI_VARIABLE_LENGTH:
322
323 /* Variable length resource, length must be at least the minimum */
324
325 if (resource_length < minimum_resource_length) {
326 return (AE_AML_BAD_RESOURCE_LENGTH);
327 }
328 break;
329
330 case ACPI_SMALL_VARIABLE_LENGTH:
331
332 /* Small variable length resource, length can be (Min) or (Min-1) */
333
334 if ((resource_length > minimum_resource_length) ||
335 (resource_length < (minimum_resource_length - 1))) {
336 return (AE_AML_BAD_RESOURCE_LENGTH);
337 }
338 break;
339
340 default:
341
342 /* Shouldn't happen (because of validation earlier), but be sure */
343
344 return (AE_AML_INVALID_RESOURCE_TYPE);
345 }
346
347 /* Optionally return the resource table index */
348
349 if (return_index) {
350 *return_index = resource_index;
351 }
352
353 return (AE_OK);
354}
355
356/*******************************************************************************
357 *
358 * FUNCTION: acpi_ut_get_resource_type
359 *
360 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
361 *
362 * RETURN: The Resource Type with no extraneous bits (except the
363 * Large/Small descriptor bit -- this is left alone)
364 *
365 * DESCRIPTION: Extract the Resource Type/Name from the first byte of
366 * a resource descriptor.
367 *
368 ******************************************************************************/
369
370u8 acpi_ut_get_resource_type(void *aml)
371{
372 ACPI_FUNCTION_ENTRY();
373
374 /*
375 * Byte 0 contains the descriptor name (Resource Type)
376 * Examine the large/small bit in the resource header
377 */
378 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
379 /* Large Resource Type -- bits 6:0 contain the name */
380
381 return (ACPI_GET8(aml));
382 } else {
383 /* Small Resource Type -- bits 6:3 contain the name */
384
385 return ((u8) (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
386 }
387}
388
389/*******************************************************************************
390 *
391 * FUNCTION: acpi_ut_get_resource_length
392 *
393 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
394 *
395 * RETURN: Byte Length
396 *
397 * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
398 * definition, this does not include the size of the descriptor
399 * header or the length field itself.
400 *
401 ******************************************************************************/
402
403u16 acpi_ut_get_resource_length(void *aml)
404{
405 acpi_rs_length resource_length;
406
407 ACPI_FUNCTION_ENTRY();
408
409 /*
410 * Byte 0 contains the descriptor name (Resource Type)
411 * Examine the large/small bit in the resource header
412 */
413 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
414 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
415
416 ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1));
417
418 } else {
419 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
420
421 resource_length = (u16) (ACPI_GET8(aml) &
422 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
423 }
424
425 return (resource_length);
426}
427
428/*******************************************************************************
429 *
430 * FUNCTION: acpi_ut_get_resource_header_length
431 *
432 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
433 *
434 * RETURN: Length of the AML header (depends on large/small descriptor)
435 *
436 * DESCRIPTION: Get the length of the header for this resource.
437 *
438 ******************************************************************************/
439
440u8 acpi_ut_get_resource_header_length(void *aml)
441{
442 ACPI_FUNCTION_ENTRY();
443
444 /* Examine the large/small bit in the resource header */
445
446 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
447 return (sizeof(struct aml_resource_large_header));
448 } else {
449 return (sizeof(struct aml_resource_small_header));
450 }
451}
452
453/*******************************************************************************
454 *
455 * FUNCTION: acpi_ut_get_descriptor_length
456 *
457 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
458 *
459 * RETURN: Byte length
460 *
461 * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
462 * length of the descriptor header and the length field itself.
463 * Used to walk descriptor lists.
464 *
465 ******************************************************************************/
466
467u32 acpi_ut_get_descriptor_length(void *aml)
468{
469 ACPI_FUNCTION_ENTRY();
470
471 /*
472 * Get the Resource Length (does not include header length) and add
473 * the header length (depends on if this is a small or large resource)
474 */
475 return (acpi_ut_get_resource_length(aml) +
476 acpi_ut_get_resource_header_length(aml));
477}
478
479/*******************************************************************************
480 *
481 * FUNCTION: acpi_ut_get_resource_end_tag
482 *
483 * PARAMETERS: obj_desc - The resource template buffer object
484 * end_tag - Where the pointer to the end_tag is returned
485 *
486 * RETURN: Status, pointer to the end tag
487 *
488 * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template
489 * Note: allows a buffer length of zero.
490 *
491 ******************************************************************************/
492
493acpi_status
494acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
495 u8 ** end_tag)
496{
497 acpi_status status;
498 u8 *aml;
499 u8 *end_aml;
500
501 ACPI_FUNCTION_TRACE("ut_get_resource_end_tag");
502
503 /* Get start and end pointers */
504
505 aml = obj_desc->buffer.pointer;
506 end_aml = aml + obj_desc->buffer.length;
507
508 /* Allow a buffer length of zero */
509
510 if (!obj_desc->buffer.length) {
511 *end_tag = aml;
512 return_ACPI_STATUS(AE_OK);
513 }
514
515 /* Walk the resource template, one descriptor per iteration */
516
517 while (aml < end_aml) {
518 /* Validate the Resource Type and Resource Length */
519
520 status = acpi_ut_validate_resource(aml, NULL);
521 if (ACPI_FAILURE(status)) {
522 return_ACPI_STATUS(status);
523 }
524
525 /* end_tag resource indicates the end of the resource template */
526
527 if (acpi_ut_get_resource_type(aml) ==
528 ACPI_RESOURCE_NAME_END_TAG) {
529 /*
530 * There must be at least one more byte in the buffer for
531 * the 2nd byte of the end_tag
532 */
533 if ((aml + 1) >= end_aml) {
534 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
535 }
536
537 /* Return the pointer to the end_tag */
538
539 *end_tag = aml;
540 return_ACPI_STATUS(AE_OK);
541 }
542
543 /*
544 * Point to the next resource descriptor in the AML buffer. The
545 * descriptor length is guaranteed to be non-zero by resource
546 * validation above.
547 */
548 aml += acpi_ut_get_descriptor_length(aml);
549 }
550
551 /* Did not find an end_tag resource descriptor */
552
553 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
554}
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c
index c1cb27583be8..4b134a722907 100644
--- a/drivers/acpi/utilities/utstate.c
+++ b/drivers/acpi/utilities/utstate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -63,7 +63,7 @@ acpi_status
63acpi_ut_create_pkg_state_and_push(void *internal_object, 63acpi_ut_create_pkg_state_and_push(void *internal_object,
64 void *external_object, 64 void *external_object,
65 u16 index, 65 u16 index,
66 union acpi_generic_state ** state_list) 66 union acpi_generic_state **state_list)
67{ 67{
68 union acpi_generic_state *state; 68 union acpi_generic_state *state;
69 69
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index f06bd5e5e9d1..308a960871be 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -75,8 +75,7 @@ acpi_status acpi_initialize_subsystem(void)
75 75
76 status = acpi_os_initialize(); 76 status = acpi_os_initialize();
77 if (ACPI_FAILURE(status)) { 77 if (ACPI_FAILURE(status)) {
78 ACPI_REPORT_ERROR(("OSD failed to initialize, %s\n", 78 ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
79 acpi_format_exception(status)));
80 return_ACPI_STATUS(status); 79 return_ACPI_STATUS(status);
81 } 80 }
82 81
@@ -88,8 +87,8 @@ acpi_status acpi_initialize_subsystem(void)
88 87
89 status = acpi_ut_mutex_initialize(); 88 status = acpi_ut_mutex_initialize();
90 if (ACPI_FAILURE(status)) { 89 if (ACPI_FAILURE(status)) {
91 ACPI_REPORT_ERROR(("Global mutex creation failure, %s\n", 90 ACPI_EXCEPTION((AE_INFO, status,
92 acpi_format_exception(status))); 91 "During Global Mutex creation"));
93 return_ACPI_STATUS(status); 92 return_ACPI_STATUS(status);
94 } 93 }
95 94
@@ -99,15 +98,14 @@ acpi_status acpi_initialize_subsystem(void)
99 */ 98 */
100 status = acpi_ns_root_initialize(); 99 status = acpi_ns_root_initialize();
101 if (ACPI_FAILURE(status)) { 100 if (ACPI_FAILURE(status)) {
102 ACPI_REPORT_ERROR(("Namespace initialization failure, %s\n", 101 ACPI_EXCEPTION((AE_INFO, status,
103 acpi_format_exception(status))); 102 "During Namespace initialization"));
104 return_ACPI_STATUS(status); 103 return_ACPI_STATUS(status);
105 } 104 }
106 105
107 /* If configured, initialize the AML debugger */ 106 /* If configured, initialize the AML debugger */
108 107
109 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize()); 108 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
110
111 return_ACPI_STATUS(status); 109 return_ACPI_STATUS(status);
112} 110}
113 111
@@ -154,8 +152,7 @@ acpi_status acpi_enable_subsystem(u32 flags)
154 152
155 status = acpi_enable(); 153 status = acpi_enable();
156 if (ACPI_FAILURE(status)) { 154 if (ACPI_FAILURE(status)) {
157 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 155 ACPI_WARNING((AE_INFO, "acpi_enable failed"));
158 "acpi_enable failed.\n"));
159 return_ACPI_STATUS(status); 156 return_ACPI_STATUS(status);
160 } 157 }
161 } 158 }
@@ -178,10 +175,14 @@ acpi_status acpi_enable_subsystem(u32 flags)
178 /* 175 /*
179 * Initialize ACPI Event handling (Fixed and General Purpose) 176 * Initialize ACPI Event handling (Fixed and General Purpose)
180 * 177 *
181 * NOTE: We must have the hardware AND events initialized before we can 178 * Note1: We must have the hardware and events initialized before we can
182 * execute ANY control methods SAFELY. Any control method can require 179 * execute any control methods safely. Any control method can require
183 * ACPI hardware support, so the hardware MUST be initialized before 180 * ACPI hardware support, so the hardware must be fully initialized before
184 * execution! 181 * any method execution!
182 *
183 * Note2: Fixed events are initialized and enabled here. GPEs are
184 * initialized, but cannot be enabled until after the hardware is
185 * completely initialized (SCI and global_lock activated)
185 */ 186 */
186 if (!(flags & ACPI_NO_EVENT_INIT)) { 187 if (!(flags & ACPI_NO_EVENT_INIT)) {
187 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 188 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
@@ -193,8 +194,10 @@ acpi_status acpi_enable_subsystem(u32 flags)
193 } 194 }
194 } 195 }
195 196
196 /* Install the SCI handler and Global Lock handler */ 197 /*
197 198 * Install the SCI handler and Global Lock handler. This completes the
199 * hardware initialization.
200 */
198 if (!(flags & ACPI_NO_HANDLER_INIT)) { 201 if (!(flags & ACPI_NO_HANDLER_INIT)) {
199 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 202 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
200 "[Init] Installing SCI/GL handlers\n")); 203 "[Init] Installing SCI/GL handlers\n"));
@@ -205,6 +208,24 @@ acpi_status acpi_enable_subsystem(u32 flags)
205 } 208 }
206 } 209 }
207 210
211 /*
212 * Complete the GPE initialization for the GPE blocks defined in the FADT
213 * (GPE block 0 and 1).
214 *
215 * Note1: This is where the _PRW methods are executed for the GPEs. These
216 * methods can only be executed after the SCI and Global Lock handlers are
217 * installed and initialized.
218 *
219 * Note2: Currently, there seems to be no need to run the _REG methods
220 * before execution of the _PRW methods and enabling of the GPEs.
221 */
222 if (!(flags & ACPI_NO_EVENT_INIT)) {
223 status = acpi_ev_install_fadt_gpes();
224 if (ACPI_FAILURE(status)) {
225 return (status);
226 }
227 }
228
208 return_ACPI_STATUS(status); 229 return_ACPI_STATUS(status);
209} 230}
210 231
@@ -230,9 +251,9 @@ acpi_status acpi_initialize_objects(u32 flags)
230 /* 251 /*
231 * Run all _REG methods 252 * Run all _REG methods
232 * 253 *
233 * NOTE: Any objects accessed 254 * Note: Any objects accessed by the _REG methods will be automatically
234 * by the _REG methods will be automatically initialized, even if they 255 * initialized, even if they contain executable AML (see the call to
235 * contain executable AML (see call to acpi_ns_initialize_objects below). 256 * acpi_ns_initialize_objects below).
236 */ 257 */
237 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { 258 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
238 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 259 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
@@ -245,9 +266,9 @@ acpi_status acpi_initialize_objects(u32 flags)
245 } 266 }
246 267
247 /* 268 /*
248 * Initialize the objects that remain uninitialized. This 269 * Initialize the objects that remain uninitialized. This runs the
249 * runs the executable AML that may be part of the declaration of these 270 * executable AML that may be part of the declaration of these objects:
250 * objects: operation_regions, buffer_fields, Buffers, and Packages. 271 * operation_regions, buffer_fields, Buffers, and Packages.
251 */ 272 */
252 if (!(flags & ACPI_NO_OBJECT_INIT)) { 273 if (!(flags & ACPI_NO_OBJECT_INIT)) {
253 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 274 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
@@ -260,8 +281,8 @@ acpi_status acpi_initialize_objects(u32 flags)
260 } 281 }
261 282
262 /* 283 /*
263 * Initialize all device objects in the namespace 284 * Initialize all device objects in the namespace. This runs the device
264 * This runs the _STA and _INI methods. 285 * _STA and _INI methods.
265 */ 286 */
266 if (!(flags & ACPI_NO_DEVICE_INIT)) { 287 if (!(flags & ACPI_NO_DEVICE_INIT)) {
267 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 288 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index d10668f14699..bd4887518373 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -920,8 +920,8 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
920 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 920 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
921 "Unable to create 'state' fs entry\n")); 921 "Unable to create 'state' fs entry\n"));
922 else { 922 else {
923 acpi_video_device_state_fops.write = acpi_video_device_write_state;
923 entry->proc_fops = &acpi_video_device_state_fops; 924 entry->proc_fops = &acpi_video_device_state_fops;
924 entry->proc_fops->write = acpi_video_device_write_state;
925 entry->data = acpi_driver_data(device); 925 entry->data = acpi_driver_data(device);
926 entry->owner = THIS_MODULE; 926 entry->owner = THIS_MODULE;
927 } 927 }
@@ -934,8 +934,8 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
934 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 934 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
935 "Unable to create 'brightness' fs entry\n")); 935 "Unable to create 'brightness' fs entry\n"));
936 else { 936 else {
937 acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
937 entry->proc_fops = &acpi_video_device_brightness_fops; 938 entry->proc_fops = &acpi_video_device_brightness_fops;
938 entry->proc_fops->write = acpi_video_device_write_brightness;
939 entry->data = acpi_driver_data(device); 939 entry->data = acpi_driver_data(device);
940 entry->owner = THIS_MODULE; 940 entry->owner = THIS_MODULE;
941 } 941 }
@@ -1239,8 +1239,8 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1240 "Unable to create 'POST' fs entry\n")); 1240 "Unable to create 'POST' fs entry\n"));
1241 else { 1241 else {
1242 acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
1242 entry->proc_fops = &acpi_video_bus_POST_fops; 1243 entry->proc_fops = &acpi_video_bus_POST_fops;
1243 entry->proc_fops->write = acpi_video_bus_write_POST;
1244 entry->data = acpi_driver_data(device); 1244 entry->data = acpi_driver_data(device);
1245 entry->owner = THIS_MODULE; 1245 entry->owner = THIS_MODULE;
1246 } 1246 }
@@ -1253,8 +1253,8 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1254 "Unable to create 'DOS' fs entry\n")); 1254 "Unable to create 'DOS' fs entry\n"));
1255 else { 1255 else {
1256 acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
1256 entry->proc_fops = &acpi_video_bus_DOS_fops; 1257 entry->proc_fops = &acpi_video_bus_DOS_fops;
1257 entry->proc_fops->write = acpi_video_bus_write_DOS;
1258 entry->data = acpi_driver_data(device); 1258 entry->data = acpi_driver_data(device);
1259 entry->owner = THIS_MODULE; 1259 entry->owner = THIS_MODULE;
1260 } 1260 }
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index f12898d53078..e99471d3232b 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -8,6 +8,7 @@ obj-y += power/
8obj-$(CONFIG_FW_LOADER) += firmware_class.o 8obj-$(CONFIG_FW_LOADER) += firmware_class.o
9obj-$(CONFIG_NUMA) += node.o 9obj-$(CONFIG_NUMA) += node.o
10obj-$(CONFIG_MEMORY_HOTPLUG) += memory.o 10obj-$(CONFIG_MEMORY_HOTPLUG) += memory.o
11obj-$(CONFIG_SMP) += topology.o
11 12
12ifeq ($(CONFIG_DEBUG_DRIVER),y) 13ifeq ($(CONFIG_DEBUG_DRIVER),y)
13EXTRA_CFLAGS += -DDEBUG 14EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
new file mode 100644
index 000000000000..915810f6237e
--- /dev/null
+++ b/drivers/base/topology.c
@@ -0,0 +1,148 @@
1/*
2 * driver/base/topology.c - Populate sysfs with cpu topology information
3 *
4 * Written by: Zhang Yanmin, Intel Corporation
5 *
6 * Copyright (C) 2006, Intel Corp.
7 *
8 * All rights reserved.
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 as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 */
26#include <linux/sysdev.h>
27#include <linux/init.h>
28#include <linux/mm.h>
29#include <linux/cpu.h>
30#include <linux/module.h>
31#include <linux/topology.h>
32
33#define define_one_ro(_name) \
34static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
35
36#define define_id_show_func(name) \
37static ssize_t show_##name(struct sys_device *dev, char *buf) \
38{ \
39 unsigned int cpu = dev->id; \
40 return sprintf(buf, "%d\n", topology_##name(cpu)); \
41}
42
43#define define_siblings_show_func(name) \
44static ssize_t show_##name(struct sys_device *dev, char *buf) \
45{ \
46 ssize_t len = -1; \
47 unsigned int cpu = dev->id; \
48 len = cpumask_scnprintf(buf, NR_CPUS+1, topology_##name(cpu)); \
49 return (len + sprintf(buf + len, "\n")); \
50}
51
52#ifdef topology_physical_package_id
53define_id_show_func(physical_package_id);
54define_one_ro(physical_package_id);
55#define ref_physical_package_id_attr &attr_physical_package_id.attr,
56#else
57#define ref_physical_package_id_attr
58#endif
59
60#ifdef topology_core_id
61define_id_show_func(core_id);
62define_one_ro(core_id);
63#define ref_core_id_attr &attr_core_id.attr,
64#else
65#define ref_core_id_attr
66#endif
67
68#ifdef topology_thread_siblings
69define_siblings_show_func(thread_siblings);
70define_one_ro(thread_siblings);
71#define ref_thread_siblings_attr &attr_thread_siblings.attr,
72#else
73#define ref_thread_siblings_attr
74#endif
75
76#ifdef topology_core_siblings
77define_siblings_show_func(core_siblings);
78define_one_ro(core_siblings);
79#define ref_core_siblings_attr &attr_core_siblings.attr,
80#else
81#define ref_core_siblings_attr
82#endif
83
84static struct attribute *default_attrs[] = {
85 ref_physical_package_id_attr
86 ref_core_id_attr
87 ref_thread_siblings_attr
88 ref_core_siblings_attr
89 NULL
90};
91
92static struct attribute_group topology_attr_group = {
93 .attrs = default_attrs,
94 .name = "topology"
95};
96
97/* Add/Remove cpu_topology interface for CPU device */
98static int __cpuinit topology_add_dev(struct sys_device * sys_dev)
99{
100 sysfs_create_group(&sys_dev->kobj, &topology_attr_group);
101 return 0;
102}
103
104static int __cpuinit topology_remove_dev(struct sys_device * sys_dev)
105{
106 sysfs_remove_group(&sys_dev->kobj, &topology_attr_group);
107 return 0;
108}
109
110static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
111 unsigned long action, void *hcpu)
112{
113 unsigned int cpu = (unsigned long)hcpu;
114 struct sys_device *sys_dev;
115
116 sys_dev = get_cpu_sysdev(cpu);
117 switch (action) {
118 case CPU_ONLINE:
119 topology_add_dev(sys_dev);
120 break;
121 case CPU_DEAD:
122 topology_remove_dev(sys_dev);
123 break;
124 }
125 return NOTIFY_OK;
126}
127
128static struct notifier_block topology_cpu_notifier =
129{
130 .notifier_call = topology_cpu_callback,
131};
132
133static int __cpuinit topology_sysfs_init(void)
134{
135 int i;
136
137 for_each_online_cpu(i) {
138 topology_cpu_callback(&topology_cpu_notifier, CPU_ONLINE,
139 (void *)(long)i);
140 }
141
142 register_cpu_notifier(&topology_cpu_notifier);
143
144 return 0;
145}
146
147device_initcall(topology_sysfs_init);
148
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 139cbba76180..8b1331677407 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -433,12 +433,12 @@ config CDROM_PKTCDVD_BUFFERS
433 This controls the maximum number of active concurrent packets. More 433 This controls the maximum number of active concurrent packets. More
434 concurrent packets can increase write performance, but also require 434 concurrent packets can increase write performance, but also require
435 more memory. Each concurrent packet will require approximately 64Kb 435 more memory. Each concurrent packet will require approximately 64Kb
436 of non-swappable kernel memory, memory which will be allocated at 436 of non-swappable kernel memory, memory which will be allocated when
437 pktsetup time. 437 a disc is opened for writing.
438 438
439config CDROM_PKTCDVD_WCACHE 439config CDROM_PKTCDVD_WCACHE
440 bool "Enable write caching" 440 bool "Enable write caching (EXPERIMENTAL)"
441 depends on CDROM_PKTCDVD 441 depends on CDROM_PKTCDVD && EXPERIMENTAL
442 help 442 help
443 If enabled, write caching will be set for the CD-R/W device. For now 443 If enabled, write caching will be set for the CD-R/W device. For now
444 this option is dangerous unless the CD-RW media is known good, as we 444 this option is dangerous unless the CD-RW media is known good, as we
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 93affeeef7bd..4e7dbcc425ff 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -43,8 +43,6 @@
43 * 43 *
44 *************************************************************************/ 44 *************************************************************************/
45 45
46#define VERSION_CODE "v0.2.0a 2004-07-14 Jens Axboe (axboe@suse.de) and petero2@telia.com"
47
48#include <linux/pktcdvd.h> 46#include <linux/pktcdvd.h>
49#include <linux/config.h> 47#include <linux/config.h>
50#include <linux/module.h> 48#include <linux/module.h>
@@ -131,7 +129,7 @@ static struct bio *pkt_bio_alloc(int nr_iovecs)
131/* 129/*
132 * Allocate a packet_data struct 130 * Allocate a packet_data struct
133 */ 131 */
134static struct packet_data *pkt_alloc_packet_data(void) 132static struct packet_data *pkt_alloc_packet_data(int frames)
135{ 133{
136 int i; 134 int i;
137 struct packet_data *pkt; 135 struct packet_data *pkt;
@@ -140,11 +138,12 @@ static struct packet_data *pkt_alloc_packet_data(void)
140 if (!pkt) 138 if (!pkt)
141 goto no_pkt; 139 goto no_pkt;
142 140
143 pkt->w_bio = pkt_bio_alloc(PACKET_MAX_SIZE); 141 pkt->frames = frames;
142 pkt->w_bio = pkt_bio_alloc(frames);
144 if (!pkt->w_bio) 143 if (!pkt->w_bio)
145 goto no_bio; 144 goto no_bio;
146 145
147 for (i = 0; i < PAGES_PER_PACKET; i++) { 146 for (i = 0; i < frames / FRAMES_PER_PAGE; i++) {
148 pkt->pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO); 147 pkt->pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO);
149 if (!pkt->pages[i]) 148 if (!pkt->pages[i])
150 goto no_page; 149 goto no_page;
@@ -152,7 +151,7 @@ static struct packet_data *pkt_alloc_packet_data(void)
152 151
153 spin_lock_init(&pkt->lock); 152 spin_lock_init(&pkt->lock);
154 153
155 for (i = 0; i < PACKET_MAX_SIZE; i++) { 154 for (i = 0; i < frames; i++) {
156 struct bio *bio = pkt_bio_alloc(1); 155 struct bio *bio = pkt_bio_alloc(1);
157 if (!bio) 156 if (!bio)
158 goto no_rd_bio; 157 goto no_rd_bio;
@@ -162,14 +161,14 @@ static struct packet_data *pkt_alloc_packet_data(void)
162 return pkt; 161 return pkt;
163 162
164no_rd_bio: 163no_rd_bio:
165 for (i = 0; i < PACKET_MAX_SIZE; i++) { 164 for (i = 0; i < frames; i++) {
166 struct bio *bio = pkt->r_bios[i]; 165 struct bio *bio = pkt->r_bios[i];
167 if (bio) 166 if (bio)
168 bio_put(bio); 167 bio_put(bio);
169 } 168 }
170 169
171no_page: 170no_page:
172 for (i = 0; i < PAGES_PER_PACKET; i++) 171 for (i = 0; i < frames / FRAMES_PER_PAGE; i++)
173 if (pkt->pages[i]) 172 if (pkt->pages[i])
174 __free_page(pkt->pages[i]); 173 __free_page(pkt->pages[i]);
175 bio_put(pkt->w_bio); 174 bio_put(pkt->w_bio);
@@ -186,12 +185,12 @@ static void pkt_free_packet_data(struct packet_data *pkt)
186{ 185{
187 int i; 186 int i;
188 187
189 for (i = 0; i < PACKET_MAX_SIZE; i++) { 188 for (i = 0; i < pkt->frames; i++) {
190 struct bio *bio = pkt->r_bios[i]; 189 struct bio *bio = pkt->r_bios[i];
191 if (bio) 190 if (bio)
192 bio_put(bio); 191 bio_put(bio);
193 } 192 }
194 for (i = 0; i < PAGES_PER_PACKET; i++) 193 for (i = 0; i < pkt->frames / FRAMES_PER_PAGE; i++)
195 __free_page(pkt->pages[i]); 194 __free_page(pkt->pages[i]);
196 bio_put(pkt->w_bio); 195 bio_put(pkt->w_bio);
197 kfree(pkt); 196 kfree(pkt);
@@ -206,17 +205,17 @@ static void pkt_shrink_pktlist(struct pktcdvd_device *pd)
206 list_for_each_entry_safe(pkt, next, &pd->cdrw.pkt_free_list, list) { 205 list_for_each_entry_safe(pkt, next, &pd->cdrw.pkt_free_list, list) {
207 pkt_free_packet_data(pkt); 206 pkt_free_packet_data(pkt);
208 } 207 }
208 INIT_LIST_HEAD(&pd->cdrw.pkt_free_list);
209} 209}
210 210
211static int pkt_grow_pktlist(struct pktcdvd_device *pd, int nr_packets) 211static int pkt_grow_pktlist(struct pktcdvd_device *pd, int nr_packets)
212{ 212{
213 struct packet_data *pkt; 213 struct packet_data *pkt;
214 214
215 INIT_LIST_HEAD(&pd->cdrw.pkt_free_list); 215 BUG_ON(!list_empty(&pd->cdrw.pkt_free_list));
216 INIT_LIST_HEAD(&pd->cdrw.pkt_active_list); 216
217 spin_lock_init(&pd->cdrw.active_list_lock);
218 while (nr_packets > 0) { 217 while (nr_packets > 0) {
219 pkt = pkt_alloc_packet_data(); 218 pkt = pkt_alloc_packet_data(pd->settings.size >> 2);
220 if (!pkt) { 219 if (!pkt) {
221 pkt_shrink_pktlist(pd); 220 pkt_shrink_pktlist(pd);
222 return 0; 221 return 0;
@@ -951,7 +950,7 @@ try_next_bio:
951 950
952 pd->current_sector = zone + pd->settings.size; 951 pd->current_sector = zone + pd->settings.size;
953 pkt->sector = zone; 952 pkt->sector = zone;
954 pkt->frames = pd->settings.size >> 2; 953 BUG_ON(pkt->frames != pd->settings.size >> 2);
955 pkt->write_size = 0; 954 pkt->write_size = 0;
956 955
957 /* 956 /*
@@ -1639,7 +1638,7 @@ static int pkt_probe_settings(struct pktcdvd_device *pd)
1639 pd->settings.size = be32_to_cpu(ti.fixed_packet_size) << 2; 1638 pd->settings.size = be32_to_cpu(ti.fixed_packet_size) << 2;
1640 if (pd->settings.size == 0) { 1639 if (pd->settings.size == 0) {
1641 printk("pktcdvd: detected zero packet size!\n"); 1640 printk("pktcdvd: detected zero packet size!\n");
1642 pd->settings.size = 128; 1641 return -ENXIO;
1643 } 1642 }
1644 if (pd->settings.size > PACKET_MAX_SECTORS) { 1643 if (pd->settings.size > PACKET_MAX_SECTORS) {
1645 printk("pktcdvd: packet size is too big\n"); 1644 printk("pktcdvd: packet size is too big\n");
@@ -1987,8 +1986,14 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write)
1987 if ((ret = pkt_set_segment_merging(pd, q))) 1986 if ((ret = pkt_set_segment_merging(pd, q)))
1988 goto out_unclaim; 1987 goto out_unclaim;
1989 1988
1990 if (write) 1989 if (write) {
1990 if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) {
1991 printk("pktcdvd: not enough memory for buffers\n");
1992 ret = -ENOMEM;
1993 goto out_unclaim;
1994 }
1991 printk("pktcdvd: %lukB available on disc\n", lba << 1); 1995 printk("pktcdvd: %lukB available on disc\n", lba << 1);
1996 }
1992 1997
1993 return 0; 1998 return 0;
1994 1999
@@ -2014,6 +2019,8 @@ static void pkt_release_dev(struct pktcdvd_device *pd, int flush)
2014 pkt_set_speed(pd, MAX_SPEED, MAX_SPEED); 2019 pkt_set_speed(pd, MAX_SPEED, MAX_SPEED);
2015 bd_release(pd->bdev); 2020 bd_release(pd->bdev);
2016 blkdev_put(pd->bdev); 2021 blkdev_put(pd->bdev);
2022
2023 pkt_shrink_pktlist(pd);
2017} 2024}
2018 2025
2019static struct pktcdvd_device *pkt_find_dev_from_minor(int dev_minor) 2026static struct pktcdvd_device *pkt_find_dev_from_minor(int dev_minor)
@@ -2379,12 +2386,6 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
2379 /* This is safe, since we have a reference from open(). */ 2386 /* This is safe, since we have a reference from open(). */
2380 __module_get(THIS_MODULE); 2387 __module_get(THIS_MODULE);
2381 2388
2382 if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) {
2383 printk("pktcdvd: not enough memory for buffers\n");
2384 ret = -ENOMEM;
2385 goto out_mem;
2386 }
2387
2388 pd->bdev = bdev; 2389 pd->bdev = bdev;
2389 set_blocksize(bdev, CD_FRAMESIZE); 2390 set_blocksize(bdev, CD_FRAMESIZE);
2390 2391
@@ -2395,7 +2396,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
2395 if (IS_ERR(pd->cdrw.thread)) { 2396 if (IS_ERR(pd->cdrw.thread)) {
2396 printk("pktcdvd: can't start kernel thread\n"); 2397 printk("pktcdvd: can't start kernel thread\n");
2397 ret = -ENOMEM; 2398 ret = -ENOMEM;
2398 goto out_thread; 2399 goto out_mem;
2399 } 2400 }
2400 2401
2401 proc = create_proc_entry(pd->name, 0, pkt_proc); 2402 proc = create_proc_entry(pd->name, 0, pkt_proc);
@@ -2406,8 +2407,6 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
2406 DPRINTK("pktcdvd: writer %s mapped to %s\n", pd->name, bdevname(bdev, b)); 2407 DPRINTK("pktcdvd: writer %s mapped to %s\n", pd->name, bdevname(bdev, b));
2407 return 0; 2408 return 0;
2408 2409
2409out_thread:
2410 pkt_shrink_pktlist(pd);
2411out_mem: 2410out_mem:
2412 blkdev_put(bdev); 2411 blkdev_put(bdev);
2413 /* This is safe: open() is still holding a reference. */ 2412 /* This is safe: open() is still holding a reference. */
@@ -2503,6 +2502,10 @@ static int pkt_setup_dev(struct pkt_ctrl_command *ctrl_cmd)
2503 goto out_mem; 2502 goto out_mem;
2504 pd->disk = disk; 2503 pd->disk = disk;
2505 2504
2505 INIT_LIST_HEAD(&pd->cdrw.pkt_free_list);
2506 INIT_LIST_HEAD(&pd->cdrw.pkt_active_list);
2507 spin_lock_init(&pd->cdrw.active_list_lock);
2508
2506 spin_lock_init(&pd->lock); 2509 spin_lock_init(&pd->lock);
2507 spin_lock_init(&pd->iosched.lock); 2510 spin_lock_init(&pd->iosched.lock);
2508 sprintf(pd->name, "pktcdvd%d", idx); 2511 sprintf(pd->name, "pktcdvd%d", idx);
@@ -2567,8 +2570,6 @@ static int pkt_remove_dev(struct pkt_ctrl_command *ctrl_cmd)
2567 2570
2568 blkdev_put(pd->bdev); 2571 blkdev_put(pd->bdev);
2569 2572
2570 pkt_shrink_pktlist(pd);
2571
2572 remove_proc_entry(pd->name, pkt_proc); 2573 remove_proc_entry(pd->name, pkt_proc);
2573 DPRINTK("pktcdvd: writer %s unmapped\n", pd->name); 2574 DPRINTK("pktcdvd: writer %s unmapped\n", pd->name);
2574 2575
@@ -2678,7 +2679,6 @@ static int __init pkt_init(void)
2678 2679
2679 pkt_proc = proc_mkdir("pktcdvd", proc_root_driver); 2680 pkt_proc = proc_mkdir("pktcdvd", proc_root_driver);
2680 2681
2681 DPRINTK("pktcdvd: %s\n", VERSION_CODE);
2682 return 0; 2682 return 0;
2683 2683
2684out: 2684out:
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index a05fe5843e6c..f04d864770ad 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -14,7 +14,6 @@
14 * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries 14 * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries
15 * -- verify the 13 conditions and do bulk resets 15 * -- verify the 13 conditions and do bulk resets
16 * -- kill last_pipe and simply do two-state clearing on both pipes 16 * -- kill last_pipe and simply do two-state clearing on both pipes
17 * -- verify protocol (bulk) from USB descriptors (maybe...)
18 * -- highmem 17 * -- highmem
19 * -- move top_sense and work_bcs into separate allocations (if they survive) 18 * -- move top_sense and work_bcs into separate allocations (if they survive)
20 * for cache purists and esoteric architectures. 19 * for cache purists and esoteric architectures.
@@ -355,7 +354,7 @@ struct ub_lun {
355 * The USB device instance. 354 * The USB device instance.
356 */ 355 */
357struct ub_dev { 356struct ub_dev {
358 spinlock_t lock; 357 spinlock_t *lock;
359 atomic_t poison; /* The USB device is disconnected */ 358 atomic_t poison; /* The USB device is disconnected */
360 int openc; /* protected by ub_lock! */ 359 int openc; /* protected by ub_lock! */
361 /* kref is too implicit for our taste */ 360 /* kref is too implicit for our taste */
@@ -420,11 +419,13 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
420static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, 419static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd,
421 int stalled_pipe); 420 int stalled_pipe);
422static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); 421static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd);
423static void ub_reset_enter(struct ub_dev *sc); 422static void ub_reset_enter(struct ub_dev *sc, int try);
424static void ub_reset_task(void *arg); 423static void ub_reset_task(void *arg);
425static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun); 424static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun);
426static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, 425static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
427 struct ub_capacity *ret); 426 struct ub_capacity *ret);
427static int ub_sync_reset(struct ub_dev *sc);
428static int ub_probe_clear_stall(struct ub_dev *sc, int stalled_pipe);
428static int ub_probe_lun(struct ub_dev *sc, int lnum); 429static int ub_probe_lun(struct ub_dev *sc, int lnum);
429 430
430/* 431/*
@@ -452,6 +453,10 @@ MODULE_DEVICE_TABLE(usb, ub_usb_ids);
452#define UB_MAX_HOSTS 26 453#define UB_MAX_HOSTS 26
453static char ub_hostv[UB_MAX_HOSTS]; 454static char ub_hostv[UB_MAX_HOSTS];
454 455
456#define UB_QLOCK_NUM 5
457static spinlock_t ub_qlockv[UB_QLOCK_NUM];
458static int ub_qlock_next = 0;
459
455static DEFINE_SPINLOCK(ub_lock); /* Locks globals and ->openc */ 460static DEFINE_SPINLOCK(ub_lock); /* Locks globals and ->openc */
456 461
457/* 462/*
@@ -531,7 +536,7 @@ static ssize_t ub_diag_show(struct device *dev, struct device_attribute *attr,
531 return 0; 536 return 0;
532 537
533 cnt = 0; 538 cnt = 0;
534 spin_lock_irqsave(&sc->lock, flags); 539 spin_lock_irqsave(sc->lock, flags);
535 540
536 cnt += sprintf(page + cnt, 541 cnt += sprintf(page + cnt,
537 "poison %d reset %d\n", 542 "poison %d reset %d\n",
@@ -579,7 +584,7 @@ static ssize_t ub_diag_show(struct device *dev, struct device_attribute *attr,
579 if (++nc == SCMD_TRACE_SZ) nc = 0; 584 if (++nc == SCMD_TRACE_SZ) nc = 0;
580 } 585 }
581 586
582 spin_unlock_irqrestore(&sc->lock, flags); 587 spin_unlock_irqrestore(sc->lock, flags);
583 return cnt; 588 return cnt;
584} 589}
585 590
@@ -627,6 +632,24 @@ static void ub_id_put(int id)
627} 632}
628 633
629/* 634/*
635 * This is necessitated by the fact that blk_cleanup_queue does not
636 * necesserily destroy the queue. Instead, it may merely decrease q->refcnt.
637 * Since our blk_init_queue() passes a spinlock common with ub_dev,
638 * we have life time issues when ub_cleanup frees ub_dev.
639 */
640static spinlock_t *ub_next_lock(void)
641{
642 unsigned long flags;
643 spinlock_t *ret;
644
645 spin_lock_irqsave(&ub_lock, flags);
646 ret = &ub_qlockv[ub_qlock_next];
647 ub_qlock_next = (ub_qlock_next + 1) % UB_QLOCK_NUM;
648 spin_unlock_irqrestore(&ub_lock, flags);
649 return ret;
650}
651
652/*
630 * Downcount for deallocation. This rides on two assumptions: 653 * Downcount for deallocation. This rides on two assumptions:
631 * - once something is poisoned, its refcount cannot grow 654 * - once something is poisoned, its refcount cannot grow
632 * - opens cannot happen at this time (del_gendisk was done) 655 * - opens cannot happen at this time (del_gendisk was done)
@@ -961,7 +984,7 @@ static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
961 if (atomic_read(&sc->poison)) 984 if (atomic_read(&sc->poison))
962 return -ENXIO; 985 return -ENXIO;
963 986
964 ub_reset_enter(sc); 987 ub_reset_enter(sc, urq->current_try);
965 988
966 if (urq->current_try >= 3) 989 if (urq->current_try >= 3)
967 return -EIO; 990 return -EIO;
@@ -997,8 +1020,6 @@ static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
997 * No exceptions. 1020 * No exceptions.
998 * 1021 *
999 * Host is assumed locked. 1022 * Host is assumed locked.
1000 *
1001 * XXX We only support Bulk for the moment.
1002 */ 1023 */
1003static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd) 1024static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1004{ 1025{
@@ -1083,9 +1104,10 @@ static void ub_urb_timeout(unsigned long arg)
1083 struct ub_dev *sc = (struct ub_dev *) arg; 1104 struct ub_dev *sc = (struct ub_dev *) arg;
1084 unsigned long flags; 1105 unsigned long flags;
1085 1106
1086 spin_lock_irqsave(&sc->lock, flags); 1107 spin_lock_irqsave(sc->lock, flags);
1087 usb_unlink_urb(&sc->work_urb); 1108 if (!ub_is_completed(&sc->work_done))
1088 spin_unlock_irqrestore(&sc->lock, flags); 1109 usb_unlink_urb(&sc->work_urb);
1110 spin_unlock_irqrestore(sc->lock, flags);
1089} 1111}
1090 1112
1091/* 1113/*
@@ -1108,10 +1130,9 @@ static void ub_scsi_action(unsigned long _dev)
1108 struct ub_dev *sc = (struct ub_dev *) _dev; 1130 struct ub_dev *sc = (struct ub_dev *) _dev;
1109 unsigned long flags; 1131 unsigned long flags;
1110 1132
1111 spin_lock_irqsave(&sc->lock, flags); 1133 spin_lock_irqsave(sc->lock, flags);
1112 del_timer(&sc->work_timer);
1113 ub_scsi_dispatch(sc); 1134 ub_scsi_dispatch(sc);
1114 spin_unlock_irqrestore(&sc->lock, flags); 1135 spin_unlock_irqrestore(sc->lock, flags);
1115} 1136}
1116 1137
1117static void ub_scsi_dispatch(struct ub_dev *sc) 1138static void ub_scsi_dispatch(struct ub_dev *sc)
@@ -1133,6 +1154,7 @@ static void ub_scsi_dispatch(struct ub_dev *sc)
1133 } else { 1154 } else {
1134 if (!ub_is_completed(&sc->work_done)) 1155 if (!ub_is_completed(&sc->work_done))
1135 break; 1156 break;
1157 del_timer(&sc->work_timer);
1136 ub_scsi_urb_compl(sc, cmd); 1158 ub_scsi_urb_compl(sc, cmd);
1137 } 1159 }
1138 } 1160 }
@@ -1680,16 +1702,18 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd)
1680 1702
1681/* 1703/*
1682 * Reset management 1704 * Reset management
1705 * XXX Move usb_reset_device to khubd. Hogging kevent is not a good thing.
1706 * XXX Make usb_sync_reset asynchronous.
1683 */ 1707 */
1684 1708
1685static void ub_reset_enter(struct ub_dev *sc) 1709static void ub_reset_enter(struct ub_dev *sc, int try)
1686{ 1710{
1687 1711
1688 if (sc->reset) { 1712 if (sc->reset) {
1689 /* This happens often on multi-LUN devices. */ 1713 /* This happens often on multi-LUN devices. */
1690 return; 1714 return;
1691 } 1715 }
1692 sc->reset = 1; 1716 sc->reset = try + 1;
1693 1717
1694#if 0 /* Not needed because the disconnect waits for us. */ 1718#if 0 /* Not needed because the disconnect waits for us. */
1695 unsigned long flags; 1719 unsigned long flags;
@@ -1727,6 +1751,11 @@ static void ub_reset_task(void *arg)
1727 if (atomic_read(&sc->poison)) { 1751 if (atomic_read(&sc->poison)) {
1728 printk(KERN_NOTICE "%s: Not resetting disconnected device\n", 1752 printk(KERN_NOTICE "%s: Not resetting disconnected device\n",
1729 sc->name); /* P3 This floods. Remove soon. XXX */ 1753 sc->name); /* P3 This floods. Remove soon. XXX */
1754 } else if ((sc->reset & 1) == 0) {
1755 ub_sync_reset(sc);
1756 msleep(700); /* usb-storage sleeps 6s (!) */
1757 ub_probe_clear_stall(sc, sc->recv_bulk_pipe);
1758 ub_probe_clear_stall(sc, sc->send_bulk_pipe);
1730 } else if (sc->dev->actconfig->desc.bNumInterfaces != 1) { 1759 } else if (sc->dev->actconfig->desc.bNumInterfaces != 1) {
1731 printk(KERN_NOTICE "%s: Not resetting multi-interface device\n", 1760 printk(KERN_NOTICE "%s: Not resetting multi-interface device\n",
1732 sc->name); /* P3 This floods. Remove soon. XXX */ 1761 sc->name); /* P3 This floods. Remove soon. XXX */
@@ -1754,7 +1783,7 @@ static void ub_reset_task(void *arg)
1754 * queues of resets or anything. We do need a spinlock though, 1783 * queues of resets or anything. We do need a spinlock though,
1755 * to interact with block layer. 1784 * to interact with block layer.
1756 */ 1785 */
1757 spin_lock_irqsave(&sc->lock, flags); 1786 spin_lock_irqsave(sc->lock, flags);
1758 sc->reset = 0; 1787 sc->reset = 0;
1759 tasklet_schedule(&sc->tasklet); 1788 tasklet_schedule(&sc->tasklet);
1760 list_for_each(p, &sc->luns) { 1789 list_for_each(p, &sc->luns) {
@@ -1762,7 +1791,7 @@ static void ub_reset_task(void *arg)
1762 blk_start_queue(lun->disk->queue); 1791 blk_start_queue(lun->disk->queue);
1763 } 1792 }
1764 wake_up(&sc->reset_wait); 1793 wake_up(&sc->reset_wait);
1765 spin_unlock_irqrestore(&sc->lock, flags); 1794 spin_unlock_irqrestore(sc->lock, flags);
1766} 1795}
1767 1796
1768/* 1797/*
@@ -1990,11 +2019,11 @@ static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun)
1990 cmd->done = ub_probe_done; 2019 cmd->done = ub_probe_done;
1991 cmd->back = &compl; 2020 cmd->back = &compl;
1992 2021
1993 spin_lock_irqsave(&sc->lock, flags); 2022 spin_lock_irqsave(sc->lock, flags);
1994 cmd->tag = sc->tagcnt++; 2023 cmd->tag = sc->tagcnt++;
1995 2024
1996 rc = ub_submit_scsi(sc, cmd); 2025 rc = ub_submit_scsi(sc, cmd);
1997 spin_unlock_irqrestore(&sc->lock, flags); 2026 spin_unlock_irqrestore(sc->lock, flags);
1998 2027
1999 if (rc != 0) { 2028 if (rc != 0) {
2000 printk("ub: testing ready: submit error (%d)\n", rc); /* P3 */ 2029 printk("ub: testing ready: submit error (%d)\n", rc); /* P3 */
@@ -2052,11 +2081,11 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
2052 cmd->done = ub_probe_done; 2081 cmd->done = ub_probe_done;
2053 cmd->back = &compl; 2082 cmd->back = &compl;
2054 2083
2055 spin_lock_irqsave(&sc->lock, flags); 2084 spin_lock_irqsave(sc->lock, flags);
2056 cmd->tag = sc->tagcnt++; 2085 cmd->tag = sc->tagcnt++;
2057 2086
2058 rc = ub_submit_scsi(sc, cmd); 2087 rc = ub_submit_scsi(sc, cmd);
2059 spin_unlock_irqrestore(&sc->lock, flags); 2088 spin_unlock_irqrestore(sc->lock, flags);
2060 2089
2061 if (rc != 0) { 2090 if (rc != 0) {
2062 printk("ub: reading capacity: submit error (%d)\n", rc); /* P3 */ 2091 printk("ub: reading capacity: submit error (%d)\n", rc); /* P3 */
@@ -2118,6 +2147,52 @@ static void ub_probe_timeout(unsigned long arg)
2118} 2147}
2119 2148
2120/* 2149/*
2150 * Reset with a Bulk reset.
2151 */
2152static int ub_sync_reset(struct ub_dev *sc)
2153{
2154 int ifnum = sc->intf->cur_altsetting->desc.bInterfaceNumber;
2155 struct usb_ctrlrequest *cr;
2156 struct completion compl;
2157 struct timer_list timer;
2158 int rc;
2159
2160 init_completion(&compl);
2161
2162 cr = &sc->work_cr;
2163 cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
2164 cr->bRequest = US_BULK_RESET_REQUEST;
2165 cr->wValue = cpu_to_le16(0);
2166 cr->wIndex = cpu_to_le16(ifnum);
2167 cr->wLength = cpu_to_le16(0);
2168
2169 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe,
2170 (unsigned char*) cr, NULL, 0, ub_probe_urb_complete, &compl);
2171 sc->work_urb.actual_length = 0;
2172 sc->work_urb.error_count = 0;
2173 sc->work_urb.status = 0;
2174
2175 if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) {
2176 printk(KERN_WARNING
2177 "%s: Unable to submit a bulk reset (%d)\n", sc->name, rc);
2178 return rc;
2179 }
2180
2181 init_timer(&timer);
2182 timer.function = ub_probe_timeout;
2183 timer.data = (unsigned long) &compl;
2184 timer.expires = jiffies + UB_CTRL_TIMEOUT;
2185 add_timer(&timer);
2186
2187 wait_for_completion(&compl);
2188
2189 del_timer_sync(&timer);
2190 usb_kill_urb(&sc->work_urb);
2191
2192 return sc->work_urb.status;
2193}
2194
2195/*
2121 * Get number of LUNs by the way of Bulk GetMaxLUN command. 2196 * Get number of LUNs by the way of Bulk GetMaxLUN command.
2122 */ 2197 */
2123static int ub_sync_getmaxlun(struct ub_dev *sc) 2198static int ub_sync_getmaxlun(struct ub_dev *sc)
@@ -2333,7 +2408,7 @@ static int ub_probe(struct usb_interface *intf,
2333 if ((sc = kmalloc(sizeof(struct ub_dev), GFP_KERNEL)) == NULL) 2408 if ((sc = kmalloc(sizeof(struct ub_dev), GFP_KERNEL)) == NULL)
2334 goto err_core; 2409 goto err_core;
2335 memset(sc, 0, sizeof(struct ub_dev)); 2410 memset(sc, 0, sizeof(struct ub_dev));
2336 spin_lock_init(&sc->lock); 2411 sc->lock = ub_next_lock();
2337 INIT_LIST_HEAD(&sc->luns); 2412 INIT_LIST_HEAD(&sc->luns);
2338 usb_init_urb(&sc->work_urb); 2413 usb_init_urb(&sc->work_urb);
2339 tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); 2414 tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc);
@@ -2483,7 +2558,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum)
2483 disk->driverfs_dev = &sc->intf->dev; 2558 disk->driverfs_dev = &sc->intf->dev;
2484 2559
2485 rc = -ENOMEM; 2560 rc = -ENOMEM;
2486 if ((q = blk_init_queue(ub_request_fn, &sc->lock)) == NULL) 2561 if ((q = blk_init_queue(ub_request_fn, sc->lock)) == NULL)
2487 goto err_blkqinit; 2562 goto err_blkqinit;
2488 2563
2489 disk->queue = q; 2564 disk->queue = q;
@@ -2554,7 +2629,7 @@ static void ub_disconnect(struct usb_interface *intf)
2554 * and the whole queue drains. So, we just use this code to 2629 * and the whole queue drains. So, we just use this code to
2555 * print warnings. 2630 * print warnings.
2556 */ 2631 */
2557 spin_lock_irqsave(&sc->lock, flags); 2632 spin_lock_irqsave(sc->lock, flags);
2558 { 2633 {
2559 struct ub_scsi_cmd *cmd; 2634 struct ub_scsi_cmd *cmd;
2560 int cnt = 0; 2635 int cnt = 0;
@@ -2571,7 +2646,7 @@ static void ub_disconnect(struct usb_interface *intf)
2571 "%d was queued after shutdown\n", sc->name, cnt); 2646 "%d was queued after shutdown\n", sc->name, cnt);
2572 } 2647 }
2573 } 2648 }
2574 spin_unlock_irqrestore(&sc->lock, flags); 2649 spin_unlock_irqrestore(sc->lock, flags);
2575 2650
2576 /* 2651 /*
2577 * Unregister the upper layer. 2652 * Unregister the upper layer.
@@ -2590,19 +2665,15 @@ static void ub_disconnect(struct usb_interface *intf)
2590 } 2665 }
2591 2666
2592 /* 2667 /*
2593 * Taking a lock on a structure which is about to be freed
2594 * is very nonsensual. Here it is largely a way to do a debug freeze,
2595 * and a bracket which shows where the nonsensual code segment ends.
2596 *
2597 * Testing for -EINPROGRESS is always a bug, so we are bending 2668 * Testing for -EINPROGRESS is always a bug, so we are bending
2598 * the rules a little. 2669 * the rules a little.
2599 */ 2670 */
2600 spin_lock_irqsave(&sc->lock, flags); 2671 spin_lock_irqsave(sc->lock, flags);
2601 if (sc->work_urb.status == -EINPROGRESS) { /* janitors: ignore */ 2672 if (sc->work_urb.status == -EINPROGRESS) { /* janitors: ignore */
2602 printk(KERN_WARNING "%s: " 2673 printk(KERN_WARNING "%s: "
2603 "URB is active after disconnect\n", sc->name); 2674 "URB is active after disconnect\n", sc->name);
2604 } 2675 }
2605 spin_unlock_irqrestore(&sc->lock, flags); 2676 spin_unlock_irqrestore(sc->lock, flags);
2606 2677
2607 /* 2678 /*
2608 * There is virtually no chance that other CPU runs times so long 2679 * There is virtually no chance that other CPU runs times so long
@@ -2636,6 +2707,10 @@ static struct usb_driver ub_driver = {
2636static int __init ub_init(void) 2707static int __init ub_init(void)
2637{ 2708{
2638 int rc; 2709 int rc;
2710 int i;
2711
2712 for (i = 0; i < UB_QLOCK_NUM; i++)
2713 spin_lock_init(&ub_qlockv[i]);
2639 2714
2640 if ((rc = register_blkdev(UB_MAJOR, DRV_NAME)) != 0) 2715 if ((rc = register_blkdev(UB_MAJOR, DRV_NAME)) != 0)
2641 goto err_regblkdev; 2716 goto err_regblkdev;
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index a3614e6a68d0..4ada1268b40d 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -882,7 +882,7 @@ static int __devinit mm_pci_probe(struct pci_dev *dev, const struct pci_device_i
882 card->card_number, dev->bus->number, dev->devfn); 882 card->card_number, dev->bus->number, dev->devfn);
883 883
884 if (pci_set_dma_mask(dev, 0xffffffffffffffffLL) && 884 if (pci_set_dma_mask(dev, 0xffffffffffffffffLL) &&
885 !pci_set_dma_mask(dev, 0xffffffffLL)) { 885 pci_set_dma_mask(dev, 0xffffffffLL)) {
886 printk(KERN_WARNING "MM%d: NO suitable DMA found\n",num_cards); 886 printk(KERN_WARNING "MM%d: NO suitable DMA found\n",num_cards);
887 return -ENOMEM; 887 return -ENOMEM;
888 } 888 }
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 4135d8c5bcae..4c67727d75b1 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -992,7 +992,7 @@ config HPET_MMAP
992 992
993config HANGCHECK_TIMER 993config HANGCHECK_TIMER
994 tristate "Hangcheck timer" 994 tristate "Hangcheck timer"
995 depends on X86 || IA64 || PPC64 || S390 995 depends on X86 || IA64 || PPC64
996 help 996 help
997 The hangcheck-timer module detects when the system has gone 997 The hangcheck-timer module detects when the system has gone
998 out to lunch past a certain margin. It can reboot the system 998 out to lunch past a certain margin. It can reboot the system
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 810679dcbbb0..9964c508c111 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -600,6 +600,26 @@ static void __devexit agp_amd64_remove(struct pci_dev *pdev)
600 agp_put_bridge(bridge); 600 agp_put_bridge(bridge);
601} 601}
602 602
603#ifdef CONFIG_PM
604
605static int agp_amd64_suspend(struct pci_dev *pdev, pm_message_t state)
606{
607 pci_save_state(pdev);
608 pci_set_power_state(pdev, pci_choose_state(pdev, state));
609
610 return 0;
611}
612
613static int agp_amd64_resume(struct pci_dev *pdev)
614{
615 pci_set_power_state(pdev, PCI_D0);
616 pci_restore_state(pdev);
617
618 return amd_8151_configure();
619}
620
621#endif /* CONFIG_PM */
622
603static struct pci_device_id agp_amd64_pci_table[] = { 623static struct pci_device_id agp_amd64_pci_table[] = {
604 { 624 {
605 .class = (PCI_CLASS_BRIDGE_HOST << 8), 625 .class = (PCI_CLASS_BRIDGE_HOST << 8),
@@ -718,6 +738,10 @@ static struct pci_driver agp_amd64_pci_driver = {
718 .id_table = agp_amd64_pci_table, 738 .id_table = agp_amd64_pci_table,
719 .probe = agp_amd64_probe, 739 .probe = agp_amd64_probe,
720 .remove = agp_amd64_remove, 740 .remove = agp_amd64_remove,
741#ifdef CONFIG_PM
742 .suspend = agp_amd64_suspend,
743 .resume = agp_amd64_resume,
744#endif
721}; 745};
722 746
723 747
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 53372a83b675..5b74c36c116c 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -244,6 +244,22 @@ static int ati_configure(void)
244} 244}
245 245
246 246
247#ifdef CONFIG_PM
248static int agp_ati_resume(struct pci_dev *dev)
249{
250 pci_restore_state(dev);
251
252 return ati_configure();
253}
254
255static int agp_ati_suspend(struct pci_dev *dev, pm_message_t state)
256{
257 pci_save_state(dev);
258
259 return 0;
260}
261#endif
262
247/* 263/*
248 *Since we don't need contigious memory we just try 264 *Since we don't need contigious memory we just try
249 * to get the gatt table once 265 * to get the gatt table once
@@ -525,6 +541,10 @@ static struct pci_driver agp_ati_pci_driver = {
525 .id_table = agp_ati_pci_table, 541 .id_table = agp_ati_pci_table,
526 .probe = agp_ati_probe, 542 .probe = agp_ati_probe,
527 .remove = agp_ati_remove, 543 .remove = agp_ati_remove,
544#ifdef CONFIG_PM
545 .resume = agp_ati_resume,
546 .suspend = agp_ati_suspend,
547#endif
528}; 548};
529 549
530static int __init agp_ati_init(void) 550static int __init agp_ati_init(void)
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index 17f520c9d471..97eeb2345b18 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -592,7 +592,7 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
592 struct agp_file_private *priv = file->private_data; 592 struct agp_file_private *priv = file->private_data;
593 struct agp_kern_info kerninfo; 593 struct agp_kern_info kerninfo;
594 594
595 down(&(agp_fe.agp_mutex)); 595 mutex_lock(&(agp_fe.agp_mutex));
596 596
597 if (agp_fe.backend_acquired != TRUE) 597 if (agp_fe.backend_acquired != TRUE)
598 goto out_eperm; 598 goto out_eperm;
@@ -627,7 +627,7 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
627 size, vma->vm_page_prot)) { 627 size, vma->vm_page_prot)) {
628 goto out_again; 628 goto out_again;
629 } 629 }
630 up(&(agp_fe.agp_mutex)); 630 mutex_unlock(&(agp_fe.agp_mutex));
631 return 0; 631 return 0;
632 } 632 }
633 633
@@ -643,20 +643,20 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
643 size, vma->vm_page_prot)) { 643 size, vma->vm_page_prot)) {
644 goto out_again; 644 goto out_again;
645 } 645 }
646 up(&(agp_fe.agp_mutex)); 646 mutex_unlock(&(agp_fe.agp_mutex));
647 return 0; 647 return 0;
648 } 648 }
649 649
650out_eperm: 650out_eperm:
651 up(&(agp_fe.agp_mutex)); 651 mutex_unlock(&(agp_fe.agp_mutex));
652 return -EPERM; 652 return -EPERM;
653 653
654out_inval: 654out_inval:
655 up(&(agp_fe.agp_mutex)); 655 mutex_unlock(&(agp_fe.agp_mutex));
656 return -EINVAL; 656 return -EINVAL;
657 657
658out_again: 658out_again:
659 up(&(agp_fe.agp_mutex)); 659 mutex_unlock(&(agp_fe.agp_mutex));
660 return -EAGAIN; 660 return -EAGAIN;
661} 661}
662 662
@@ -664,7 +664,7 @@ static int agp_release(struct inode *inode, struct file *file)
664{ 664{
665 struct agp_file_private *priv = file->private_data; 665 struct agp_file_private *priv = file->private_data;
666 666
667 down(&(agp_fe.agp_mutex)); 667 mutex_lock(&(agp_fe.agp_mutex));
668 668
669 DBG("priv=%p", priv); 669 DBG("priv=%p", priv);
670 670
@@ -687,7 +687,7 @@ static int agp_release(struct inode *inode, struct file *file)
687 agp_remove_file_private(priv); 687 agp_remove_file_private(priv);
688 kfree(priv); 688 kfree(priv);
689 file->private_data = NULL; 689 file->private_data = NULL;
690 up(&(agp_fe.agp_mutex)); 690 mutex_unlock(&(agp_fe.agp_mutex));
691 return 0; 691 return 0;
692} 692}
693 693
@@ -698,7 +698,7 @@ static int agp_open(struct inode *inode, struct file *file)
698 struct agp_client *client; 698 struct agp_client *client;
699 int rc = -ENXIO; 699 int rc = -ENXIO;
700 700
701 down(&(agp_fe.agp_mutex)); 701 mutex_lock(&(agp_fe.agp_mutex));
702 702
703 if (minor != AGPGART_MINOR) 703 if (minor != AGPGART_MINOR)
704 goto err_out; 704 goto err_out;
@@ -723,13 +723,13 @@ static int agp_open(struct inode *inode, struct file *file)
723 file->private_data = (void *) priv; 723 file->private_data = (void *) priv;
724 agp_insert_file_private(priv); 724 agp_insert_file_private(priv);
725 DBG("private=%p, client=%p", priv, client); 725 DBG("private=%p, client=%p", priv, client);
726 up(&(agp_fe.agp_mutex)); 726 mutex_unlock(&(agp_fe.agp_mutex));
727 return 0; 727 return 0;
728 728
729err_out_nomem: 729err_out_nomem:
730 rc = -ENOMEM; 730 rc = -ENOMEM;
731err_out: 731err_out:
732 up(&(agp_fe.agp_mutex)); 732 mutex_unlock(&(agp_fe.agp_mutex));
733 return rc; 733 return rc;
734} 734}
735 735
@@ -985,7 +985,7 @@ static int agp_ioctl(struct inode *inode, struct file *file,
985 int ret_val = -ENOTTY; 985 int ret_val = -ENOTTY;
986 986
987 DBG("priv=%p, cmd=%x", curr_priv, cmd); 987 DBG("priv=%p, cmd=%x", curr_priv, cmd);
988 down(&(agp_fe.agp_mutex)); 988 mutex_lock(&(agp_fe.agp_mutex));
989 989
990 if ((agp_fe.current_controller == NULL) && 990 if ((agp_fe.current_controller == NULL) &&
991 (cmd != AGPIOC_ACQUIRE)) { 991 (cmd != AGPIOC_ACQUIRE)) {
@@ -1055,7 +1055,7 @@ static int agp_ioctl(struct inode *inode, struct file *file,
1055 1055
1056ioctl_out: 1056ioctl_out:
1057 DBG("ioctl returns %d\n", ret_val); 1057 DBG("ioctl returns %d\n", ret_val);
1058 up(&(agp_fe.agp_mutex)); 1058 mutex_unlock(&(agp_fe.agp_mutex));
1059 return ret_val; 1059 return ret_val;
1060} 1060}
1061 1061
@@ -1081,7 +1081,7 @@ static struct miscdevice agp_miscdev =
1081int agp_frontend_initialize(void) 1081int agp_frontend_initialize(void)
1082{ 1082{
1083 memset(&agp_fe, 0, sizeof(struct agp_front_data)); 1083 memset(&agp_fe, 0, sizeof(struct agp_front_data));
1084 sema_init(&(agp_fe.agp_mutex), 1); 1084 mutex_init(&(agp_fe.agp_mutex));
1085 1085
1086 if (misc_register(&agp_miscdev)) { 1086 if (misc_register(&agp_miscdev)) {
1087 printk(KERN_ERR PFX "unable to get minor: %d\n", AGPGART_MINOR); 1087 printk(KERN_ERR PFX "unable to get minor: %d\n", AGPGART_MINOR);
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index e7bed5047dcc..631531fd97a5 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -422,7 +422,8 @@ static void intel_i830_init_gtt_entries(void)
422 /* Check it's really I915G */ 422 /* Check it's really I915G */
423 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 423 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
424 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 424 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
425 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB) 425 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
426 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB)
426 gtt_entries = MB(48) - KB(size); 427 gtt_entries = MB(48) - KB(size);
427 else 428 else
428 gtt_entries = 0; 429 gtt_entries = 0;
@@ -431,7 +432,8 @@ static void intel_i830_init_gtt_entries(void)
431 /* Check it's really I915G */ 432 /* Check it's really I915G */
432 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 433 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
433 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 434 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
434 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB) 435 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
436 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB)
435 gtt_entries = MB(64) - KB(size); 437 gtt_entries = MB(64) - KB(size);
436 else 438 else
437 gtt_entries = 0; 439 gtt_entries = 0;
@@ -1681,6 +1683,14 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1681 } 1683 }
1682 name = "945G"; 1684 name = "945G";
1683 break; 1685 break;
1686 case PCI_DEVICE_ID_INTEL_82945GM_HB:
1687 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG)) {
1688 bridge->driver = &intel_915_driver;
1689 } else {
1690 bridge->driver = &intel_845_driver;
1691 }
1692 name = "945GM";
1693 break;
1684 case PCI_DEVICE_ID_INTEL_7505_0: 1694 case PCI_DEVICE_ID_INTEL_7505_0:
1685 bridge->driver = &intel_7505_driver; 1695 bridge->driver = &intel_7505_driver;
1686 name = "E7505"; 1696 name = "E7505";
@@ -1821,6 +1831,7 @@ static struct pci_device_id agp_intel_pci_table[] = {
1821 ID(PCI_DEVICE_ID_INTEL_82915G_HB), 1831 ID(PCI_DEVICE_ID_INTEL_82915G_HB),
1822 ID(PCI_DEVICE_ID_INTEL_82915GM_HB), 1832 ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
1823 ID(PCI_DEVICE_ID_INTEL_82945G_HB), 1833 ID(PCI_DEVICE_ID_INTEL_82945G_HB),
1834 ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
1824 { } 1835 { }
1825}; 1836};
1826 1837
diff --git a/drivers/char/agp/isoch.c b/drivers/char/agp/isoch.c
index 40083241804e..7c14a096b85e 100644
--- a/drivers/char/agp/isoch.c
+++ b/drivers/char/agp/isoch.c
@@ -218,10 +218,8 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge,
218 master[cdev].rq *= (1 << (master[cdev].y - 1)); 218 master[cdev].rq *= (1 << (master[cdev].y - 1));
219 219
220 tot_rq += master[cdev].rq; 220 tot_rq += master[cdev].rq;
221
222 if (cdev == ndevs-1)
223 master[cdev].n += rem;
224 } 221 }
222 master[ndevs-1].n += rem;
225 223
226 /* Figure the number of isochronous and asynchronous RQ slots the 224 /* Figure the number of isochronous and asynchronous RQ slots the
227 * target is providing. */ 225 * target is providing. */
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 39c61a71176e..cc7acf877dc0 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -1233,7 +1233,7 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1233 } 1233 }
1234 info->idle_stats.recv_idle = jiffies; 1234 info->idle_stats.recv_idle = jiffies;
1235 } 1235 }
1236 schedule_delayed_work(&tty->buf.work, 1); 1236 tty_schedule_flip(tty);
1237 } 1237 }
1238 /* end of service */ 1238 /* end of service */
1239 cy_writeb(base_addr+(CyRIR<<index), (save_xir & 0x3f)); 1239 cy_writeb(base_addr+(CyRIR<<index), (save_xir & 0x3f));
@@ -1606,7 +1606,7 @@ cyz_handle_rx(struct cyclades_port *info,
1606 } 1606 }
1607#endif 1607#endif
1608 info->idle_stats.recv_idle = jiffies; 1608 info->idle_stats.recv_idle = jiffies;
1609 schedule_delayed_work(&tty->buf.work, 1); 1609 tty_schedule_flip(tty);
1610 } 1610 }
1611 /* Update rx_get */ 1611 /* Update rx_get */
1612 cy_writel(&buf_ctrl->rx_get, new_rx_get); 1612 cy_writel(&buf_ctrl->rx_get, new_rx_get);
@@ -1809,7 +1809,7 @@ cyz_handle_cmd(struct cyclades_card *cinfo)
1809 if(delta_count) 1809 if(delta_count)
1810 cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); 1810 cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP);
1811 if(special_count) 1811 if(special_count)
1812 schedule_delayed_work(&tty->buf.work, 1); 1812 tty_schedule_flip(tty);
1813 } 1813 }
1814} 1814}
1815 1815
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c
index 5485382cadec..bd7be09ea53d 100644
--- a/drivers/char/drm/ati_pcigart.c
+++ b/drivers/char/drm/ati_pcigart.c
@@ -59,17 +59,16 @@ static void *drm_ati_alloc_pcigart_table(void)
59 int i; 59 int i;
60 DRM_DEBUG("%s\n", __FUNCTION__); 60 DRM_DEBUG("%s\n", __FUNCTION__);
61 61
62 address = __get_free_pages(GFP_KERNEL, ATI_PCIGART_TABLE_ORDER); 62 address = __get_free_pages(GFP_KERNEL | __GFP_COMP,
63 ATI_PCIGART_TABLE_ORDER);
63 if (address == 0UL) { 64 if (address == 0UL) {
64 return 0; 65 return NULL;
65 } 66 }
66 67
67 page = virt_to_page(address); 68 page = virt_to_page(address);
68 69
69 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { 70 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++)
70 get_page(page);
71 SetPageReserved(page); 71 SetPageReserved(page);
72 }
73 72
74 DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address); 73 DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address);
75 return (void *)address; 74 return (void *)address;
@@ -83,10 +82,8 @@ static void drm_ati_free_pcigart_table(void *address)
83 82
84 page = virt_to_page((unsigned long)address); 83 page = virt_to_page((unsigned long)address);
85 84
86 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { 85 for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++)
87 __put_page(page);
88 ClearPageReserved(page); 86 ClearPageReserved(page);
89 }
90 87
91 free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER); 88 free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER);
92} 89}
@@ -127,7 +124,7 @@ int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
127 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN 124 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN
128 && gart_info->addr) { 125 && gart_info->addr) {
129 drm_ati_free_pcigart_table(gart_info->addr); 126 drm_ati_free_pcigart_table(gart_info->addr);
130 gart_info->addr = 0; 127 gart_info->addr = NULL;
131 } 128 }
132 129
133 return 1; 130 return 1;
@@ -168,7 +165,7 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
168 if (bus_address == 0) { 165 if (bus_address == 0) {
169 DRM_ERROR("unable to map PCIGART pages!\n"); 166 DRM_ERROR("unable to map PCIGART pages!\n");
170 drm_ati_free_pcigart_table(address); 167 drm_ati_free_pcigart_table(address);
171 address = 0; 168 address = NULL;
172 goto done; 169 goto done;
173 } 170 }
174 } else { 171 } else {
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index 54b561e69486..71b8b32b075f 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -57,6 +57,7 @@
57#include <linux/smp_lock.h> /* For (un)lock_kernel */ 57#include <linux/smp_lock.h> /* For (un)lock_kernel */
58#include <linux/mm.h> 58#include <linux/mm.h>
59#include <linux/cdev.h> 59#include <linux/cdev.h>
60#include <linux/mutex.h>
60#if defined(__alpha__) || defined(__powerpc__) 61#if defined(__alpha__) || defined(__powerpc__)
61#include <asm/pgtable.h> /* For pte_wrprotect */ 62#include <asm/pgtable.h> /* For pte_wrprotect */
62#endif 63#endif
@@ -623,7 +624,7 @@ typedef struct drm_device {
623 /** \name Locks */ 624 /** \name Locks */
624 /*@{ */ 625 /*@{ */
625 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ 626 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
626 struct semaphore struct_sem; /**< For others */ 627 struct mutex struct_mutex; /**< For others */
627 /*@} */ 628 /*@} */
628 629
629 /** \name Usage Counters */ 630 /** \name Usage Counters */
@@ -658,7 +659,7 @@ typedef struct drm_device {
658 /*@{ */ 659 /*@{ */
659 drm_ctx_list_t *ctxlist; /**< Linked list of context handles */ 660 drm_ctx_list_t *ctxlist; /**< Linked list of context handles */
660 int ctx_count; /**< Number of context handles */ 661 int ctx_count; /**< Number of context handles */
661 struct semaphore ctxlist_sem; /**< For ctxlist */ 662 struct mutex ctxlist_mutex; /**< For ctxlist */
662 663
663 drm_map_t **context_sareas; /**< per-context SAREA's */ 664 drm_map_t **context_sareas; /**< per-context SAREA's */
664 int max_context; 665 int max_context;
diff --git a/drivers/char/drm/drm_auth.c b/drivers/char/drm/drm_auth.c
index a47b502bc7cc..2a37586a7ee8 100644
--- a/drivers/char/drm/drm_auth.c
+++ b/drivers/char/drm/drm_auth.c
@@ -56,7 +56,7 @@ static int drm_hash_magic(drm_magic_t magic)
56 * \param magic magic number. 56 * \param magic magic number.
57 * 57 *
58 * Searches in drm_device::magiclist within all files with the same hash key 58 * Searches in drm_device::magiclist within all files with the same hash key
59 * the one with matching magic number, while holding the drm_device::struct_sem 59 * the one with matching magic number, while holding the drm_device::struct_mutex
60 * lock. 60 * lock.
61 */ 61 */
62static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic) 62static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
@@ -65,14 +65,14 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
65 drm_magic_entry_t *pt; 65 drm_magic_entry_t *pt;
66 int hash = drm_hash_magic(magic); 66 int hash = drm_hash_magic(magic);
67 67
68 down(&dev->struct_sem); 68 mutex_lock(&dev->struct_mutex);
69 for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { 69 for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
70 if (pt->magic == magic) { 70 if (pt->magic == magic) {
71 retval = pt->priv; 71 retval = pt->priv;
72 break; 72 break;
73 } 73 }
74 } 74 }
75 up(&dev->struct_sem); 75 mutex_unlock(&dev->struct_mutex);
76 return retval; 76 return retval;
77} 77}
78 78
@@ -85,7 +85,7 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic)
85 * 85 *
86 * Creates a drm_magic_entry structure and appends to the linked list 86 * Creates a drm_magic_entry structure and appends to the linked list
87 * associated the magic number hash key in drm_device::magiclist, while holding 87 * associated the magic number hash key in drm_device::magiclist, while holding
88 * the drm_device::struct_sem lock. 88 * the drm_device::struct_mutex lock.
89 */ 89 */
90static int drm_add_magic(drm_device_t * dev, drm_file_t * priv, 90static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
91 drm_magic_t magic) 91 drm_magic_t magic)
@@ -104,7 +104,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
104 entry->priv = priv; 104 entry->priv = priv;
105 entry->next = NULL; 105 entry->next = NULL;
106 106
107 down(&dev->struct_sem); 107 mutex_lock(&dev->struct_mutex);
108 if (dev->magiclist[hash].tail) { 108 if (dev->magiclist[hash].tail) {
109 dev->magiclist[hash].tail->next = entry; 109 dev->magiclist[hash].tail->next = entry;
110 dev->magiclist[hash].tail = entry; 110 dev->magiclist[hash].tail = entry;
@@ -112,7 +112,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
112 dev->magiclist[hash].head = entry; 112 dev->magiclist[hash].head = entry;
113 dev->magiclist[hash].tail = entry; 113 dev->magiclist[hash].tail = entry;
114 } 114 }
115 up(&dev->struct_sem); 115 mutex_unlock(&dev->struct_mutex);
116 116
117 return 0; 117 return 0;
118} 118}
@@ -124,7 +124,7 @@ static int drm_add_magic(drm_device_t * dev, drm_file_t * priv,
124 * \param magic magic number. 124 * \param magic magic number.
125 * 125 *
126 * Searches and unlinks the entry in drm_device::magiclist with the magic 126 * Searches and unlinks the entry in drm_device::magiclist with the magic
127 * number hash key, while holding the drm_device::struct_sem lock. 127 * number hash key, while holding the drm_device::struct_mutex lock.
128 */ 128 */
129static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic) 129static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
130{ 130{
@@ -135,7 +135,7 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
135 DRM_DEBUG("%d\n", magic); 135 DRM_DEBUG("%d\n", magic);
136 hash = drm_hash_magic(magic); 136 hash = drm_hash_magic(magic);
137 137
138 down(&dev->struct_sem); 138 mutex_lock(&dev->struct_mutex);
139 for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { 139 for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) {
140 if (pt->magic == magic) { 140 if (pt->magic == magic) {
141 if (dev->magiclist[hash].head == pt) { 141 if (dev->magiclist[hash].head == pt) {
@@ -147,11 +147,11 @@ static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic)
147 if (prev) { 147 if (prev) {
148 prev->next = pt->next; 148 prev->next = pt->next;
149 } 149 }
150 up(&dev->struct_sem); 150 mutex_unlock(&dev->struct_mutex);
151 return 0; 151 return 0;
152 } 152 }
153 } 153 }
154 up(&dev->struct_sem); 154 mutex_unlock(&dev->struct_mutex);
155 155
156 drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); 156 drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
157 157
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index 1db12dcb6802..e2637b4d51de 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -255,14 +255,14 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
255 memset(list, 0, sizeof(*list)); 255 memset(list, 0, sizeof(*list));
256 list->map = map; 256 list->map = map;
257 257
258 down(&dev->struct_sem); 258 mutex_lock(&dev->struct_mutex);
259 list_add(&list->head, &dev->maplist->head); 259 list_add(&list->head, &dev->maplist->head);
260 /* Assign a 32-bit handle */ 260 /* Assign a 32-bit handle */
261 /* We do it here so that dev->struct_sem protects the increment */ 261 /* We do it here so that dev->struct_mutex protects the increment */
262 list->user_token = HandleID(map->type == _DRM_SHM 262 list->user_token = HandleID(map->type == _DRM_SHM
263 ? (unsigned long)map->handle 263 ? (unsigned long)map->handle
264 : map->offset, dev); 264 : map->offset, dev);
265 up(&dev->struct_sem); 265 mutex_unlock(&dev->struct_mutex);
266 266
267 *maplist = list; 267 *maplist = list;
268 return 0; 268 return 0;
@@ -392,9 +392,9 @@ int drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
392{ 392{
393 int ret; 393 int ret;
394 394
395 down(&dev->struct_sem); 395 mutex_lock(&dev->struct_mutex);
396 ret = drm_rmmap_locked(dev, map); 396 ret = drm_rmmap_locked(dev, map);
397 up(&dev->struct_sem); 397 mutex_unlock(&dev->struct_mutex);
398 398
399 return ret; 399 return ret;
400} 400}
@@ -423,7 +423,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
423 return -EFAULT; 423 return -EFAULT;
424 } 424 }
425 425
426 down(&dev->struct_sem); 426 mutex_lock(&dev->struct_mutex);
427 list_for_each(list, &dev->maplist->head) { 427 list_for_each(list, &dev->maplist->head) {
428 drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head); 428 drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
429 429
@@ -439,7 +439,7 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
439 * find anything. 439 * find anything.
440 */ 440 */
441 if (list == (&dev->maplist->head)) { 441 if (list == (&dev->maplist->head)) {
442 up(&dev->struct_sem); 442 mutex_unlock(&dev->struct_mutex);
443 return -EINVAL; 443 return -EINVAL;
444 } 444 }
445 445
@@ -448,13 +448,13 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
448 448
449 /* Register and framebuffer maps are permanent */ 449 /* Register and framebuffer maps are permanent */
450 if ((map->type == _DRM_REGISTERS) || (map->type == _DRM_FRAME_BUFFER)) { 450 if ((map->type == _DRM_REGISTERS) || (map->type == _DRM_FRAME_BUFFER)) {
451 up(&dev->struct_sem); 451 mutex_unlock(&dev->struct_mutex);
452 return 0; 452 return 0;
453 } 453 }
454 454
455 ret = drm_rmmap_locked(dev, map); 455 ret = drm_rmmap_locked(dev, map);
456 456
457 up(&dev->struct_sem); 457 mutex_unlock(&dev->struct_mutex);
458 458
459 return ret; 459 return ret;
460} 460}
@@ -566,16 +566,16 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
566 atomic_inc(&dev->buf_alloc); 566 atomic_inc(&dev->buf_alloc);
567 spin_unlock(&dev->count_lock); 567 spin_unlock(&dev->count_lock);
568 568
569 down(&dev->struct_sem); 569 mutex_lock(&dev->struct_mutex);
570 entry = &dma->bufs[order]; 570 entry = &dma->bufs[order];
571 if (entry->buf_count) { 571 if (entry->buf_count) {
572 up(&dev->struct_sem); 572 mutex_unlock(&dev->struct_mutex);
573 atomic_dec(&dev->buf_alloc); 573 atomic_dec(&dev->buf_alloc);
574 return -ENOMEM; /* May only call once for each order */ 574 return -ENOMEM; /* May only call once for each order */
575 } 575 }
576 576
577 if (count < 0 || count > 4096) { 577 if (count < 0 || count > 4096) {
578 up(&dev->struct_sem); 578 mutex_unlock(&dev->struct_mutex);
579 atomic_dec(&dev->buf_alloc); 579 atomic_dec(&dev->buf_alloc);
580 return -EINVAL; 580 return -EINVAL;
581 } 581 }
@@ -583,7 +583,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
583 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 583 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
584 DRM_MEM_BUFS); 584 DRM_MEM_BUFS);
585 if (!entry->buflist) { 585 if (!entry->buflist) {
586 up(&dev->struct_sem); 586 mutex_unlock(&dev->struct_mutex);
587 atomic_dec(&dev->buf_alloc); 587 atomic_dec(&dev->buf_alloc);
588 return -ENOMEM; 588 return -ENOMEM;
589 } 589 }
@@ -616,7 +616,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
616 /* Set count correctly so we free the proper amount. */ 616 /* Set count correctly so we free the proper amount. */
617 entry->buf_count = count; 617 entry->buf_count = count;
618 drm_cleanup_buf_error(dev, entry); 618 drm_cleanup_buf_error(dev, entry);
619 up(&dev->struct_sem); 619 mutex_unlock(&dev->struct_mutex);
620 atomic_dec(&dev->buf_alloc); 620 atomic_dec(&dev->buf_alloc);
621 return -ENOMEM; 621 return -ENOMEM;
622 } 622 }
@@ -638,7 +638,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
638 if (!temp_buflist) { 638 if (!temp_buflist) {
639 /* Free the entry because it isn't valid */ 639 /* Free the entry because it isn't valid */
640 drm_cleanup_buf_error(dev, entry); 640 drm_cleanup_buf_error(dev, entry);
641 up(&dev->struct_sem); 641 mutex_unlock(&dev->struct_mutex);
642 atomic_dec(&dev->buf_alloc); 642 atomic_dec(&dev->buf_alloc);
643 return -ENOMEM; 643 return -ENOMEM;
644 } 644 }
@@ -656,7 +656,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
656 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); 656 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
657 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); 657 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
658 658
659 up(&dev->struct_sem); 659 mutex_unlock(&dev->struct_mutex);
660 660
661 request->count = entry->buf_count; 661 request->count = entry->buf_count;
662 request->size = size; 662 request->size = size;
@@ -722,16 +722,16 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
722 atomic_inc(&dev->buf_alloc); 722 atomic_inc(&dev->buf_alloc);
723 spin_unlock(&dev->count_lock); 723 spin_unlock(&dev->count_lock);
724 724
725 down(&dev->struct_sem); 725 mutex_lock(&dev->struct_mutex);
726 entry = &dma->bufs[order]; 726 entry = &dma->bufs[order];
727 if (entry->buf_count) { 727 if (entry->buf_count) {
728 up(&dev->struct_sem); 728 mutex_unlock(&dev->struct_mutex);
729 atomic_dec(&dev->buf_alloc); 729 atomic_dec(&dev->buf_alloc);
730 return -ENOMEM; /* May only call once for each order */ 730 return -ENOMEM; /* May only call once for each order */
731 } 731 }
732 732
733 if (count < 0 || count > 4096) { 733 if (count < 0 || count > 4096) {
734 up(&dev->struct_sem); 734 mutex_unlock(&dev->struct_mutex);
735 atomic_dec(&dev->buf_alloc); 735 atomic_dec(&dev->buf_alloc);
736 return -EINVAL; 736 return -EINVAL;
737 } 737 }
@@ -739,7 +739,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
739 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 739 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
740 DRM_MEM_BUFS); 740 DRM_MEM_BUFS);
741 if (!entry->buflist) { 741 if (!entry->buflist) {
742 up(&dev->struct_sem); 742 mutex_unlock(&dev->struct_mutex);
743 atomic_dec(&dev->buf_alloc); 743 atomic_dec(&dev->buf_alloc);
744 return -ENOMEM; 744 return -ENOMEM;
745 } 745 }
@@ -750,7 +750,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
750 if (!entry->seglist) { 750 if (!entry->seglist) {
751 drm_free(entry->buflist, 751 drm_free(entry->buflist,
752 count * sizeof(*entry->buflist), DRM_MEM_BUFS); 752 count * sizeof(*entry->buflist), DRM_MEM_BUFS);
753 up(&dev->struct_sem); 753 mutex_unlock(&dev->struct_mutex);
754 atomic_dec(&dev->buf_alloc); 754 atomic_dec(&dev->buf_alloc);
755 return -ENOMEM; 755 return -ENOMEM;
756 } 756 }
@@ -766,7 +766,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
766 count * sizeof(*entry->buflist), DRM_MEM_BUFS); 766 count * sizeof(*entry->buflist), DRM_MEM_BUFS);
767 drm_free(entry->seglist, 767 drm_free(entry->seglist,
768 count * sizeof(*entry->seglist), DRM_MEM_SEGS); 768 count * sizeof(*entry->seglist), DRM_MEM_SEGS);
769 up(&dev->struct_sem); 769 mutex_unlock(&dev->struct_mutex);
770 atomic_dec(&dev->buf_alloc); 770 atomic_dec(&dev->buf_alloc);
771 return -ENOMEM; 771 return -ENOMEM;
772 } 772 }
@@ -790,7 +790,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
790 drm_free(temp_pagelist, 790 drm_free(temp_pagelist,
791 (dma->page_count + (count << page_order)) 791 (dma->page_count + (count << page_order))
792 * sizeof(*dma->pagelist), DRM_MEM_PAGES); 792 * sizeof(*dma->pagelist), DRM_MEM_PAGES);
793 up(&dev->struct_sem); 793 mutex_unlock(&dev->struct_mutex);
794 atomic_dec(&dev->buf_alloc); 794 atomic_dec(&dev->buf_alloc);
795 return -ENOMEM; 795 return -ENOMEM;
796 } 796 }
@@ -831,7 +831,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
831 (count << page_order)) 831 (count << page_order))
832 * sizeof(*dma->pagelist), 832 * sizeof(*dma->pagelist),
833 DRM_MEM_PAGES); 833 DRM_MEM_PAGES);
834 up(&dev->struct_sem); 834 mutex_unlock(&dev->struct_mutex);
835 atomic_dec(&dev->buf_alloc); 835 atomic_dec(&dev->buf_alloc);
836 return -ENOMEM; 836 return -ENOMEM;
837 } 837 }
@@ -853,7 +853,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
853 drm_free(temp_pagelist, 853 drm_free(temp_pagelist,
854 (dma->page_count + (count << page_order)) 854 (dma->page_count + (count << page_order))
855 * sizeof(*dma->pagelist), DRM_MEM_PAGES); 855 * sizeof(*dma->pagelist), DRM_MEM_PAGES);
856 up(&dev->struct_sem); 856 mutex_unlock(&dev->struct_mutex);
857 atomic_dec(&dev->buf_alloc); 857 atomic_dec(&dev->buf_alloc);
858 return -ENOMEM; 858 return -ENOMEM;
859 } 859 }
@@ -878,7 +878,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
878 dma->page_count += entry->seg_count << page_order; 878 dma->page_count += entry->seg_count << page_order;
879 dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order); 879 dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
880 880
881 up(&dev->struct_sem); 881 mutex_unlock(&dev->struct_mutex);
882 882
883 request->count = entry->buf_count; 883 request->count = entry->buf_count;
884 request->size = size; 884 request->size = size;
@@ -948,16 +948,16 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
948 atomic_inc(&dev->buf_alloc); 948 atomic_inc(&dev->buf_alloc);
949 spin_unlock(&dev->count_lock); 949 spin_unlock(&dev->count_lock);
950 950
951 down(&dev->struct_sem); 951 mutex_lock(&dev->struct_mutex);
952 entry = &dma->bufs[order]; 952 entry = &dma->bufs[order];
953 if (entry->buf_count) { 953 if (entry->buf_count) {
954 up(&dev->struct_sem); 954 mutex_unlock(&dev->struct_mutex);
955 atomic_dec(&dev->buf_alloc); 955 atomic_dec(&dev->buf_alloc);
956 return -ENOMEM; /* May only call once for each order */ 956 return -ENOMEM; /* May only call once for each order */
957 } 957 }
958 958
959 if (count < 0 || count > 4096) { 959 if (count < 0 || count > 4096) {
960 up(&dev->struct_sem); 960 mutex_unlock(&dev->struct_mutex);
961 atomic_dec(&dev->buf_alloc); 961 atomic_dec(&dev->buf_alloc);
962 return -EINVAL; 962 return -EINVAL;
963 } 963 }
@@ -965,7 +965,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
965 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 965 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
966 DRM_MEM_BUFS); 966 DRM_MEM_BUFS);
967 if (!entry->buflist) { 967 if (!entry->buflist) {
968 up(&dev->struct_sem); 968 mutex_unlock(&dev->struct_mutex);
969 atomic_dec(&dev->buf_alloc); 969 atomic_dec(&dev->buf_alloc);
970 return -ENOMEM; 970 return -ENOMEM;
971 } 971 }
@@ -999,7 +999,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
999 /* Set count correctly so we free the proper amount. */ 999 /* Set count correctly so we free the proper amount. */
1000 entry->buf_count = count; 1000 entry->buf_count = count;
1001 drm_cleanup_buf_error(dev, entry); 1001 drm_cleanup_buf_error(dev, entry);
1002 up(&dev->struct_sem); 1002 mutex_unlock(&dev->struct_mutex);
1003 atomic_dec(&dev->buf_alloc); 1003 atomic_dec(&dev->buf_alloc);
1004 return -ENOMEM; 1004 return -ENOMEM;
1005 } 1005 }
@@ -1022,7 +1022,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
1022 if (!temp_buflist) { 1022 if (!temp_buflist) {
1023 /* Free the entry because it isn't valid */ 1023 /* Free the entry because it isn't valid */
1024 drm_cleanup_buf_error(dev, entry); 1024 drm_cleanup_buf_error(dev, entry);
1025 up(&dev->struct_sem); 1025 mutex_unlock(&dev->struct_mutex);
1026 atomic_dec(&dev->buf_alloc); 1026 atomic_dec(&dev->buf_alloc);
1027 return -ENOMEM; 1027 return -ENOMEM;
1028 } 1028 }
@@ -1040,7 +1040,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
1040 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); 1040 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
1041 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); 1041 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
1042 1042
1043 up(&dev->struct_sem); 1043 mutex_unlock(&dev->struct_mutex);
1044 1044
1045 request->count = entry->buf_count; 1045 request->count = entry->buf_count;
1046 request->size = size; 1046 request->size = size;
@@ -1110,16 +1110,16 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1110 atomic_inc(&dev->buf_alloc); 1110 atomic_inc(&dev->buf_alloc);
1111 spin_unlock(&dev->count_lock); 1111 spin_unlock(&dev->count_lock);
1112 1112
1113 down(&dev->struct_sem); 1113 mutex_lock(&dev->struct_mutex);
1114 entry = &dma->bufs[order]; 1114 entry = &dma->bufs[order];
1115 if (entry->buf_count) { 1115 if (entry->buf_count) {
1116 up(&dev->struct_sem); 1116 mutex_unlock(&dev->struct_mutex);
1117 atomic_dec(&dev->buf_alloc); 1117 atomic_dec(&dev->buf_alloc);
1118 return -ENOMEM; /* May only call once for each order */ 1118 return -ENOMEM; /* May only call once for each order */
1119 } 1119 }
1120 1120
1121 if (count < 0 || count > 4096) { 1121 if (count < 0 || count > 4096) {
1122 up(&dev->struct_sem); 1122 mutex_unlock(&dev->struct_mutex);
1123 atomic_dec(&dev->buf_alloc); 1123 atomic_dec(&dev->buf_alloc);
1124 return -EINVAL; 1124 return -EINVAL;
1125 } 1125 }
@@ -1127,7 +1127,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1127 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 1127 entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
1128 DRM_MEM_BUFS); 1128 DRM_MEM_BUFS);
1129 if (!entry->buflist) { 1129 if (!entry->buflist) {
1130 up(&dev->struct_sem); 1130 mutex_unlock(&dev->struct_mutex);
1131 atomic_dec(&dev->buf_alloc); 1131 atomic_dec(&dev->buf_alloc);
1132 return -ENOMEM; 1132 return -ENOMEM;
1133 } 1133 }
@@ -1160,7 +1160,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1160 /* Set count correctly so we free the proper amount. */ 1160 /* Set count correctly so we free the proper amount. */
1161 entry->buf_count = count; 1161 entry->buf_count = count;
1162 drm_cleanup_buf_error(dev, entry); 1162 drm_cleanup_buf_error(dev, entry);
1163 up(&dev->struct_sem); 1163 mutex_unlock(&dev->struct_mutex);
1164 atomic_dec(&dev->buf_alloc); 1164 atomic_dec(&dev->buf_alloc);
1165 return -ENOMEM; 1165 return -ENOMEM;
1166 } 1166 }
@@ -1182,7 +1182,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1182 if (!temp_buflist) { 1182 if (!temp_buflist) {
1183 /* Free the entry because it isn't valid */ 1183 /* Free the entry because it isn't valid */
1184 drm_cleanup_buf_error(dev, entry); 1184 drm_cleanup_buf_error(dev, entry);
1185 up(&dev->struct_sem); 1185 mutex_unlock(&dev->struct_mutex);
1186 atomic_dec(&dev->buf_alloc); 1186 atomic_dec(&dev->buf_alloc);
1187 return -ENOMEM; 1187 return -ENOMEM;
1188 } 1188 }
@@ -1200,7 +1200,7 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
1200 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); 1200 DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
1201 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); 1201 DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
1202 1202
1203 up(&dev->struct_sem); 1203 mutex_unlock(&dev->struct_mutex);
1204 1204
1205 request->count = entry->buf_count; 1205 request->count = entry->buf_count;
1206 request->size = size; 1206 request->size = size;
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c
index f84254526949..83094c73da67 100644
--- a/drivers/char/drm/drm_context.c
+++ b/drivers/char/drm/drm_context.c
@@ -53,7 +53,7 @@
53 * \param ctx_handle context handle. 53 * \param ctx_handle context handle.
54 * 54 *
55 * Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry 55 * Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry
56 * in drm_device::context_sareas, while holding the drm_device::struct_sem 56 * in drm_device::context_sareas, while holding the drm_device::struct_mutex
57 * lock. 57 * lock.
58 */ 58 */
59void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) 59void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
@@ -64,10 +64,10 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
64 goto failed; 64 goto failed;
65 65
66 if (ctx_handle < DRM_MAX_CTXBITMAP) { 66 if (ctx_handle < DRM_MAX_CTXBITMAP) {
67 down(&dev->struct_sem); 67 mutex_lock(&dev->struct_mutex);
68 clear_bit(ctx_handle, dev->ctx_bitmap); 68 clear_bit(ctx_handle, dev->ctx_bitmap);
69 dev->context_sareas[ctx_handle] = NULL; 69 dev->context_sareas[ctx_handle] = NULL;
70 up(&dev->struct_sem); 70 mutex_unlock(&dev->struct_mutex);
71 return; 71 return;
72 } 72 }
73 failed: 73 failed:
@@ -83,7 +83,7 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
83 * 83 *
84 * Find the first zero bit in drm_device::ctx_bitmap and (re)allocates 84 * Find the first zero bit in drm_device::ctx_bitmap and (re)allocates
85 * drm_device::context_sareas to accommodate the new entry while holding the 85 * drm_device::context_sareas to accommodate the new entry while holding the
86 * drm_device::struct_sem lock. 86 * drm_device::struct_mutex lock.
87 */ 87 */
88static int drm_ctxbitmap_next(drm_device_t * dev) 88static int drm_ctxbitmap_next(drm_device_t * dev)
89{ 89{
@@ -92,7 +92,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
92 if (!dev->ctx_bitmap) 92 if (!dev->ctx_bitmap)
93 return -1; 93 return -1;
94 94
95 down(&dev->struct_sem); 95 mutex_lock(&dev->struct_mutex);
96 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP); 96 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
97 if (bit < DRM_MAX_CTXBITMAP) { 97 if (bit < DRM_MAX_CTXBITMAP) {
98 set_bit(bit, dev->ctx_bitmap); 98 set_bit(bit, dev->ctx_bitmap);
@@ -113,7 +113,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
113 DRM_MEM_MAPS); 113 DRM_MEM_MAPS);
114 if (!ctx_sareas) { 114 if (!ctx_sareas) {
115 clear_bit(bit, dev->ctx_bitmap); 115 clear_bit(bit, dev->ctx_bitmap);
116 up(&dev->struct_sem); 116 mutex_unlock(&dev->struct_mutex);
117 return -1; 117 return -1;
118 } 118 }
119 dev->context_sareas = ctx_sareas; 119 dev->context_sareas = ctx_sareas;
@@ -126,16 +126,16 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
126 DRM_MEM_MAPS); 126 DRM_MEM_MAPS);
127 if (!dev->context_sareas) { 127 if (!dev->context_sareas) {
128 clear_bit(bit, dev->ctx_bitmap); 128 clear_bit(bit, dev->ctx_bitmap);
129 up(&dev->struct_sem); 129 mutex_unlock(&dev->struct_mutex);
130 return -1; 130 return -1;
131 } 131 }
132 dev->context_sareas[bit] = NULL; 132 dev->context_sareas[bit] = NULL;
133 } 133 }
134 } 134 }
135 up(&dev->struct_sem); 135 mutex_unlock(&dev->struct_mutex);
136 return bit; 136 return bit;
137 } 137 }
138 up(&dev->struct_sem); 138 mutex_unlock(&dev->struct_mutex);
139 return -1; 139 return -1;
140} 140}
141 141
@@ -145,24 +145,24 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
145 * \param dev DRM device. 145 * \param dev DRM device.
146 * 146 *
147 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding 147 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding
148 * the drm_device::struct_sem lock. 148 * the drm_device::struct_mutex lock.
149 */ 149 */
150int drm_ctxbitmap_init(drm_device_t * dev) 150int drm_ctxbitmap_init(drm_device_t * dev)
151{ 151{
152 int i; 152 int i;
153 int temp; 153 int temp;
154 154
155 down(&dev->struct_sem); 155 mutex_lock(&dev->struct_mutex);
156 dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE, 156 dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE,
157 DRM_MEM_CTXBITMAP); 157 DRM_MEM_CTXBITMAP);
158 if (dev->ctx_bitmap == NULL) { 158 if (dev->ctx_bitmap == NULL) {
159 up(&dev->struct_sem); 159 mutex_unlock(&dev->struct_mutex);
160 return -ENOMEM; 160 return -ENOMEM;
161 } 161 }
162 memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE); 162 memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE);
163 dev->context_sareas = NULL; 163 dev->context_sareas = NULL;
164 dev->max_context = -1; 164 dev->max_context = -1;
165 up(&dev->struct_sem); 165 mutex_unlock(&dev->struct_mutex);
166 166
167 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { 167 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
168 temp = drm_ctxbitmap_next(dev); 168 temp = drm_ctxbitmap_next(dev);
@@ -178,17 +178,17 @@ int drm_ctxbitmap_init(drm_device_t * dev)
178 * \param dev DRM device. 178 * \param dev DRM device.
179 * 179 *
180 * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding 180 * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding
181 * the drm_device::struct_sem lock. 181 * the drm_device::struct_mutex lock.
182 */ 182 */
183void drm_ctxbitmap_cleanup(drm_device_t * dev) 183void drm_ctxbitmap_cleanup(drm_device_t * dev)
184{ 184{
185 down(&dev->struct_sem); 185 mutex_lock(&dev->struct_mutex);
186 if (dev->context_sareas) 186 if (dev->context_sareas)
187 drm_free(dev->context_sareas, 187 drm_free(dev->context_sareas,
188 sizeof(*dev->context_sareas) * 188 sizeof(*dev->context_sareas) *
189 dev->max_context, DRM_MEM_MAPS); 189 dev->max_context, DRM_MEM_MAPS);
190 drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); 190 drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP);
191 up(&dev->struct_sem); 191 mutex_unlock(&dev->struct_mutex);
192} 192}
193 193
194/*@}*/ 194/*@}*/
@@ -222,15 +222,15 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
222 if (copy_from_user(&request, argp, sizeof(request))) 222 if (copy_from_user(&request, argp, sizeof(request)))
223 return -EFAULT; 223 return -EFAULT;
224 224
225 down(&dev->struct_sem); 225 mutex_lock(&dev->struct_mutex);
226 if (dev->max_context < 0 226 if (dev->max_context < 0
227 || request.ctx_id >= (unsigned)dev->max_context) { 227 || request.ctx_id >= (unsigned)dev->max_context) {
228 up(&dev->struct_sem); 228 mutex_unlock(&dev->struct_mutex);
229 return -EINVAL; 229 return -EINVAL;
230 } 230 }
231 231
232 map = dev->context_sareas[request.ctx_id]; 232 map = dev->context_sareas[request.ctx_id];
233 up(&dev->struct_sem); 233 mutex_unlock(&dev->struct_mutex);
234 234
235 request.handle = NULL; 235 request.handle = NULL;
236 list_for_each_entry(_entry, &dev->maplist->head, head) { 236 list_for_each_entry(_entry, &dev->maplist->head, head) {
@@ -274,7 +274,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
274 (drm_ctx_priv_map_t __user *) arg, sizeof(request))) 274 (drm_ctx_priv_map_t __user *) arg, sizeof(request)))
275 return -EFAULT; 275 return -EFAULT;
276 276
277 down(&dev->struct_sem); 277 mutex_lock(&dev->struct_mutex);
278 list_for_each(list, &dev->maplist->head) { 278 list_for_each(list, &dev->maplist->head) {
279 r_list = list_entry(list, drm_map_list_t, head); 279 r_list = list_entry(list, drm_map_list_t, head);
280 if (r_list->map 280 if (r_list->map
@@ -282,7 +282,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
282 goto found; 282 goto found;
283 } 283 }
284 bad: 284 bad:
285 up(&dev->struct_sem); 285 mutex_unlock(&dev->struct_mutex);
286 return -EINVAL; 286 return -EINVAL;
287 287
288 found: 288 found:
@@ -294,7 +294,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
294 if (request.ctx_id >= (unsigned)dev->max_context) 294 if (request.ctx_id >= (unsigned)dev->max_context)
295 goto bad; 295 goto bad;
296 dev->context_sareas[request.ctx_id] = map; 296 dev->context_sareas[request.ctx_id] = map;
297 up(&dev->struct_sem); 297 mutex_unlock(&dev->struct_mutex);
298 return 0; 298 return 0;
299} 299}
300 300
@@ -448,10 +448,10 @@ int drm_addctx(struct inode *inode, struct file *filp,
448 ctx_entry->handle = ctx.handle; 448 ctx_entry->handle = ctx.handle;
449 ctx_entry->tag = priv; 449 ctx_entry->tag = priv;
450 450
451 down(&dev->ctxlist_sem); 451 mutex_lock(&dev->ctxlist_mutex);
452 list_add(&ctx_entry->head, &dev->ctxlist->head); 452 list_add(&ctx_entry->head, &dev->ctxlist->head);
453 ++dev->ctx_count; 453 ++dev->ctx_count;
454 up(&dev->ctxlist_sem); 454 mutex_unlock(&dev->ctxlist_mutex);
455 455
456 if (copy_to_user(argp, &ctx, sizeof(ctx))) 456 if (copy_to_user(argp, &ctx, sizeof(ctx)))
457 return -EFAULT; 457 return -EFAULT;
@@ -574,7 +574,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
574 drm_ctxbitmap_free(dev, ctx.handle); 574 drm_ctxbitmap_free(dev, ctx.handle);
575 } 575 }
576 576
577 down(&dev->ctxlist_sem); 577 mutex_lock(&dev->ctxlist_mutex);
578 if (!list_empty(&dev->ctxlist->head)) { 578 if (!list_empty(&dev->ctxlist->head)) {
579 drm_ctx_list_t *pos, *n; 579 drm_ctx_list_t *pos, *n;
580 580
@@ -586,7 +586,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
586 } 586 }
587 } 587 }
588 } 588 }
589 up(&dev->ctxlist_sem); 589 mutex_unlock(&dev->ctxlist_mutex);
590 590
591 return 0; 591 return 0;
592} 592}
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index c4fa5a29582b..dc6bbe8a18dc 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -151,7 +151,7 @@ int drm_lastclose(drm_device_t * dev)
151 if (dev->irq_enabled) 151 if (dev->irq_enabled)
152 drm_irq_uninstall(dev); 152 drm_irq_uninstall(dev);
153 153
154 down(&dev->struct_sem); 154 mutex_lock(&dev->struct_mutex);
155 del_timer(&dev->timer); 155 del_timer(&dev->timer);
156 156
157 /* Clear pid list */ 157 /* Clear pid list */
@@ -231,7 +231,7 @@ int drm_lastclose(drm_device_t * dev)
231 dev->lock.filp = NULL; 231 dev->lock.filp = NULL;
232 wake_up_interruptible(&dev->lock.lock_queue); 232 wake_up_interruptible(&dev->lock.lock_queue);
233 } 233 }
234 up(&dev->struct_sem); 234 mutex_unlock(&dev->struct_mutex);
235 235
236 DRM_DEBUG("lastclose completed\n"); 236 DRM_DEBUG("lastclose completed\n");
237 return 0; 237 return 0;
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index 403f44a1bf01..641f7633878c 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -262,7 +262,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
262 goto out_free; 262 goto out_free;
263 } 263 }
264 264
265 down(&dev->struct_sem); 265 mutex_lock(&dev->struct_mutex);
266 if (!dev->file_last) { 266 if (!dev->file_last) {
267 priv->next = NULL; 267 priv->next = NULL;
268 priv->prev = NULL; 268 priv->prev = NULL;
@@ -276,7 +276,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
276 dev->file_last->next = priv; 276 dev->file_last->next = priv;
277 dev->file_last = priv; 277 dev->file_last = priv;
278 } 278 }
279 up(&dev->struct_sem); 279 mutex_unlock(&dev->struct_mutex);
280 280
281#ifdef __alpha__ 281#ifdef __alpha__
282 /* 282 /*
@@ -413,7 +413,7 @@ int drm_release(struct inode *inode, struct file *filp)
413 413
414 drm_fasync(-1, filp, 0); 414 drm_fasync(-1, filp, 0);
415 415
416 down(&dev->ctxlist_sem); 416 mutex_lock(&dev->ctxlist_mutex);
417 if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) { 417 if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) {
418 drm_ctx_list_t *pos, *n; 418 drm_ctx_list_t *pos, *n;
419 419
@@ -432,9 +432,9 @@ int drm_release(struct inode *inode, struct file *filp)
432 } 432 }
433 } 433 }
434 } 434 }
435 up(&dev->ctxlist_sem); 435 mutex_unlock(&dev->ctxlist_mutex);
436 436
437 down(&dev->struct_sem); 437 mutex_lock(&dev->struct_mutex);
438 if (priv->remove_auth_on_close == 1) { 438 if (priv->remove_auth_on_close == 1) {
439 drm_file_t *temp = dev->file_first; 439 drm_file_t *temp = dev->file_first;
440 while (temp) { 440 while (temp) {
@@ -452,7 +452,7 @@ int drm_release(struct inode *inode, struct file *filp)
452 } else { 452 } else {
453 dev->file_last = priv->prev; 453 dev->file_last = priv->prev;
454 } 454 }
455 up(&dev->struct_sem); 455 mutex_unlock(&dev->struct_mutex);
456 456
457 if (dev->driver->postclose) 457 if (dev->driver->postclose)
458 dev->driver->postclose(dev, priv); 458 dev->driver->postclose(dev, priv);
diff --git a/drivers/char/drm/drm_ioctl.c b/drivers/char/drm/drm_ioctl.c
index bcd4e604d3ec..555f323b8a32 100644
--- a/drivers/char/drm/drm_ioctl.c
+++ b/drivers/char/drm/drm_ioctl.c
@@ -194,9 +194,9 @@ int drm_getmap(struct inode *inode, struct file *filp,
194 return -EFAULT; 194 return -EFAULT;
195 idx = map.offset; 195 idx = map.offset;
196 196
197 down(&dev->struct_sem); 197 mutex_lock(&dev->struct_mutex);
198 if (idx < 0) { 198 if (idx < 0) {
199 up(&dev->struct_sem); 199 mutex_unlock(&dev->struct_mutex);
200 return -EINVAL; 200 return -EINVAL;
201 } 201 }
202 202
@@ -209,7 +209,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
209 i++; 209 i++;
210 } 210 }
211 if (!r_list || !r_list->map) { 211 if (!r_list || !r_list->map) {
212 up(&dev->struct_sem); 212 mutex_unlock(&dev->struct_mutex);
213 return -EINVAL; 213 return -EINVAL;
214 } 214 }
215 215
@@ -219,7 +219,7 @@ int drm_getmap(struct inode *inode, struct file *filp,
219 map.flags = r_list->map->flags; 219 map.flags = r_list->map->flags;
220 map.handle = (void *)(unsigned long)r_list->user_token; 220 map.handle = (void *)(unsigned long)r_list->user_token;
221 map.mtrr = r_list->map->mtrr; 221 map.mtrr = r_list->map->mtrr;
222 up(&dev->struct_sem); 222 mutex_unlock(&dev->struct_mutex);
223 223
224 if (copy_to_user(argp, &map, sizeof(map))) 224 if (copy_to_user(argp, &map, sizeof(map)))
225 return -EFAULT; 225 return -EFAULT;
@@ -253,11 +253,11 @@ int drm_getclient(struct inode *inode, struct file *filp,
253 if (copy_from_user(&client, argp, sizeof(client))) 253 if (copy_from_user(&client, argp, sizeof(client)))
254 return -EFAULT; 254 return -EFAULT;
255 idx = client.idx; 255 idx = client.idx;
256 down(&dev->struct_sem); 256 mutex_lock(&dev->struct_mutex);
257 for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ; 257 for (i = 0, pt = dev->file_first; i < idx && pt; i++, pt = pt->next) ;
258 258
259 if (!pt) { 259 if (!pt) {
260 up(&dev->struct_sem); 260 mutex_unlock(&dev->struct_mutex);
261 return -EINVAL; 261 return -EINVAL;
262 } 262 }
263 client.auth = pt->authenticated; 263 client.auth = pt->authenticated;
@@ -265,7 +265,7 @@ int drm_getclient(struct inode *inode, struct file *filp,
265 client.uid = pt->uid; 265 client.uid = pt->uid;
266 client.magic = pt->magic; 266 client.magic = pt->magic;
267 client.iocs = pt->ioctl_count; 267 client.iocs = pt->ioctl_count;
268 up(&dev->struct_sem); 268 mutex_unlock(&dev->struct_mutex);
269 269
270 if (copy_to_user(argp, &client, sizeof(client))) 270 if (copy_to_user(argp, &client, sizeof(client)))
271 return -EFAULT; 271 return -EFAULT;
@@ -292,7 +292,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
292 292
293 memset(&stats, 0, sizeof(stats)); 293 memset(&stats, 0, sizeof(stats));
294 294
295 down(&dev->struct_sem); 295 mutex_lock(&dev->struct_mutex);
296 296
297 for (i = 0; i < dev->counters; i++) { 297 for (i = 0; i < dev->counters; i++) {
298 if (dev->types[i] == _DRM_STAT_LOCK) 298 if (dev->types[i] == _DRM_STAT_LOCK)
@@ -305,7 +305,7 @@ int drm_getstats(struct inode *inode, struct file *filp,
305 305
306 stats.count = dev->counters; 306 stats.count = dev->counters;
307 307
308 up(&dev->struct_sem); 308 mutex_unlock(&dev->struct_mutex);
309 309
310 if (copy_to_user((drm_stats_t __user *) arg, &stats, sizeof(stats))) 310 if (copy_to_user((drm_stats_t __user *) arg, &stats, sizeof(stats)))
311 return -EFAULT; 311 return -EFAULT;
diff --git a/drivers/char/drm/drm_irq.c b/drivers/char/drm/drm_irq.c
index b0d4b236e837..611a1173091d 100644
--- a/drivers/char/drm/drm_irq.c
+++ b/drivers/char/drm/drm_irq.c
@@ -98,20 +98,20 @@ static int drm_irq_install(drm_device_t * dev)
98 if (dev->irq == 0) 98 if (dev->irq == 0)
99 return -EINVAL; 99 return -EINVAL;
100 100
101 down(&dev->struct_sem); 101 mutex_lock(&dev->struct_mutex);
102 102
103 /* Driver must have been initialized */ 103 /* Driver must have been initialized */
104 if (!dev->dev_private) { 104 if (!dev->dev_private) {
105 up(&dev->struct_sem); 105 mutex_unlock(&dev->struct_mutex);
106 return -EINVAL; 106 return -EINVAL;
107 } 107 }
108 108
109 if (dev->irq_enabled) { 109 if (dev->irq_enabled) {
110 up(&dev->struct_sem); 110 mutex_unlock(&dev->struct_mutex);
111 return -EBUSY; 111 return -EBUSY;
112 } 112 }
113 dev->irq_enabled = 1; 113 dev->irq_enabled = 1;
114 up(&dev->struct_sem); 114 mutex_unlock(&dev->struct_mutex);
115 115
116 DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq); 116 DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq);
117 117
@@ -135,9 +135,9 @@ static int drm_irq_install(drm_device_t * dev)
135 ret = request_irq(dev->irq, dev->driver->irq_handler, 135 ret = request_irq(dev->irq, dev->driver->irq_handler,
136 sh_flags, dev->devname, dev); 136 sh_flags, dev->devname, dev);
137 if (ret < 0) { 137 if (ret < 0) {
138 down(&dev->struct_sem); 138 mutex_lock(&dev->struct_mutex);
139 dev->irq_enabled = 0; 139 dev->irq_enabled = 0;
140 up(&dev->struct_sem); 140 mutex_unlock(&dev->struct_mutex);
141 return ret; 141 return ret;
142 } 142 }
143 143
@@ -161,10 +161,10 @@ int drm_irq_uninstall(drm_device_t * dev)
161 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 161 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
162 return -EINVAL; 162 return -EINVAL;
163 163
164 down(&dev->struct_sem); 164 mutex_lock(&dev->struct_mutex);
165 irq_enabled = dev->irq_enabled; 165 irq_enabled = dev->irq_enabled;
166 dev->irq_enabled = 0; 166 dev->irq_enabled = 0;
167 up(&dev->struct_sem); 167 mutex_unlock(&dev->struct_mutex);
168 168
169 if (!irq_enabled) 169 if (!irq_enabled)
170 return -EINVAL; 170 return -EINVAL;
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h
index 5b1d3a04458d..8fd6357a48da 100644
--- a/drivers/char/drm/drm_pciids.h
+++ b/drivers/char/drm/drm_pciids.h
@@ -3,6 +3,7 @@
3 Please contact dri-devel@lists.sf.net to add new cards to this list 3 Please contact dri-devel@lists.sf.net to add new cards to this list
4*/ 4*/
5#define radeon_PCI_IDS \ 5#define radeon_PCI_IDS \
6 {0x1002, 0x3150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350},\
6 {0x1002, 0x4136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|CHIP_IS_IGP}, \ 7 {0x1002, 0x4136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|CHIP_IS_IGP}, \
7 {0x1002, 0x4137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|CHIP_IS_IGP}, \ 8 {0x1002, 0x4137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|CHIP_IS_IGP}, \
8 {0x1002, 0x4144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ 9 {0x1002, 0x4144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
@@ -242,5 +243,6 @@
242 {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 243 {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
243 {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 244 {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
244 {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ 245 {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
246 {0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
245 {0, 0, 0} 247 {0, 0, 0}
246 248
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c
index 6f943e3309ef..362a270af0f1 100644
--- a/drivers/char/drm/drm_proc.c
+++ b/drivers/char/drm/drm_proc.c
@@ -258,7 +258,7 @@ static int drm__vm_info(char *buf, char **start, off_t offset, int request,
258} 258}
259 259
260/** 260/**
261 * Simply calls _vm_info() while holding the drm_device::struct_sem lock. 261 * Simply calls _vm_info() while holding the drm_device::struct_mutex lock.
262 */ 262 */
263static int drm_vm_info(char *buf, char **start, off_t offset, int request, 263static int drm_vm_info(char *buf, char **start, off_t offset, int request,
264 int *eof, void *data) 264 int *eof, void *data)
@@ -266,9 +266,9 @@ static int drm_vm_info(char *buf, char **start, off_t offset, int request,
266 drm_device_t *dev = (drm_device_t *) data; 266 drm_device_t *dev = (drm_device_t *) data;
267 int ret; 267 int ret;
268 268
269 down(&dev->struct_sem); 269 mutex_lock(&dev->struct_mutex);
270 ret = drm__vm_info(buf, start, offset, request, eof, data); 270 ret = drm__vm_info(buf, start, offset, request, eof, data);
271 up(&dev->struct_sem); 271 mutex_unlock(&dev->struct_mutex);
272 return ret; 272 return ret;
273} 273}
274 274
@@ -331,7 +331,7 @@ static int drm__queues_info(char *buf, char **start, off_t offset,
331} 331}
332 332
333/** 333/**
334 * Simply calls _queues_info() while holding the drm_device::struct_sem lock. 334 * Simply calls _queues_info() while holding the drm_device::struct_mutex lock.
335 */ 335 */
336static int drm_queues_info(char *buf, char **start, off_t offset, int request, 336static int drm_queues_info(char *buf, char **start, off_t offset, int request,
337 int *eof, void *data) 337 int *eof, void *data)
@@ -339,9 +339,9 @@ static int drm_queues_info(char *buf, char **start, off_t offset, int request,
339 drm_device_t *dev = (drm_device_t *) data; 339 drm_device_t *dev = (drm_device_t *) data;
340 int ret; 340 int ret;
341 341
342 down(&dev->struct_sem); 342 mutex_lock(&dev->struct_mutex);
343 ret = drm__queues_info(buf, start, offset, request, eof, data); 343 ret = drm__queues_info(buf, start, offset, request, eof, data);
344 up(&dev->struct_sem); 344 mutex_unlock(&dev->struct_mutex);
345 return ret; 345 return ret;
346} 346}
347 347
@@ -403,7 +403,7 @@ static int drm__bufs_info(char *buf, char **start, off_t offset, int request,
403} 403}
404 404
405/** 405/**
406 * Simply calls _bufs_info() while holding the drm_device::struct_sem lock. 406 * Simply calls _bufs_info() while holding the drm_device::struct_mutex lock.
407 */ 407 */
408static int drm_bufs_info(char *buf, char **start, off_t offset, int request, 408static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
409 int *eof, void *data) 409 int *eof, void *data)
@@ -411,9 +411,9 @@ static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
411 drm_device_t *dev = (drm_device_t *) data; 411 drm_device_t *dev = (drm_device_t *) data;
412 int ret; 412 int ret;
413 413
414 down(&dev->struct_sem); 414 mutex_lock(&dev->struct_mutex);
415 ret = drm__bufs_info(buf, start, offset, request, eof, data); 415 ret = drm__bufs_info(buf, start, offset, request, eof, data);
416 up(&dev->struct_sem); 416 mutex_unlock(&dev->struct_mutex);
417 return ret; 417 return ret;
418} 418}
419 419
@@ -459,7 +459,7 @@ static int drm__clients_info(char *buf, char **start, off_t offset,
459} 459}
460 460
461/** 461/**
462 * Simply calls _clients_info() while holding the drm_device::struct_sem lock. 462 * Simply calls _clients_info() while holding the drm_device::struct_mutex lock.
463 */ 463 */
464static int drm_clients_info(char *buf, char **start, off_t offset, 464static int drm_clients_info(char *buf, char **start, off_t offset,
465 int request, int *eof, void *data) 465 int request, int *eof, void *data)
@@ -467,9 +467,9 @@ static int drm_clients_info(char *buf, char **start, off_t offset,
467 drm_device_t *dev = (drm_device_t *) data; 467 drm_device_t *dev = (drm_device_t *) data;
468 int ret; 468 int ret;
469 469
470 down(&dev->struct_sem); 470 mutex_lock(&dev->struct_mutex);
471 ret = drm__clients_info(buf, start, offset, request, eof, data); 471 ret = drm__clients_info(buf, start, offset, request, eof, data);
472 up(&dev->struct_sem); 472 mutex_unlock(&dev->struct_mutex);
473 return ret; 473 return ret;
474} 474}
475 475
@@ -540,9 +540,9 @@ static int drm_vma_info(char *buf, char **start, off_t offset, int request,
540 drm_device_t *dev = (drm_device_t *) data; 540 drm_device_t *dev = (drm_device_t *) data;
541 int ret; 541 int ret;
542 542
543 down(&dev->struct_sem); 543 mutex_lock(&dev->struct_mutex);
544 ret = drm__vma_info(buf, start, offset, request, eof, data); 544 ret = drm__vma_info(buf, start, offset, request, eof, data);
545 up(&dev->struct_sem); 545 mutex_unlock(&dev->struct_mutex);
546 return ret; 546 return ret;
547} 547}
548#endif 548#endif
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c
index 42d766359caa..7a9263ff3007 100644
--- a/drivers/char/drm/drm_stub.c
+++ b/drivers/char/drm/drm_stub.c
@@ -61,8 +61,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
61 61
62 spin_lock_init(&dev->count_lock); 62 spin_lock_init(&dev->count_lock);
63 init_timer(&dev->timer); 63 init_timer(&dev->timer);
64 sema_init(&dev->struct_sem, 1); 64 mutex_init(&dev->struct_mutex);
65 sema_init(&dev->ctxlist_sem, 1); 65 mutex_init(&dev->ctxlist_mutex);
66 66
67 dev->pdev = pdev; 67 dev->pdev = pdev;
68 68
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index 3f73aa774c80..0291cd62c69f 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -188,7 +188,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
188 188
189 map = vma->vm_private_data; 189 map = vma->vm_private_data;
190 190
191 down(&dev->struct_sem); 191 mutex_lock(&dev->struct_mutex);
192 for (pt = dev->vmalist, prev = NULL; pt; pt = next) { 192 for (pt = dev->vmalist, prev = NULL; pt; pt = next) {
193 next = pt->next; 193 next = pt->next;
194 if (pt->vma->vm_private_data == map) 194 if (pt->vma->vm_private_data == map)
@@ -248,7 +248,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
248 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 248 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
249 } 249 }
250 } 250 }
251 up(&dev->struct_sem); 251 mutex_unlock(&dev->struct_mutex);
252} 252}
253 253
254/** 254/**
@@ -404,12 +404,12 @@ static void drm_vm_open(struct vm_area_struct *vma)
404 404
405 vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); 405 vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
406 if (vma_entry) { 406 if (vma_entry) {
407 down(&dev->struct_sem); 407 mutex_lock(&dev->struct_mutex);
408 vma_entry->vma = vma; 408 vma_entry->vma = vma;
409 vma_entry->next = dev->vmalist; 409 vma_entry->next = dev->vmalist;
410 vma_entry->pid = current->pid; 410 vma_entry->pid = current->pid;
411 dev->vmalist = vma_entry; 411 dev->vmalist = vma_entry;
412 up(&dev->struct_sem); 412 mutex_unlock(&dev->struct_mutex);
413 } 413 }
414} 414}
415 415
@@ -431,7 +431,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
431 vma->vm_start, vma->vm_end - vma->vm_start); 431 vma->vm_start, vma->vm_end - vma->vm_start);
432 atomic_dec(&dev->vma_count); 432 atomic_dec(&dev->vma_count);
433 433
434 down(&dev->struct_sem); 434 mutex_lock(&dev->struct_mutex);
435 for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) { 435 for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) {
436 if (pt->vma == vma) { 436 if (pt->vma == vma) {
437 if (prev) { 437 if (prev) {
@@ -443,7 +443,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
443 break; 443 break;
444 } 444 }
445 } 445 }
446 up(&dev->struct_sem); 446 mutex_unlock(&dev->struct_mutex);
447} 447}
448 448
449/** 449/**
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
index cc1b89086876..ae0aa6d7e0bb 100644
--- a/drivers/char/drm/i810_dma.c
+++ b/drivers/char/drm/i810_dma.c
@@ -958,7 +958,7 @@ static int i810_flush_queue(drm_device_t * dev)
958} 958}
959 959
960/* Must be called with the lock held */ 960/* Must be called with the lock held */
961void i810_reclaim_buffers(drm_device_t * dev, struct file *filp) 961static void i810_reclaim_buffers(drm_device_t * dev, struct file *filp)
962{ 962{
963 drm_device_dma_t *dma = dev->dma; 963 drm_device_dma_t *dma = dev->dma;
964 int i; 964 int i;
diff --git a/drivers/char/drm/i810_drv.h b/drivers/char/drm/i810_drv.h
index a18b80d91920..e8cf3ff606f0 100644
--- a/drivers/char/drm/i810_drv.h
+++ b/drivers/char/drm/i810_drv.h
@@ -113,8 +113,6 @@ typedef struct drm_i810_private {
113} drm_i810_private_t; 113} drm_i810_private_t;
114 114
115 /* i810_dma.c */ 115 /* i810_dma.c */
116extern void i810_reclaim_buffers(drm_device_t * dev, struct file *filp);
117
118extern int i810_driver_dma_quiescent(drm_device_t * dev); 116extern int i810_driver_dma_quiescent(drm_device_t * dev);
119extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev, 117extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev,
120 struct file *filp); 118 struct file *filp);
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
index 4fea32aed6d2..163f2cbfe60d 100644
--- a/drivers/char/drm/i830_dma.c
+++ b/drivers/char/drm/i830_dma.c
@@ -1239,7 +1239,7 @@ static int i830_flush_queue(drm_device_t * dev)
1239} 1239}
1240 1240
1241/* Must be called with the lock held */ 1241/* Must be called with the lock held */
1242void i830_reclaim_buffers(drm_device_t * dev, struct file *filp) 1242static void i830_reclaim_buffers(drm_device_t * dev, struct file *filp)
1243{ 1243{
1244 drm_device_dma_t *dma = dev->dma; 1244 drm_device_dma_t *dma = dev->dma;
1245 int i; 1245 int i;
diff --git a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h
index bf9075b576bd..85bc5be6f916 100644
--- a/drivers/char/drm/i830_drv.h
+++ b/drivers/char/drm/i830_drv.h
@@ -123,9 +123,6 @@ typedef struct drm_i830_private {
123extern drm_ioctl_desc_t i830_ioctls[]; 123extern drm_ioctl_desc_t i830_ioctls[];
124extern int i830_max_ioctl; 124extern int i830_max_ioctl;
125 125
126/* i830_dma.c */
127extern void i830_reclaim_buffers(drm_device_t * dev, struct file *filp);
128
129/* i830_irq.c */ 126/* i830_irq.c */
130extern int i830_irq_emit(struct inode *inode, struct file *filp, 127extern int i830_irq_emit(struct inode *inode, struct file *filp,
131 unsigned int cmd, unsigned long arg); 128 unsigned int cmd, unsigned long arg);
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index 9140703da1ba..1ff4c7ca0bff 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -344,18 +344,20 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
344 int i; 344 int i;
345 RING_LOCALS; 345 RING_LOCALS;
346 346
347 if ((dwords+1) * sizeof(int) >= dev_priv->ring.Size - 8)
348 return DRM_ERR(EINVAL);
349
350 BEGIN_LP_RING(((dwords+1)&~1));
351
347 for (i = 0; i < dwords;) { 352 for (i = 0; i < dwords;) {
348 int cmd, sz; 353 int cmd, sz;
349 354
350 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd))) 355 if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd)))
351 return DRM_ERR(EINVAL); 356 return DRM_ERR(EINVAL);
352 357
353/* printk("%d/%d ", i, dwords); */
354
355 if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords) 358 if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords)
356 return DRM_ERR(EINVAL); 359 return DRM_ERR(EINVAL);
357 360
358 BEGIN_LP_RING(sz);
359 OUT_RING(cmd); 361 OUT_RING(cmd);
360 362
361 while (++i, --sz) { 363 while (++i, --sz) {
@@ -365,9 +367,13 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords)
365 } 367 }
366 OUT_RING(cmd); 368 OUT_RING(cmd);
367 } 369 }
368 ADVANCE_LP_RING();
369 } 370 }
370 371
372 if (dwords & 1)
373 OUT_RING(0);
374
375 ADVANCE_LP_RING();
376
371 return 0; 377 return 0;
372} 378}
373 379
@@ -401,6 +407,21 @@ static int i915_emit_box(drm_device_t * dev,
401 return 0; 407 return 0;
402} 408}
403 409
410static void i915_emit_breadcrumb(drm_device_t *dev)
411{
412 drm_i915_private_t *dev_priv = dev->dev_private;
413 RING_LOCALS;
414
415 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++;
416
417 BEGIN_LP_RING(4);
418 OUT_RING(CMD_STORE_DWORD_IDX);
419 OUT_RING(20);
420 OUT_RING(dev_priv->counter);
421 OUT_RING(0);
422 ADVANCE_LP_RING();
423}
424
404static int i915_dispatch_cmdbuffer(drm_device_t * dev, 425static int i915_dispatch_cmdbuffer(drm_device_t * dev,
405 drm_i915_cmdbuffer_t * cmd) 426 drm_i915_cmdbuffer_t * cmd)
406{ 427{
@@ -429,6 +450,7 @@ static int i915_dispatch_cmdbuffer(drm_device_t * dev,
429 return ret; 450 return ret;
430 } 451 }
431 452
453 i915_emit_breadcrumb(dev);
432 return 0; 454 return 0;
433} 455}
434 456
@@ -475,12 +497,7 @@ static int i915_dispatch_batchbuffer(drm_device_t * dev,
475 497
476 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++; 498 dev_priv->sarea_priv->last_enqueue = dev_priv->counter++;
477 499
478 BEGIN_LP_RING(4); 500 i915_emit_breadcrumb(dev);
479 OUT_RING(CMD_STORE_DWORD_IDX);
480 OUT_RING(20);
481 OUT_RING(dev_priv->counter);
482 OUT_RING(0);
483 ADVANCE_LP_RING();
484 501
485 return 0; 502 return 0;
486} 503}
@@ -657,7 +674,7 @@ static int i915_getparam(DRM_IOCTL_ARGS)
657 value = READ_BREADCRUMB(dev_priv); 674 value = READ_BREADCRUMB(dev_priv);
658 break; 675 break;
659 default: 676 default:
660 DRM_ERROR("Unkown parameter %d\n", param.param); 677 DRM_ERROR("Unknown parameter %d\n", param.param);
661 return DRM_ERR(EINVAL); 678 return DRM_ERR(EINVAL);
662 } 679 }
663 680
@@ -742,7 +759,8 @@ drm_ioctl_desc_t i915_ioctls[] = {
742 [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH}, 759 [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH},
743 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, 760 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH},
744 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 761 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
745 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH} 762 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH},
763 [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }
746}; 764};
747 765
748int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); 766int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/char/drm/i915_drm.h b/drivers/char/drm/i915_drm.h
index 77412ddac007..4cb3da578330 100644
--- a/drivers/char/drm/i915_drm.h
+++ b/drivers/char/drm/i915_drm.h
@@ -74,6 +74,30 @@ typedef struct _drm_i915_sarea {
74 int pf_active; 74 int pf_active;
75 int pf_current_page; /* which buffer is being displayed? */ 75 int pf_current_page; /* which buffer is being displayed? */
76 int perf_boxes; /* performance boxes to be displayed */ 76 int perf_boxes; /* performance boxes to be displayed */
77 int width, height; /* screen size in pixels */
78
79 drm_handle_t front_handle;
80 int front_offset;
81 int front_size;
82
83 drm_handle_t back_handle;
84 int back_offset;
85 int back_size;
86
87 drm_handle_t depth_handle;
88 int depth_offset;
89 int depth_size;
90
91 drm_handle_t tex_handle;
92 int tex_offset;
93 int tex_size;
94 int log_tex_granularity;
95 int pitch;
96 int rotation; /* 0, 90, 180 or 270 */
97 int rotated_offset;
98 int rotated_size;
99 int rotated_pitch;
100 int virtualX, virtualY;
77} drm_i915_sarea_t; 101} drm_i915_sarea_t;
78 102
79/* Flags for perf_boxes 103/* Flags for perf_boxes
@@ -99,6 +123,7 @@ typedef struct _drm_i915_sarea {
99#define DRM_I915_FREE 0x09 123#define DRM_I915_FREE 0x09
100#define DRM_I915_INIT_HEAP 0x0a 124#define DRM_I915_INIT_HEAP 0x0a
101#define DRM_I915_CMDBUFFER 0x0b 125#define DRM_I915_CMDBUFFER 0x0b
126#define DRM_I915_DESTROY_HEAP 0x0c
102 127
103#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 128#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
104#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) 129#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -112,6 +137,7 @@ typedef struct _drm_i915_sarea {
112#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t) 137#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
113#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t) 138#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
114#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t) 139#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
140#define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
115 141
116/* Allow drivers to submit batchbuffers directly to hardware, relying 142/* Allow drivers to submit batchbuffers directly to hardware, relying
117 * on the security mechanisms provided by hardware. 143 * on the security mechanisms provided by hardware.
@@ -191,4 +217,11 @@ typedef struct drm_i915_mem_init_heap {
191 int start; 217 int start;
192} drm_i915_mem_init_heap_t; 218} drm_i915_mem_init_heap_t;
193 219
220/* Allow memory manager to be torn down and re-initialized (eg on
221 * rotate):
222 */
223typedef struct drm_i915_mem_destroy_heap {
224 int region;
225} drm_i915_mem_destroy_heap_t;
226
194#endif /* _I915_DRM_H_ */ 227#endif /* _I915_DRM_H_ */
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index c6c71b45f101..7a65666899e4 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -37,16 +37,17 @@
37 37
38#define DRIVER_NAME "i915" 38#define DRIVER_NAME "i915"
39#define DRIVER_DESC "Intel Graphics" 39#define DRIVER_DESC "Intel Graphics"
40#define DRIVER_DATE "20051209" 40#define DRIVER_DATE "20060119"
41 41
42/* Interface history: 42/* Interface history:
43 * 43 *
44 * 1.1: Original. 44 * 1.1: Original.
45 * 1.2: Add Power Management 45 * 1.2: Add Power Management
46 * 1.3: Add vblank support 46 * 1.3: Add vblank support
47 * 1.4: Fix cmdbuffer path, add heap destroy
47 */ 48 */
48#define DRIVER_MAJOR 1 49#define DRIVER_MAJOR 1
49#define DRIVER_MINOR 3 50#define DRIVER_MINOR 4
50#define DRIVER_PATCHLEVEL 0 51#define DRIVER_PATCHLEVEL 0
51 52
52typedef struct _drm_i915_ring_buffer { 53typedef struct _drm_i915_ring_buffer {
@@ -123,6 +124,7 @@ extern void i915_driver_irq_uninstall(drm_device_t * dev);
123extern int i915_mem_alloc(DRM_IOCTL_ARGS); 124extern int i915_mem_alloc(DRM_IOCTL_ARGS);
124extern int i915_mem_free(DRM_IOCTL_ARGS); 125extern int i915_mem_free(DRM_IOCTL_ARGS);
125extern int i915_mem_init_heap(DRM_IOCTL_ARGS); 126extern int i915_mem_init_heap(DRM_IOCTL_ARGS);
127extern int i915_mem_destroy_heap(DRM_IOCTL_ARGS);
126extern void i915_mem_takedown(struct mem_block **heap); 128extern void i915_mem_takedown(struct mem_block **heap);
127extern void i915_mem_release(drm_device_t * dev, 129extern void i915_mem_release(drm_device_t * dev,
128 DRMFILE filp, struct mem_block *heap); 130 DRMFILE filp, struct mem_block *heap);
diff --git a/drivers/char/drm/i915_mem.c b/drivers/char/drm/i915_mem.c
index ba87ff17ff64..52c67324df58 100644
--- a/drivers/char/drm/i915_mem.c
+++ b/drivers/char/drm/i915_mem.c
@@ -365,3 +365,34 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS)
365 365
366 return init_heap(heap, initheap.start, initheap.size); 366 return init_heap(heap, initheap.start, initheap.size);
367} 367}
368
369int i915_mem_destroy_heap( DRM_IOCTL_ARGS )
370{
371 DRM_DEVICE;
372 drm_i915_private_t *dev_priv = dev->dev_private;
373 drm_i915_mem_destroy_heap_t destroyheap;
374 struct mem_block **heap;
375
376 if ( !dev_priv ) {
377 DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
378 return DRM_ERR(EINVAL);
379 }
380
381 DRM_COPY_FROM_USER_IOCTL( destroyheap, (drm_i915_mem_destroy_heap_t *)data,
382 sizeof(destroyheap) );
383
384 heap = get_heap( dev_priv, destroyheap.region );
385 if (!heap) {
386 DRM_ERROR("get_heap failed");
387 return DRM_ERR(EFAULT);
388 }
389
390 if (!*heap) {
391 DRM_ERROR("heap not initialized?");
392 return DRM_ERR(EFAULT);
393 }
394
395 i915_mem_takedown( heap );
396 return 0;
397}
398
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 915665c7fe7c..9bb8ae0c1c27 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -1640,7 +1640,7 @@ static int radeon_do_cleanup_cp(drm_device_t * dev)
1640 if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB) 1640 if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB)
1641 { 1641 {
1642 drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev); 1642 drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev);
1643 dev_priv->gart_info.addr = 0; 1643 dev_priv->gart_info.addr = NULL;
1644 } 1644 }
1645 } 1645 }
1646 /* only clear to the start of flags */ 1646 /* only clear to the start of flags */
diff --git a/drivers/char/drm/savage_bci.c b/drivers/char/drm/savage_bci.c
index 0d426deeefec..59c7520bf9a2 100644
--- a/drivers/char/drm/savage_bci.c
+++ b/drivers/char/drm/savage_bci.c
@@ -32,6 +32,8 @@
32#define SAVAGE_EVENT_USEC_TIMEOUT 5000000 /* 5s */ 32#define SAVAGE_EVENT_USEC_TIMEOUT 5000000 /* 5s */
33#define SAVAGE_FREELIST_DEBUG 0 33#define SAVAGE_FREELIST_DEBUG 0
34 34
35static int savage_do_cleanup_bci(drm_device_t *dev);
36
35static int 37static int
36savage_bci_wait_fifo_shadow(drm_savage_private_t * dev_priv, unsigned int n) 38savage_bci_wait_fifo_shadow(drm_savage_private_t * dev_priv, unsigned int n)
37{ 39{
@@ -895,7 +897,7 @@ static int savage_do_init_bci(drm_device_t * dev, drm_savage_init_t * init)
895 return 0; 897 return 0;
896} 898}
897 899
898int savage_do_cleanup_bci(drm_device_t * dev) 900static int savage_do_cleanup_bci(drm_device_t * dev)
899{ 901{
900 drm_savage_private_t *dev_priv = dev->dev_private; 902 drm_savage_private_t *dev_priv = dev->dev_private;
901 903
diff --git a/drivers/char/drm/savage_drv.h b/drivers/char/drm/savage_drv.h
index dd46cb85439c..8f04b3d82292 100644
--- a/drivers/char/drm/savage_drv.h
+++ b/drivers/char/drm/savage_drv.h
@@ -212,7 +212,6 @@ extern int savage_driver_load(drm_device_t *dev, unsigned long chipset);
212extern int savage_driver_firstopen(drm_device_t *dev); 212extern int savage_driver_firstopen(drm_device_t *dev);
213extern void savage_driver_lastclose(drm_device_t *dev); 213extern void savage_driver_lastclose(drm_device_t *dev);
214extern int savage_driver_unload(drm_device_t *dev); 214extern int savage_driver_unload(drm_device_t *dev);
215extern int savage_do_cleanup_bci(drm_device_t * dev);
216extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp); 215extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp);
217 216
218/* state functions */ 217/* state functions */
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c
index 593c0b8f650a..a691ae74129d 100644
--- a/drivers/char/drm/via_dma.c
+++ b/drivers/char/drm/via_dma.c
@@ -222,7 +222,7 @@ static int via_initialize(drm_device_t * dev,
222 return 0; 222 return 0;
223} 223}
224 224
225int via_dma_init(DRM_IOCTL_ARGS) 225static int via_dma_init(DRM_IOCTL_ARGS)
226{ 226{
227 DRM_DEVICE; 227 DRM_DEVICE;
228 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 228 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
@@ -321,7 +321,7 @@ int via_driver_dma_quiescent(drm_device_t * dev)
321 return 0; 321 return 0;
322} 322}
323 323
324int via_flush_ioctl(DRM_IOCTL_ARGS) 324static int via_flush_ioctl(DRM_IOCTL_ARGS)
325{ 325{
326 DRM_DEVICE; 326 DRM_DEVICE;
327 327
@@ -330,7 +330,7 @@ int via_flush_ioctl(DRM_IOCTL_ARGS)
330 return via_driver_dma_quiescent(dev); 330 return via_driver_dma_quiescent(dev);
331} 331}
332 332
333int via_cmdbuffer(DRM_IOCTL_ARGS) 333static int via_cmdbuffer(DRM_IOCTL_ARGS)
334{ 334{
335 DRM_DEVICE; 335 DRM_DEVICE;
336 drm_via_cmdbuffer_t cmdbuf; 336 drm_via_cmdbuffer_t cmdbuf;
@@ -375,7 +375,7 @@ static int via_dispatch_pci_cmdbuffer(drm_device_t * dev,
375 return ret; 375 return ret;
376} 376}
377 377
378int via_pci_cmdbuffer(DRM_IOCTL_ARGS) 378static int via_pci_cmdbuffer(DRM_IOCTL_ARGS)
379{ 379{
380 DRM_DEVICE; 380 DRM_DEVICE;
381 drm_via_cmdbuffer_t cmdbuf; 381 drm_via_cmdbuffer_t cmdbuf;
@@ -665,7 +665,7 @@ static void via_cmdbuf_reset(drm_via_private_t * dev_priv)
665 * User interface to the space and lag functions. 665 * User interface to the space and lag functions.
666 */ 666 */
667 667
668int via_cmdbuf_size(DRM_IOCTL_ARGS) 668static int via_cmdbuf_size(DRM_IOCTL_ARGS)
669{ 669{
670 DRM_DEVICE; 670 DRM_DEVICE;
671 drm_via_cmdbuf_size_t d_siz; 671 drm_via_cmdbuf_size_t d_siz;
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index 9d5e027dae0e..b7f17457b424 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -108,7 +108,7 @@ via_map_blit_for_device(struct pci_dev *pdev,
108 int num_desc = 0; 108 int num_desc = 0;
109 int cur_line; 109 int cur_line;
110 dma_addr_t next = 0 | VIA_DMA_DPR_EC; 110 dma_addr_t next = 0 | VIA_DMA_DPR_EC;
111 drm_via_descriptor_t *desc_ptr = 0; 111 drm_via_descriptor_t *desc_ptr = NULL;
112 112
113 if (mode == 1) 113 if (mode == 1)
114 desc_ptr = vsg->desc_pages[cur_descriptor_page]; 114 desc_ptr = vsg->desc_pages[cur_descriptor_page];
@@ -167,7 +167,7 @@ via_map_blit_for_device(struct pci_dev *pdev,
167 */ 167 */
168 168
169 169
170void 170static void
171via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg) 171via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
172{ 172{
173 struct page *page; 173 struct page *page;
@@ -581,7 +581,7 @@ via_build_sg_info(drm_device_t *dev, drm_via_sg_info_t *vsg, drm_via_dmablit_t *
581 int ret = 0; 581 int ret = 0;
582 582
583 vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE; 583 vsg->direction = (draw) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
584 vsg->bounce_buffer = 0; 584 vsg->bounce_buffer = NULL;
585 585
586 vsg->state = dr_via_sg_init; 586 vsg->state = dr_via_sg_init;
587 587
diff --git a/drivers/char/drm/via_drv.h b/drivers/char/drm/via_drv.h
index aad4f99f5405..52bcc7b1ba45 100644
--- a/drivers/char/drm/via_drv.h
+++ b/drivers/char/drm/via_drv.h
@@ -110,11 +110,6 @@ extern int via_mem_free(DRM_IOCTL_ARGS);
110extern int via_agp_init(DRM_IOCTL_ARGS); 110extern int via_agp_init(DRM_IOCTL_ARGS);
111extern int via_map_init(DRM_IOCTL_ARGS); 111extern int via_map_init(DRM_IOCTL_ARGS);
112extern int via_decoder_futex(DRM_IOCTL_ARGS); 112extern int via_decoder_futex(DRM_IOCTL_ARGS);
113extern int via_dma_init(DRM_IOCTL_ARGS);
114extern int via_cmdbuffer(DRM_IOCTL_ARGS);
115extern int via_flush_ioctl(DRM_IOCTL_ARGS);
116extern int via_pci_cmdbuffer(DRM_IOCTL_ARGS);
117extern int via_cmdbuf_size(DRM_IOCTL_ARGS);
118extern int via_wait_irq(DRM_IOCTL_ARGS); 113extern int via_wait_irq(DRM_IOCTL_ARGS);
119extern int via_dma_blit_sync( DRM_IOCTL_ARGS ); 114extern int via_dma_blit_sync( DRM_IOCTL_ARGS );
120extern int via_dma_blit( DRM_IOCTL_ARGS ); 115extern int via_dma_blit( DRM_IOCTL_ARGS );
@@ -139,8 +134,6 @@ extern int via_driver_dma_quiescent(drm_device_t * dev);
139extern void via_init_futex(drm_via_private_t * dev_priv); 134extern void via_init_futex(drm_via_private_t * dev_priv);
140extern void via_cleanup_futex(drm_via_private_t * dev_priv); 135extern void via_cleanup_futex(drm_via_private_t * dev_priv);
141extern void via_release_futex(drm_via_private_t * dev_priv, int context); 136extern void via_release_futex(drm_via_private_t * dev_priv, int context);
142extern int via_driver_irq_wait(drm_device_t * dev, unsigned int irq,
143 int force_sequence, unsigned int *sequence);
144 137
145extern void via_dmablit_handler(drm_device_t *dev, int engine, int from_irq); 138extern void via_dmablit_handler(drm_device_t *dev, int engine, int from_irq);
146extern void via_init_dmablit(drm_device_t *dev); 139extern void via_init_dmablit(drm_device_t *dev);
diff --git a/drivers/char/drm/via_irq.c b/drivers/char/drm/via_irq.c
index 56d7e3daea12..6152415644e9 100644
--- a/drivers/char/drm/via_irq.c
+++ b/drivers/char/drm/via_irq.c
@@ -190,7 +190,7 @@ int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
190 return ret; 190 return ret;
191} 191}
192 192
193int 193static int
194via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, 194via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence,
195 unsigned int *sequence) 195 unsigned int *sequence)
196{ 196{
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index 3f3ac039f4d9..57539d8f9f7c 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -359,7 +359,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
359 } 359 }
360 } 360 }
361 361
362 schedule_delayed_work(&tty->buf.work, 1); 362 tty_schedule_flip(tty);
363 363
364 info->stat_flags &= ~ESP_STAT_RX_TIMEOUT; 364 info->stat_flags &= ~ESP_STAT_RX_TIMEOUT;
365 release_pio_buffer(pio_buf); 365 release_pio_buffer(pio_buf);
@@ -426,7 +426,7 @@ static inline void receive_chars_dma_done(struct esp_struct *info,
426 } 426 }
427 tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag); 427 tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag);
428 } 428 }
429 schedule_delayed_work(&tty->buf.work, 1); 429 tty_schedule_flip(tty);
430 } 430 }
431 431
432 if (dma_bytes != num_bytes) { 432 if (dma_bytes != num_bytes) {
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c
index 40a67c86420c..ac626418b329 100644
--- a/drivers/char/hangcheck-timer.c
+++ b/drivers/char/hangcheck-timer.c
@@ -117,12 +117,9 @@ __setup("hcheck_reboot", hangcheck_parse_reboot);
117__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); 117__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks);
118#endif /* not MODULE */ 118#endif /* not MODULE */
119 119
120#if defined(CONFIG_X86) 120#if defined(CONFIG_X86) || defined(CONFIG_S390)
121# define HAVE_MONOTONIC 121# define HAVE_MONOTONIC
122# define TIMER_FREQ 1000000000ULL 122# define TIMER_FREQ 1000000000ULL
123#elif defined(CONFIG_S390)
124/* FA240000 is 1 Second in the IBM time universe (Page 4-38 Principles of Op for zSeries */
125# define TIMER_FREQ 0xFA240000ULL
126#elif defined(CONFIG_IA64) 123#elif defined(CONFIG_IA64)
127# define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq) 124# define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq)
128#elif defined(CONFIG_PPC64) 125#elif defined(CONFIG_PPC64)
@@ -134,12 +131,7 @@ extern unsigned long long monotonic_clock(void);
134#else 131#else
135static inline unsigned long long monotonic_clock(void) 132static inline unsigned long long monotonic_clock(void)
136{ 133{
137# ifdef __s390__
138 /* returns the TOD. see 4-38 Principles of Op of zSeries */
139 return get_clock();
140# else
141 return get_cycles(); 134 return get_cycles();
142# endif /* __s390__ */
143} 135}
144#endif /* HAVE_MONOTONIC */ 136#endif /* HAVE_MONOTONIC */
145 137
@@ -188,8 +180,6 @@ static int __init hangcheck_init(void)
188 VERSION_STR, hangcheck_tick, hangcheck_margin); 180 VERSION_STR, hangcheck_tick, hangcheck_margin);
189#if defined (HAVE_MONOTONIC) 181#if defined (HAVE_MONOTONIC)
190 printk("Hangcheck: Using monotonic_clock().\n"); 182 printk("Hangcheck: Using monotonic_clock().\n");
191#elif defined(__s390__)
192 printk("Hangcheck: Using TOD.\n");
193#else 183#else
194 printk("Hangcheck: Using get_cycles().\n"); 184 printk("Hangcheck: Using get_cycles().\n");
195#endif /* HAVE_MONOTONIC */ 185#endif /* HAVE_MONOTONIC */
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 3808d9572619..66a2fee06eb9 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -927,9 +927,9 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
927 if (ACPI_SUCCESS(status)) { 927 if (ACPI_SUCCESS(status)) {
928 unsigned long size; 928 unsigned long size;
929 929
930 size = addr.max_address_range - addr.min_address_range + 1; 930 size = addr.maximum - addr.minimum + 1;
931 hdp->hd_phys_address = addr.min_address_range; 931 hdp->hd_phys_address = addr.minimum;
932 hdp->hd_address = ioremap(addr.min_address_range, size); 932 hdp->hd_address = ioremap(addr.minimum, size);
933 933
934 if (hpet_is_known(hdp)) { 934 if (hpet_is_known(hdp)) {
935 printk(KERN_DEBUG "%s: 0x%lx is busy\n", 935 printk(KERN_DEBUG "%s: 0x%lx is busy\n",
@@ -937,15 +937,15 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
937 iounmap(hdp->hd_address); 937 iounmap(hdp->hd_address);
938 return -EBUSY; 938 return -EBUSY;
939 } 939 }
940 } else if (res->id == ACPI_RSTYPE_FIXED_MEM32) { 940 } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) {
941 struct acpi_resource_fixed_mem32 *fixmem32; 941 struct acpi_resource_fixed_memory32 *fixmem32;
942 942
943 fixmem32 = &res->data.fixed_memory32; 943 fixmem32 = &res->data.fixed_memory32;
944 if (!fixmem32) 944 if (!fixmem32)
945 return -EINVAL; 945 return -EINVAL;
946 946
947 hdp->hd_phys_address = fixmem32->range_base_address; 947 hdp->hd_phys_address = fixmem32->address;
948 hdp->hd_address = ioremap(fixmem32->range_base_address, 948 hdp->hd_address = ioremap(fixmem32->address,
949 HPET_RANGE_SIZE); 949 HPET_RANGE_SIZE);
950 950
951 if (hpet_is_known(hdp)) { 951 if (hpet_is_known(hdp)) {
@@ -954,20 +954,20 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
954 iounmap(hdp->hd_address); 954 iounmap(hdp->hd_address);
955 return -EBUSY; 955 return -EBUSY;
956 } 956 }
957 } else if (res->id == ACPI_RSTYPE_EXT_IRQ) { 957 } else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) {
958 struct acpi_resource_ext_irq *irqp; 958 struct acpi_resource_extended_irq *irqp;
959 int i; 959 int i;
960 960
961 irqp = &res->data.extended_irq; 961 irqp = &res->data.extended_irq;
962 962
963 if (irqp->number_of_interrupts > 0) { 963 if (irqp->interrupt_count > 0) {
964 hdp->hd_nirqs = irqp->number_of_interrupts; 964 hdp->hd_nirqs = irqp->interrupt_count;
965 965
966 for (i = 0; i < hdp->hd_nirqs; i++) { 966 for (i = 0; i < hdp->hd_nirqs; i++) {
967 int rc = 967 int rc =
968 acpi_register_gsi(irqp->interrupts[i], 968 acpi_register_gsi(irqp->interrupts[i],
969 irqp->edge_level, 969 irqp->triggering,
970 irqp->active_high_low); 970 irqp->polarity);
971 if (rc < 0) 971 if (rc < 0)
972 return AE_ERROR; 972 return AE_ERROR;
973 hdp->hd_irq[i] = rc; 973 hdp->hd_irq[i] = rc;
diff --git a/drivers/char/ip2/i2cmd.c b/drivers/char/ip2/i2cmd.c
index cb8f4198e9a3..e7af647800b6 100644
--- a/drivers/char/ip2/i2cmd.c
+++ b/drivers/char/ip2/i2cmd.c
@@ -139,7 +139,6 @@ static UCHAR ct79[] = { 2, BYP, 0x4F,0 }; // XMIT_NOW
139//static UCHAR ct86[]={ 2, BTH, 0x56,0 }; // RCV_ENABLE 139//static UCHAR ct86[]={ 2, BTH, 0x56,0 }; // RCV_ENABLE
140static UCHAR ct87[] = { 1, BYP, 0x57 }; // HW_TEST 140static UCHAR ct87[] = { 1, BYP, 0x57 }; // HW_TEST
141//static UCHAR ct88[]={ 3, BTH, 0x58,0,0 }; // RCV_THRESHOLD 141//static UCHAR ct88[]={ 3, BTH, 0x58,0,0 }; // RCV_THRESHOLD
142static UCHAR ct89[]={ 1, BYP, 0x59 }; // DSS_NOW
143//static UCHAR ct90[]={ 3, BYP, 0x5A,0,0 }; // Set SILO 142//static UCHAR ct90[]={ 3, BYP, 0x5A,0,0 }; // Set SILO
144//static UCHAR ct91[]={ 2, BYP, 0x5B,0 }; // timed break 143//static UCHAR ct91[]={ 2, BYP, 0x5B,0 }; // timed break
145 144
diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c
index 56e93a5a1e24..48fcfba37bfa 100644
--- a/drivers/char/ip2main.c
+++ b/drivers/char/ip2main.c
@@ -2906,65 +2906,16 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
2906 rc = -EINVAL; 2906 rc = -EINVAL;
2907 break; 2907 break;
2908 case 3: // Trace device 2908 case 3: // Trace device
2909 if ( cmd == 1 ) { 2909 /*
2910 rc = put_user(iiSendPendingMail, pIndex++ ); 2910 * akpm: This used to write a whole bunch of function addresses
2911 rc = put_user(i2InitChannels, pIndex++ ); 2911 * to userspace, which generated lots of put_user() warnings.
2912 rc = put_user(i2QueueNeeds, pIndex++ ); 2912 * I killed it all. Just return "success" and don't do
2913 rc = put_user(i2QueueCommands, pIndex++ ); 2913 * anything.
2914 rc = put_user(i2GetStatus, pIndex++ ); 2914 */
2915 rc = put_user(i2Input, pIndex++ ); 2915 if (cmd == 1)
2916 rc = put_user(i2InputFlush, pIndex++ ); 2916 rc = 0;
2917 rc = put_user(i2Output, pIndex++ ); 2917 else
2918 rc = put_user(i2FlushOutput, pIndex++ );
2919 rc = put_user(i2DrainWakeup, pIndex++ );
2920 rc = put_user(i2DrainOutput, pIndex++ );
2921 rc = put_user(i2OutputFree, pIndex++ );
2922 rc = put_user(i2StripFifo, pIndex++ );
2923 rc = put_user(i2StuffFifoBypass, pIndex++ );
2924 rc = put_user(i2StuffFifoFlow, pIndex++ );
2925 rc = put_user(i2StuffFifoInline, pIndex++ );
2926 rc = put_user(i2ServiceBoard, pIndex++ );
2927 rc = put_user(serviceOutgoingFifo, pIndex++ );
2928 // rc = put_user(ip2_init, pIndex++ );
2929 rc = put_user(ip2_init_board, pIndex++ );
2930 rc = put_user(find_eisa_board, pIndex++ );
2931 rc = put_user(set_irq, pIndex++ );
2932 rc = put_user(ip2_interrupt, pIndex++ );
2933 rc = put_user(ip2_poll, pIndex++ );
2934 rc = put_user(service_all_boards, pIndex++ );
2935 rc = put_user(do_input, pIndex++ );
2936 rc = put_user(do_status, pIndex++ );
2937#ifndef IP2DEBUG_OPEN
2938 rc = put_user(0, pIndex++ );
2939#else
2940 rc = put_user(open_sanity_check, pIndex++ );
2941#endif
2942 rc = put_user(ip2_open, pIndex++ );
2943 rc = put_user(ip2_close, pIndex++ );
2944 rc = put_user(ip2_hangup, pIndex++ );
2945 rc = put_user(ip2_write, pIndex++ );
2946 rc = put_user(ip2_putchar, pIndex++ );
2947 rc = put_user(ip2_flush_chars, pIndex++ );
2948 rc = put_user(ip2_write_room, pIndex++ );
2949 rc = put_user(ip2_chars_in_buf, pIndex++ );
2950 rc = put_user(ip2_flush_buffer, pIndex++ );
2951
2952 //rc = put_user(ip2_wait_until_sent, pIndex++ );
2953 rc = put_user(0, pIndex++ );
2954
2955 rc = put_user(ip2_throttle, pIndex++ );
2956 rc = put_user(ip2_unthrottle, pIndex++ );
2957 rc = put_user(ip2_ioctl, pIndex++ );
2958 rc = put_user(0, pIndex++ );
2959 rc = put_user(get_serial_info, pIndex++ );
2960 rc = put_user(set_serial_info, pIndex++ );
2961 rc = put_user(ip2_set_termios, pIndex++ );
2962 rc = put_user(ip2_set_line_discipline, pIndex++ );
2963 rc = put_user(set_params, pIndex++ );
2964 } else {
2965 rc = -EINVAL; 2918 rc = -EINVAL;
2966 }
2967
2968 break; 2919 break;
2969 2920
2970 default: 2921 default:
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 0097f06fa67b..d745004281d0 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -481,7 +481,7 @@ int ipmi_validate_addr(struct ipmi_addr *addr, int len)
481 } 481 }
482 482
483 if ((addr->channel == IPMI_BMC_CHANNEL) 483 if ((addr->channel == IPMI_BMC_CHANNEL)
484 || (addr->channel >= IPMI_NUM_CHANNELS) 484 || (addr->channel >= IPMI_MAX_CHANNELS)
485 || (addr->channel < 0)) 485 || (addr->channel < 0))
486 return -EINVAL; 486 return -EINVAL;
487 487
@@ -1321,7 +1321,7 @@ static int i_ipmi_request(ipmi_user_t user,
1321 unsigned char ipmb_seq; 1321 unsigned char ipmb_seq;
1322 long seqid; 1322 long seqid;
1323 1323
1324 if (addr->channel >= IPMI_NUM_CHANNELS) { 1324 if (addr->channel >= IPMI_MAX_CHANNELS) {
1325 spin_lock_irqsave(&intf->counter_lock, flags); 1325 spin_lock_irqsave(&intf->counter_lock, flags);
1326 intf->sent_invalid_commands++; 1326 intf->sent_invalid_commands++;
1327 spin_unlock_irqrestore(&intf->counter_lock, flags); 1327 spin_unlock_irqrestore(&intf->counter_lock, flags);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index c67ef3e47ad5..e59b638766ef 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1270,36 +1270,36 @@ static int try_init_port(int intf_num, struct smi_info **new_info)
1270 return 0; 1270 return 0;
1271} 1271}
1272 1272
1273static unsigned char mem_inb(struct si_sm_io *io, unsigned int offset) 1273static unsigned char intf_mem_inb(struct si_sm_io *io, unsigned int offset)
1274{ 1274{
1275 return readb((io->addr)+(offset * io->regspacing)); 1275 return readb((io->addr)+(offset * io->regspacing));
1276} 1276}
1277 1277
1278static void mem_outb(struct si_sm_io *io, unsigned int offset, 1278static void intf_mem_outb(struct si_sm_io *io, unsigned int offset,
1279 unsigned char b) 1279 unsigned char b)
1280{ 1280{
1281 writeb(b, (io->addr)+(offset * io->regspacing)); 1281 writeb(b, (io->addr)+(offset * io->regspacing));
1282} 1282}
1283 1283
1284static unsigned char mem_inw(struct si_sm_io *io, unsigned int offset) 1284static unsigned char intf_mem_inw(struct si_sm_io *io, unsigned int offset)
1285{ 1285{
1286 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift) 1286 return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift)
1287 && 0xff; 1287 && 0xff;
1288} 1288}
1289 1289
1290static void mem_outw(struct si_sm_io *io, unsigned int offset, 1290static void intf_mem_outw(struct si_sm_io *io, unsigned int offset,
1291 unsigned char b) 1291 unsigned char b)
1292{ 1292{
1293 writeb(b << io->regshift, (io->addr)+(offset * io->regspacing)); 1293 writeb(b << io->regshift, (io->addr)+(offset * io->regspacing));
1294} 1294}
1295 1295
1296static unsigned char mem_inl(struct si_sm_io *io, unsigned int offset) 1296static unsigned char intf_mem_inl(struct si_sm_io *io, unsigned int offset)
1297{ 1297{
1298 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift) 1298 return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift)
1299 && 0xff; 1299 && 0xff;
1300} 1300}
1301 1301
1302static void mem_outl(struct si_sm_io *io, unsigned int offset, 1302static void intf_mem_outl(struct si_sm_io *io, unsigned int offset,
1303 unsigned char b) 1303 unsigned char b)
1304{ 1304{
1305 writel(b << io->regshift, (io->addr)+(offset * io->regspacing)); 1305 writel(b << io->regshift, (io->addr)+(offset * io->regspacing));
@@ -1349,16 +1349,16 @@ static int mem_setup(struct smi_info *info)
1349 upon the register size. */ 1349 upon the register size. */
1350 switch (info->io.regsize) { 1350 switch (info->io.regsize) {
1351 case 1: 1351 case 1:
1352 info->io.inputb = mem_inb; 1352 info->io.inputb = intf_mem_inb;
1353 info->io.outputb = mem_outb; 1353 info->io.outputb = intf_mem_outb;
1354 break; 1354 break;
1355 case 2: 1355 case 2:
1356 info->io.inputb = mem_inw; 1356 info->io.inputb = intf_mem_inw;
1357 info->io.outputb = mem_outw; 1357 info->io.outputb = intf_mem_outw;
1358 break; 1358 break;
1359 case 4: 1359 case 4:
1360 info->io.inputb = mem_inl; 1360 info->io.inputb = intf_mem_inl;
1361 info->io.outputb = mem_outl; 1361 info->io.outputb = intf_mem_outl;
1362 break; 1362 break;
1363#ifdef readq 1363#ifdef readq
1364 case 8: 1364 case 8:
@@ -1580,11 +1580,6 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1580 if (! is_new_interface(-1, addr_space, spmi->addr.address)) 1580 if (! is_new_interface(-1, addr_space, spmi->addr.address))
1581 return -ENODEV; 1581 return -ENODEV;
1582 1582
1583 if (! spmi->addr.register_bit_width) {
1584 acpi_failure = 1;
1585 return -ENODEV;
1586 }
1587
1588 /* Figure out the interface type. */ 1583 /* Figure out the interface type. */
1589 switch (spmi->InterfaceType) 1584 switch (spmi->InterfaceType)
1590 { 1585 {
@@ -1634,9 +1629,6 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1634 regspacings[intf_num] = spmi->addr.register_bit_width / 8; 1629 regspacings[intf_num] = spmi->addr.register_bit_width / 8;
1635 info->io.regspacing = spmi->addr.register_bit_width / 8; 1630 info->io.regspacing = spmi->addr.register_bit_width / 8;
1636 } else { 1631 } else {
1637 /* Some broken systems get this wrong and set the value
1638 * to zero. Assume it is the default spacing. If that
1639 * is wrong, too bad, the vendor should fix the tables. */
1640 regspacings[intf_num] = DEFAULT_REGSPACING; 1632 regspacings[intf_num] = DEFAULT_REGSPACING;
1641 info->io.regspacing = DEFAULT_REGSPACING; 1633 info->io.regspacing = DEFAULT_REGSPACING;
1642 } 1634 }
diff --git a/drivers/char/rio/cirrus.h b/drivers/char/rio/cirrus.h
index 217ff09f2fa1..89bd94eb45be 100644
--- a/drivers/char/rio/cirrus.h
+++ b/drivers/char/rio/cirrus.h
@@ -40,148 +40,6 @@
40#endif 40#endif
41#define _cirrus_h 1 41#define _cirrus_h 1
42 42
43#ifdef RTA
44#define TO_UART RX
45#define TO_DRIVER TX
46#endif
47
48#ifdef HOST
49#define TO_UART TX
50#define TO_DRIVER RX
51#endif
52#ifdef RTA
53/* Miscellaneous defines for CIRRUS addresses and related logic for
54 interrupts etc.
55*/
56#define MAP(a) ((short *)(cirrus_base + (a)))
57#define outp(a,b) (*MAP (a) =(b))
58#define inp(a) ((*MAP (a)) & 0xff)
59#define CIRRUS_FIRST (short*)0x7300
60#define CIRRUS_SECOND (short*)0x7200
61#define CIRRUS_THIRD (short*)0x7100
62#define CIRRUS_FOURTH (short*)0x7000
63#define PORTS_ON_CIRRUS 4
64#define CIRRUS_FIFO_SIZE 12
65#define SPACE 0x20
66#define TAB 0x09
67#define LINE_FEED 0x0a
68#define CARRIAGE_RETURN 0x0d
69#define BACKSPACE 0x08
70#define SPACES_IN_TABS 8
71#define SEND_ESCAPE 0x00
72#define START_BREAK 0x81
73#define TIMER_TICK 0x82
74#define STOP_BREAK 0x83
75#define BASE(a) ((a) < 4 ? (short*)CIRRUS_FIRST : ((a) < 8 ? (short *)CIRRUS_SECOND : ((a) < 12 ? (short*)CIRRUS_THIRD : (short *)CIRRUS_FOURTH)))
76#define txack1 ((short *)0x7104)
77#define rxack1 ((short *)0x7102)
78#define mdack1 ((short *)0x7106)
79#define txack2 ((short *)0x7006)
80#define rxack2 ((short *)0x7004)
81#define mdack2 ((short *)0x7100)
82#define int_latch ((short *) 0x7800)
83#define int_status ((short *) 0x7c00)
84#define tx1_pending 0x20
85#define rx1_pending 0x10
86#define md1_pending 0x40
87#define tx2_pending 0x02
88#define rx2_pending 0x01
89#define md2_pending 0x40
90#define module1_bits 0x07
91#define module1_modern 0x08
92#define module2_bits 0x70
93#define module2_modern 0x80
94#define module_blank 0xf
95#define rs232_d25 0x0
96#define rs232_rj45 0x1
97#define rs422_d25 0x3
98#define parallel 0x5
99
100#define CLK0 0x00
101#define CLK1 0x01
102#define CLK2 0x02
103#define CLK3 0x03
104#define CLK4 0x04
105
106#define CIRRUS_REVC 0x42
107#define CIRRUS_REVE 0x44
108
109#define TURNON 1
110#define TURNOFF 0
111
112/* The list of CIRRUS registers.
113 NB. These registers are relative values on 8 bit boundaries whereas
114 on the RTA's the CIRRUS registers are on word boundaries. Use pointer
115 arithmetic (short *) to obtain the real addresses required */
116#define ccr 0x05 /* Channel Command Register */
117#define ier 0x06 /* Interrupt Enable Register */
118#define cor1 0x08 /* Channel Option Register 1 */
119#define cor2 0x09 /* Channel Option Register 2 */
120#define cor3 0x0a /* Channel Option Register 3 */
121#define cor4 0x1e /* Channel Option Register 4 */
122#define cor5 0x1f /* Channel Option Register 5 */
123
124#define ccsr 0x0b /* Channel Control Status Register */
125#define rdcr 0x0e /* Receive Data Count Register */
126#define tdcr 0x12 /* Transmit Data Count Register */
127#define mcor1 0x15 /* Modem Change Option Register 1 */
128#define mcor2 0x16 /* Modem Change Option Regsiter 2 */
129
130#define livr 0x18 /* Local Interrupt Vector Register */
131#define schr1 0x1a /* Special Character Register 1 */
132#define schr2 0x1b /* Special Character Register 2 */
133#define schr3 0x1c /* Special Character Register 3 */
134#define schr4 0x1d /* Special Character Register 4 */
135
136#define rtr 0x20 /* Receive Timer Register */
137#define rtpr 0x21 /* Receive Timeout Period Register */
138#define lnc 0x24 /* Lnext character */
139
140#define rivr 0x43 /* Receive Interrupt Vector Register */
141#define tivr 0x42 /* Transmit Interrupt Vector Register */
142#define mivr 0x41 /* Modem Interrupt Vector Register */
143#define gfrcr 0x40 /* Global Firmware Revision code Reg */
144#define ricr 0x44 /* Receive Interrupting Channel Reg */
145#define ticr 0x45 /* Transmit Interrupting Channel Reg */
146#define micr 0x46 /* Modem Interrupting Channel Register */
147
148#define gcr 0x4b /* Global configuration register */
149#define misr 0x4c /* Modem interrupt status register */
150
151#define rbusr 0x59
152#define tbusr 0x5a
153#define mbusr 0x5b
154
155#define eoir 0x60 /* End Of Interrupt Register */
156#define rdsr 0x62 /* Receive Data / Status Register */
157#define tdr 0x63 /* Transmit Data Register */
158#define svrr 0x67 /* Service Request Register */
159
160#define car 0x68 /* Channel Access Register */
161#define mir 0x69 /* Modem Interrupt Register */
162#define tir 0x6a /* Transmit Interrupt Register */
163#define rir 0x6b /* Receive Interrupt Register */
164#define msvr1 0x6c /* Modem Signal Value Register 1 */
165#define msvr2 0x6d /* Modem Signal Value Register 2 */
166#define psvr 0x6f /* Printer Signal Value Register */
167
168#define tbpr 0x72 /* Transmit Baud Rate Period Register */
169#define tcor 0x76 /* Transmit Clock Option Register */
170
171#define rbpr 0x78 /* Receive Baud Rate Period Register */
172#define rber 0x7a /* Receive Baud Rate Extension Register */
173#define rcor 0x7c /* Receive Clock Option Register */
174#define ppr 0x7e /* Prescalar Period Register */
175
176/* Misc registers used for forcing the 1400 out of its reset woes */
177#define airl 0x6d
178#define airm 0x6e
179#define airh 0x6f
180#define btcr 0x66
181#define mtcr 0x6c
182#define tber 0x74
183
184#endif /* #ifdef RTA */
185 43
186 44
187/* Bit fields for particular registers */ 45/* Bit fields for particular registers */
diff --git a/drivers/char/rio/defaults.h b/drivers/char/rio/defaults.h
index 5b600c32ac02..d55c2f6a9877 100644
--- a/drivers/char/rio/defaults.h
+++ b/drivers/char/rio/defaults.h
@@ -45,13 +45,6 @@ static char *_rio_defaults_h_sccs = "@(#)defaults.h 1.1";
45#define MILLISECOND (int) (1000/64) /* 15.625 low ticks */ 45#define MILLISECOND (int) (1000/64) /* 15.625 low ticks */
46#define SECOND (int) 15625 /* Low priority ticks */ 46#define SECOND (int) 15625 /* Low priority ticks */
47 47
48#ifdef RTA
49#define RX_LIMIT (ushort) 3
50#endif
51#ifdef HOST
52#define RX_LIMIT (ushort) 1
53#endif
54
55#define LINK_TIMEOUT (int) (POLL_PERIOD / 2) 48#define LINK_TIMEOUT (int) (POLL_PERIOD / 2)
56 49
57 50
diff --git a/drivers/char/rio/link.h b/drivers/char/rio/link.h
index bfba5b0c033e..48d68ca7f825 100644
--- a/drivers/char/rio/link.h
+++ b/drivers/char/rio/link.h
@@ -102,30 +102,14 @@
102/* 102/*
103** LED stuff 103** LED stuff
104*/ 104*/
105#if defined(RTA)
106#define LED_OFF ((ushort) 0) /* LED off */
107#define LED_RED ((ushort) 1) /* LED Red */
108#define LED_GREEN ((ushort) 2) /* LED Green */
109#define LED_ORANGE ((ushort) 4) /* LED Orange */
110#define LED_1TO8_OPEN ((ushort) 1) /* Port 1->8 LED on */
111#define LED_9TO16_OPEN ((ushort) 2) /* Port 9->16 LED on */
112#define LED_SET_COLOUR(colour) (link->led = (colour))
113#define LED_OR_COLOUR(colour) (link->led |= (colour))
114#define LED_TIMEOUT(time) (link->led_timeout = RioTimePlus(RioTime(),(time)))
115#else
116#define LED_SET_COLOUR(colour) 105#define LED_SET_COLOUR(colour)
117#define LED_OR_COLOUR(colour) 106#define LED_OR_COLOUR(colour)
118#define LED_TIMEOUT(time) 107#define LED_TIMEOUT(time)
119#endif /* RTA */
120 108
121struct LPB { 109struct LPB {
122 WORD link_number; /* Link Number */ 110 WORD link_number; /* Link Number */
123 Channel_ptr in_ch; /* Link In Channel */ 111 Channel_ptr in_ch; /* Link In Channel */
124 Channel_ptr out_ch; /* Link Out Channel */ 112 Channel_ptr out_ch; /* Link Out Channel */
125#ifdef RTA
126 uchar stat_led; /* Port open leds */
127 uchar led; /* True, light led! */
128#endif
129 BYTE attached_serial[4]; /* Attached serial number */ 113 BYTE attached_serial[4]; /* Attached serial number */
130 BYTE attached_host_serial[4]; 114 BYTE attached_host_serial[4];
131 /* Serial number of Host who 115 /* Serial number of Host who
@@ -144,30 +128,12 @@ struct LPB {
144 WORD WaitNoBoot; /* Secs to hold off booting */ 128 WORD WaitNoBoot; /* Secs to hold off booting */
145 PKT_ptr add_packet_list; /* Add packets to here */ 129 PKT_ptr add_packet_list; /* Add packets to here */
146 PKT_ptr remove_packet_list; /* Send packets from here */ 130 PKT_ptr remove_packet_list; /* Send packets from here */
147#ifdef RTA
148#ifdef DCIRRUS
149#define QBUFS_PER_REDIRECT (4 / PKTS_PER_BUFFER + 1)
150#else
151#define QBUFS_PER_REDIRECT (8 / PKTS_PER_BUFFER + 1)
152#endif
153 PKT_ptr_ptr rd_add; /* Add a new Packet here */
154 Q_BUF_ptr rd_add_qb; /* Pointer to the add Q buf */
155 PKT_ptr_ptr rd_add_st_qbb; /* Pointer to start of the Q's buf */
156 PKT_ptr_ptr rd_add_end_qbb; /* Pointer to the end of the Q's buf */
157 PKT_ptr_ptr rd_remove; /* Remove a Packet here */
158 Q_BUF_ptr rd_remove_qb; /* Pointer to the remove Q buf */
159 PKT_ptr_ptr rd_remove_st_qbb; /* Pointer to the start of the Q buf */
160 PKT_ptr_ptr rd_remove_end_qbb; /* Pointer to the end of the Q buf */
161 ushort pkts_in_q; /* Packets in queue */
162#endif
163 131
164 Channel_ptr lrt_fail_chan; /* Lrt's failure channel */ 132 Channel_ptr lrt_fail_chan; /* Lrt's failure channel */
165 Channel_ptr ltt_fail_chan; /* Ltt's failure channel */ 133 Channel_ptr ltt_fail_chan; /* Ltt's failure channel */
166 134
167#if defined (HOST) || defined (INKERNEL)
168 /* RUP structure for HOST to driver communications */ 135 /* RUP structure for HOST to driver communications */
169 struct RUP rup; 136 struct RUP rup;
170#endif
171 struct RUP link_rup; /* RUP for the link (POLL, 137 struct RUP link_rup; /* RUP for the link (POLL,
172 topology etc.) */ 138 topology etc.) */
173 WORD attached_link; /* Number of attached link */ 139 WORD attached_link; /* Number of attached link */
diff --git a/drivers/char/rio/list.h b/drivers/char/rio/list.h
index 36aad4c9cb3a..79b853140ae5 100644
--- a/drivers/char/rio/list.h
+++ b/drivers/char/rio/list.h
@@ -44,8 +44,6 @@ static char *_rio_list_h_sccs = "@(#)list.h 1.9";
44 44
45#define PKT_IN_USE 0x1 45#define PKT_IN_USE 0x1
46 46
47#ifdef INKERNEL
48
49#define ZERO_PTR (ushort) 0x8000 47#define ZERO_PTR (ushort) 0x8000
50#define CaD PortP->Caddr 48#define CaD PortP->Caddr
51 49
@@ -54,143 +52,5 @@ static char *_rio_list_h_sccs = "@(#)list.h 1.9";
54** to by the TxAdd pointer has PKT_IN_USE clear in its address. 52** to by the TxAdd pointer has PKT_IN_USE clear in its address.
55*/ 53*/
56 54
57#ifndef linux
58#if defined( MIPS ) && !defined( MIPSEISA )
59/* May the shoes of the Devil dance on your grave for creating this */
60#define can_add_transmit(PacketP,PortP) \
61 (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,RINDW(PortP->TxAdd))) \
62 & (PKT_IN_USE<<2)))
63
64#elif defined(MIPSEISA) || defined(nx6000) || \
65 defined(drs6000) || defined(UWsparc)
66
67#define can_add_transmit(PacketP,PortP) \
68 (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,RINDW(PortP->TxAdd))) \
69 & PKT_IN_USE))
70
71#else
72#define can_add_transmit(PacketP,PortP) \
73 (!((uint)(PacketP = (struct PKT *)RIO_PTR(CaD,*PortP->TxAdd)) \
74 & PKT_IN_USE))
75#endif
76
77/*
78** To add a packet to the queue, you set the PKT_IN_USE bit in the address,
79** and then move the TxAdd pointer along one position to point to the next
80** packet pointer. You must wrap the pointer from the end back to the start.
81*/
82#if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
83# define add_transmit(PortP) \
84 WINDW(PortP->TxAdd,RINDW(PortP->TxAdd) | PKT_IN_USE);\
85 if (PortP->TxAdd == PortP->TxEnd)\
86 PortP->TxAdd = PortP->TxStart;\
87 else\
88 PortP->TxAdd++;\
89 WWORD(PortP->PhbP->tx_add , RIO_OFF(CaD,PortP->TxAdd));
90#elif defined(AIX)
91# define add_transmit(PortP) \
92 {\
93 register ushort *TxAddP = (ushort *)RIO_PTR(Cad,PortP->TxAddO);\
94 WINDW( TxAddP, RINDW( TxAddP ) | PKT_IN_USE );\
95 if (PortP->TxAddO == PortP->TxEndO )\
96 PortP->TxAddO = PortP->TxStartO;\
97 else\
98 PortP->TxAddO += sizeof(ushort);\
99 WWORD(((PHB *)RIO_PTR(Cad,PortP->PhbO))->tx_add , PortP->TxAddO );\
100 }
101#else
102# define add_transmit(PortP) \
103 *PortP->TxAdd |= PKT_IN_USE;\
104 if (PortP->TxAdd == PortP->TxEnd)\
105 PortP->TxAdd = PortP->TxStart;\
106 else\
107 PortP->TxAdd++;\
108 PortP->PhbP->tx_add = RIO_OFF(CaD,PortP->TxAdd);
109#endif
110
111/*
112** can_remove_receive( PacketP, PortP ) returns non-zero if PKT_IN_USE is set
113** for the next packet on the queue. It will also set PacketP to point to the
114** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
115** then can_remove_receive() returns 0.
116*/
117#if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
118# define can_remove_receive(PacketP,PortP) \
119 ((RINDW(PortP->RxRemove) & PKT_IN_USE) ? \
120 (PacketP=(struct PKT *)RIO_PTR(CaD,(RINDW(PortP->RxRemove) & ~PKT_IN_USE))):0)
121#elif defined(AIX)
122# define can_remove_receive(PacketP,PortP) \
123 ((RINDW((ushort *)RIO_PTR(Cad,PortP->RxRemoveO)) & PKT_IN_USE) ? \
124 (PacketP=(struct PKT *)RIO_PTR(Cad,RINDW((ushort *)RIO_PTR(Cad,PortP->RxRemoveO)) & ~PKT_IN_USE)):0)
125#else
126# define can_remove_receive(PacketP,PortP) \
127 ((*PortP->RxRemove & PKT_IN_USE) ? \
128 (PacketP=(struct PKT *)RIO_PTR(CaD,(*PortP->RxRemove & ~PKT_IN_USE))):0)
129#endif
130
131
132/*
133** Will God see it within his heart to forgive us for this thing that
134** we have created? To remove a packet from the receive queue you clear
135** its PKT_IN_USE bit, and then bump the pointers. Once the pointers
136** get to the end, they must be wrapped back to the start.
137*/
138#if defined(MIPS) || defined(nx6000) || defined(drs6000) || defined(UWsparc)
139# define remove_receive(PortP) \
140 WINDW(PortP->RxRemove, (RINDW(PortP->RxRemove) & ~PKT_IN_USE));\
141 if (PortP->RxRemove == PortP->RxEnd)\
142 PortP->RxRemove = PortP->RxStart;\
143 else\
144 PortP->RxRemove++;\
145 WWORD(PortP->PhbP->rx_remove , RIO_OFF(CaD,PortP->RxRemove));
146#elif defined(AIX)
147# define remove_receive(PortP) \
148 {\
149 register ushort *RxRemoveP = (ushort *)RIO_PTR(Cad,PortP->RxRemoveO);\
150 WINDW( RxRemoveP, RINDW( RxRemoveP ) & ~PKT_IN_USE );\
151 if (PortP->RxRemoveO == PortP->RxEndO)\
152 PortP->RxRemoveO = PortP->RxStartO;\
153 else\
154 PortP->RxRemoveO += sizeof(ushort);\
155 WWORD(((PHB *)RIO_PTR(Cad,PortP->PhbO))->rx_remove, PortP->RxRemoveO );\
156 }
157#else
158# define remove_receive(PortP) \
159 *PortP->RxRemove &= ~PKT_IN_USE;\
160 if (PortP->RxRemove == PortP->RxEnd)\
161 PortP->RxRemove = PortP->RxStart;\
162 else\
163 PortP->RxRemove++;\
164 PortP->PhbP->rx_remove = RIO_OFF(CaD,PortP->RxRemove);
165#endif
166#endif
167
168
169#else /* !IN_KERNEL */
170
171#define ZERO_PTR NULL
172
173
174#ifdef HOST
175/* #define can_remove_transmit(pkt,phb) ((((char*)pkt = (*(char**)(phb->tx_remove))-1) || 1)) && (*phb->u3.s2.tx_remove_ptr & PKT_IN_USE)) */
176#define remove_transmit(phb) *phb->u3.s2.tx_remove_ptr &= ~(ushort)PKT_IN_USE;\
177 if (phb->tx_remove == phb->tx_end)\
178 phb->tx_remove = phb->tx_start;\
179 else\
180 phb->tx_remove++;
181#define can_add_receive(phb) !(*phb->u4.s2.rx_add_ptr & PKT_IN_USE)
182#define add_receive(pkt,phb) *phb->rx_add = pkt;\
183 *phb->u4.s2.rx_add_ptr |= PKT_IN_USE;\
184 if (phb->rx_add == phb->rx_end)\
185 phb->rx_add = phb->rx_start;\
186 else\
187 phb->rx_add++;
188#endif
189#endif
190
191#ifdef RTA
192#define splx(oldspl) if ((oldspl) == 0) spl0()
193#endif
194
195#endif /* ifndef _list.h */ 55#endif /* ifndef _list.h */
196/*********** end of file ***********/ 56/*********** end of file ***********/
diff --git a/drivers/char/rio/parmmap.h b/drivers/char/rio/parmmap.h
index fe4e00567065..e24acc1d1844 100644
--- a/drivers/char/rio/parmmap.h
+++ b/drivers/char/rio/parmmap.h
@@ -78,14 +78,9 @@ struct PARM_MAP {
78 WORD idle_count; /* Idle time counter */ 78 WORD idle_count; /* Idle time counter */
79 WORD busy_count; /* Busy counter */ 79 WORD busy_count; /* Busy counter */
80 WORD idle_control; /* Control Idle Process */ 80 WORD idle_control; /* Control Idle Process */
81#if defined(HOST) || defined(INKERNEL)
82 WORD tx_intr; /* TX interrupt pending */ 81 WORD tx_intr; /* TX interrupt pending */
83 WORD rx_intr; /* RX interrupt pending */ 82 WORD rx_intr; /* RX interrupt pending */
84 WORD rup_intr; /* RUP interrupt pending */ 83 WORD rup_intr; /* RUP interrupt pending */
85#endif
86#if defined(RTA)
87 WORD dying_count; /* Count of processes dead */
88#endif
89}; 84};
90 85
91#endif 86#endif
diff --git a/drivers/char/rio/phb.h b/drivers/char/rio/phb.h
index 3baebf8513af..2663ca0306e2 100644
--- a/drivers/char/rio/phb.h
+++ b/drivers/char/rio/phb.h
@@ -44,17 +44,6 @@
44#endif 44#endif
45 45
46 46
47 /*************************************************
48 * Set the LIMIT values.
49 ************************************************/
50#ifdef RTA
51#define RX_LIMIT (ushort) 3
52#endif
53#ifdef HOST
54#define RX_LIMIT (ushort) 1
55#endif
56
57
58/************************************************* 47/*************************************************
59 * Handshake asserted. Deasserted by the LTT(s) 48 * Handshake asserted. Deasserted by the LTT(s)
60 ************************************************/ 49 ************************************************/
@@ -69,11 +58,7 @@
69/************************************************* 58/*************************************************
70 * Maximum number of PHB's 59 * Maximum number of PHB's
71 ************************************************/ 60 ************************************************/
72#if defined (HOST) || defined (INKERNEL)
73#define MAX_PHB ((ushort) 128) /* range 0-127 */ 61#define MAX_PHB ((ushort) 128) /* range 0-127 */
74#else
75#define MAX_PHB ((ushort) 8) /* range 0-7 */
76#endif
77 62
78/************************************************* 63/*************************************************
79 * Defines for the mode fields 64 * Defines for the mode fields
@@ -139,141 +124,23 @@
139 * the start. The pointer tx_add points to a SPACE to put a Packet. 124 * the start. The pointer tx_add points to a SPACE to put a Packet.
140 * The pointer tx_remove points to the next Packet to remove 125 * The pointer tx_remove points to the next Packet to remove
141 *************************************************************************/ 126 *************************************************************************/
142#ifndef INKERNEL
143#define src_unit u2.s2.unit
144#define src_port u2.s2.port
145#define dest_unit u1.s1.unit
146#define dest_port u1.s1.port
147#endif
148#ifdef HOST
149#define tx_start u3.s1.tx_start_ptr_ptr
150#define tx_add u3.s1.tx_add_ptr_ptr
151#define tx_end u3.s1.tx_end_ptr_ptr
152#define tx_remove u3.s1.tx_remove_ptr_ptr
153#define rx_start u4.s1.rx_start_ptr_ptr
154#define rx_add u4.s1.rx_add_ptr_ptr
155#define rx_end u4.s1.rx_end_ptr_ptr
156#define rx_remove u4.s1.rx_remove_ptr_ptr
157#endif
158typedef struct PHB PHB; 127typedef struct PHB PHB;
159struct PHB { 128struct PHB {
160#ifdef RTA
161 ushort port;
162#endif
163#ifdef INKERNEL
164 WORD source; 129 WORD source;
165#else
166 union {
167 ushort source; /* Complete source */
168 struct {
169 unsigned char unit; /* Source unit */
170 unsigned char port; /* Source port */
171 } s2;
172 } u2;
173#endif
174 WORD handshake; 130 WORD handshake;
175 WORD status; 131 WORD status;
176 NUMBER timeout; /* Maximum of 1.9 seconds */ 132 NUMBER timeout; /* Maximum of 1.9 seconds */
177 WORD link; /* Send down this link */ 133 WORD link; /* Send down this link */
178#ifdef INKERNEL
179 WORD destination; 134 WORD destination;
180#else
181 union {
182 ushort destination; /* Complete destination */
183 struct {
184 unsigned char unit; /* Destination unit */
185 unsigned char port; /* Destination port */
186 } s1;
187 } u1;
188#endif
189#ifdef RTA
190 ushort tx_pkts_added;
191 ushort tx_pkts_removed;
192 Q_BUF_ptr tx_q_start; /* Start of the Q list chain */
193 short num_tx_q_bufs; /* Number of Q buffers in the chain */
194 PKT_ptr_ptr tx_add; /* Add a new Packet here */
195 Q_BUF_ptr tx_add_qb; /* Pointer to the add Q buf */
196 PKT_ptr_ptr tx_add_st_qbb; /* Pointer to start of the Q's buf */
197 PKT_ptr_ptr tx_add_end_qbb; /* Pointer to the end of the Q's buf */
198 PKT_ptr_ptr tx_remove; /* Remove a Packet here */
199 Q_BUF_ptr tx_remove_qb; /* Pointer to the remove Q buf */
200 PKT_ptr_ptr tx_remove_st_qbb; /* Pointer to the start of the Q buf */
201 PKT_ptr_ptr tx_remove_end_qbb; /* Pointer to the end of the Q buf */
202#endif
203#ifdef INKERNEL
204 PKT_ptr_ptr tx_start; 135 PKT_ptr_ptr tx_start;
205 PKT_ptr_ptr tx_end; 136 PKT_ptr_ptr tx_end;
206 PKT_ptr_ptr tx_add; 137 PKT_ptr_ptr tx_add;
207 PKT_ptr_ptr tx_remove; 138 PKT_ptr_ptr tx_remove;
208#endif
209#ifdef HOST
210 union {
211 struct {
212 PKT_ptr_ptr tx_start_ptr_ptr;
213 PKT_ptr_ptr tx_end_ptr_ptr;
214 PKT_ptr_ptr tx_add_ptr_ptr;
215 PKT_ptr_ptr tx_remove_ptr_ptr;
216 } s1;
217 struct {
218 ushort *tx_start_ptr;
219 ushort *tx_end_ptr;
220 ushort *tx_add_ptr;
221 ushort *tx_remove_ptr;
222 } s2;
223 } u3;
224#endif
225 139
226#ifdef RTA
227 ushort rx_pkts_added;
228 ushort rx_pkts_removed;
229 Q_BUF_ptr rx_q_start; /* Start of the Q list chain */
230 short num_rx_q_bufs; /* Number of Q buffers in the chain */
231 PKT_ptr_ptr rx_add; /* Add a new Packet here */
232 Q_BUF_ptr rx_add_qb; /* Pointer to the add Q buf */
233 PKT_ptr_ptr rx_add_st_qbb; /* Pointer to start of the Q's buf */
234 PKT_ptr_ptr rx_add_end_qbb; /* Pointer to the end of the Q's buf */
235 PKT_ptr_ptr rx_remove; /* Remove a Packet here */
236 Q_BUF_ptr rx_remove_qb; /* Pointer to the remove Q buf */
237 PKT_ptr_ptr rx_remove_st_qbb; /* Pointer to the start of the Q buf */
238 PKT_ptr_ptr rx_remove_end_qbb; /* Pointer to the end of the Q buf */
239#endif
240#ifdef INKERNEL
241 PKT_ptr_ptr rx_start; 140 PKT_ptr_ptr rx_start;
242 PKT_ptr_ptr rx_end; 141 PKT_ptr_ptr rx_end;
243 PKT_ptr_ptr rx_add; 142 PKT_ptr_ptr rx_add;
244 PKT_ptr_ptr rx_remove; 143 PKT_ptr_ptr rx_remove;
245#endif
246#ifdef HOST
247 union {
248 struct {
249 PKT_ptr_ptr rx_start_ptr_ptr;
250 PKT_ptr_ptr rx_end_ptr_ptr;
251 PKT_ptr_ptr rx_add_ptr_ptr;
252 PKT_ptr_ptr rx_remove_ptr_ptr;
253 } s1;
254 struct {
255 ushort *rx_start_ptr;
256 ushort *rx_end_ptr;
257 ushort *rx_add_ptr;
258 ushort *rx_remove_ptr;
259 } s2;
260 } u4;
261#endif
262
263#ifdef RTA /* some fields for the remotes */
264 ushort flush_count; /* Count of write flushes */
265 ushort txmode; /* Modes for tx */
266 ushort rxmode; /* Modes for rx */
267 ushort portmode; /* Generic modes */
268 ushort column; /* TAB3 column count */
269 ushort tx_subscript; /* (TX) Subscript into data field */
270 ushort rx_subscript; /* (RX) Subscript into data field */
271 PKT_ptr rx_incomplete; /* Hold an incomplete packet here */
272 ushort modem_bits; /* Modem bits to mask */
273 ushort lastModem; /* Modem control lines. */
274 ushort addr; /* Address for sub commands */
275 ushort MonitorTstate; /* TRUE if monitoring tstop */
276#endif
277 144
278}; 145};
279 146
diff --git a/drivers/char/rio/pkt.h b/drivers/char/rio/pkt.h
index 882fd429ac2e..7011e52e82db 100644
--- a/drivers/char/rio/pkt.h
+++ b/drivers/char/rio/pkt.h
@@ -70,39 +70,12 @@
70#define CONTROL_DATA_WNDW (DATA_WNDW << 8) 70#define CONTROL_DATA_WNDW (DATA_WNDW << 8)
71 71
72struct PKT { 72struct PKT {
73#ifdef INKERNEL
74 BYTE dest_unit; /* Destination Unit Id */ 73 BYTE dest_unit; /* Destination Unit Id */
75 BYTE dest_port; /* Destination POrt */ 74 BYTE dest_port; /* Destination POrt */
76 BYTE src_unit; /* Source Unit Id */ 75 BYTE src_unit; /* Source Unit Id */
77 BYTE src_port; /* Source POrt */ 76 BYTE src_port; /* Source POrt */
78#else
79 union {
80 ushort destination; /* Complete destination */
81 struct {
82 unsigned char unit; /* Destination unit */
83 unsigned char port; /* Destination port */
84 } s1;
85 } u1;
86 union {
87 ushort source; /* Complete source */
88 struct {
89 unsigned char unit; /* Source unit */
90 unsigned char port; /* Source port */
91 } s2;
92 } u2;
93#endif
94#ifdef INKERNEL
95 BYTE len; 77 BYTE len;
96 BYTE control; 78 BYTE control;
97#else
98 union {
99 ushort control;
100 struct {
101 unsigned char len;
102 unsigned char control;
103 } s3;
104 } u3;
105#endif
106 BYTE data[PKT_MAX_DATA_LEN]; 79 BYTE data[PKT_MAX_DATA_LEN];
107 /* Actual data :-) */ 80 /* Actual data :-) */
108 WORD csum; /* C-SUM */ 81 WORD csum; /* C-SUM */
diff --git a/drivers/char/rio/qbuf.h b/drivers/char/rio/qbuf.h
index acd9e8e5307d..391ffc335535 100644
--- a/drivers/char/rio/qbuf.h
+++ b/drivers/char/rio/qbuf.h
@@ -46,11 +46,7 @@ static char *_rio_qbuf_h_sccs = "@(#)qbuf.h 1.1";
46 46
47 47
48 48
49#ifdef HOST
50#define PKTS_PER_BUFFER 1
51#else
52#define PKTS_PER_BUFFER (220 / PKT_LENGTH) 49#define PKTS_PER_BUFFER (220 / PKT_LENGTH)
53#endif
54 50
55typedef struct Q_BUF Q_BUF; 51typedef struct Q_BUF Q_BUF;
56struct Q_BUF { 52struct Q_BUF {
diff --git a/drivers/char/rio/riotypes.h b/drivers/char/rio/riotypes.h
index 9b67e2468bec..46084d5c7e98 100644
--- a/drivers/char/rio/riotypes.h
+++ b/drivers/char/rio/riotypes.h
@@ -43,9 +43,6 @@
43#endif 43#endif
44#endif 44#endif
45 45
46#ifdef INKERNEL
47
48#if !defined(MIPSAT)
49typedef unsigned short NUMBER_ptr; 46typedef unsigned short NUMBER_ptr;
50typedef unsigned short WORD_ptr; 47typedef unsigned short WORD_ptr;
51typedef unsigned short BYTE_ptr; 48typedef unsigned short BYTE_ptr;
@@ -65,69 +62,6 @@ typedef unsigned short RUP_ptr;
65typedef unsigned short short_ptr; 62typedef unsigned short short_ptr;
66typedef unsigned short u_short_ptr; 63typedef unsigned short u_short_ptr;
67typedef unsigned short ushort_ptr; 64typedef unsigned short ushort_ptr;
68#else
69/* MIPSAT types */
70typedef char RIO_POINTER[8];
71typedef RIO_POINTER NUMBER_ptr;
72typedef RIO_POINTER WORD_ptr;
73typedef RIO_POINTER BYTE_ptr;
74typedef RIO_POINTER char_ptr;
75typedef RIO_POINTER Channel_ptr;
76typedef RIO_POINTER FREE_LIST_ptr_ptr;
77typedef RIO_POINTER FREE_LIST_ptr;
78typedef RIO_POINTER LPB_ptr;
79typedef RIO_POINTER Process_ptr;
80typedef RIO_POINTER PHB_ptr;
81typedef RIO_POINTER PKT_ptr;
82typedef RIO_POINTER PKT_ptr_ptr;
83typedef RIO_POINTER Q_BUF_ptr;
84typedef RIO_POINTER Q_BUF_ptr_ptr;
85typedef RIO_POINTER ROUTE_STR_ptr;
86typedef RIO_POINTER RUP_ptr;
87typedef RIO_POINTER short_ptr;
88typedef RIO_POINTER u_short_ptr;
89typedef RIO_POINTER ushort_ptr;
90#endif
91
92#else /* not INKERNEL */
93typedef unsigned char BYTE;
94typedef unsigned short WORD;
95typedef unsigned long DWORD;
96typedef short NUMBER;
97typedef short *NUMBER_ptr;
98typedef unsigned short *WORD_ptr;
99typedef unsigned char *BYTE_ptr;
100typedef unsigned char uchar;
101typedef unsigned short ushort;
102typedef unsigned int uint;
103typedef unsigned long ulong;
104typedef unsigned char u_char;
105typedef unsigned short u_short;
106typedef unsigned int u_int;
107typedef unsigned long u_long;
108typedef unsigned short ERROR;
109typedef unsigned long ID;
110typedef char *char_ptr;
111typedef Channel *Channel_ptr;
112typedef struct FREE_LIST *FREE_LIST_ptr;
113typedef struct FREE_LIST **FREE_LIST_ptr_ptr;
114typedef struct LPB *LPB_ptr;
115typedef struct Process *Process_ptr;
116typedef struct PHB *PHB_ptr;
117typedef struct PKT *PKT_ptr;
118typedef struct PKT **PKT_ptr_ptr;
119typedef struct Q_BUF *Q_BUF_ptr;
120typedef struct Q_BUF **Q_BUF_ptr_ptr;
121typedef struct ROUTE_STR *ROUTE_STR_ptr;
122typedef struct RUP *RUP_ptr;
123typedef short *short_ptr;
124typedef u_short *u_short_ptr;
125typedef ushort *ushort_ptr;
126typedef struct PKT PKT;
127typedef struct LPB LPB;
128typedef struct RUP RUP;
129#endif
130
131 65
132#endif /* __riotypes__ */ 66#endif /* __riotypes__ */
133 67
diff --git a/drivers/char/rio/rup.h b/drivers/char/rio/rup.h
index 8d44fec91dd5..f74f67c6f702 100644
--- a/drivers/char/rio/rup.h
+++ b/drivers/char/rio/rup.h
@@ -43,12 +43,7 @@
43#endif 43#endif
44#endif 44#endif
45 45
46#if defined( HOST ) || defined( INKERNEL )
47#define MAX_RUP ((short) 16) 46#define MAX_RUP ((short) 16)
48#endif
49#ifdef RTA
50#define MAX_RUP ((short) 1)
51#endif
52 47
53#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */ 48#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */
54 49
diff --git a/drivers/char/rio/sam.h b/drivers/char/rio/sam.h
index 31494054b213..6f754e19015d 100644
--- a/drivers/char/rio/sam.h
+++ b/drivers/char/rio/sam.h
@@ -43,10 +43,6 @@
43#endif 43#endif
44 44
45 45
46#if !defined( HOST ) && !defined( INKERNEL )
47#define RTA 1
48#endif
49
50#define NUM_FREE_LIST_UNITS 500 46#define NUM_FREE_LIST_UNITS 500
51 47
52#ifndef FALSE 48#ifndef FALSE
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 0949dcef0697..7edc6a4dbdc4 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -433,7 +433,7 @@ static void rp_do_receive(struct r_port *info,
433 count += ToRecv; 433 count += ToRecv;
434 } 434 }
435 /* Push the data up to the tty layer */ 435 /* Push the data up to the tty layer */
436 ld->receive_buf(tty, cbuf, fbuf, count); 436 ld->receive_buf(tty, chead, fhead, count);
437done: 437done:
438 tty_ldisc_deref(ld); 438 tty_ldisc_deref(ld);
439} 439}
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 64bf89cb574f..c2490e270f1f 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -931,7 +931,7 @@ static int sx_set_real_termios (void *ptr)
931 case CS6:sx_write_channel_byte (port, hi_mask, 0x3f);break; 931 case CS6:sx_write_channel_byte (port, hi_mask, 0x3f);break;
932 case CS5:sx_write_channel_byte (port, hi_mask, 0x1f);break; 932 case CS5:sx_write_channel_byte (port, hi_mask, 0x1f);break;
933 default: 933 default:
934 printk (KERN_INFO "sx: Invalid wordsize: %d\n", CFLAG & CSIZE); 934 printk (KERN_INFO "sx: Invalid wordsize: %u\n", CFLAG & CSIZE);
935 break; 935 break;
936 } 936 }
937 937
@@ -958,7 +958,7 @@ static int sx_set_real_termios (void *ptr)
958 } else { 958 } else {
959 set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags); 959 set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
960 } 960 }
961 sx_dprintk (SX_DEBUG_TERMIOS, "iflags: %x(%d) ", 961 sx_dprintk (SX_DEBUG_TERMIOS, "iflags: %x(%d) ",
962 port->gs.tty->termios->c_iflag, 962 port->gs.tty->termios->c_iflag,
963 I_OTHER(port->gs.tty)); 963 I_OTHER(port->gs.tty));
964 964
@@ -973,7 +973,7 @@ static int sx_set_real_termios (void *ptr)
973 } else { 973 } else {
974 clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags); 974 clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
975 } 975 }
976 sx_dprintk (SX_DEBUG_TERMIOS, "oflags: %x(%d)\n", 976 sx_dprintk (SX_DEBUG_TERMIOS, "oflags: %x(%d)\n",
977 port->gs.tty->termios->c_oflag, 977 port->gs.tty->termios->c_oflag,
978 O_OTHER(port->gs.tty)); 978 O_OTHER(port->gs.tty));
979 /* port->c_dcd = sx_get_CD (port); */ 979 /* port->c_dcd = sx_get_CD (port); */
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index aedf7a8e6da7..537aa45d8c67 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -191,7 +191,7 @@ static int get_event_name(char *dest, struct tcpa_event *event,
191 const char *name = ""; 191 const char *name = "";
192 char data[40] = ""; 192 char data[40] = "";
193 int i, n_len = 0, d_len = 0; 193 int i, n_len = 0, d_len = 0;
194 u32 event_id, event_data_size; 194 u32 event_id;
195 195
196 switch(event->event_type) { 196 switch(event->event_type) {
197 case PREBOOT: 197 case PREBOOT:
@@ -220,8 +220,7 @@ static int get_event_name(char *dest, struct tcpa_event *event,
220 } 220 }
221 break; 221 break;
222 case EVENT_TAG: 222 case EVENT_TAG:
223 event_id = be32_to_cpu(event_entry); 223 event_id = be32_to_cpu(*((u32 *)event_entry));
224 event_data_size = be32_to_cpu(&event_entry[4]);
225 224
226 /* ToDo Row data -> Base64 */ 225 /* ToDo Row data -> Base64 */
227 226
@@ -376,7 +375,7 @@ static int read_log(struct tpm_bios_log *log)
376{ 375{
377 struct acpi_tcpa *buff; 376 struct acpi_tcpa *buff;
378 acpi_status status; 377 acpi_status status;
379 void *virt; 378 struct acpi_table_header *virt;
380 379
381 if (log->bios_event_log != NULL) { 380 if (log->bios_event_log != NULL) {
382 printk(KERN_ERR 381 printk(KERN_ERR
@@ -413,7 +412,7 @@ static int read_log(struct tpm_bios_log *log)
413 412
414 log->bios_event_log_end = log->bios_event_log + buff->log_max_len; 413 log->bios_event_log_end = log->bios_event_log + buff->log_max_len;
415 414
416 acpi_os_map_memory(buff->log_start_addr, buff->log_max_len, &virt); 415 acpi_os_map_memory(buff->log_start_addr, buff->log_max_len, (void *) &virt);
417 416
418 memcpy(log->bios_event_log, virt, buff->log_max_len); 417 memcpy(log->bios_event_log, virt, buff->log_max_len);
419 418
@@ -487,26 +486,35 @@ struct file_operations tpm_binary_bios_measurements_ops = {
487 .release = tpm_bios_measurements_release, 486 .release = tpm_bios_measurements_release,
488}; 487};
489 488
489static int is_bad(void *p)
490{
491 if (!p)
492 return 1;
493 if (IS_ERR(p) && (PTR_ERR(p) != -ENODEV))
494 return 1;
495 return 0;
496}
497
490struct dentry **tpm_bios_log_setup(char *name) 498struct dentry **tpm_bios_log_setup(char *name)
491{ 499{
492 struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file; 500 struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file;
493 501
494 tpm_dir = securityfs_create_dir(name, NULL); 502 tpm_dir = securityfs_create_dir(name, NULL);
495 if (!tpm_dir) 503 if (is_bad(tpm_dir))
496 goto out; 504 goto out;
497 505
498 bin_file = 506 bin_file =
499 securityfs_create_file("binary_bios_measurements", 507 securityfs_create_file("binary_bios_measurements",
500 S_IRUSR | S_IRGRP, tpm_dir, NULL, 508 S_IRUSR | S_IRGRP, tpm_dir, NULL,
501 &tpm_binary_bios_measurements_ops); 509 &tpm_binary_bios_measurements_ops);
502 if (!bin_file) 510 if (is_bad(bin_file))
503 goto out_tpm; 511 goto out_tpm;
504 512
505 ascii_file = 513 ascii_file =
506 securityfs_create_file("ascii_bios_measurements", 514 securityfs_create_file("ascii_bios_measurements",
507 S_IRUSR | S_IRGRP, tpm_dir, NULL, 515 S_IRUSR | S_IRGRP, tpm_dir, NULL,
508 &tpm_ascii_bios_measurements_ops); 516 &tpm_ascii_bios_measurements_ops);
509 if (!ascii_file) 517 if (is_bad(ascii_file))
510 goto out_bin; 518 goto out_bin;
511 519
512 ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL); 520 ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL);
@@ -538,3 +546,4 @@ void tpm_bios_log_teardown(struct dentry **lst)
538 securityfs_remove(lst[i]); 546 securityfs_remove(lst[i]);
539} 547}
540EXPORT_SYMBOL_GPL(tpm_bios_log_teardown); 548EXPORT_SYMBOL_GPL(tpm_bios_log_teardown);
549MODULE_LICENSE("GPL");
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index 8198dbb7370f..ec7590951af5 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -441,7 +441,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
441 441
442 if ((ioh << 8 | iol) != tpm_inf.base) { 442 if ((ioh << 8 | iol) != tpm_inf.base) {
443 dev_err(&dev->dev, 443 dev_err(&dev->dev,
444 "Could not set IO-ports to %04x\n", 444 "Could not set IO-ports to 0x%lx\n",
445 tpm_inf.base); 445 tpm_inf.base);
446 release_region(tpm_inf.base, TPM_INF_PORT_LEN); 446 release_region(tpm_inf.base, TPM_INF_PORT_LEN);
447 return -EIO; 447 return -EIO;
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index eb8b5be4e249..076e07c1da38 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -253,6 +253,7 @@ static void tty_buffer_free_all(struct tty_struct *tty)
253 253
254static void tty_buffer_init(struct tty_struct *tty) 254static void tty_buffer_init(struct tty_struct *tty)
255{ 255{
256 spin_lock_init(&tty->buf.lock);
256 tty->buf.head = NULL; 257 tty->buf.head = NULL;
257 tty->buf.tail = NULL; 258 tty->buf.tail = NULL;
258 tty->buf.free = NULL; 259 tty->buf.free = NULL;
@@ -266,6 +267,7 @@ static struct tty_buffer *tty_buffer_alloc(size_t size)
266 p->used = 0; 267 p->used = 0;
267 p->size = size; 268 p->size = size;
268 p->next = NULL; 269 p->next = NULL;
270 p->active = 0;
269 p->char_buf_ptr = (char *)(p->data); 271 p->char_buf_ptr = (char *)(p->data);
270 p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size; 272 p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size;
271/* printk("Flip create %p\n", p); */ 273/* printk("Flip create %p\n", p); */
@@ -312,25 +314,36 @@ static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size)
312 314
313int tty_buffer_request_room(struct tty_struct *tty, size_t size) 315int tty_buffer_request_room(struct tty_struct *tty, size_t size)
314{ 316{
315 struct tty_buffer *b = tty->buf.tail, *n; 317 struct tty_buffer *b, *n;
316 int left = 0; 318 int left;
319 unsigned long flags;
320
321 spin_lock_irqsave(&tty->buf.lock, flags);
317 322
318 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to 323 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to
319 remove this conditional if its worth it. This would be invisible 324 remove this conditional if its worth it. This would be invisible
320 to the callers */ 325 to the callers */
321 if(b != NULL) 326 if ((b = tty->buf.tail) != NULL) {
322 left = b->size - b->used; 327 left = b->size - b->used;
323 if(left >= size) 328 b->active = 1;
324 return size; 329 } else
325 /* This is the slow path - looking for new buffers to use */ 330 left = 0;
326 n = tty_buffer_find(tty, size); 331
327 if(n == NULL) 332 if (left < size) {
328 return left; 333 /* This is the slow path - looking for new buffers to use */
329 if(b != NULL) 334 if ((n = tty_buffer_find(tty, size)) != NULL) {
330 b->next = n; 335 if (b != NULL) {
331 else 336 b->next = n;
332 tty->buf.head = n; 337 b->active = 0;
333 tty->buf.tail = n; 338 } else
339 tty->buf.head = n;
340 tty->buf.tail = n;
341 n->active = 1;
342 } else
343 size = left;
344 }
345
346 spin_unlock_irqrestore(&tty->buf.lock, flags);
334 return size; 347 return size;
335} 348}
336 349
@@ -396,10 +409,12 @@ EXPORT_SYMBOL_GPL(tty_insert_flip_string_flags);
396int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size) 409int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size)
397{ 410{
398 int space = tty_buffer_request_room(tty, size); 411 int space = tty_buffer_request_room(tty, size);
399 struct tty_buffer *tb = tty->buf.tail; 412 if (likely(space)) {
400 *chars = tb->char_buf_ptr + tb->used; 413 struct tty_buffer *tb = tty->buf.tail;
401 memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); 414 *chars = tb->char_buf_ptr + tb->used;
402 tb->used += space; 415 memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space);
416 tb->used += space;
417 }
403 return space; 418 return space;
404} 419}
405 420
@@ -416,10 +431,12 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);
416int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size) 431int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size)
417{ 432{
418 int space = tty_buffer_request_room(tty, size); 433 int space = tty_buffer_request_room(tty, size);
419 struct tty_buffer *tb = tty->buf.tail; 434 if (likely(space)) {
420 *chars = tb->char_buf_ptr + tb->used; 435 struct tty_buffer *tb = tty->buf.tail;
421 *flags = tb->flag_buf_ptr + tb->used; 436 *chars = tb->char_buf_ptr + tb->used;
422 tb->used += space; 437 *flags = tb->flag_buf_ptr + tb->used;
438 tb->used += space;
439 }
423 return space; 440 return space;
424} 441}
425 442
@@ -2747,20 +2764,20 @@ static void flush_to_ldisc(void *private_)
2747 schedule_delayed_work(&tty->buf.work, 1); 2764 schedule_delayed_work(&tty->buf.work, 1);
2748 goto out; 2765 goto out;
2749 } 2766 }
2750 spin_lock_irqsave(&tty->read_lock, flags); 2767 spin_lock_irqsave(&tty->buf.lock, flags);
2751 while((tbuf = tty->buf.head) != NULL) { 2768 while((tbuf = tty->buf.head) != NULL && !tbuf->active) {
2752 tty->buf.head = tbuf->next; 2769 tty->buf.head = tbuf->next;
2753 if (tty->buf.head == NULL) 2770 if (tty->buf.head == NULL)
2754 tty->buf.tail = NULL; 2771 tty->buf.tail = NULL;
2755 spin_unlock_irqrestore(&tty->read_lock, flags); 2772 spin_unlock_irqrestore(&tty->buf.lock, flags);
2756 /* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */ 2773 /* printk("Process buffer %p for %d\n", tbuf, tbuf->used); */
2757 disc->receive_buf(tty, tbuf->char_buf_ptr, 2774 disc->receive_buf(tty, tbuf->char_buf_ptr,
2758 tbuf->flag_buf_ptr, 2775 tbuf->flag_buf_ptr,
2759 tbuf->used); 2776 tbuf->used);
2760 spin_lock_irqsave(&tty->read_lock, flags); 2777 spin_lock_irqsave(&tty->buf.lock, flags);
2761 tty_buffer_free(tty, tbuf); 2778 tty_buffer_free(tty, tbuf);
2762 } 2779 }
2763 spin_unlock_irqrestore(&tty->read_lock, flags); 2780 spin_unlock_irqrestore(&tty->buf.lock, flags);
2764out: 2781out:
2765 tty_ldisc_deref(disc); 2782 tty_ldisc_deref(disc);
2766} 2783}
@@ -2852,6 +2869,12 @@ EXPORT_SYMBOL(tty_get_baud_rate);
2852 2869
2853void tty_flip_buffer_push(struct tty_struct *tty) 2870void tty_flip_buffer_push(struct tty_struct *tty)
2854{ 2871{
2872 unsigned long flags;
2873 spin_lock_irqsave(&tty->buf.lock, flags);
2874 if (tty->buf.tail != NULL)
2875 tty->buf.tail->active = 0;
2876 spin_unlock_irqrestore(&tty->buf.lock, flags);
2877
2855 if (tty->low_latency) 2878 if (tty->low_latency)
2856 flush_to_ldisc((void *) tty); 2879 flush_to_ldisc((void *) tty);
2857 else 2880 else
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index f1d9cb7feae6..0900d1dbee59 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -3213,6 +3213,7 @@ void getconsxy(struct vc_data *vc, unsigned char *p)
3213 3213
3214void putconsxy(struct vc_data *vc, unsigned char *p) 3214void putconsxy(struct vc_data *vc, unsigned char *p)
3215{ 3215{
3216 hide_cursor(vc);
3216 gotoxy(vc, p[0], p[1]); 3217 gotoxy(vc, p[0], p[1]);
3217 set_cursor(vc); 3218 set_cursor(vc);
3218} 3219}
diff --git a/drivers/char/watchdog/sbc_epx_c3.c b/drivers/char/watchdog/sbc_epx_c3.c
index 951764614ebf..7a4dfb95d087 100644
--- a/drivers/char/watchdog/sbc_epx_c3.c
+++ b/drivers/char/watchdog/sbc_epx_c3.c
@@ -25,6 +25,7 @@
25#include <linux/notifier.h> 25#include <linux/notifier.h>
26#include <linux/reboot.h> 26#include <linux/reboot.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/ioport.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
29#include <asm/io.h> 30#include <asm/io.h>
30 31
@@ -181,11 +182,14 @@ static int __init watchdog_init(void)
181{ 182{
182 int ret; 183 int ret;
183 184
185 if (!request_region(EPXC3_WATCHDOG_CTL_REG, 2, "epxc3_watchdog"))
186 return -EBUSY;
187
184 ret = register_reboot_notifier(&epx_c3_notifier); 188 ret = register_reboot_notifier(&epx_c3_notifier);
185 if (ret) { 189 if (ret) {
186 printk(KERN_ERR PFX "cannot register reboot notifier " 190 printk(KERN_ERR PFX "cannot register reboot notifier "
187 "(err=%d)\n", ret); 191 "(err=%d)\n", ret);
188 return ret; 192 goto out;
189 } 193 }
190 194
191 ret = misc_register(&epx_c3_miscdev); 195 ret = misc_register(&epx_c3_miscdev);
@@ -193,18 +197,23 @@ static int __init watchdog_init(void)
193 printk(KERN_ERR PFX "cannot register miscdev on minor=%d " 197 printk(KERN_ERR PFX "cannot register miscdev on minor=%d "
194 "(err=%d)\n", WATCHDOG_MINOR, ret); 198 "(err=%d)\n", WATCHDOG_MINOR, ret);
195 unregister_reboot_notifier(&epx_c3_notifier); 199 unregister_reboot_notifier(&epx_c3_notifier);
196 return ret; 200 goto out;
197 } 201 }
198 202
199 printk(banner); 203 printk(banner);
200 204
201 return 0; 205 return 0;
206
207out:
208 release_region(EPXC3_WATCHDOG_CTL_REG, 2);
209 return ret;
202} 210}
203 211
204static void __exit watchdog_exit(void) 212static void __exit watchdog_exit(void)
205{ 213{
206 misc_deregister(&epx_c3_miscdev); 214 misc_deregister(&epx_c3_miscdev);
207 unregister_reboot_notifier(&epx_c3_notifier); 215 unregister_reboot_notifier(&epx_c3_notifier);
216 release_region(EPXC3_WATCHDOG_CTL_REG, 2);
208} 217}
209 218
210module_init(watchdog_init); 219module_init(watchdog_init);
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 277a843a87a6..7a511479ae29 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -26,6 +26,7 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/cpu.h> 27#include <linux/cpu.h>
28#include <linux/completion.h> 28#include <linux/completion.h>
29#include <linux/mutex.h>
29 30
30#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "cpufreq-core", msg) 31#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "cpufreq-core", msg)
31 32
@@ -55,7 +56,7 @@ static DECLARE_RWSEM (cpufreq_notifier_rwsem);
55 56
56 57
57static LIST_HEAD(cpufreq_governor_list); 58static LIST_HEAD(cpufreq_governor_list);
58static DECLARE_MUTEX (cpufreq_governor_sem); 59static DEFINE_MUTEX (cpufreq_governor_mutex);
59 60
60struct cpufreq_policy * cpufreq_cpu_get(unsigned int cpu) 61struct cpufreq_policy * cpufreq_cpu_get(unsigned int cpu)
61{ 62{
@@ -297,18 +298,18 @@ static int cpufreq_parse_governor (char *str_governor, unsigned int *policy,
297 return -EINVAL; 298 return -EINVAL;
298 } else { 299 } else {
299 struct cpufreq_governor *t; 300 struct cpufreq_governor *t;
300 down(&cpufreq_governor_sem); 301 mutex_lock(&cpufreq_governor_mutex);
301 if (!cpufreq_driver || !cpufreq_driver->target) 302 if (!cpufreq_driver || !cpufreq_driver->target)
302 goto out; 303 goto out;
303 list_for_each_entry(t, &cpufreq_governor_list, governor_list) { 304 list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
304 if (!strnicmp(str_governor,t->name,CPUFREQ_NAME_LEN)) { 305 if (!strnicmp(str_governor,t->name,CPUFREQ_NAME_LEN)) {
305 *governor = t; 306 *governor = t;
306 up(&cpufreq_governor_sem); 307 mutex_unlock(&cpufreq_governor_mutex);
307 return 0; 308 return 0;
308 } 309 }
309 } 310 }
310 out: 311 out:
311 up(&cpufreq_governor_sem); 312 mutex_unlock(&cpufreq_governor_mutex);
312 } 313 }
313 return -EINVAL; 314 return -EINVAL;
314} 315}
@@ -600,7 +601,8 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
600 policy->cpu = cpu; 601 policy->cpu = cpu;
601 policy->cpus = cpumask_of_cpu(cpu); 602 policy->cpus = cpumask_of_cpu(cpu);
602 603
603 init_MUTEX_LOCKED(&policy->lock); 604 mutex_init(&policy->lock);
605 mutex_lock(&policy->lock);
604 init_completion(&policy->kobj_unregister); 606 init_completion(&policy->kobj_unregister);
605 INIT_WORK(&policy->update, handle_update, (void *)(long)cpu); 607 INIT_WORK(&policy->update, handle_update, (void *)(long)cpu);
606 608
@@ -610,6 +612,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
610 ret = cpufreq_driver->init(policy); 612 ret = cpufreq_driver->init(policy);
611 if (ret) { 613 if (ret) {
612 dprintk("initialization failed\n"); 614 dprintk("initialization failed\n");
615 mutex_unlock(&policy->lock);
613 goto err_out; 616 goto err_out;
614 } 617 }
615 618
@@ -621,9 +624,10 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
621 strlcpy(policy->kobj.name, "cpufreq", KOBJ_NAME_LEN); 624 strlcpy(policy->kobj.name, "cpufreq", KOBJ_NAME_LEN);
622 625
623 ret = kobject_register(&policy->kobj); 626 ret = kobject_register(&policy->kobj);
624 if (ret) 627 if (ret) {
628 mutex_unlock(&policy->lock);
625 goto err_out_driver_exit; 629 goto err_out_driver_exit;
626 630 }
627 /* set up files for this cpu device */ 631 /* set up files for this cpu device */
628 drv_attr = cpufreq_driver->attr; 632 drv_attr = cpufreq_driver->attr;
629 while ((drv_attr) && (*drv_attr)) { 633 while ((drv_attr) && (*drv_attr)) {
@@ -641,7 +645,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
641 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 645 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
642 policy->governor = NULL; /* to assure that the starting sequence is 646 policy->governor = NULL; /* to assure that the starting sequence is
643 * run in cpufreq_set_policy */ 647 * run in cpufreq_set_policy */
644 up(&policy->lock); 648 mutex_unlock(&policy->lock);
645 649
646 /* set default policy */ 650 /* set default policy */
647 651
@@ -762,10 +766,10 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
762 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 766 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
763#endif 767#endif
764 768
765 down(&data->lock); 769 mutex_lock(&data->lock);
766 if (cpufreq_driver->target) 770 if (cpufreq_driver->target)
767 __cpufreq_governor(data, CPUFREQ_GOV_STOP); 771 __cpufreq_governor(data, CPUFREQ_GOV_STOP);
768 up(&data->lock); 772 mutex_unlock(&data->lock);
769 773
770 kobject_unregister(&data->kobj); 774 kobject_unregister(&data->kobj);
771 775
@@ -834,9 +838,9 @@ unsigned int cpufreq_quick_get(unsigned int cpu)
834 unsigned int ret = 0; 838 unsigned int ret = 0;
835 839
836 if (policy) { 840 if (policy) {
837 down(&policy->lock); 841 mutex_lock(&policy->lock);
838 ret = policy->cur; 842 ret = policy->cur;
839 up(&policy->lock); 843 mutex_unlock(&policy->lock);
840 cpufreq_cpu_put(policy); 844 cpufreq_cpu_put(policy);
841 } 845 }
842 846
@@ -862,7 +866,7 @@ unsigned int cpufreq_get(unsigned int cpu)
862 if (!cpufreq_driver->get) 866 if (!cpufreq_driver->get)
863 goto out; 867 goto out;
864 868
865 down(&policy->lock); 869 mutex_lock(&policy->lock);
866 870
867 ret = cpufreq_driver->get(cpu); 871 ret = cpufreq_driver->get(cpu);
868 872
@@ -875,7 +879,7 @@ unsigned int cpufreq_get(unsigned int cpu)
875 } 879 }
876 } 880 }
877 881
878 up(&policy->lock); 882 mutex_unlock(&policy->lock);
879 883
880 out: 884 out:
881 cpufreq_cpu_put(policy); 885 cpufreq_cpu_put(policy);
@@ -1158,11 +1162,11 @@ int cpufreq_driver_target(struct cpufreq_policy *policy,
1158 if (!policy) 1162 if (!policy)
1159 return -EINVAL; 1163 return -EINVAL;
1160 1164
1161 down(&policy->lock); 1165 mutex_lock(&policy->lock);
1162 1166
1163 ret = __cpufreq_driver_target(policy, target_freq, relation); 1167 ret = __cpufreq_driver_target(policy, target_freq, relation);
1164 1168
1165 up(&policy->lock); 1169 mutex_unlock(&policy->lock);
1166 1170
1167 cpufreq_cpu_put(policy); 1171 cpufreq_cpu_put(policy);
1168 1172
@@ -1199,9 +1203,9 @@ int cpufreq_governor(unsigned int cpu, unsigned int event)
1199 if (!policy) 1203 if (!policy)
1200 return -EINVAL; 1204 return -EINVAL;
1201 1205
1202 down(&policy->lock); 1206 mutex_lock(&policy->lock);
1203 ret = __cpufreq_governor(policy, event); 1207 ret = __cpufreq_governor(policy, event);
1204 up(&policy->lock); 1208 mutex_unlock(&policy->lock);
1205 1209
1206 cpufreq_cpu_put(policy); 1210 cpufreq_cpu_put(policy);
1207 1211
@@ -1217,17 +1221,17 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
1217 if (!governor) 1221 if (!governor)
1218 return -EINVAL; 1222 return -EINVAL;
1219 1223
1220 down(&cpufreq_governor_sem); 1224 mutex_lock(&cpufreq_governor_mutex);
1221 1225
1222 list_for_each_entry(t, &cpufreq_governor_list, governor_list) { 1226 list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
1223 if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) { 1227 if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) {
1224 up(&cpufreq_governor_sem); 1228 mutex_unlock(&cpufreq_governor_mutex);
1225 return -EBUSY; 1229 return -EBUSY;
1226 } 1230 }
1227 } 1231 }
1228 list_add(&governor->governor_list, &cpufreq_governor_list); 1232 list_add(&governor->governor_list, &cpufreq_governor_list);
1229 1233
1230 up(&cpufreq_governor_sem); 1234 mutex_unlock(&cpufreq_governor_mutex);
1231 1235
1232 return 0; 1236 return 0;
1233} 1237}
@@ -1239,9 +1243,9 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
1239 if (!governor) 1243 if (!governor)
1240 return; 1244 return;
1241 1245
1242 down(&cpufreq_governor_sem); 1246 mutex_lock(&cpufreq_governor_mutex);
1243 list_del(&governor->governor_list); 1247 list_del(&governor->governor_list);
1244 up(&cpufreq_governor_sem); 1248 mutex_unlock(&cpufreq_governor_mutex);
1245 return; 1249 return;
1246} 1250}
1247EXPORT_SYMBOL_GPL(cpufreq_unregister_governor); 1251EXPORT_SYMBOL_GPL(cpufreq_unregister_governor);
@@ -1268,9 +1272,9 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
1268 if (!cpu_policy) 1272 if (!cpu_policy)
1269 return -EINVAL; 1273 return -EINVAL;
1270 1274
1271 down(&cpu_policy->lock); 1275 mutex_lock(&cpu_policy->lock);
1272 memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy)); 1276 memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy));
1273 up(&cpu_policy->lock); 1277 mutex_unlock(&cpu_policy->lock);
1274 1278
1275 cpufreq_cpu_put(cpu_policy); 1279 cpufreq_cpu_put(cpu_policy);
1276 1280
@@ -1382,7 +1386,7 @@ int cpufreq_set_policy(struct cpufreq_policy *policy)
1382 return -EINVAL; 1386 return -EINVAL;
1383 1387
1384 /* lock this CPU */ 1388 /* lock this CPU */
1385 down(&data->lock); 1389 mutex_lock(&data->lock);
1386 1390
1387 ret = __cpufreq_set_policy(data, policy); 1391 ret = __cpufreq_set_policy(data, policy);
1388 data->user_policy.min = data->min; 1392 data->user_policy.min = data->min;
@@ -1390,7 +1394,7 @@ int cpufreq_set_policy(struct cpufreq_policy *policy)
1390 data->user_policy.policy = data->policy; 1394 data->user_policy.policy = data->policy;
1391 data->user_policy.governor = data->governor; 1395 data->user_policy.governor = data->governor;
1392 1396
1393 up(&data->lock); 1397 mutex_unlock(&data->lock);
1394 cpufreq_cpu_put(data); 1398 cpufreq_cpu_put(data);
1395 1399
1396 return ret; 1400 return ret;
@@ -1414,7 +1418,7 @@ int cpufreq_update_policy(unsigned int cpu)
1414 if (!data) 1418 if (!data)
1415 return -ENODEV; 1419 return -ENODEV;
1416 1420
1417 down(&data->lock); 1421 mutex_lock(&data->lock);
1418 1422
1419 dprintk("updating policy for CPU %u\n", cpu); 1423 dprintk("updating policy for CPU %u\n", cpu);
1420 memcpy(&policy, 1424 memcpy(&policy,
@@ -1425,9 +1429,17 @@ int cpufreq_update_policy(unsigned int cpu)
1425 policy.policy = data->user_policy.policy; 1429 policy.policy = data->user_policy.policy;
1426 policy.governor = data->user_policy.governor; 1430 policy.governor = data->user_policy.governor;
1427 1431
1432 /* BIOS might change freq behind our back
1433 -> ask driver for current freq and notify governors about a change */
1434 if (cpufreq_driver->get) {
1435 policy.cur = cpufreq_driver->get(cpu);
1436 if (data->cur != policy.cur)
1437 cpufreq_out_of_sync(cpu, data->cur, policy.cur);
1438 }
1439
1428 ret = __cpufreq_set_policy(data, &policy); 1440 ret = __cpufreq_set_policy(data, &policy);
1429 1441
1430 up(&data->lock); 1442 mutex_unlock(&data->lock);
1431 1443
1432 cpufreq_cpu_put(data); 1444 cpufreq_cpu_put(data);
1433 return ret; 1445 return ret;
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 39543a2bed0f..ac38766b2583 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -28,7 +28,7 @@
28#include <linux/jiffies.h> 28#include <linux/jiffies.h>
29#include <linux/kernel_stat.h> 29#include <linux/kernel_stat.h>
30#include <linux/percpu.h> 30#include <linux/percpu.h>
31 31#include <linux/mutex.h>
32/* 32/*
33 * dbs is used in this file as a shortform for demandbased switching 33 * dbs is used in this file as a shortform for demandbased switching
34 * It helps to keep variable names smaller, simpler 34 * It helps to keep variable names smaller, simpler
@@ -71,7 +71,7 @@ static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);
71 71
72static unsigned int dbs_enable; /* number of CPUs using this policy */ 72static unsigned int dbs_enable; /* number of CPUs using this policy */
73 73
74static DECLARE_MUTEX (dbs_sem); 74static DEFINE_MUTEX (dbs_mutex);
75static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); 75static DECLARE_WORK (dbs_work, do_dbs_timer, NULL);
76 76
77struct dbs_tuners { 77struct dbs_tuners {
@@ -139,9 +139,9 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
139 if (ret != 1 ) 139 if (ret != 1 )
140 return -EINVAL; 140 return -EINVAL;
141 141
142 down(&dbs_sem); 142 mutex_lock(&dbs_mutex);
143 dbs_tuners_ins.sampling_down_factor = input; 143 dbs_tuners_ins.sampling_down_factor = input;
144 up(&dbs_sem); 144 mutex_unlock(&dbs_mutex);
145 145
146 return count; 146 return count;
147} 147}
@@ -153,14 +153,14 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
153 int ret; 153 int ret;
154 ret = sscanf (buf, "%u", &input); 154 ret = sscanf (buf, "%u", &input);
155 155
156 down(&dbs_sem); 156 mutex_lock(&dbs_mutex);
157 if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) { 157 if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) {
158 up(&dbs_sem); 158 mutex_unlock(&dbs_mutex);
159 return -EINVAL; 159 return -EINVAL;
160 } 160 }
161 161
162 dbs_tuners_ins.sampling_rate = input; 162 dbs_tuners_ins.sampling_rate = input;
163 up(&dbs_sem); 163 mutex_unlock(&dbs_mutex);
164 164
165 return count; 165 return count;
166} 166}
@@ -172,16 +172,16 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
172 int ret; 172 int ret;
173 ret = sscanf (buf, "%u", &input); 173 ret = sscanf (buf, "%u", &input);
174 174
175 down(&dbs_sem); 175 mutex_lock(&dbs_mutex);
176 if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || 176 if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD ||
177 input < MIN_FREQUENCY_UP_THRESHOLD || 177 input < MIN_FREQUENCY_UP_THRESHOLD ||
178 input <= dbs_tuners_ins.down_threshold) { 178 input <= dbs_tuners_ins.down_threshold) {
179 up(&dbs_sem); 179 mutex_unlock(&dbs_mutex);
180 return -EINVAL; 180 return -EINVAL;
181 } 181 }
182 182
183 dbs_tuners_ins.up_threshold = input; 183 dbs_tuners_ins.up_threshold = input;
184 up(&dbs_sem); 184 mutex_unlock(&dbs_mutex);
185 185
186 return count; 186 return count;
187} 187}
@@ -193,16 +193,16 @@ static ssize_t store_down_threshold(struct cpufreq_policy *unused,
193 int ret; 193 int ret;
194 ret = sscanf (buf, "%u", &input); 194 ret = sscanf (buf, "%u", &input);
195 195
196 down(&dbs_sem); 196 mutex_lock(&dbs_mutex);
197 if (ret != 1 || input > MAX_FREQUENCY_DOWN_THRESHOLD || 197 if (ret != 1 || input > MAX_FREQUENCY_DOWN_THRESHOLD ||
198 input < MIN_FREQUENCY_DOWN_THRESHOLD || 198 input < MIN_FREQUENCY_DOWN_THRESHOLD ||
199 input >= dbs_tuners_ins.up_threshold) { 199 input >= dbs_tuners_ins.up_threshold) {
200 up(&dbs_sem); 200 mutex_unlock(&dbs_mutex);
201 return -EINVAL; 201 return -EINVAL;
202 } 202 }
203 203
204 dbs_tuners_ins.down_threshold = input; 204 dbs_tuners_ins.down_threshold = input;
205 up(&dbs_sem); 205 mutex_unlock(&dbs_mutex);
206 206
207 return count; 207 return count;
208} 208}
@@ -222,9 +222,9 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
222 if ( input > 1 ) 222 if ( input > 1 )
223 input = 1; 223 input = 1;
224 224
225 down(&dbs_sem); 225 mutex_lock(&dbs_mutex);
226 if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */ 226 if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */
227 up(&dbs_sem); 227 mutex_unlock(&dbs_mutex);
228 return count; 228 return count;
229 } 229 }
230 dbs_tuners_ins.ignore_nice = input; 230 dbs_tuners_ins.ignore_nice = input;
@@ -236,7 +236,7 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
236 j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); 236 j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j);
237 j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up; 237 j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up;
238 } 238 }
239 up(&dbs_sem); 239 mutex_unlock(&dbs_mutex);
240 240
241 return count; 241 return count;
242} 242}
@@ -257,9 +257,9 @@ static ssize_t store_freq_step(struct cpufreq_policy *policy,
257 257
258 /* no need to test here if freq_step is zero as the user might actually 258 /* no need to test here if freq_step is zero as the user might actually
259 * want this, they would be crazy though :) */ 259 * want this, they would be crazy though :) */
260 down(&dbs_sem); 260 mutex_lock(&dbs_mutex);
261 dbs_tuners_ins.freq_step = input; 261 dbs_tuners_ins.freq_step = input;
262 up(&dbs_sem); 262 mutex_unlock(&dbs_mutex);
263 263
264 return count; 264 return count;
265} 265}
@@ -444,12 +444,12 @@ static void dbs_check_cpu(int cpu)
444static void do_dbs_timer(void *data) 444static void do_dbs_timer(void *data)
445{ 445{
446 int i; 446 int i;
447 down(&dbs_sem); 447 mutex_lock(&dbs_mutex);
448 for_each_online_cpu(i) 448 for_each_online_cpu(i)
449 dbs_check_cpu(i); 449 dbs_check_cpu(i);
450 schedule_delayed_work(&dbs_work, 450 schedule_delayed_work(&dbs_work,
451 usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); 451 usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
452 up(&dbs_sem); 452 mutex_unlock(&dbs_mutex);
453} 453}
454 454
455static inline void dbs_timer_init(void) 455static inline void dbs_timer_init(void)
@@ -487,7 +487,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
487 if (this_dbs_info->enable) /* Already enabled */ 487 if (this_dbs_info->enable) /* Already enabled */
488 break; 488 break;
489 489
490 down(&dbs_sem); 490 mutex_lock(&dbs_mutex);
491 for_each_cpu_mask(j, policy->cpus) { 491 for_each_cpu_mask(j, policy->cpus) {
492 struct cpu_dbs_info_s *j_dbs_info; 492 struct cpu_dbs_info_s *j_dbs_info;
493 j_dbs_info = &per_cpu(cpu_dbs_info, j); 493 j_dbs_info = &per_cpu(cpu_dbs_info, j);
@@ -521,11 +521,11 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
521 dbs_timer_init(); 521 dbs_timer_init();
522 } 522 }
523 523
524 up(&dbs_sem); 524 mutex_unlock(&dbs_mutex);
525 break; 525 break;
526 526
527 case CPUFREQ_GOV_STOP: 527 case CPUFREQ_GOV_STOP:
528 down(&dbs_sem); 528 mutex_lock(&dbs_mutex);
529 this_dbs_info->enable = 0; 529 this_dbs_info->enable = 0;
530 sysfs_remove_group(&policy->kobj, &dbs_attr_group); 530 sysfs_remove_group(&policy->kobj, &dbs_attr_group);
531 dbs_enable--; 531 dbs_enable--;
@@ -536,12 +536,12 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
536 if (dbs_enable == 0) 536 if (dbs_enable == 0)
537 dbs_timer_exit(); 537 dbs_timer_exit();
538 538
539 up(&dbs_sem); 539 mutex_unlock(&dbs_mutex);
540 540
541 break; 541 break;
542 542
543 case CPUFREQ_GOV_LIMITS: 543 case CPUFREQ_GOV_LIMITS:
544 down(&dbs_sem); 544 mutex_lock(&dbs_mutex);
545 if (policy->max < this_dbs_info->cur_policy->cur) 545 if (policy->max < this_dbs_info->cur_policy->cur)
546 __cpufreq_driver_target( 546 __cpufreq_driver_target(
547 this_dbs_info->cur_policy, 547 this_dbs_info->cur_policy,
@@ -550,7 +550,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
550 __cpufreq_driver_target( 550 __cpufreq_driver_target(
551 this_dbs_info->cur_policy, 551 this_dbs_info->cur_policy,
552 policy->min, CPUFREQ_RELATION_L); 552 policy->min, CPUFREQ_RELATION_L);
553 up(&dbs_sem); 553 mutex_unlock(&dbs_mutex);
554 break; 554 break;
555 } 555 }
556 return 0; 556 return 0;
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index e69fd8dd1f1c..9ee9411f186f 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -27,6 +27,7 @@
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/kernel_stat.h> 28#include <linux/kernel_stat.h>
29#include <linux/percpu.h> 29#include <linux/percpu.h>
30#include <linux/mutex.h>
30 31
31/* 32/*
32 * dbs is used in this file as a shortform for demandbased switching 33 * dbs is used in this file as a shortform for demandbased switching
@@ -70,7 +71,7 @@ static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);
70 71
71static unsigned int dbs_enable; /* number of CPUs using this policy */ 72static unsigned int dbs_enable; /* number of CPUs using this policy */
72 73
73static DECLARE_MUTEX (dbs_sem); 74static DEFINE_MUTEX (dbs_mutex);
74static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); 75static DECLARE_WORK (dbs_work, do_dbs_timer, NULL);
75 76
76struct dbs_tuners { 77struct dbs_tuners {
@@ -136,9 +137,9 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
136 if (input > MAX_SAMPLING_DOWN_FACTOR || input < 1) 137 if (input > MAX_SAMPLING_DOWN_FACTOR || input < 1)
137 return -EINVAL; 138 return -EINVAL;
138 139
139 down(&dbs_sem); 140 mutex_lock(&dbs_mutex);
140 dbs_tuners_ins.sampling_down_factor = input; 141 dbs_tuners_ins.sampling_down_factor = input;
141 up(&dbs_sem); 142 mutex_unlock(&dbs_mutex);
142 143
143 return count; 144 return count;
144} 145}
@@ -150,14 +151,14 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
150 int ret; 151 int ret;
151 ret = sscanf (buf, "%u", &input); 152 ret = sscanf (buf, "%u", &input);
152 153
153 down(&dbs_sem); 154 mutex_lock(&dbs_mutex);
154 if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) { 155 if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) {
155 up(&dbs_sem); 156 mutex_unlock(&dbs_mutex);
156 return -EINVAL; 157 return -EINVAL;
157 } 158 }
158 159
159 dbs_tuners_ins.sampling_rate = input; 160 dbs_tuners_ins.sampling_rate = input;
160 up(&dbs_sem); 161 mutex_unlock(&dbs_mutex);
161 162
162 return count; 163 return count;
163} 164}
@@ -169,15 +170,15 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
169 int ret; 170 int ret;
170 ret = sscanf (buf, "%u", &input); 171 ret = sscanf (buf, "%u", &input);
171 172
172 down(&dbs_sem); 173 mutex_lock(&dbs_mutex);
173 if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || 174 if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD ||
174 input < MIN_FREQUENCY_UP_THRESHOLD) { 175 input < MIN_FREQUENCY_UP_THRESHOLD) {
175 up(&dbs_sem); 176 mutex_unlock(&dbs_mutex);
176 return -EINVAL; 177 return -EINVAL;
177 } 178 }
178 179
179 dbs_tuners_ins.up_threshold = input; 180 dbs_tuners_ins.up_threshold = input;
180 up(&dbs_sem); 181 mutex_unlock(&dbs_mutex);
181 182
182 return count; 183 return count;
183} 184}
@@ -197,9 +198,9 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
197 if ( input > 1 ) 198 if ( input > 1 )
198 input = 1; 199 input = 1;
199 200
200 down(&dbs_sem); 201 mutex_lock(&dbs_mutex);
201 if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */ 202 if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */
202 up(&dbs_sem); 203 mutex_unlock(&dbs_mutex);
203 return count; 204 return count;
204 } 205 }
205 dbs_tuners_ins.ignore_nice = input; 206 dbs_tuners_ins.ignore_nice = input;
@@ -211,7 +212,7 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
211 j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); 212 j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j);
212 j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up; 213 j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up;
213 } 214 }
214 up(&dbs_sem); 215 mutex_unlock(&dbs_mutex);
215 216
216 return count; 217 return count;
217} 218}
@@ -356,12 +357,12 @@ static void dbs_check_cpu(int cpu)
356static void do_dbs_timer(void *data) 357static void do_dbs_timer(void *data)
357{ 358{
358 int i; 359 int i;
359 down(&dbs_sem); 360 mutex_lock(&dbs_mutex);
360 for_each_online_cpu(i) 361 for_each_online_cpu(i)
361 dbs_check_cpu(i); 362 dbs_check_cpu(i);
362 schedule_delayed_work(&dbs_work, 363 schedule_delayed_work(&dbs_work,
363 usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); 364 usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
364 up(&dbs_sem); 365 mutex_unlock(&dbs_mutex);
365} 366}
366 367
367static inline void dbs_timer_init(void) 368static inline void dbs_timer_init(void)
@@ -399,7 +400,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
399 if (this_dbs_info->enable) /* Already enabled */ 400 if (this_dbs_info->enable) /* Already enabled */
400 break; 401 break;
401 402
402 down(&dbs_sem); 403 mutex_lock(&dbs_mutex);
403 for_each_cpu_mask(j, policy->cpus) { 404 for_each_cpu_mask(j, policy->cpus) {
404 struct cpu_dbs_info_s *j_dbs_info; 405 struct cpu_dbs_info_s *j_dbs_info;
405 j_dbs_info = &per_cpu(cpu_dbs_info, j); 406 j_dbs_info = &per_cpu(cpu_dbs_info, j);
@@ -435,11 +436,11 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
435 dbs_timer_init(); 436 dbs_timer_init();
436 } 437 }
437 438
438 up(&dbs_sem); 439 mutex_unlock(&dbs_mutex);
439 break; 440 break;
440 441
441 case CPUFREQ_GOV_STOP: 442 case CPUFREQ_GOV_STOP:
442 down(&dbs_sem); 443 mutex_lock(&dbs_mutex);
443 this_dbs_info->enable = 0; 444 this_dbs_info->enable = 0;
444 sysfs_remove_group(&policy->kobj, &dbs_attr_group); 445 sysfs_remove_group(&policy->kobj, &dbs_attr_group);
445 dbs_enable--; 446 dbs_enable--;
@@ -450,12 +451,12 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
450 if (dbs_enable == 0) 451 if (dbs_enable == 0)
451 dbs_timer_exit(); 452 dbs_timer_exit();
452 453
453 up(&dbs_sem); 454 mutex_unlock(&dbs_mutex);
454 455
455 break; 456 break;
456 457
457 case CPUFREQ_GOV_LIMITS: 458 case CPUFREQ_GOV_LIMITS:
458 down(&dbs_sem); 459 mutex_lock(&dbs_mutex);
459 if (policy->max < this_dbs_info->cur_policy->cur) 460 if (policy->max < this_dbs_info->cur_policy->cur)
460 __cpufreq_driver_target( 461 __cpufreq_driver_target(
461 this_dbs_info->cur_policy, 462 this_dbs_info->cur_policy,
@@ -464,7 +465,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
464 __cpufreq_driver_target( 465 __cpufreq_driver_target(
465 this_dbs_info->cur_policy, 466 this_dbs_info->cur_policy,
466 policy->min, CPUFREQ_RELATION_L); 467 policy->min, CPUFREQ_RELATION_L);
467 up(&dbs_sem); 468 mutex_unlock(&dbs_mutex);
468 break; 469 break;
469 } 470 }
470 return 0; 471 return 0;
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c
index d32bf3593cd3..92a0be22a2a9 100644
--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -1,3 +1,4 @@
1
1/* 2/*
2 * linux/drivers/cpufreq/cpufreq_userspace.c 3 * linux/drivers/cpufreq/cpufreq_userspace.c
3 * 4 *
@@ -21,6 +22,7 @@
21#include <linux/types.h> 22#include <linux/types.h>
22#include <linux/fs.h> 23#include <linux/fs.h>
23#include <linux/sysfs.h> 24#include <linux/sysfs.h>
25#include <linux/mutex.h>
24 26
25#include <asm/uaccess.h> 27#include <asm/uaccess.h>
26 28
@@ -33,9 +35,8 @@ static unsigned int cpu_min_freq[NR_CPUS];
33static unsigned int cpu_cur_freq[NR_CPUS]; /* current CPU freq */ 35static unsigned int cpu_cur_freq[NR_CPUS]; /* current CPU freq */
34static unsigned int cpu_set_freq[NR_CPUS]; /* CPU freq desired by userspace */ 36static unsigned int cpu_set_freq[NR_CPUS]; /* CPU freq desired by userspace */
35static unsigned int cpu_is_managed[NR_CPUS]; 37static unsigned int cpu_is_managed[NR_CPUS];
36static struct cpufreq_policy current_policy[NR_CPUS];
37 38
38static DECLARE_MUTEX (userspace_sem); 39static DEFINE_MUTEX (userspace_mutex);
39 40
40#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg) 41#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg)
41 42
@@ -64,35 +65,34 @@ static struct notifier_block userspace_cpufreq_notifier_block = {
64 * 65 *
65 * Sets the CPU frequency to freq. 66 * Sets the CPU frequency to freq.
66 */ 67 */
67static int cpufreq_set(unsigned int freq, unsigned int cpu) 68static int cpufreq_set(unsigned int freq, struct cpufreq_policy *policy)
68{ 69{
69 int ret = -EINVAL; 70 int ret = -EINVAL;
70 71
71 dprintk("cpufreq_set for cpu %u, freq %u kHz\n", cpu, freq); 72 dprintk("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq);
72 73
73 down(&userspace_sem); 74 mutex_lock(&userspace_mutex);
74 if (!cpu_is_managed[cpu]) 75 if (!cpu_is_managed[policy->cpu])
75 goto err; 76 goto err;
76 77
77 cpu_set_freq[cpu] = freq; 78 cpu_set_freq[policy->cpu] = freq;
78 79
79 if (freq < cpu_min_freq[cpu]) 80 if (freq < cpu_min_freq[policy->cpu])
80 freq = cpu_min_freq[cpu]; 81 freq = cpu_min_freq[policy->cpu];
81 if (freq > cpu_max_freq[cpu]) 82 if (freq > cpu_max_freq[policy->cpu])
82 freq = cpu_max_freq[cpu]; 83 freq = cpu_max_freq[policy->cpu];
83 84
84 /* 85 /*
85 * We're safe from concurrent calls to ->target() here 86 * We're safe from concurrent calls to ->target() here
86 * as we hold the userspace_sem lock. If we were calling 87 * as we hold the userspace_mutex lock. If we were calling
87 * cpufreq_driver_target, a deadlock situation might occur: 88 * cpufreq_driver_target, a deadlock situation might occur:
88 * A: cpufreq_set (lock userspace_sem) -> cpufreq_driver_target(lock policy->lock) 89 * A: cpufreq_set (lock userspace_mutex) -> cpufreq_driver_target(lock policy->lock)
89 * B: cpufreq_set_policy(lock policy->lock) -> __cpufreq_governor -> cpufreq_governor_userspace (lock userspace_sem) 90 * B: cpufreq_set_policy(lock policy->lock) -> __cpufreq_governor -> cpufreq_governor_userspace (lock userspace_mutex)
90 */ 91 */
91 ret = __cpufreq_driver_target(&current_policy[cpu], freq, 92 ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);
92 CPUFREQ_RELATION_L);
93 93
94 err: 94 err:
95 up(&userspace_sem); 95 mutex_unlock(&userspace_mutex);
96 return ret; 96 return ret;
97} 97}
98 98
@@ -113,7 +113,7 @@ store_speed (struct cpufreq_policy *policy, const char *buf, size_t count)
113 if (ret != 1) 113 if (ret != 1)
114 return -EINVAL; 114 return -EINVAL;
115 115
116 cpufreq_set(freq, policy->cpu); 116 cpufreq_set(freq, policy);
117 117
118 return count; 118 return count;
119} 119}
@@ -134,44 +134,48 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
134 if (!cpu_online(cpu)) 134 if (!cpu_online(cpu))
135 return -EINVAL; 135 return -EINVAL;
136 BUG_ON(!policy->cur); 136 BUG_ON(!policy->cur);
137 down(&userspace_sem); 137 mutex_lock(&userspace_mutex);
138 cpu_is_managed[cpu] = 1; 138 cpu_is_managed[cpu] = 1;
139 cpu_min_freq[cpu] = policy->min; 139 cpu_min_freq[cpu] = policy->min;
140 cpu_max_freq[cpu] = policy->max; 140 cpu_max_freq[cpu] = policy->max;
141 cpu_cur_freq[cpu] = policy->cur; 141 cpu_cur_freq[cpu] = policy->cur;
142 cpu_set_freq[cpu] = policy->cur; 142 cpu_set_freq[cpu] = policy->cur;
143 sysfs_create_file (&policy->kobj, &freq_attr_scaling_setspeed.attr); 143 sysfs_create_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
144 memcpy (&current_policy[cpu], policy, sizeof(struct cpufreq_policy));
145 dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]); 144 dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]);
146 up(&userspace_sem); 145 mutex_unlock(&userspace_mutex);
147 break; 146 break;
148 case CPUFREQ_GOV_STOP: 147 case CPUFREQ_GOV_STOP:
149 down(&userspace_sem); 148 mutex_lock(&userspace_mutex);
150 cpu_is_managed[cpu] = 0; 149 cpu_is_managed[cpu] = 0;
151 cpu_min_freq[cpu] = 0; 150 cpu_min_freq[cpu] = 0;
152 cpu_max_freq[cpu] = 0; 151 cpu_max_freq[cpu] = 0;
153 cpu_set_freq[cpu] = 0; 152 cpu_set_freq[cpu] = 0;
154 sysfs_remove_file (&policy->kobj, &freq_attr_scaling_setspeed.attr); 153 sysfs_remove_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
155 dprintk("managing cpu %u stopped\n", cpu); 154 dprintk("managing cpu %u stopped\n", cpu);
156 up(&userspace_sem); 155 mutex_unlock(&userspace_mutex);
157 break; 156 break;
158 case CPUFREQ_GOV_LIMITS: 157 case CPUFREQ_GOV_LIMITS:
159 down(&userspace_sem); 158 mutex_lock(&userspace_mutex);
160 cpu_min_freq[cpu] = policy->min; 159 dprintk("limit event for cpu %u: %u - %u kHz,"
161 cpu_max_freq[cpu] = policy->max; 160 "currently %u kHz, last set to %u kHz\n",
162 dprintk("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu], cpu_set_freq[cpu]); 161 cpu, policy->min, policy->max,
162 cpu_cur_freq[cpu], cpu_set_freq[cpu]);
163 if (policy->max < cpu_set_freq[cpu]) { 163 if (policy->max < cpu_set_freq[cpu]) {
164 __cpufreq_driver_target(&current_policy[cpu], policy->max, 164 __cpufreq_driver_target(policy, policy->max,
165 CPUFREQ_RELATION_H); 165 CPUFREQ_RELATION_H);
166 } else if (policy->min > cpu_set_freq[cpu]) { 166 }
167 __cpufreq_driver_target(&current_policy[cpu], policy->min, 167 else if (policy->min > cpu_set_freq[cpu]) {
168 CPUFREQ_RELATION_L); 168 __cpufreq_driver_target(policy, policy->min,
169 } else { 169 CPUFREQ_RELATION_L);
170 __cpufreq_driver_target(&current_policy[cpu], cpu_set_freq[cpu],
171 CPUFREQ_RELATION_L);
172 } 170 }
173 memcpy (&current_policy[cpu], policy, sizeof(struct cpufreq_policy)); 171 else {
174 up(&userspace_sem); 172 __cpufreq_driver_target(policy, cpu_set_freq[cpu],
173 CPUFREQ_RELATION_L);
174 }
175 cpu_min_freq[cpu] = policy->min;
176 cpu_max_freq[cpu] = policy->max;
177 cpu_cur_freq[cpu] = policy->cur;
178 mutex_unlock(&userspace_mutex);
175 break; 179 break;
176 } 180 }
177 return 0; 181 return 0;
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 4819e7fc00dd..18a455651121 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -11,7 +11,6 @@ menu 'EDAC - error detection and reporting (RAS)'
11config EDAC 11config EDAC
12 tristate "EDAC core system error reporting" 12 tristate "EDAC core system error reporting"
13 depends on X86 13 depends on X86
14 default y
15 help 14 help
16 EDAC is designed to report errors in the core system. 15 EDAC is designed to report errors in the core system.
17 These are low-level errors that are reported in the CPU or 16 These are low-level errors that are reported in the CPU or
@@ -46,7 +45,7 @@ config EDAC_MM_EDAC
46 45
47config EDAC_AMD76X 46config EDAC_AMD76X
48 tristate "AMD 76x (760, 762, 768)" 47 tristate "AMD 76x (760, 762, 768)"
49 depends on EDAC_MM_EDAC && PCI 48 depends on EDAC_MM_EDAC && PCI && X86_32
50 help 49 help
51 Support for error detection and correction on the AMD 76x 50 Support for error detection and correction on the AMD 76x
52 series of chipsets used with the Athlon processor. 51 series of chipsets used with the Athlon processor.
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
index 770a5a633079..c454ded2b060 100644
--- a/drivers/edac/e752x_edac.c
+++ b/drivers/edac/e752x_edac.c
@@ -1039,10 +1039,10 @@ MODULE_DEVICE_TABLE(pci, e752x_pci_tbl);
1039 1039
1040 1040
1041static struct pci_driver e752x_driver = { 1041static struct pci_driver e752x_driver = {
1042 name: BS_MOD_STR, 1042 .name = BS_MOD_STR,
1043 probe: e752x_init_one, 1043 .probe = e752x_init_one,
1044 remove: __devexit_p(e752x_remove_one), 1044 .remove = __devexit_p(e752x_remove_one),
1045 id_table: e752x_pci_tbl, 1045 .id_table = e752x_pci_tbl,
1046}; 1046};
1047 1047
1048 1048
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 4be9bd0a1267..b10ee4698b1d 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -14,7 +14,6 @@
14 14
15 15
16#include <linux/config.h> 16#include <linux/config.h>
17#include <linux/version.h>
18#include <linux/module.h> 17#include <linux/module.h>
19#include <linux/proc_fs.h> 18#include <linux/proc_fs.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 1c81174595b3..d633081fa4c5 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -52,9 +52,9 @@ config IDE
52 52
53if IDE 53if IDE
54 54
55config IDE_MAX_HWIFS 55config IDE_MAX_HWIFS
56 int "Max IDE interfaces" 56 int "Max IDE interfaces"
57 depends on ALPHA || SUPERH 57 depends on ALPHA || SUPERH || IA64
58 default 4 58 default 4
59 help 59 help
60 This is the maximum number of IDE hardware interfaces that will 60 This is the maximum number of IDE hardware interfaces that will
@@ -162,8 +162,8 @@ config BLK_DEV_IDECS
162 tristate "PCMCIA IDE support" 162 tristate "PCMCIA IDE support"
163 depends on PCMCIA 163 depends on PCMCIA
164 help 164 help
165 Support for outboard IDE disks, tape drives, and CD-ROM drives 165 Support for Compact Flash cards, outboard IDE disks, tape drives,
166 connected through a PCMCIA card. 166 and CD-ROM drives connected through a PCMCIA card.
167 167
168config BLK_DEV_IDECD 168config BLK_DEV_IDECD
169 tristate "Include IDE/ATAPI CDROM support" 169 tristate "Include IDE/ATAPI CDROM support"
@@ -267,7 +267,7 @@ config IDE_TASK_IOCTL
267 help 267 help
268 This is a direct raw access to the media. It is a complex but 268 This is a direct raw access to the media. It is a complex but
269 elegant solution to test and validate the domain of the hardware and 269 elegant solution to test and validate the domain of the hardware and
270 perform below the driver data recover if needed. This is the most 270 perform below the driver data recovery if needed. This is the most
271 basic form of media-forensics. 271 basic form of media-forensics.
272 272
273 If you are unsure, say N here. 273 If you are unsure, say N here.
@@ -525,7 +525,7 @@ config BLK_DEV_CS5520
525 tristate "Cyrix CS5510/20 MediaGX chipset support (VERY EXPERIMENTAL)" 525 tristate "Cyrix CS5510/20 MediaGX chipset support (VERY EXPERIMENTAL)"
526 depends on EXPERIMENTAL 526 depends on EXPERIMENTAL
527 help 527 help
528 Include support for PIO tuning an virtual DMA on the Cyrix MediaGX 528 Include support for PIO tuning and virtual DMA on the Cyrix MediaGX
529 5510/5520 chipset. This will automatically be detected and 529 5510/5520 chipset. This will automatically be detected and
530 configured if found. 530 configured if found.
531 531
@@ -662,7 +662,7 @@ config PDC202XX_BURST
662 662
663 It was originally designed for the PDC20246/Ultra33, whose BIOS will 663 It was originally designed for the PDC20246/Ultra33, whose BIOS will
664 only setup UDMA on the first two PDC20246 cards. It has also been 664 only setup UDMA on the first two PDC20246 cards. It has also been
665 used succesfully on a PDC20265/Ultra100, allowing use of UDMA modes 665 used successfully on a PDC20265/Ultra100, allowing use of UDMA modes
666 when the PDC20265 BIOS has been disabled (for faster boot up). 666 when the PDC20265 BIOS has been disabled (for faster boot up).
667 667
668 Please read the comments at the top of 668 Please read the comments at the top of
@@ -673,13 +673,6 @@ config PDC202XX_BURST
673config BLK_DEV_PDC202XX_NEW 673config BLK_DEV_PDC202XX_NEW
674 tristate "PROMISE PDC202{68|69|70|71|75|76|77} support" 674 tristate "PROMISE PDC202{68|69|70|71|75|76|77} support"
675 675
676# FIXME - probably wants to be one for old and for new
677config PDC202XX_FORCE
678 bool "Enable controller even if disabled by BIOS"
679 depends on BLK_DEV_PDC202XX_NEW
680 help
681 Enable the PDC202xx controller even if it has been disabled in the BIOS setup.
682
683config BLK_DEV_SVWKS 676config BLK_DEV_SVWKS
684 tristate "ServerWorks OSB4/CSB5/CSB6 chipsets support" 677 tristate "ServerWorks OSB4/CSB5/CSB6 chipsets support"
685 help 678 help
@@ -722,7 +715,7 @@ config BLK_DEV_SIS5513
722config BLK_DEV_SLC90E66 715config BLK_DEV_SLC90E66
723 tristate "SLC90E66 chipset support" 716 tristate "SLC90E66 chipset support"
724 help 717 help
725 This driver ensures (U)DMA support for Victroy66 SouthBridges for 718 This driver ensures (U)DMA support for Victory66 SouthBridges for
726 SMsC with Intel NorthBridges. This is an Ultra66 based chipset. 719 SMsC with Intel NorthBridges. This is an Ultra66 based chipset.
727 The nice thing about it is that you can mix Ultra/DMA/PIO devices 720 The nice thing about it is that you can mix Ultra/DMA/PIO devices
728 and it will handle timing cycles. Since this is an improved 721 and it will handle timing cycles. Since this is an improved
@@ -1060,7 +1053,7 @@ config IDEDMA_IVB
1060 in that mode with an 80c ribbon. 1053 in that mode with an 80c ribbon.
1061 1054
1062 If you are experiencing compatibility or performance problems, you 1055 If you are experiencing compatibility or performance problems, you
1063 MAY try to answering Y here. However, it does not necessarily solve 1056 MAY try to answer Y here. However, it does not necessarily solve
1064 any of your problems, it could even cause more of them. 1057 any of your problems, it could even cause more of them.
1065 1058
1066 It is normally safe to answer Y; however, the default is N. 1059 It is normally safe to answer Y; however, the default is N.
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index ca25f9e3d0f4..6c60a9d2afd8 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -776,7 +776,7 @@ static void update_ordered(ide_drive_t *drive)
776 ide_id_has_flush_cache_ext(id)); 776 ide_id_has_flush_cache_ext(id));
777 777
778 printk(KERN_INFO "%s: cache flushes %ssupported\n", 778 printk(KERN_INFO "%s: cache flushes %ssupported\n",
779 drive->name, barrier ? "" : "not"); 779 drive->name, barrier ? "" : "not ");
780 780
781 if (barrier) { 781 if (barrier) {
782 ordered = QUEUE_ORDERED_DRAIN_FLUSH; 782 ordered = QUEUE_ORDERED_DRAIN_FLUSH;
@@ -889,11 +889,7 @@ static void idedisk_setup (ide_drive_t *drive)
889 if (drive->id_read == 0) 889 if (drive->id_read == 0)
890 return; 890 return;
891 891
892 /* 892 if (drive->removable) {
893 * CompactFlash cards and their brethern look just like hard drives
894 * to us, but they are removable and don't have a doorlock mechanism.
895 */
896 if (drive->removable && !(drive->is_flash)) {
897 /* 893 /*
898 * Removable disks (eg. SYQUEST); ignore 'WD' drives 894 * Removable disks (eg. SYQUEST); ignore 'WD' drives
899 */ 895 */
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 8d50df4526a4..c01615dec202 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -55,8 +55,8 @@
55#include <asm/io.h> 55#include <asm/io.h>
56#include <asm/bitops.h> 56#include <asm/bitops.h>
57 57
58int __ide_end_request(ide_drive_t *drive, struct request *rq, int uptodate, 58static int __ide_end_request(ide_drive_t *drive, struct request *rq,
59 int nr_sectors) 59 int uptodate, int nr_sectors)
60{ 60{
61 int ret = 1; 61 int ret = 1;
62 62
@@ -91,7 +91,6 @@ int __ide_end_request(ide_drive_t *drive, struct request *rq, int uptodate,
91 91
92 return ret; 92 return ret;
93} 93}
94EXPORT_SYMBOL(__ide_end_request);
95 94
96/** 95/**
97 * ide_end_request - complete an IDE I/O 96 * ide_end_request - complete an IDE I/O
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index af7af958ab3e..b72dde70840a 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -1243,6 +1243,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
1243 */ 1243 */
1244 if (stat == 0xff) 1244 if (stat == 0xff)
1245 return -ENODEV; 1245 return -ENODEV;
1246 touch_softlockup_watchdog();
1246 } 1247 }
1247 return -EBUSY; 1248 return -EBUSY;
1248} 1249}
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index e7425546b4b1..427d1c204174 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -125,45 +125,6 @@ static void ide_disk_init_mult_count(ide_drive_t *drive)
125} 125}
126 126
127/** 127/**
128 * drive_is_flashcard - check for compact flash
129 * @drive: drive to check
130 *
131 * CompactFlash cards and their brethern pretend to be removable
132 * hard disks, except:
133 * (1) they never have a slave unit, and
134 * (2) they don't have doorlock mechanisms.
135 * This test catches them, and is invoked elsewhere when setting
136 * appropriate config bits.
137 *
138 * FIXME: This treatment is probably applicable for *all* PCMCIA (PC CARD)
139 * devices, so in linux 2.3.x we should change this to just treat all
140 * PCMCIA drives this way, and get rid of the model-name tests below
141 * (too big of an interface change for 2.4.x).
142 * At that time, we might also consider parameterizing the timeouts and
143 * retries, since these are MUCH faster than mechanical drives. -M.Lord
144 */
145
146static inline int drive_is_flashcard (ide_drive_t *drive)
147{
148 struct hd_driveid *id = drive->id;
149
150 if (drive->removable) {
151 if (id->config == 0x848a) return 1; /* CompactFlash */
152 if (!strncmp(id->model, "KODAK ATA_FLASH", 15) /* Kodak */
153 || !strncmp(id->model, "Hitachi CV", 10) /* Hitachi */
154 || !strncmp(id->model, "SunDisk SDCFB", 13) /* old SanDisk */
155 || !strncmp(id->model, "SanDisk SDCFB", 13) /* SanDisk */
156 || !strncmp(id->model, "HAGIWARA HPC", 12) /* Hagiwara */
157 || !strncmp(id->model, "LEXAR ATA_FLASH", 15) /* Lexar */
158 || !strncmp(id->model, "ATA_FLASH", 9)) /* Simple Tech */
159 {
160 return 1; /* yes, it is a flash memory card */
161 }
162 }
163 return 0; /* no, it is not a flash memory card */
164}
165
166/**
167 * do_identify - identify a drive 128 * do_identify - identify a drive
168 * @drive: drive to identify 129 * @drive: drive to identify
169 * @cmd: command used 130 * @cmd: command used
@@ -278,13 +239,17 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
278 /* 239 /*
279 * Not an ATAPI device: looks like a "regular" hard disk 240 * Not an ATAPI device: looks like a "regular" hard disk
280 */ 241 */
281 if (id->config & (1<<7)) 242
243 /*
244 * 0x848a = CompactFlash device
245 * These are *not* removable in Linux definition of the term
246 */
247
248 if ((id->config != 0x848a) && (id->config & (1<<7)))
282 drive->removable = 1; 249 drive->removable = 1;
283 250
284 if (drive_is_flashcard(drive))
285 drive->is_flash = 1;
286 drive->media = ide_disk; 251 drive->media = ide_disk;
287 printk("%s DISK drive\n", (drive->is_flash) ? "CFA" : "ATA" ); 252 printk("%s DISK drive\n", (id->config == 0x848a) ? "CFA" : "ATA" );
288 QUIRK_LIST(drive); 253 QUIRK_LIST(drive);
289 return; 254 return;
290 255
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index afeb02bbb722..b2cc43702f65 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -242,7 +242,6 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
242 drive->name[2] = 'a' + (index * MAX_DRIVES) + unit; 242 drive->name[2] = 'a' + (index * MAX_DRIVES) + unit;
243 drive->max_failures = IDE_DEFAULT_MAX_FAILURES; 243 drive->max_failures = IDE_DEFAULT_MAX_FAILURES;
244 drive->using_dma = 0; 244 drive->using_dma = 0;
245 drive->is_flash = 0;
246 drive->vdma = 0; 245 drive->vdma = 0;
247 INIT_LIST_HEAD(&drive->list); 246 INIT_LIST_HEAD(&drive->list);
248 init_completion(&drive->gendev_rel_comp); 247 init_completion(&drive->gendev_rel_comp);
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index a21b1e11eef4..c743e68c33aa 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -262,6 +262,21 @@ static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const ch
262 else 262 else
263 pci_set_drvdata(dev, (void *) aec6xxx_34_base); 263 pci_set_drvdata(dev, (void *) aec6xxx_34_base);
264 264
265 /* These are necessary to get AEC6280 Macintosh cards to work */
266 if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) ||
267 (dev->device == PCI_DEVICE_ID_ARTOP_ATP865R)) {
268 u8 reg49h = 0, reg4ah = 0;
269 /* Clear reset and test bits. */
270 pci_read_config_byte(dev, 0x49, &reg49h);
271 pci_write_config_byte(dev, 0x49, reg49h & ~0x30);
272 /* Enable chip interrupt output. */
273 pci_read_config_byte(dev, 0x4a, &reg4ah);
274 pci_write_config_byte(dev, 0x4a, reg4ah & ~0x01);
275 /* Enable burst mode. */
276 pci_read_config_byte(dev, 0x4a, &reg4ah);
277 pci_write_config_byte(dev, 0x4a, reg4ah | 0x80);
278 }
279
265 return dev->irq; 280 return dev->irq;
266} 281}
267 282
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 7b589d948bf9..940bdd4c5784 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1288,6 +1288,10 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif)
1288 goto init_hpt37X_done; 1288 goto init_hpt37X_done;
1289 } 1289 }
1290 } 1290 }
1291 if (!pci_get_drvdata(dev)) {
1292 printk("No Clock Stabilization!!!\n");
1293 return;
1294 }
1291pll_recal: 1295pll_recal:
1292 if (adjust & 1) 1296 if (adjust & 1)
1293 pll -= (adjust >> 1); 1297 pll -= (adjust >> 1);
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 108fda83fea4..38f41b377ff6 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -733,7 +733,7 @@ static void __devinit it8212_disable_raid(struct pci_dev *dev)
733 733
734 pci_write_config_dword(dev,0x4C, 0x02040204); 734 pci_write_config_dword(dev,0x4C, 0x02040204);
735 pci_write_config_byte(dev, 0x42, 0x36); 735 pci_write_config_byte(dev, 0x42, 0x36);
736 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0); 736 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20);
737} 737}
738 738
739static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const char *name) 739static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const char *name)
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index fe06ebb0e5bf..acd63173199b 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -420,9 +420,6 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
420 .init_hwif = init_hwif_pdc202new, 420 .init_hwif = init_hwif_pdc202new,
421 .channels = 2, 421 .channels = 2,
422 .autodma = AUTODMA, 422 .autodma = AUTODMA,
423#ifndef CONFIG_PDC202XX_FORCE
424 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
425#endif
426 .bootable = OFF_BOARD, 423 .bootable = OFF_BOARD,
427 },{ /* 3 */ 424 },{ /* 3 */
428 .name = "PDC20271", 425 .name = "PDC20271",
@@ -447,9 +444,6 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
447 .init_hwif = init_hwif_pdc202new, 444 .init_hwif = init_hwif_pdc202new,
448 .channels = 2, 445 .channels = 2,
449 .autodma = AUTODMA, 446 .autodma = AUTODMA,
450#ifndef CONFIG_PDC202XX_FORCE
451 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
452#endif
453 .bootable = OFF_BOARD, 447 .bootable = OFF_BOARD,
454 },{ /* 6 */ 448 },{ /* 6 */
455 .name = "PDC20277", 449 .name = "PDC20277",
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index ad9d95817f95..6f8f8645b02c 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -786,9 +786,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
786 .init_dma = init_dma_pdc202xx, 786 .init_dma = init_dma_pdc202xx,
787 .channels = 2, 787 .channels = 2,
788 .autodma = AUTODMA, 788 .autodma = AUTODMA,
789#ifndef CONFIG_PDC202XX_FORCE
790 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
791#endif
792 .bootable = OFF_BOARD, 789 .bootable = OFF_BOARD,
793 .extra = 16, 790 .extra = 16,
794 },{ /* 1 */ 791 },{ /* 1 */
@@ -799,9 +796,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
799 .init_dma = init_dma_pdc202xx, 796 .init_dma = init_dma_pdc202xx,
800 .channels = 2, 797 .channels = 2,
801 .autodma = AUTODMA, 798 .autodma = AUTODMA,
802#ifndef CONFIG_PDC202XX_FORCE
803 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
804#endif
805 .bootable = OFF_BOARD, 799 .bootable = OFF_BOARD,
806 .extra = 48, 800 .extra = 48,
807 .flags = IDEPCI_FLAG_FORCE_PDC, 801 .flags = IDEPCI_FLAG_FORCE_PDC,
@@ -813,9 +807,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
813 .init_dma = init_dma_pdc202xx, 807 .init_dma = init_dma_pdc202xx,
814 .channels = 2, 808 .channels = 2,
815 .autodma = AUTODMA, 809 .autodma = AUTODMA,
816#ifndef CONFIG_PDC202XX_FORCE
817 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
818#endif
819 .bootable = OFF_BOARD, 810 .bootable = OFF_BOARD,
820 .extra = 48, 811 .extra = 48,
821 },{ /* 3 */ 812 },{ /* 3 */
@@ -826,9 +817,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
826 .init_dma = init_dma_pdc202xx, 817 .init_dma = init_dma_pdc202xx,
827 .channels = 2, 818 .channels = 2,
828 .autodma = AUTODMA, 819 .autodma = AUTODMA,
829#ifndef CONFIG_PDC202XX_FORCE
830 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
831#endif
832 .bootable = OFF_BOARD, 820 .bootable = OFF_BOARD,
833 .extra = 48, 821 .extra = 48,
834 .flags = IDEPCI_FLAG_FORCE_PDC, 822 .flags = IDEPCI_FLAG_FORCE_PDC,
@@ -840,9 +828,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
840 .init_dma = init_dma_pdc202xx, 828 .init_dma = init_dma_pdc202xx,
841 .channels = 2, 829 .channels = 2,
842 .autodma = AUTODMA, 830 .autodma = AUTODMA,
843#ifndef CONFIG_PDC202XX_FORCE
844 .enablebits = {{0x50,0x02,0x02}, {0x50,0x04,0x04}},
845#endif
846 .bootable = OFF_BOARD, 831 .bootable = OFF_BOARD,
847 .extra = 48, 832 .extra = 48,
848 } 833 }
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index b3e77df63cef..e9b83e1a3028 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -135,6 +135,7 @@ static u8 piix_ratemask (ide_drive_t *drive)
135 case PCI_DEVICE_ID_INTEL_ICH6_19: 135 case PCI_DEVICE_ID_INTEL_ICH6_19:
136 case PCI_DEVICE_ID_INTEL_ICH7_21: 136 case PCI_DEVICE_ID_INTEL_ICH7_21:
137 case PCI_DEVICE_ID_INTEL_ESB2_18: 137 case PCI_DEVICE_ID_INTEL_ESB2_18:
138 case PCI_DEVICE_ID_INTEL_ICH8_6:
138 mode = 3; 139 mode = 3;
139 break; 140 break;
140 /* UDMA 66 capable */ 141 /* UDMA 66 capable */
@@ -449,6 +450,7 @@ static unsigned int __devinit init_chipset_piix (struct pci_dev *dev, const char
449 case PCI_DEVICE_ID_INTEL_ICH6_19: 450 case PCI_DEVICE_ID_INTEL_ICH6_19:
450 case PCI_DEVICE_ID_INTEL_ICH7_21: 451 case PCI_DEVICE_ID_INTEL_ICH7_21:
451 case PCI_DEVICE_ID_INTEL_ESB2_18: 452 case PCI_DEVICE_ID_INTEL_ESB2_18:
453 case PCI_DEVICE_ID_INTEL_ICH8_6:
452 { 454 {
453 unsigned int extra = 0; 455 unsigned int extra = 0;
454 pci_read_config_dword(dev, 0x54, &extra); 456 pci_read_config_dword(dev, 0x54, &extra);
@@ -575,6 +577,7 @@ static ide_pci_device_t piix_pci_info[] __devinitdata = {
575 /* 21 */ DECLARE_PIIX_DEV("ICH7"), 577 /* 21 */ DECLARE_PIIX_DEV("ICH7"),
576 /* 22 */ DECLARE_PIIX_DEV("ICH4"), 578 /* 22 */ DECLARE_PIIX_DEV("ICH4"),
577 /* 23 */ DECLARE_PIIX_DEV("ESB2"), 579 /* 23 */ DECLARE_PIIX_DEV("ESB2"),
580 /* 24 */ DECLARE_PIIX_DEV("ICH8M"),
578}; 581};
579 582
580/** 583/**
@@ -651,6 +654,7 @@ static struct pci_device_id piix_pci_tbl[] = {
651 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 21}, 654 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 21},
652 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 22}, 655 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 22},
653 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 23}, 656 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 23},
657 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 24},
654 { 0, }, 658 { 0, },
655}; 659};
656MODULE_DEVICE_TABLE(pci, piix_pci_tbl); 660MODULE_DEVICE_TABLE(pci, piix_pci_tbl);
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 4ee597d08797..2b286e865163 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2003-2006 Silicon Graphics, Inc. All Rights Reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License 5 * under the terms of version 2 of the GNU General Public License
@@ -510,7 +510,7 @@ sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
510 drive->name); 510 drive->name);
511 goto use_pio_instead; 511 goto use_pio_instead;
512 } else { 512 } else {
513 u32 xcount, bcount = 513 u32 bcount =
514 0x10000 - (cur_addr & 0xffff); 514 0x10000 - (cur_addr & 0xffff);
515 515
516 if (bcount > cur_len) 516 if (bcount > cur_len)
@@ -525,8 +525,7 @@ sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
525 *table = 0x0; 525 *table = 0x0;
526 table++; 526 table++;
527 527
528 xcount = bcount & 0xffff; 528 *table = cpu_to_be32(bcount);
529 *table = cpu_to_be32(xcount);
530 table++; 529 table++;
531 530
532 cur_addr += bcount; 531 cur_addr += bcount;
@@ -680,7 +679,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
680 return -EIO; 679 return -EIO;
681 680
682 /* Create /proc/ide entries */ 681 /* Create /proc/ide entries */
683 create_proc_ide_interfaces(); 682 create_proc_ide_interfaces();
684 683
685 return 0; 684 return 0;
686} 685}
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index acda7d63d6fe..501cc054cb3b 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -956,6 +956,8 @@ static void ib_sa_remove_one(struct ib_device *device)
956 956
957 ib_unregister_event_handler(&sa_dev->event_handler); 957 ib_unregister_event_handler(&sa_dev->event_handler);
958 958
959 flush_scheduled_work();
960
959 for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) { 961 for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
960 ib_unregister_mad_agent(sa_dev->port[i].agent); 962 ib_unregister_mad_agent(sa_dev->port[i].agent);
961 kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah); 963 kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 96ea79b63df7..903f85a4bc0c 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -902,6 +902,7 @@ static void __exit ib_uverbs_cleanup(void)
902 unregister_filesystem(&uverbs_event_fs); 902 unregister_filesystem(&uverbs_event_fs);
903 class_destroy(uverbs_class); 903 class_destroy(uverbs_class);
904 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES); 904 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
905 flush_scheduled_work();
905 idr_destroy(&ib_uverbs_pd_idr); 906 idr_destroy(&ib_uverbs_pd_idr);
906 idr_destroy(&ib_uverbs_mr_idr); 907 idr_destroy(&ib_uverbs_mr_idr);
907 idr_destroy(&ib_uverbs_mw_idr); 908 idr_destroy(&ib_uverbs_mw_idr);
diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c
index a14eed08a0fc..a19e0ed03d7c 100644
--- a/drivers/infiniband/hw/mthca/mthca_av.c
+++ b/drivers/infiniband/hw/mthca/mthca_av.c
@@ -184,7 +184,7 @@ int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
184 ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff); 184 ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff);
185 ib_get_cached_gid(&dev->ib_dev, 185 ib_get_cached_gid(&dev->ib_dev,
186 be32_to_cpu(ah->av->port_pd) >> 24, 186 be32_to_cpu(ah->av->port_pd) >> 24,
187 ah->av->gid_index, 187 ah->av->gid_index % dev->limits.gid_table_len,
188 &header->grh.source_gid); 188 &header->grh.source_gid);
189 memcpy(header->grh.destination_gid.raw, 189 memcpy(header->grh.destination_gid.raw,
190 ah->av->dgid, 16); 190 ah->av->dgid, 16);
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index be1791be627b..f9b9b93dc501 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -199,8 +199,7 @@ static int mthca_cmd_post(struct mthca_dev *dev,
199{ 199{
200 int err = 0; 200 int err = 0;
201 201
202 if (down_interruptible(&dev->cmd.hcr_sem)) 202 mutex_lock(&dev->cmd.hcr_mutex);
203 return -EINTR;
204 203
205 if (event) { 204 if (event) {
206 unsigned long end = jiffies + GO_BIT_TIMEOUT; 205 unsigned long end = jiffies + GO_BIT_TIMEOUT;
@@ -238,7 +237,7 @@ static int mthca_cmd_post(struct mthca_dev *dev,
238 op), dev->hcr + 6 * 4); 237 op), dev->hcr + 6 * 4);
239 238
240out: 239out:
241 up(&dev->cmd.hcr_sem); 240 mutex_unlock(&dev->cmd.hcr_mutex);
242 return err; 241 return err;
243} 242}
244 243
@@ -255,8 +254,7 @@ static int mthca_cmd_poll(struct mthca_dev *dev,
255 int err = 0; 254 int err = 0;
256 unsigned long end; 255 unsigned long end;
257 256
258 if (down_interruptible(&dev->cmd.poll_sem)) 257 down(&dev->cmd.poll_sem);
259 return -EINTR;
260 258
261 err = mthca_cmd_post(dev, in_param, 259 err = mthca_cmd_post(dev, in_param,
262 out_param ? *out_param : 0, 260 out_param ? *out_param : 0,
@@ -333,8 +331,7 @@ static int mthca_cmd_wait(struct mthca_dev *dev,
333 int err = 0; 331 int err = 0;
334 struct mthca_cmd_context *context; 332 struct mthca_cmd_context *context;
335 333
336 if (down_interruptible(&dev->cmd.event_sem)) 334 down(&dev->cmd.event_sem);
337 return -EINTR;
338 335
339 spin_lock(&dev->cmd.context_lock); 336 spin_lock(&dev->cmd.context_lock);
340 BUG_ON(dev->cmd.free_head < 0); 337 BUG_ON(dev->cmd.free_head < 0);
@@ -438,7 +435,7 @@ static int mthca_cmd_imm(struct mthca_dev *dev,
438 435
439int mthca_cmd_init(struct mthca_dev *dev) 436int mthca_cmd_init(struct mthca_dev *dev)
440{ 437{
441 sema_init(&dev->cmd.hcr_sem, 1); 438 mutex_init(&dev->cmd.hcr_mutex);
442 sema_init(&dev->cmd.poll_sem, 1); 439 sema_init(&dev->cmd.poll_sem, 1);
443 dev->cmd.use_events = 0; 440 dev->cmd.use_events = 0;
444 441
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
index a104ab041ea3..2a165fd06e57 100644
--- a/drivers/infiniband/hw/mthca/mthca_dev.h
+++ b/drivers/infiniband/hw/mthca/mthca_dev.h
@@ -44,6 +44,8 @@
44#include <linux/pci.h> 44#include <linux/pci.h>
45#include <linux/dma-mapping.h> 45#include <linux/dma-mapping.h>
46#include <linux/timer.h> 46#include <linux/timer.h>
47#include <linux/mutex.h>
48
47#include <asm/semaphore.h> 49#include <asm/semaphore.h>
48 50
49#include "mthca_provider.h" 51#include "mthca_provider.h"
@@ -111,7 +113,7 @@ enum {
111struct mthca_cmd { 113struct mthca_cmd {
112 struct pci_pool *pool; 114 struct pci_pool *pool;
113 int use_events; 115 int use_events;
114 struct semaphore hcr_sem; 116 struct mutex hcr_mutex;
115 struct semaphore poll_sem; 117 struct semaphore poll_sem;
116 struct semaphore event_sem; 118 struct semaphore event_sem;
117 int max_cmds; 119 int max_cmds;
@@ -256,7 +258,7 @@ struct mthca_av_table {
256}; 258};
257 259
258struct mthca_mcg_table { 260struct mthca_mcg_table {
259 struct semaphore sem; 261 struct mutex mutex;
260 struct mthca_alloc alloc; 262 struct mthca_alloc alloc;
261 struct mthca_icm_table *table; 263 struct mthca_icm_table *table;
262}; 264};
@@ -301,7 +303,7 @@ struct mthca_dev {
301 u64 ddr_end; 303 u64 ddr_end;
302 304
303 MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock) 305 MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock)
304 struct semaphore cap_mask_mutex; 306 struct mutex cap_mask_mutex;
305 307
306 void __iomem *hcr; 308 void __iomem *hcr;
307 void __iomem *kar; 309 void __iomem *kar;
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 8b00d9a0f6f4..9c849d27b06e 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -155,6 +155,13 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim
155 return -ENODEV; 155 return -ENODEV;
156 } 156 }
157 157
158 if (dev_lim->uar_size > pci_resource_len(mdev->pdev, 2)) {
159 mthca_err(mdev, "HCA reported UAR size of 0x%x bigger than "
160 "PCI resource 2 size of 0x%lx, aborting.\n",
161 dev_lim->uar_size, pci_resource_len(mdev->pdev, 2));
162 return -ENODEV;
163 }
164
158 mdev->limits.num_ports = dev_lim->num_ports; 165 mdev->limits.num_ports = dev_lim->num_ports;
159 mdev->limits.vl_cap = dev_lim->max_vl; 166 mdev->limits.vl_cap = dev_lim->max_vl;
160 mdev->limits.mtu_cap = dev_lim->max_mtu; 167 mdev->limits.mtu_cap = dev_lim->max_mtu;
@@ -976,8 +983,7 @@ static int __devinit mthca_init_one(struct pci_dev *pdev,
976 err = -ENODEV; 983 err = -ENODEV;
977 goto err_disable_pdev; 984 goto err_disable_pdev;
978 } 985 }
979 if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM) || 986 if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) {
980 pci_resource_len(pdev, 2) != 1 << 23) {
981 dev_err(&pdev->dev, "Missing UAR, aborting.\n"); 987 dev_err(&pdev->dev, "Missing UAR, aborting.\n");
982 err = -ENODEV; 988 err = -ENODEV;
983 goto err_disable_pdev; 989 goto err_disable_pdev;
diff --git a/drivers/infiniband/hw/mthca/mthca_mcg.c b/drivers/infiniband/hw/mthca/mthca_mcg.c
index 77bc6c746f43..321f11e707f2 100644
--- a/drivers/infiniband/hw/mthca/mthca_mcg.c
+++ b/drivers/infiniband/hw/mthca/mthca_mcg.c
@@ -154,10 +154,7 @@ int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
154 return PTR_ERR(mailbox); 154 return PTR_ERR(mailbox);
155 mgm = mailbox->buf; 155 mgm = mailbox->buf;
156 156
157 if (down_interruptible(&dev->mcg_table.sem)) { 157 mutex_lock(&dev->mcg_table.mutex);
158 err = -EINTR;
159 goto err_sem;
160 }
161 158
162 err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index); 159 err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index);
163 if (err) 160 if (err)
@@ -241,8 +238,8 @@ int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
241 BUG_ON(index < dev->limits.num_mgms); 238 BUG_ON(index < dev->limits.num_mgms);
242 mthca_free(&dev->mcg_table.alloc, index); 239 mthca_free(&dev->mcg_table.alloc, index);
243 } 240 }
244 up(&dev->mcg_table.sem); 241 mutex_unlock(&dev->mcg_table.mutex);
245 err_sem: 242
246 mthca_free_mailbox(dev, mailbox); 243 mthca_free_mailbox(dev, mailbox);
247 return err; 244 return err;
248} 245}
@@ -263,10 +260,7 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
263 return PTR_ERR(mailbox); 260 return PTR_ERR(mailbox);
264 mgm = mailbox->buf; 261 mgm = mailbox->buf;
265 262
266 if (down_interruptible(&dev->mcg_table.sem)) { 263 mutex_lock(&dev->mcg_table.mutex);
267 err = -EINTR;
268 goto err_sem;
269 }
270 264
271 err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index); 265 err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index);
272 if (err) 266 if (err)
@@ -371,8 +365,8 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
371 } 365 }
372 366
373 out: 367 out:
374 up(&dev->mcg_table.sem); 368 mutex_unlock(&dev->mcg_table.mutex);
375 err_sem: 369
376 mthca_free_mailbox(dev, mailbox); 370 mthca_free_mailbox(dev, mailbox);
377 return err; 371 return err;
378} 372}
@@ -389,7 +383,7 @@ int __devinit mthca_init_mcg_table(struct mthca_dev *dev)
389 if (err) 383 if (err)
390 return err; 384 return err;
391 385
392 init_MUTEX(&dev->mcg_table.sem); 386 mutex_init(&dev->mcg_table.mutex);
393 387
394 return 0; 388 return 0;
395} 389}
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 9fb985a016e9..d709cb162a72 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -50,7 +50,7 @@ enum {
50}; 50};
51 51
52struct mthca_user_db_table { 52struct mthca_user_db_table {
53 struct semaphore mutex; 53 struct mutex mutex;
54 struct { 54 struct {
55 u64 uvirt; 55 u64 uvirt;
56 struct scatterlist mem; 56 struct scatterlist mem;
@@ -158,7 +158,7 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob
158 int ret = 0; 158 int ret = 0;
159 u8 status; 159 u8 status;
160 160
161 down(&table->mutex); 161 mutex_lock(&table->mutex);
162 162
163 if (table->icm[i]) { 163 if (table->icm[i]) {
164 ++table->icm[i]->refcount; 164 ++table->icm[i]->refcount;
@@ -184,7 +184,7 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob
184 ++table->icm[i]->refcount; 184 ++table->icm[i]->refcount;
185 185
186out: 186out:
187 up(&table->mutex); 187 mutex_unlock(&table->mutex);
188 return ret; 188 return ret;
189} 189}
190 190
@@ -198,7 +198,7 @@ void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int o
198 198
199 i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE; 199 i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE;
200 200
201 down(&table->mutex); 201 mutex_lock(&table->mutex);
202 202
203 if (--table->icm[i]->refcount == 0) { 203 if (--table->icm[i]->refcount == 0) {
204 mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE, 204 mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE,
@@ -207,7 +207,7 @@ void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int o
207 table->icm[i] = NULL; 207 table->icm[i] = NULL;
208 } 208 }
209 209
210 up(&table->mutex); 210 mutex_unlock(&table->mutex);
211} 211}
212 212
213void *mthca_table_find(struct mthca_icm_table *table, int obj) 213void *mthca_table_find(struct mthca_icm_table *table, int obj)
@@ -220,7 +220,7 @@ void *mthca_table_find(struct mthca_icm_table *table, int obj)
220 if (!table->lowmem) 220 if (!table->lowmem)
221 return NULL; 221 return NULL;
222 222
223 down(&table->mutex); 223 mutex_lock(&table->mutex);
224 224
225 idx = (obj & (table->num_obj - 1)) * table->obj_size; 225 idx = (obj & (table->num_obj - 1)) * table->obj_size;
226 icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE]; 226 icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE];
@@ -240,7 +240,7 @@ void *mthca_table_find(struct mthca_icm_table *table, int obj)
240 } 240 }
241 241
242out: 242out:
243 up(&table->mutex); 243 mutex_unlock(&table->mutex);
244 return page ? lowmem_page_address(page) + offset : NULL; 244 return page ? lowmem_page_address(page) + offset : NULL;
245} 245}
246 246
@@ -301,7 +301,7 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
301 table->num_obj = nobj; 301 table->num_obj = nobj;
302 table->obj_size = obj_size; 302 table->obj_size = obj_size;
303 table->lowmem = use_lowmem; 303 table->lowmem = use_lowmem;
304 init_MUTEX(&table->mutex); 304 mutex_init(&table->mutex);
305 305
306 for (i = 0; i < num_icm; ++i) 306 for (i = 0; i < num_icm; ++i)
307 table->icm[i] = NULL; 307 table->icm[i] = NULL;
@@ -380,7 +380,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
380 if (index < 0 || index > dev->uar_table.uarc_size / 8) 380 if (index < 0 || index > dev->uar_table.uarc_size / 8)
381 return -EINVAL; 381 return -EINVAL;
382 382
383 down(&db_tab->mutex); 383 mutex_lock(&db_tab->mutex);
384 384
385 i = index / MTHCA_DB_REC_PER_PAGE; 385 i = index / MTHCA_DB_REC_PER_PAGE;
386 386
@@ -424,7 +424,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
424 db_tab->page[i].refcount = 1; 424 db_tab->page[i].refcount = 1;
425 425
426out: 426out:
427 up(&db_tab->mutex); 427 mutex_unlock(&db_tab->mutex);
428 return ret; 428 return ret;
429} 429}
430 430
@@ -439,11 +439,11 @@ void mthca_unmap_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
439 * pages until we clean up the whole db table. 439 * pages until we clean up the whole db table.
440 */ 440 */
441 441
442 down(&db_tab->mutex); 442 mutex_lock(&db_tab->mutex);
443 443
444 --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount; 444 --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount;
445 445
446 up(&db_tab->mutex); 446 mutex_unlock(&db_tab->mutex);
447} 447}
448 448
449struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev) 449struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev)
@@ -460,7 +460,7 @@ struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev)
460 if (!db_tab) 460 if (!db_tab)
461 return ERR_PTR(-ENOMEM); 461 return ERR_PTR(-ENOMEM);
462 462
463 init_MUTEX(&db_tab->mutex); 463 mutex_init(&db_tab->mutex);
464 for (i = 0; i < npages; ++i) { 464 for (i = 0; i < npages; ++i) {
465 db_tab->page[i].refcount = 0; 465 db_tab->page[i].refcount = 0;
466 db_tab->page[i].uvirt = 0; 466 db_tab->page[i].uvirt = 0;
@@ -499,7 +499,7 @@ int mthca_alloc_db(struct mthca_dev *dev, enum mthca_db_type type,
499 int ret = 0; 499 int ret = 0;
500 u8 status; 500 u8 status;
501 501
502 down(&dev->db_tab->mutex); 502 mutex_lock(&dev->db_tab->mutex);
503 503
504 switch (type) { 504 switch (type) {
505 case MTHCA_DB_TYPE_CQ_ARM: 505 case MTHCA_DB_TYPE_CQ_ARM:
@@ -585,7 +585,7 @@ found:
585 *db = (__be32 *) &page->db_rec[j]; 585 *db = (__be32 *) &page->db_rec[j];
586 586
587out: 587out:
588 up(&dev->db_tab->mutex); 588 mutex_unlock(&dev->db_tab->mutex);
589 589
590 return ret; 590 return ret;
591} 591}
@@ -601,7 +601,7 @@ void mthca_free_db(struct mthca_dev *dev, int type, int db_index)
601 601
602 page = dev->db_tab->page + i; 602 page = dev->db_tab->page + i;
603 603
604 down(&dev->db_tab->mutex); 604 mutex_lock(&dev->db_tab->mutex);
605 605
606 page->db_rec[j] = 0; 606 page->db_rec[j] = 0;
607 if (i >= dev->db_tab->min_group2) 607 if (i >= dev->db_tab->min_group2)
@@ -624,7 +624,7 @@ void mthca_free_db(struct mthca_dev *dev, int type, int db_index)
624 ++dev->db_tab->min_group2; 624 ++dev->db_tab->min_group2;
625 } 625 }
626 626
627 up(&dev->db_tab->mutex); 627 mutex_unlock(&dev->db_tab->mutex);
628} 628}
629 629
630int mthca_init_db_tab(struct mthca_dev *dev) 630int mthca_init_db_tab(struct mthca_dev *dev)
@@ -638,7 +638,7 @@ int mthca_init_db_tab(struct mthca_dev *dev)
638 if (!dev->db_tab) 638 if (!dev->db_tab)
639 return -ENOMEM; 639 return -ENOMEM;
640 640
641 init_MUTEX(&dev->db_tab->mutex); 641 mutex_init(&dev->db_tab->mutex);
642 642
643 dev->db_tab->npages = dev->uar_table.uarc_size / 4096; 643 dev->db_tab->npages = dev->uar_table.uarc_size / 4096;
644 dev->db_tab->max_group1 = 0; 644 dev->db_tab->max_group1 = 0;
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.h b/drivers/infiniband/hw/mthca/mthca_memfree.h
index 4fdca26eea85..36f1141a08aa 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.h
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.h
@@ -39,8 +39,7 @@
39 39
40#include <linux/list.h> 40#include <linux/list.h>
41#include <linux/pci.h> 41#include <linux/pci.h>
42 42#include <linux/mutex.h>
43#include <asm/semaphore.h>
44 43
45#define MTHCA_ICM_CHUNK_LEN \ 44#define MTHCA_ICM_CHUNK_LEN \
46 ((256 - sizeof (struct list_head) - 2 * sizeof (int)) / \ 45 ((256 - sizeof (struct list_head) - 2 * sizeof (int)) / \
@@ -64,7 +63,7 @@ struct mthca_icm_table {
64 int num_obj; 63 int num_obj;
65 int obj_size; 64 int obj_size;
66 int lowmem; 65 int lowmem;
67 struct semaphore mutex; 66 struct mutex mutex;
68 struct mthca_icm *icm[0]; 67 struct mthca_icm *icm[0];
69}; 68};
70 69
@@ -147,7 +146,7 @@ struct mthca_db_table {
147 int max_group1; 146 int max_group1;
148 int min_group2; 147 int min_group2;
149 struct mthca_db_page *page; 148 struct mthca_db_page *page;
150 struct semaphore mutex; 149 struct mutex mutex;
151}; 150};
152 151
153enum mthca_db_type { 152enum mthca_db_type {
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 484a7e6b7f8c..e88e39aef85a 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -185,7 +185,7 @@ static int mthca_modify_port(struct ib_device *ibdev,
185 int err; 185 int err;
186 u8 status; 186 u8 status;
187 187
188 if (down_interruptible(&to_mdev(ibdev)->cap_mask_mutex)) 188 if (mutex_lock_interruptible(&to_mdev(ibdev)->cap_mask_mutex))
189 return -ERESTARTSYS; 189 return -ERESTARTSYS;
190 190
191 err = mthca_query_port(ibdev, port, &attr); 191 err = mthca_query_port(ibdev, port, &attr);
@@ -207,7 +207,7 @@ static int mthca_modify_port(struct ib_device *ibdev,
207 } 207 }
208 208
209out: 209out:
210 up(&to_mdev(ibdev)->cap_mask_mutex); 210 mutex_unlock(&to_mdev(ibdev)->cap_mask_mutex);
211 return err; 211 return err;
212} 212}
213 213
@@ -1185,7 +1185,7 @@ int mthca_register_device(struct mthca_dev *dev)
1185 dev->ib_dev.post_recv = mthca_tavor_post_receive; 1185 dev->ib_dev.post_recv = mthca_tavor_post_receive;
1186 } 1186 }
1187 1187
1188 init_MUTEX(&dev->cap_mask_mutex); 1188 mutex_init(&dev->cap_mask_mutex);
1189 1189
1190 ret = ib_register_device(&dev->ib_dev); 1190 ret = ib_register_device(&dev->ib_dev);
1191 if (ret) 1191 if (ret)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index fd3f5c862a5d..c3b5f79d1168 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -505,7 +505,7 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
505 505
506 list_add_tail(&neigh->list, &path->neigh_list); 506 list_add_tail(&neigh->list, &path->neigh_list);
507 507
508 if (path->pathrec.dlid) { 508 if (path->ah) {
509 kref_get(&path->ah->ref); 509 kref_get(&path->ah->ref);
510 neigh->ah = path->ah; 510 neigh->ah = path->ah;
511 511
@@ -591,7 +591,7 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
591 return; 591 return;
592 } 592 }
593 593
594 if (path->pathrec.dlid) { 594 if (path->ah) {
595 ipoib_dbg(priv, "Send unicast ARP to %04x\n", 595 ipoib_dbg(priv, "Send unicast ARP to %04x\n",
596 be16_to_cpu(path->pathrec.dlid)); 596 be16_to_cpu(path->pathrec.dlid));
597 597
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index 98039da0caf0..ccaa0c387076 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -97,6 +97,7 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast)
97 struct ipoib_dev_priv *priv = netdev_priv(dev); 97 struct ipoib_dev_priv *priv = netdev_priv(dev);
98 struct ipoib_neigh *neigh, *tmp; 98 struct ipoib_neigh *neigh, *tmp;
99 unsigned long flags; 99 unsigned long flags;
100 int tx_dropped = 0;
100 101
101 ipoib_dbg_mcast(netdev_priv(dev), 102 ipoib_dbg_mcast(netdev_priv(dev),
102 "deleting multicast group " IPOIB_GID_FMT "\n", 103 "deleting multicast group " IPOIB_GID_FMT "\n",
@@ -123,8 +124,14 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast)
123 if (mcast->ah) 124 if (mcast->ah)
124 ipoib_put_ah(mcast->ah); 125 ipoib_put_ah(mcast->ah);
125 126
126 while (!skb_queue_empty(&mcast->pkt_queue)) 127 while (!skb_queue_empty(&mcast->pkt_queue)) {
128 ++tx_dropped;
127 dev_kfree_skb_any(skb_dequeue(&mcast->pkt_queue)); 129 dev_kfree_skb_any(skb_dequeue(&mcast->pkt_queue));
130 }
131
132 spin_lock_irqsave(&priv->tx_lock, flags);
133 priv->stats.tx_dropped += tx_dropped;
134 spin_unlock_irqrestore(&priv->tx_lock, flags);
128 135
129 kfree(mcast); 136 kfree(mcast);
130} 137}
@@ -276,8 +283,10 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
276 } 283 }
277 284
278 /* actually send any queued packets */ 285 /* actually send any queued packets */
286 spin_lock_irq(&priv->tx_lock);
279 while (!skb_queue_empty(&mcast->pkt_queue)) { 287 while (!skb_queue_empty(&mcast->pkt_queue)) {
280 struct sk_buff *skb = skb_dequeue(&mcast->pkt_queue); 288 struct sk_buff *skb = skb_dequeue(&mcast->pkt_queue);
289 spin_unlock_irq(&priv->tx_lock);
281 290
282 skb->dev = dev; 291 skb->dev = dev;
283 292
@@ -288,7 +297,9 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
288 297
289 if (dev_queue_xmit(skb)) 298 if (dev_queue_xmit(skb))
290 ipoib_warn(priv, "dev_queue_xmit failed to requeue packet\n"); 299 ipoib_warn(priv, "dev_queue_xmit failed to requeue packet\n");
300 spin_lock_irq(&priv->tx_lock);
291 } 301 }
302 spin_unlock_irq(&priv->tx_lock);
292 303
293 return 0; 304 return 0;
294} 305}
@@ -300,6 +311,7 @@ ipoib_mcast_sendonly_join_complete(int status,
300{ 311{
301 struct ipoib_mcast *mcast = mcast_ptr; 312 struct ipoib_mcast *mcast = mcast_ptr;
302 struct net_device *dev = mcast->dev; 313 struct net_device *dev = mcast->dev;
314 struct ipoib_dev_priv *priv = netdev_priv(dev);
303 315
304 if (!status) 316 if (!status)
305 ipoib_mcast_join_finish(mcast, mcmember); 317 ipoib_mcast_join_finish(mcast, mcmember);
@@ -310,8 +322,12 @@ ipoib_mcast_sendonly_join_complete(int status,
310 IPOIB_GID_ARG(mcast->mcmember.mgid), status); 322 IPOIB_GID_ARG(mcast->mcmember.mgid), status);
311 323
312 /* Flush out any queued packets */ 324 /* Flush out any queued packets */
313 while (!skb_queue_empty(&mcast->pkt_queue)) 325 spin_lock_irq(&priv->tx_lock);
326 while (!skb_queue_empty(&mcast->pkt_queue)) {
327 ++priv->stats.tx_dropped;
314 dev_kfree_skb_any(skb_dequeue(&mcast->pkt_queue)); 328 dev_kfree_skb_any(skb_dequeue(&mcast->pkt_queue));
329 }
330 spin_unlock_irq(&priv->tx_lock);
315 331
316 /* Clear the busy flag so we try again */ 332 /* Clear the busy flag so we try again */
317 clear_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags); 333 clear_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags);
@@ -687,6 +703,7 @@ void ipoib_mcast_send(struct net_device *dev, union ib_gid *mgid,
687 if (!mcast) { 703 if (!mcast) {
688 ipoib_warn(priv, "unable to allocate memory for " 704 ipoib_warn(priv, "unable to allocate memory for "
689 "multicast structure\n"); 705 "multicast structure\n");
706 ++priv->stats.tx_dropped;
690 dev_kfree_skb_any(skb); 707 dev_kfree_skb_any(skb);
691 goto out; 708 goto out;
692 } 709 }
@@ -700,8 +717,10 @@ void ipoib_mcast_send(struct net_device *dev, union ib_gid *mgid,
700 if (!mcast->ah) { 717 if (!mcast->ah) {
701 if (skb_queue_len(&mcast->pkt_queue) < IPOIB_MAX_MCAST_QUEUE) 718 if (skb_queue_len(&mcast->pkt_queue) < IPOIB_MAX_MCAST_QUEUE)
702 skb_queue_tail(&mcast->pkt_queue, skb); 719 skb_queue_tail(&mcast->pkt_queue, skb);
703 else 720 else {
721 ++priv->stats.tx_dropped;
704 dev_kfree_skb_any(skb); 722 dev_kfree_skb_any(skb);
723 }
705 724
706 if (mcast->query) 725 if (mcast->query)
707 ipoib_dbg_mcast(priv, "no address vector, " 726 ipoib_dbg_mcast(priv, "no address vector, "
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 31207e664148..2d2d4ac3525a 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -357,9 +357,9 @@ static void srp_remove_work(void *target_ptr)
357 target->state = SRP_TARGET_REMOVED; 357 target->state = SRP_TARGET_REMOVED;
358 spin_unlock_irq(target->scsi_host->host_lock); 358 spin_unlock_irq(target->scsi_host->host_lock);
359 359
360 down(&target->srp_host->target_mutex); 360 mutex_lock(&target->srp_host->target_mutex);
361 list_del(&target->list); 361 list_del(&target->list);
362 up(&target->srp_host->target_mutex); 362 mutex_unlock(&target->srp_host->target_mutex);
363 363
364 scsi_remove_host(target->scsi_host); 364 scsi_remove_host(target->scsi_host);
365 ib_destroy_cm_id(target->cm_id); 365 ib_destroy_cm_id(target->cm_id);
@@ -1254,9 +1254,9 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
1254 if (scsi_add_host(target->scsi_host, host->dev->dma_device)) 1254 if (scsi_add_host(target->scsi_host, host->dev->dma_device))
1255 return -ENODEV; 1255 return -ENODEV;
1256 1256
1257 down(&host->target_mutex); 1257 mutex_lock(&host->target_mutex);
1258 list_add_tail(&target->list, &host->target_list); 1258 list_add_tail(&target->list, &host->target_list);
1259 up(&host->target_mutex); 1259 mutex_unlock(&host->target_mutex);
1260 1260
1261 target->state = SRP_TARGET_LIVE; 1261 target->state = SRP_TARGET_LIVE;
1262 1262
@@ -1525,7 +1525,7 @@ static struct srp_host *srp_add_port(struct ib_device *device, u8 port)
1525 return NULL; 1525 return NULL;
1526 1526
1527 INIT_LIST_HEAD(&host->target_list); 1527 INIT_LIST_HEAD(&host->target_list);
1528 init_MUTEX(&host->target_mutex); 1528 mutex_init(&host->target_mutex);
1529 init_completion(&host->released); 1529 init_completion(&host->released);
1530 host->dev = device; 1530 host->dev = device;
1531 host->port = port; 1531 host->port = port;
@@ -1626,7 +1626,7 @@ static void srp_remove_one(struct ib_device *device)
1626 * Mark all target ports as removed, so we stop queueing 1626 * Mark all target ports as removed, so we stop queueing
1627 * commands and don't try to reconnect. 1627 * commands and don't try to reconnect.
1628 */ 1628 */
1629 down(&host->target_mutex); 1629 mutex_lock(&host->target_mutex);
1630 list_for_each_entry_safe(target, tmp_target, 1630 list_for_each_entry_safe(target, tmp_target,
1631 &host->target_list, list) { 1631 &host->target_list, list) {
1632 spin_lock_irqsave(target->scsi_host->host_lock, flags); 1632 spin_lock_irqsave(target->scsi_host->host_lock, flags);
@@ -1634,7 +1634,7 @@ static void srp_remove_one(struct ib_device *device)
1634 target->state = SRP_TARGET_REMOVED; 1634 target->state = SRP_TARGET_REMOVED;
1635 spin_unlock_irqrestore(target->scsi_host->host_lock, flags); 1635 spin_unlock_irqrestore(target->scsi_host->host_lock, flags);
1636 } 1636 }
1637 up(&host->target_mutex); 1637 mutex_unlock(&host->target_mutex);
1638 1638
1639 /* 1639 /*
1640 * Wait for any reconnection tasks that may have 1640 * Wait for any reconnection tasks that may have
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index b564f18caf78..4e7727df32f1 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -37,8 +37,7 @@
37 37
38#include <linux/types.h> 38#include <linux/types.h>
39#include <linux/list.h> 39#include <linux/list.h>
40 40#include <linux/mutex.h>
41#include <asm/semaphore.h>
42 41
43#include <scsi/scsi_host.h> 42#include <scsi/scsi_host.h>
44#include <scsi/scsi_cmnd.h> 43#include <scsi/scsi_cmnd.h>
@@ -85,7 +84,7 @@ struct srp_host {
85 struct ib_mr *mr; 84 struct ib_mr *mr;
86 struct class_device class_dev; 85 struct class_device class_dev;
87 struct list_head target_list; 86 struct list_head target_list;
88 struct semaphore target_mutex; 87 struct mutex target_mutex;
89 struct completion released; 88 struct completion released;
90 struct list_head list; 89 struct list_head list;
91}; 90};
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
index 4571ea3a4b92..4612d13ea756 100644
--- a/drivers/input/joystick/a3d.c
+++ b/drivers/input/joystick/a3d.c
@@ -57,7 +57,7 @@ static char *a3d_names[] = { NULL, "FP-Gaming Assassin 3D", "MadCatz Panther", "
57struct a3d { 57struct a3d {
58 struct gameport *gameport; 58 struct gameport *gameport;
59 struct gameport *adc; 59 struct gameport *adc;
60 struct input_dev dev; 60 struct input_dev *dev;
61 int axes[4]; 61 int axes[4];
62 int buttons; 62 int buttons;
63 int mode; 63 int mode;
@@ -115,7 +115,7 @@ static int a3d_csum(char *data, int count)
115 115
116static void a3d_read(struct a3d *a3d, unsigned char *data) 116static void a3d_read(struct a3d *a3d, unsigned char *data)
117{ 117{
118 struct input_dev *dev = &a3d->dev; 118 struct input_dev *dev = a3d->dev;
119 119
120 switch (a3d->mode) { 120 switch (a3d->mode) {
121 121
@@ -265,14 +265,20 @@ static void a3d_close(struct input_dev *dev)
265static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) 265static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv)
266{ 266{
267 struct a3d *a3d; 267 struct a3d *a3d;
268 struct input_dev *input_dev;
268 struct gameport *adc; 269 struct gameport *adc;
269 unsigned char data[A3D_MAX_LENGTH]; 270 unsigned char data[A3D_MAX_LENGTH];
270 int i; 271 int i;
271 int err; 272 int err;
272 273
273 if (!(a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL))) 274 a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL);
274 return -ENOMEM; 275 input_dev = input_allocate_device();
276 if (!a3d || !input_dev) {
277 err = -ENOMEM;
278 goto fail1;
279 }
275 280
281 a3d->dev = input_dev;
276 a3d->gameport = gameport; 282 a3d->gameport = gameport;
277 283
278 gameport_set_drvdata(gameport, a3d); 284 gameport_set_drvdata(gameport, a3d);
@@ -302,42 +308,48 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv)
302 308
303 sprintf(a3d->phys, "%s/input0", gameport->phys); 309 sprintf(a3d->phys, "%s/input0", gameport->phys);
304 310
311 input_dev->name = a3d_names[a3d->mode];
312 input_dev->phys = a3d->phys;
313 input_dev->id.bustype = BUS_GAMEPORT;
314 input_dev->id.vendor = GAMEPORT_ID_VENDOR_MADCATZ;
315 input_dev->id.product = a3d->mode;
316 input_dev->id.version = 0x0100;
317 input_dev->cdev.dev = &gameport->dev;
318 input_dev->private = a3d;
319 input_dev->open = a3d_open;
320 input_dev->close = a3d_close;
321
305 if (a3d->mode == A3D_MODE_PXL) { 322 if (a3d->mode == A3D_MODE_PXL) {
306 323
307 int axes[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER }; 324 int axes[] = { ABS_X, ABS_Y, ABS_THROTTLE, ABS_RUDDER };
308 325
309 a3d->length = 33; 326 a3d->length = 33;
310 327
311 init_input_dev(&a3d->dev); 328 input_dev->evbit[0] |= BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL);
312 329 input_dev->relbit[0] |= BIT(REL_X) | BIT(REL_Y);
313 a3d->dev.evbit[0] |= BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); 330 input_dev->absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_RUDDER)
314 a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y); 331 | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y) | BIT(ABS_HAT1X) | BIT(ABS_HAT1Y);
315 a3d->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_RUDDER) 332 input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE)
316 | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y) | BIT(ABS_HAT1X) | BIT(ABS_HAT1Y); 333 | BIT(BTN_SIDE) | BIT(BTN_EXTRA);
317 334 input_dev->keybit[LONG(BTN_JOYSTICK)] |= BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP)
318 a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE) 335 | BIT(BTN_PINKIE);
319 | BIT(BTN_SIDE) | BIT(BTN_EXTRA);
320
321 a3d->dev.keybit[LONG(BTN_JOYSTICK)] |= BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_PINKIE);
322 336
323 a3d_read(a3d, data); 337 a3d_read(a3d, data);
324 338
325 for (i = 0; i < 4; i++) { 339 for (i = 0; i < 4; i++) {
326 if (i < 2) 340 if (i < 2)
327 input_set_abs_params(&a3d->dev, axes[i], 48, a3d->dev.abs[axes[i]] * 2 - 48, 0, 8); 341 input_set_abs_params(input_dev, axes[i], 48, input_dev->abs[axes[i]] * 2 - 48, 0, 8);
328 else 342 else
329 input_set_abs_params(&a3d->dev, axes[i], 2, 253, 0, 0); 343 input_set_abs_params(input_dev, axes[i], 2, 253, 0, 0);
330 input_set_abs_params(&a3d->dev, ABS_HAT0X + i, -1, 1, 0, 0); 344 input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0);
331 } 345 }
332 346
333 } else { 347 } else {
334 a3d->length = 29; 348 a3d->length = 29;
335 349
336 init_input_dev(&a3d->dev); 350 input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_REL);
337 351 input_dev->relbit[0] |= BIT(REL_X) | BIT(REL_Y);
338 a3d->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_REL); 352 input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE);
339 a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y);
340 a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE);
341 353
342 a3d_read(a3d, data); 354 a3d_read(a3d, data);
343 355
@@ -358,24 +370,17 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv)
358 } 370 }
359 } 371 }
360 372
361 a3d->dev.private = a3d; 373 err = input_register_device(a3d->dev);
362 a3d->dev.open = a3d_open; 374 if (err)
363 a3d->dev.close = a3d_close; 375 goto fail3;
364
365 a3d->dev.name = a3d_names[a3d->mode];
366 a3d->dev.phys = a3d->phys;
367 a3d->dev.id.bustype = BUS_GAMEPORT;
368 a3d->dev.id.vendor = GAMEPORT_ID_VENDOR_MADCATZ;
369 a3d->dev.id.product = a3d->mode;
370 a3d->dev.id.version = 0x0100;
371
372 input_register_device(&a3d->dev);
373 printk(KERN_INFO "input: %s on %s\n", a3d_names[a3d->mode], a3d->phys);
374 376
375 return 0; 377 return 0;
376 378
377fail2: gameport_close(gameport); 379 fail3: if (a3d->adc)
378fail1: gameport_set_drvdata(gameport, NULL); 380 gameport_unregister_port(a3d->adc);
381 fail2: gameport_close(gameport);
382 fail1: gameport_set_drvdata(gameport, NULL);
383 input_free_device(input_dev);
379 kfree(a3d); 384 kfree(a3d);
380 return err; 385 return err;
381} 386}
@@ -384,11 +389,9 @@ static void a3d_disconnect(struct gameport *gameport)
384{ 389{
385 struct a3d *a3d = gameport_get_drvdata(gameport); 390 struct a3d *a3d = gameport_get_drvdata(gameport);
386 391
387 input_unregister_device(&a3d->dev); 392 input_unregister_device(a3d->dev);
388 if (a3d->adc) { 393 if (a3d->adc)
389 gameport_unregister_port(a3d->adc); 394 gameport_unregister_port(a3d->adc);
390 a3d->adc = NULL;
391 }
392 gameport_close(gameport); 395 gameport_close(gameport);
393 gameport_set_drvdata(gameport, NULL); 396 gameport_set_drvdata(gameport, NULL);
394 kfree(a3d); 397 kfree(a3d);
@@ -397,6 +400,7 @@ static void a3d_disconnect(struct gameport *gameport)
397static struct gameport_driver a3d_drv = { 400static struct gameport_driver a3d_drv = {
398 .driver = { 401 .driver = {
399 .name = "adc", 402 .name = "adc",
403 .owner = THIS_MODULE,
400 }, 404 },
401 .description = DRIVER_DESC, 405 .description = DRIVER_DESC,
402 .connect = a3d_connect, 406 .connect = a3d_connect,
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index 499344c72756..dcffc34f30c3 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -275,68 +275,70 @@ static unsigned char db9_saturn_read_packet(struct parport *port, unsigned char
275/* 275/*
276 * db9_saturn_report() analyzes packet and reports. 276 * db9_saturn_report() analyzes packet and reports.
277 */ 277 */
278static int db9_saturn_report(unsigned char id, unsigned char data[60], struct input_dev *dev, int n, int max_pads) 278static int db9_saturn_report(unsigned char id, unsigned char data[60], struct input_dev *devs[], int n, int max_pads)
279{ 279{
280 struct input_dev *dev;
280 int tmp, i, j; 281 int tmp, i, j;
281 282
282 tmp = (id == 0x41) ? 60 : 10; 283 tmp = (id == 0x41) ? 60 : 10;
283 for (j = 0; (j < tmp) && (n < max_pads); j += 10, n++) { 284 for (j = 0; j < tmp && n < max_pads; j += 10, n++) {
285 dev = devs[n];
284 switch (data[j]) { 286 switch (data[j]) {
285 case 0x16: /* multi controller (analog 4 axis) */ 287 case 0x16: /* multi controller (analog 4 axis) */
286 input_report_abs(dev + n, db9_abs[5], data[j + 6]); 288 input_report_abs(dev, db9_abs[5], data[j + 6]);
287 case 0x15: /* mission stick (analog 3 axis) */ 289 case 0x15: /* mission stick (analog 3 axis) */
288 input_report_abs(dev + n, db9_abs[3], data[j + 4]); 290 input_report_abs(dev, db9_abs[3], data[j + 4]);
289 input_report_abs(dev + n, db9_abs[4], data[j + 5]); 291 input_report_abs(dev, db9_abs[4], data[j + 5]);
290 case 0x13: /* racing controller (analog 1 axis) */ 292 case 0x13: /* racing controller (analog 1 axis) */
291 input_report_abs(dev + n, db9_abs[2], data[j + 3]); 293 input_report_abs(dev, db9_abs[2], data[j + 3]);
292 case 0x34: /* saturn keyboard (udlr ZXC ASD QE Esc) */ 294 case 0x34: /* saturn keyboard (udlr ZXC ASD QE Esc) */
293 case 0x02: /* digital pad (digital 2 axis + buttons) */ 295 case 0x02: /* digital pad (digital 2 axis + buttons) */
294 input_report_abs(dev + n, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); 296 input_report_abs(dev, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64));
295 input_report_abs(dev + n, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16)); 297 input_report_abs(dev, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16));
296 for (i = 0; i < 9; i++) 298 for (i = 0; i < 9; i++)
297 input_report_key(dev + n, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]); 299 input_report_key(dev, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]);
298 break; 300 break;
299 case 0x19: /* mission stick x2 (analog 6 axis + buttons) */ 301 case 0x19: /* mission stick x2 (analog 6 axis + buttons) */
300 input_report_abs(dev + n, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64)); 302 input_report_abs(dev, db9_abs[0], !(data[j + 1] & 128) - !(data[j + 1] & 64));
301 input_report_abs(dev + n, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16)); 303 input_report_abs(dev, db9_abs[1], !(data[j + 1] & 32) - !(data[j + 1] & 16));
302 for (i = 0; i < 9; i++) 304 for (i = 0; i < 9; i++)
303 input_report_key(dev + n, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]); 305 input_report_key(dev, db9_cd32_btn[i], ~data[j + db9_saturn_byte[i]] & db9_saturn_mask[i]);
304 input_report_abs(dev + n, db9_abs[2], data[j + 3]); 306 input_report_abs(dev, db9_abs[2], data[j + 3]);
305 input_report_abs(dev + n, db9_abs[3], data[j + 4]); 307 input_report_abs(dev, db9_abs[3], data[j + 4]);
306 input_report_abs(dev + n, db9_abs[4], data[j + 5]); 308 input_report_abs(dev, db9_abs[4], data[j + 5]);
307 /* 309 /*
308 input_report_abs(dev + n, db9_abs[8], (data[j + 6] & 128 ? 0 : 1) - (data[j + 6] & 64 ? 0 : 1)); 310 input_report_abs(dev, db9_abs[8], (data[j + 6] & 128 ? 0 : 1) - (data[j + 6] & 64 ? 0 : 1));
309 input_report_abs(dev + n, db9_abs[9], (data[j + 6] & 32 ? 0 : 1) - (data[j + 6] & 16 ? 0 : 1)); 311 input_report_abs(dev, db9_abs[9], (data[j + 6] & 32 ? 0 : 1) - (data[j + 6] & 16 ? 0 : 1));
310 */ 312 */
311 input_report_abs(dev + n, db9_abs[6], data[j + 7]); 313 input_report_abs(dev, db9_abs[6], data[j + 7]);
312 input_report_abs(dev + n, db9_abs[7], data[j + 8]); 314 input_report_abs(dev, db9_abs[7], data[j + 8]);
313 input_report_abs(dev + n, db9_abs[5], data[j + 9]); 315 input_report_abs(dev, db9_abs[5], data[j + 9]);
314 break; 316 break;
315 case 0xd3: /* sankyo ff (analog 1 axis + stop btn) */ 317 case 0xd3: /* sankyo ff (analog 1 axis + stop btn) */
316 input_report_key(dev + n, BTN_A, data[j + 3] & 0x80); 318 input_report_key(dev, BTN_A, data[j + 3] & 0x80);
317 input_report_abs(dev + n, db9_abs[2], data[j + 3] & 0x7f); 319 input_report_abs(dev, db9_abs[2], data[j + 3] & 0x7f);
318 break; 320 break;
319 case 0xe3: /* shuttle mouse (analog 2 axis + buttons. signed value) */ 321 case 0xe3: /* shuttle mouse (analog 2 axis + buttons. signed value) */
320 input_report_key(dev + n, BTN_START, data[j + 1] & 0x08); 322 input_report_key(dev, BTN_START, data[j + 1] & 0x08);
321 input_report_key(dev + n, BTN_A, data[j + 1] & 0x04); 323 input_report_key(dev, BTN_A, data[j + 1] & 0x04);
322 input_report_key(dev + n, BTN_C, data[j + 1] & 0x02); 324 input_report_key(dev, BTN_C, data[j + 1] & 0x02);
323 input_report_key(dev + n, BTN_B, data[j + 1] & 0x01); 325 input_report_key(dev, BTN_B, data[j + 1] & 0x01);
324 input_report_abs(dev + n, db9_abs[2], data[j + 2] ^ 0x80); 326 input_report_abs(dev, db9_abs[2], data[j + 2] ^ 0x80);
325 input_report_abs(dev + n, db9_abs[3], (0xff-(data[j + 3] ^ 0x80))+1); /* */ 327 input_report_abs(dev, db9_abs[3], (0xff-(data[j + 3] ^ 0x80))+1); /* */
326 break; 328 break;
327 case 0xff: 329 case 0xff:
328 default: /* no pad */ 330 default: /* no pad */
329 input_report_abs(dev + n, db9_abs[0], 0); 331 input_report_abs(dev, db9_abs[0], 0);
330 input_report_abs(dev + n, db9_abs[1], 0); 332 input_report_abs(dev, db9_abs[1], 0);
331 for (i = 0; i < 9; i++) 333 for (i = 0; i < 9; i++)
332 input_report_key(dev + n, db9_cd32_btn[i], 0); 334 input_report_key(dev, db9_cd32_btn[i], 0);
333 break; 335 break;
334 } 336 }
335 } 337 }
336 return n; 338 return n;
337} 339}
338 340
339static int db9_saturn(int mode, struct parport *port, struct input_dev *dev) 341static int db9_saturn(int mode, struct parport *port, struct input_dev *devs[])
340{ 342{
341 unsigned char id, data[60]; 343 unsigned char id, data[60];
342 int type, n, max_pads; 344 int type, n, max_pads;
@@ -361,7 +363,7 @@ static int db9_saturn(int mode, struct parport *port, struct input_dev *dev)
361 max_pads = min(db9_modes[mode].n_pads, DB9_MAX_DEVICES); 363 max_pads = min(db9_modes[mode].n_pads, DB9_MAX_DEVICES);
362 for (tmp = 0, i = 0; i < n; i++) { 364 for (tmp = 0, i = 0; i < n; i++) {
363 id = db9_saturn_read_packet(port, data, type + i, 1); 365 id = db9_saturn_read_packet(port, data, type + i, 1);
364 tmp = db9_saturn_report(id, data, dev, tmp, max_pads); 366 tmp = db9_saturn_report(id, data, devs, tmp, max_pads);
365 } 367 }
366 return 0; 368 return 0;
367} 369}
@@ -489,7 +491,7 @@ static void db9_timer(unsigned long private)
489 case DB9_SATURN_DPP: 491 case DB9_SATURN_DPP:
490 case DB9_SATURN_DPP_2: 492 case DB9_SATURN_DPP_2:
491 493
492 db9_saturn(db9->mode, port, dev); 494 db9_saturn(db9->mode, port, db9->dev);
493 break; 495 break;
494 496
495 case DB9_CD32_PAD: 497 case DB9_CD32_PAD:
@@ -614,7 +616,7 @@ static struct db9 __init *db9_probe(int parport, int mode)
614 if (!input_dev) { 616 if (!input_dev) {
615 printk(KERN_ERR "db9.c: Not enough memory for input device\n"); 617 printk(KERN_ERR "db9.c: Not enough memory for input device\n");
616 err = -ENOMEM; 618 err = -ENOMEM;
617 goto err_free_devs; 619 goto err_unreg_devs;
618 } 620 }
619 621
620 sprintf(db9->phys[i], "%s/input%d", db9->pd->port->name, i); 622 sprintf(db9->phys[i], "%s/input%d", db9->pd->port->name, i);
@@ -640,13 +642,17 @@ static struct db9 __init *db9_probe(int parport, int mode)
640 input_set_abs_params(input_dev, db9_abs[j], 1, 255, 0, 0); 642 input_set_abs_params(input_dev, db9_abs[j], 1, 255, 0, 0);
641 } 643 }
642 644
643 input_register_device(input_dev); 645 err = input_register_device(input_dev);
646 if (err)
647 goto err_free_dev;
644 } 648 }
645 649
646 parport_put_port(pp); 650 parport_put_port(pp);
647 return db9; 651 return db9;
648 652
649 err_free_devs: 653 err_free_dev:
654 input_free_device(db9->dev[i]);
655 err_unreg_devs:
650 while (--i >= 0) 656 while (--i >= 0)
651 input_unregister_device(db9->dev[i]); 657 input_unregister_device(db9->dev[i]);
652 kfree(db9); 658 kfree(db9);
@@ -658,7 +664,7 @@ static struct db9 __init *db9_probe(int parport, int mode)
658 return ERR_PTR(err); 664 return ERR_PTR(err);
659} 665}
660 666
661static void __exit db9_remove(struct db9 *db9) 667static void db9_remove(struct db9 *db9)
662{ 668{
663 int i; 669 int i;
664 670
@@ -696,7 +702,8 @@ static int __init db9_init(void)
696 702
697 if (err) { 703 if (err) {
698 while (--i >= 0) 704 while (--i >= 0)
699 db9_remove(db9_base[i]); 705 if (db9_base[i])
706 db9_remove(db9_base[i]);
700 return err; 707 return err;
701 } 708 }
702 709
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index 7df2d82f2c83..900587acdb47 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -159,6 +159,48 @@ static void gc_n64_read_packet(struct gc *gc, unsigned char *data)
159 159
160} 160}
161 161
162static void gc_n64_process_packet(struct gc *gc)
163{
164 unsigned char data[GC_N64_LENGTH];
165 signed char axes[2];
166 struct input_dev *dev;
167 int i, j, s;
168
169 gc_n64_read_packet(gc, data);
170
171 for (i = 0; i < GC_MAX_DEVICES; i++) {
172
173 dev = gc->dev[i];
174 if (!dev)
175 continue;
176
177 s = gc_status_bit[i];
178
179 if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) {
180
181 axes[0] = axes[1] = 0;
182
183 for (j = 0; j < 8; j++) {
184 if (data[23 - j] & s)
185 axes[0] |= 1 << j;
186 if (data[31 - j] & s)
187 axes[1] |= 1 << j;
188 }
189
190 input_report_abs(dev, ABS_X, axes[0]);
191 input_report_abs(dev, ABS_Y, -axes[1]);
192
193 input_report_abs(dev, ABS_HAT0X, !(s & data[6]) - !(s & data[7]));
194 input_report_abs(dev, ABS_HAT0Y, !(s & data[4]) - !(s & data[5]));
195
196 for (j = 0; j < 10; j++)
197 input_report_key(dev, gc_n64_btn[j], s & data[gc_n64_bytes[j]]);
198
199 input_sync(dev);
200 }
201 }
202}
203
162/* 204/*
163 * NES/SNES support. 205 * NES/SNES support.
164 */ 206 */
@@ -198,6 +240,39 @@ static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data)
198 } 240 }
199} 241}
200 242
243static void gc_nes_process_packet(struct gc *gc)
244{
245 unsigned char data[GC_SNES_LENGTH];
246 struct input_dev *dev;
247 int i, j, s;
248
249 gc_nes_read_packet(gc, gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH, data);
250
251 for (i = 0; i < GC_MAX_DEVICES; i++) {
252
253 dev = gc->dev[i];
254 if (!dev)
255 continue;
256
257 s = gc_status_bit[i];
258
259 if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) {
260 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7]));
261 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5]));
262 }
263
264 if (s & gc->pads[GC_NES])
265 for (j = 0; j < 4; j++)
266 input_report_key(dev, gc_snes_btn[j], s & data[gc_nes_bytes[j]]);
267
268 if (s & gc->pads[GC_SNES])
269 for (j = 0; j < 8; j++)
270 input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]);
271
272 input_sync(dev);
273 }
274}
275
201/* 276/*
202 * Multisystem joystick support 277 * Multisystem joystick support
203 */ 278 */
@@ -219,6 +294,35 @@ static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data)
219 } 294 }
220} 295}
221 296
297static void gc_multi_process_packet(struct gc *gc)
298{
299 unsigned char data[GC_MULTI2_LENGTH];
300 struct input_dev *dev;
301 int i, s;
302
303 gc_multi_read_packet(gc, gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH, data);
304
305 for (i = 0; i < GC_MAX_DEVICES; i++) {
306
307 dev = gc->dev[i];
308 if (!dev)
309 continue;
310
311 s = gc_status_bit[i];
312
313 if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) {
314 input_report_abs(dev, ABS_X, !(s & data[2]) - !(s & data[3]));
315 input_report_abs(dev, ABS_Y, !(s & data[0]) - !(s & data[1]));
316 input_report_key(dev, BTN_TRIGGER, s & data[4]);
317 }
318
319 if (s & gc->pads[GC_MULTI2])
320 input_report_key(dev, BTN_THUMB, s & data[5]);
321
322 input_sync(dev);
323 }
324}
325
222/* 326/*
223 * PSX support 327 * PSX support
224 * 328 *
@@ -263,10 +367,11 @@ static short gc_psx_ddr_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3 };
263 * the psx pad. 367 * the psx pad.
264 */ 368 */
265 369
266static void gc_psx_command(struct gc *gc, int b, unsigned char data[5]) 370static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_MAX_DEVICES])
267{ 371{
268 int i, j, cmd, read; 372 int i, j, cmd, read;
269 for (i = 0; i < 5; i++) 373
374 for (i = 0; i < GC_MAX_DEVICES; i++)
270 data[i] = 0; 375 data[i] = 0;
271 376
272 for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) { 377 for (i = 0; i < GC_PSX_LENGTH; i++, b >>= 1) {
@@ -274,7 +379,7 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char data[5])
274 parport_write_data(gc->pd->port, cmd | GC_PSX_POWER); 379 parport_write_data(gc->pd->port, cmd | GC_PSX_POWER);
275 udelay(gc_psx_delay); 380 udelay(gc_psx_delay);
276 read = parport_read_status(gc->pd->port) ^ 0x80; 381 read = parport_read_status(gc->pd->port) ^ 0x80;
277 for (j = 0; j < 5; j++) 382 for (j = 0; j < GC_MAX_DEVICES; j++)
278 data[j] |= (read & gc_status_bit[j] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) ? (1 << i) : 0; 383 data[j] |= (read & gc_status_bit[j] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) ? (1 << i) : 0;
279 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); 384 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER);
280 udelay(gc_psx_delay); 385 udelay(gc_psx_delay);
@@ -286,11 +391,12 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char data[5])
286 * device identifier code. 391 * device identifier code.
287 */ 392 */
288 393
289static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES], unsigned char id[5]) 394static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES],
395 unsigned char id[GC_MAX_DEVICES])
290{ 396{
291 int i, j, max_len = 0; 397 int i, j, max_len = 0;
292 unsigned long flags; 398 unsigned long flags;
293 unsigned char data2[5]; 399 unsigned char data2[GC_MAX_DEVICES];
294 400
295 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); /* Select pad */ 401 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); /* Select pad */
296 udelay(gc_psx_delay); 402 udelay(gc_psx_delay);
@@ -303,7 +409,7 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES
303 gc_psx_command(gc, 0x42, id); /* Get device ids */ 409 gc_psx_command(gc, 0x42, id); /* Get device ids */
304 gc_psx_command(gc, 0, data2); /* Dump status */ 410 gc_psx_command(gc, 0, data2); /* Dump status */
305 411
306 for (i =0; i < 5; i++) /* Find the longest pad */ 412 for (i =0; i < GC_MAX_DEVICES; i++) /* Find the longest pad */
307 if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) 413 if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR]))
308 && (GC_PSX_LEN(id[i]) > max_len) 414 && (GC_PSX_LEN(id[i]) > max_len)
309 && (GC_PSX_LEN(id[i]) <= GC_PSX_BYTES)) 415 && (GC_PSX_LEN(id[i]) <= GC_PSX_BYTES))
@@ -311,7 +417,7 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES
311 417
312 for (i = 0; i < max_len; i++) { /* Read in all the data */ 418 for (i = 0; i < max_len; i++) { /* Read in all the data */
313 gc_psx_command(gc, 0, data2); 419 gc_psx_command(gc, 0, data2);
314 for (j = 0; j < 5; j++) 420 for (j = 0; j < GC_MAX_DEVICES; j++)
315 data[j][i] = data2[j]; 421 data[j][i] = data2[j];
316 } 422 }
317 423
@@ -319,185 +425,124 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES
319 425
320 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER); 426 parport_write_data(gc->pd->port, GC_PSX_CLOCK | GC_PSX_SELECT | GC_PSX_POWER);
321 427
322 for(i = 0; i < 5; i++) /* Set id's to the real value */ 428 for(i = 0; i < GC_MAX_DEVICES; i++) /* Set id's to the real value */
323 id[i] = GC_PSX_ID(id[i]); 429 id[i] = GC_PSX_ID(id[i]);
324} 430}
325 431
326/* 432static void gc_psx_process_packet(struct gc *gc)
327 * gc_timer() reads and analyzes console pads data. 433{
328 */ 434 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES];
435 unsigned char id[GC_MAX_DEVICES];
436 struct input_dev *dev;
437 int i, j;
329 438
330#define GC_MAX_LENGTH GC_N64_LENGTH 439 gc_psx_read_packet(gc, data, id);
331 440
332static void gc_timer(unsigned long private) 441 for (i = 0; i < GC_MAX_DEVICES; i++) {
333{
334 struct gc *gc = (void *) private;
335 unsigned char data[GC_MAX_LENGTH];
336 unsigned char data_psx[5][GC_PSX_BYTES];
337 int i, j, s;
338 442
339/* 443 dev = gc->dev[i];
340 * N64 pads - must be read first, any read confuses them for 200 us 444 if (!dev)
341 */ 445 continue;
342 446
343 if (gc->pads[GC_N64]) { 447 switch (id[i]) {
344 448
345 gc_n64_read_packet(gc, data); 449 case GC_PSX_RUMBLE:
346 450
347 for (i = 0; i < 5; i++) { 451 input_report_key(dev, BTN_THUMBL, ~data[i][0] & 0x04);
452 input_report_key(dev, BTN_THUMBR, ~data[i][0] & 0x02);
348 453
349 s = gc_status_bit[i]; 454 case GC_PSX_NEGCON:
455 case GC_PSX_ANALOG:
350 456
351 if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) { 457 if (gc->pads[GC_DDR] & gc_status_bit[i]) {
458 for(j = 0; j < 4; j++)
459 input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j));
460 } else {
461 for (j = 0; j < 4; j++)
462 input_report_abs(dev, gc_psx_abs[j + 2], data[i][j + 2]);
352 463
353 signed char axes[2]; 464 input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128);
354 axes[0] = axes[1] = 0; 465 input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128);
466 }
355 467
356 for (j = 0; j < 8; j++) { 468 for (j = 0; j < 8; j++)
357 if (data[23 - j] & s) axes[0] |= 1 << j; 469 input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j));
358 if (data[31 - j] & s) axes[1] |= 1 << j; 470
471 input_report_key(dev, BTN_START, ~data[i][0] & 0x08);
472 input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01);
473
474 input_sync(dev);
475
476 break;
477
478 case GC_PSX_NORMAL:
479 if (gc->pads[GC_DDR] & gc_status_bit[i]) {
480 for(j = 0; j < 4; j++)
481 input_report_key(dev, gc_psx_ddr_btn[j], ~data[i][0] & (0x10 << j));
482 } else {
483 input_report_abs(dev, ABS_X, 128 + !(data[i][0] & 0x20) * 127 - !(data[i][0] & 0x80) * 128);
484 input_report_abs(dev, ABS_Y, 128 + !(data[i][0] & 0x40) * 127 - !(data[i][0] & 0x10) * 128);
485
486 /* for some reason if the extra axes are left unset they drift */
487 /* for (j = 0; j < 4; j++)
488 input_report_abs(dev, gc_psx_abs[j + 2], 128);
489 * This needs to be debugged properly,
490 * maybe fuzz processing needs to be done in input_sync()
491 * --vojtech
492 */
359 } 493 }
360 494
361 input_report_abs(gc->dev[i], ABS_X, axes[0]); 495 for (j = 0; j < 8; j++)
362 input_report_abs(gc->dev[i], ABS_Y, -axes[1]); 496 input_report_key(dev, gc_psx_btn[j], ~data[i][1] & (1 << j));
497
498 input_report_key(dev, BTN_START, ~data[i][0] & 0x08);
499 input_report_key(dev, BTN_SELECT, ~data[i][0] & 0x01);
363 500
364 input_report_abs(gc->dev[i], ABS_HAT0X, !(s & data[6]) - !(s & data[7])); 501 input_sync(dev);
365 input_report_abs(gc->dev[i], ABS_HAT0Y, !(s & data[4]) - !(s & data[5]));
366 502
367 for (j = 0; j < 10; j++) 503 break;
368 input_report_key(gc->dev[i], gc_n64_btn[j], s & data[gc_n64_bytes[j]]);
369 504
370 input_sync(gc->dev[i]); 505 case 0: /* not a pad, ignore */
371 } 506 break;
372 } 507 }
373 } 508 }
509}
374 510
375/* 511/*
376 * NES and SNES pads 512 * gc_timer() initiates reads of console pads data.
377 */ 513 */
378 514
379 if (gc->pads[GC_NES] || gc->pads[GC_SNES]) { 515static void gc_timer(unsigned long private)
380 516{
381 gc_nes_read_packet(gc, gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH, data); 517 struct gc *gc = (void *) private;
382
383 for (i = 0; i < 5; i++) {
384
385 s = gc_status_bit[i];
386 518
387 if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { 519/*
388 input_report_abs(gc->dev[i], ABS_X, !(s & data[6]) - !(s & data[7])); 520 * N64 pads - must be read first, any read confuses them for 200 us
389 input_report_abs(gc->dev[i], ABS_Y, !(s & data[4]) - !(s & data[5])); 521 */
390 }
391 522
392 if (s & gc->pads[GC_NES]) 523 if (gc->pads[GC_N64])
393 for (j = 0; j < 4; j++) 524 gc_n64_process_packet(gc);
394 input_report_key(gc->dev[i], gc_snes_btn[j], s & data[gc_nes_bytes[j]]);
395 525
396 if (s & gc->pads[GC_SNES]) 526/*
397 for (j = 0; j < 8; j++) 527 * NES and SNES pads
398 input_report_key(gc->dev[i], gc_snes_btn[j], s & data[gc_snes_bytes[j]]); 528 */
399 529
400 input_sync(gc->dev[i]); 530 if (gc->pads[GC_NES] || gc->pads[GC_SNES])
401 } 531 gc_nes_process_packet(gc);
402 }
403 532
404/* 533/*
405 * Multi and Multi2 joysticks 534 * Multi and Multi2 joysticks
406 */ 535 */
407 536
408 if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2]) { 537 if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2])
409 538 gc_multi_process_packet(gc);
410 gc_multi_read_packet(gc, gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH, data);
411
412 for (i = 0; i < 5; i++) {
413
414 s = gc_status_bit[i];
415
416 if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) {
417 input_report_abs(gc->dev[i], ABS_X, !(s & data[2]) - !(s & data[3]));
418 input_report_abs(gc->dev[i], ABS_Y, !(s & data[0]) - !(s & data[1]));
419 input_report_key(gc->dev[i], BTN_TRIGGER, s & data[4]);
420 }
421
422 if (s & gc->pads[GC_MULTI2])
423 input_report_key(gc->dev[i], BTN_THUMB, s & data[5]);
424
425 input_sync(gc->dev[i]);
426 }
427 }
428 539
429/* 540/*
430 * PSX controllers 541 * PSX controllers
431 */ 542 */
432 543
433 if (gc->pads[GC_PSX] || gc->pads[GC_DDR]) { 544 if (gc->pads[GC_PSX] || gc->pads[GC_DDR])
434 545 gc_psx_process_packet(gc);
435 gc_psx_read_packet(gc, data_psx, data);
436
437 for (i = 0; i < 5; i++) {
438 switch (data[i]) {
439
440 case GC_PSX_RUMBLE:
441
442 input_report_key(gc->dev[i], BTN_THUMBL, ~data_psx[i][0] & 0x04);
443 input_report_key(gc->dev[i], BTN_THUMBR, ~data_psx[i][0] & 0x02);
444
445 case GC_PSX_NEGCON:
446 case GC_PSX_ANALOG:
447
448 if (gc->pads[GC_DDR] & gc_status_bit[i]) {
449 for(j = 0; j < 4; j++)
450 input_report_key(gc->dev[i], gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j));
451 } else {
452 for (j = 0; j < 4; j++)
453 input_report_abs(gc->dev[i], gc_psx_abs[j+2], data_psx[i][j + 2]);
454
455 input_report_abs(gc->dev[i], ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128);
456 input_report_abs(gc->dev[i], ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128);
457 }
458
459 for (j = 0; j < 8; j++)
460 input_report_key(gc->dev[i], gc_psx_btn[j], ~data_psx[i][1] & (1 << j));
461
462 input_report_key(gc->dev[i], BTN_START, ~data_psx[i][0] & 0x08);
463 input_report_key(gc->dev[i], BTN_SELECT, ~data_psx[i][0] & 0x01);
464
465 input_sync(gc->dev[i]);
466
467 break;
468
469 case GC_PSX_NORMAL:
470 if (gc->pads[GC_DDR] & gc_status_bit[i]) {
471 for(j = 0; j < 4; j++)
472 input_report_key(gc->dev[i], gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j));
473 } else {
474 input_report_abs(gc->dev[i], ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128);
475 input_report_abs(gc->dev[i], ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128);
476
477 /* for some reason if the extra axes are left unset they drift */
478 /* for (j = 0; j < 4; j++)
479 input_report_abs(gc->dev[i], gc_psx_abs[j+2], 128);
480 * This needs to be debugged properly,
481 * maybe fuzz processing needs to be done in input_sync()
482 * --vojtech
483 */
484 }
485
486 for (j = 0; j < 8; j++)
487 input_report_key(gc->dev[i], gc_psx_btn[j], ~data_psx[i][1] & (1 << j));
488
489 input_report_key(gc->dev[i], BTN_START, ~data_psx[i][0] & 0x08);
490 input_report_key(gc->dev[i], BTN_SELECT, ~data_psx[i][0] & 0x01);
491
492 input_sync(gc->dev[i]);
493
494 break;
495
496 case 0: /* not a pad, ignore */
497 break;
498 }
499 }
500 }
501 546
502 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); 547 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
503} 548}
@@ -654,16 +699,18 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
654 gc->timer.data = (long) gc; 699 gc->timer.data = (long) gc;
655 gc->timer.function = gc_timer; 700 gc->timer.function = gc_timer;
656 701
657 for (i = 0; i < n_pads; i++) { 702 for (i = 0; i < n_pads && i < GC_MAX_DEVICES; i++) {
658 if (!pads[i]) 703 if (!pads[i])
659 continue; 704 continue;
660 705
661 sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i); 706 sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i);
662 err = gc_setup_pad(gc, i, pads[i]); 707 err = gc_setup_pad(gc, i, pads[i]);
663 if (err) 708 if (err)
664 goto err_free_devs; 709 goto err_unreg_devs;
665 710
666 input_register_device(gc->dev[i]); 711 err = input_register_device(gc->dev[i]);
712 if (err)
713 goto err_free_dev;
667 } 714 }
668 715
669 if (!gc->pads[0]) { 716 if (!gc->pads[0]) {
@@ -675,9 +722,12 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
675 parport_put_port(pp); 722 parport_put_port(pp);
676 return gc; 723 return gc;
677 724
678 err_free_devs: 725 err_free_dev:
726 input_free_device(gc->dev[i]);
727 err_unreg_devs:
679 while (--i >= 0) 728 while (--i >= 0)
680 input_unregister_device(gc->dev[i]); 729 if (gc->dev[i])
730 input_unregister_device(gc->dev[i]);
681 err_free_gc: 731 err_free_gc:
682 kfree(gc); 732 kfree(gc);
683 err_unreg_pardev: 733 err_unreg_pardev:
@@ -688,7 +738,7 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
688 return ERR_PTR(err); 738 return ERR_PTR(err);
689} 739}
690 740
691static void __exit gc_remove(struct gc *gc) 741static void gc_remove(struct gc *gc)
692{ 742{
693 int i; 743 int i;
694 744
@@ -726,7 +776,8 @@ static int __init gc_init(void)
726 776
727 if (err) { 777 if (err) {
728 while (--i >= 0) 778 while (--i >= 0)
729 gc_remove(gc_base[i]); 779 if (gc_base[i])
780 gc_remove(gc_base[i]);
730 return err; 781 return err;
731 } 782 }
732 783
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
index a936e7aedb10..20cb98ac2d79 100644
--- a/drivers/input/joystick/grip.c
+++ b/drivers/input/joystick/grip.c
@@ -192,6 +192,9 @@ static void grip_poll(struct gameport *gameport)
192 for (i = 0; i < 2; i++) { 192 for (i = 0; i < 2; i++) {
193 193
194 dev = grip->dev[i]; 194 dev = grip->dev[i];
195 if (!dev)
196 continue;
197
195 grip->reads++; 198 grip->reads++;
196 199
197 switch (grip->mode[i]) { 200 switch (grip->mode[i]) {
@@ -381,12 +384,15 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
381 if (t > 0) 384 if (t > 0)
382 set_bit(t, input_dev->keybit); 385 set_bit(t, input_dev->keybit);
383 386
384 input_register_device(grip->dev[i]); 387 err = input_register_device(grip->dev[i]);
388 if (err)
389 goto fail4;
385 } 390 }
386 391
387 return 0; 392 return 0;
388 393
389 fail3: for (i = 0; i < 2; i++) 394 fail4: input_free_device(grip->dev[i]);
395 fail3: while (--i >= 0)
390 if (grip->dev[i]) 396 if (grip->dev[i])
391 input_unregister_device(grip->dev[i]); 397 input_unregister_device(grip->dev[i]);
392 fail2: gameport_close(gameport); 398 fail2: gameport_close(gameport);
@@ -411,6 +417,7 @@ static void grip_disconnect(struct gameport *gameport)
411static struct gameport_driver grip_drv = { 417static struct gameport_driver grip_drv = {
412 .driver = { 418 .driver = {
413 .name = "grip", 419 .name = "grip",
420 .owner = THIS_MODULE,
414 }, 421 },
415 .description = DRIVER_DESC, 422 .description = DRIVER_DESC,
416 .connect = grip_connect, 423 .connect = grip_connect,
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index 64b9c31c47fc..b6bc04998047 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -345,7 +345,7 @@ int iforce_init_device(struct iforce *iforce)
345 int i; 345 int i;
346 346
347 input_dev = input_allocate_device(); 347 input_dev = input_allocate_device();
348 if (input_dev) 348 if (!input_dev)
349 return -ENOMEM; 349 return -ENOMEM;
350 350
351 init_waitqueue_head(&iforce->wait); 351 init_waitqueue_head(&iforce->wait);
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c
index 4a2629243e19..76cb1f88f4e8 100644
--- a/drivers/input/joystick/iforce/iforce-packets.c
+++ b/drivers/input/joystick/iforce/iforce-packets.c
@@ -167,9 +167,9 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data,
167 iforce->expect_packet = 0; 167 iforce->expect_packet = 0;
168 iforce->ecmd = cmd; 168 iforce->ecmd = cmd;
169 memcpy(iforce->edata, data, IFORCE_MAX_LENGTH); 169 memcpy(iforce->edata, data, IFORCE_MAX_LENGTH);
170 wake_up(&iforce->wait);
171 } 170 }
172#endif 171#endif
172 wake_up(&iforce->wait);
173 173
174 if (!iforce->type) { 174 if (!iforce->type) {
175 being_used--; 175 being_used--;
@@ -264,7 +264,7 @@ int iforce_get_id_packet(struct iforce *iforce, char *packet)
264 wait_event_interruptible_timeout(iforce->wait, 264 wait_event_interruptible_timeout(iforce->wait,
265 iforce->ctrl->status != -EINPROGRESS, HZ); 265 iforce->ctrl->status != -EINPROGRESS, HZ);
266 266
267 if (iforce->ctrl->status != -EINPROGRESS) { 267 if (iforce->ctrl->status) {
268 usb_unlink_urb(iforce->ctrl); 268 usb_unlink_urb(iforce->ctrl);
269 return -1; 269 return -1;
270 } 270 }
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index bc2fce60f9f8..fe79d158456d 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -95,7 +95,6 @@ static void iforce_usb_irq(struct urb *urb, struct pt_regs *regs)
95 goto exit; 95 goto exit;
96 } 96 }
97 97
98 wake_up(&iforce->wait);
99 iforce_process_packet(iforce, 98 iforce_process_packet(iforce,
100 (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs); 99 (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1, regs);
101 100
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 78dd163cd702..2b2ec1057dee 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -736,7 +736,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
736 sprintf(sw->name, "Microsoft SideWinder %s", sw_name[sw->type]); 736 sprintf(sw->name, "Microsoft SideWinder %s", sw_name[sw->type]);
737 sprintf(sw->phys[i], "%s/input%d", gameport->phys, i); 737 sprintf(sw->phys[i], "%s/input%d", gameport->phys, i);
738 738
739 input_dev = input_allocate_device(); 739 sw->dev[i] = input_dev = input_allocate_device();
740 if (!input_dev) { 740 if (!input_dev) {
741 err = -ENOMEM; 741 err = -ENOMEM;
742 goto fail3; 742 goto fail3;
@@ -771,12 +771,15 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
771 771
772 dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k); 772 dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k);
773 773
774 input_register_device(sw->dev[i]); 774 err = input_register_device(sw->dev[i]);
775 if (err)
776 goto fail4;
775 } 777 }
776 778
777 return 0; 779 return 0;
778 780
779 fail3: while (--i >= 0) 781 fail4: input_free_device(sw->dev[i]);
782 fail3: while (--i >= 0)
780 input_unregister_device(sw->dev[i]); 783 input_unregister_device(sw->dev[i]);
781 fail2: gameport_close(gameport); 784 fail2: gameport_close(gameport);
782 fail1: gameport_set_drvdata(gameport, NULL); 785 fail1: gameport_set_drvdata(gameport, NULL);
@@ -801,6 +804,7 @@ static void sw_disconnect(struct gameport *gameport)
801static struct gameport_driver sw_drv = { 804static struct gameport_driver sw_drv = {
802 .driver = { 805 .driver = {
803 .name = "sidewinder", 806 .name = "sidewinder",
807 .owner = THIS_MODULE,
804 }, 808 },
805 .description = DRIVER_DESC, 809 .description = DRIVER_DESC,
806 .connect = sw_connect, 810 .connect = sw_connect,
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
index 60e2aac7d06e..bb23ed2a04a6 100644
--- a/drivers/input/joystick/tmdc.c
+++ b/drivers/input/joystick/tmdc.c
@@ -284,13 +284,13 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data)
284 struct tmdc_port *port; 284 struct tmdc_port *port;
285 struct input_dev *input_dev; 285 struct input_dev *input_dev;
286 int i, j, b = 0; 286 int i, j, b = 0;
287 int err;
287 288
288 tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL); 289 tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL);
289 input_dev = input_allocate_device(); 290 input_dev = input_allocate_device();
290 if (!port || !input_dev) { 291 if (!port || !input_dev) {
291 kfree(port); 292 err = -ENOMEM;
292 input_free_device(input_dev); 293 goto fail;
293 return -ENOMEM;
294 } 294 }
295 295
296 port->mode = data[TMDC_BYTE_ID]; 296 port->mode = data[TMDC_BYTE_ID];
@@ -347,9 +347,15 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data)
347 b += port->btnc[i]; 347 b += port->btnc[i];
348 } 348 }
349 349
350 input_register_device(port->dev); 350 err = input_register_device(port->dev);
351 if (err)
352 goto fail;
351 353
352 return 0; 354 return 0;
355
356 fail: input_free_device(input_dev);
357 kfree(port);
358 return err;
353} 359}
354 360
355/* 361/*
@@ -424,6 +430,7 @@ static void tmdc_disconnect(struct gameport *gameport)
424static struct gameport_driver tmdc_drv = { 430static struct gameport_driver tmdc_drv = {
425 .driver = { 431 .driver = {
426 .name = "tmdc", 432 .name = "tmdc",
433 .owner = THIS_MODULE,
427 }, 434 },
428 .description = DRIVER_DESC, 435 .description = DRIVER_DESC,
429 .connect = tmdc_connect, 436 .connect = tmdc_connect,
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index 7e9764937d06..b154938e88a4 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -204,14 +204,14 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
204 if (n_buttons[i] > 6) { 204 if (n_buttons[i] > 6) {
205 printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]); 205 printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]);
206 err = -EINVAL; 206 err = -EINVAL;
207 goto err_free_devs; 207 goto err_unreg_devs;
208 } 208 }
209 209
210 tgfx->dev[i] = input_dev = input_allocate_device(); 210 tgfx->dev[i] = input_dev = input_allocate_device();
211 if (!input_dev) { 211 if (!input_dev) {
212 printk(KERN_ERR "turbografx.c: Not enough memory for input device\n"); 212 printk(KERN_ERR "turbografx.c: Not enough memory for input device\n");
213 err = -ENOMEM; 213 err = -ENOMEM;
214 goto err_free_devs; 214 goto err_unreg_devs;
215 } 215 }
216 216
217 tgfx->sticks |= (1 << i); 217 tgfx->sticks |= (1 << i);
@@ -238,7 +238,9 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
238 for (j = 0; j < n_buttons[i]; j++) 238 for (j = 0; j < n_buttons[i]; j++)
239 set_bit(tgfx_buttons[j], input_dev->keybit); 239 set_bit(tgfx_buttons[j], input_dev->keybit);
240 240
241 input_register_device(tgfx->dev[i]); 241 err = input_register_device(tgfx->dev[i]);
242 if (err)
243 goto err_free_dev;
242 } 244 }
243 245
244 if (!tgfx->sticks) { 246 if (!tgfx->sticks) {
@@ -249,9 +251,12 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
249 251
250 return tgfx; 252 return tgfx;
251 253
252 err_free_devs: 254 err_free_dev:
255 input_free_device(tgfx->dev[i]);
256 err_unreg_devs:
253 while (--i >= 0) 257 while (--i >= 0)
254 input_unregister_device(tgfx->dev[i]); 258 if (tgfx->dev[i])
259 input_unregister_device(tgfx->dev[i]);
255 err_free_tgfx: 260 err_free_tgfx:
256 kfree(tgfx); 261 kfree(tgfx);
257 err_unreg_pardev: 262 err_unreg_pardev:
@@ -262,7 +267,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
262 return ERR_PTR(err); 267 return ERR_PTR(err);
263} 268}
264 269
265static void __exit tgfx_remove(struct tgfx *tgfx) 270static void tgfx_remove(struct tgfx *tgfx)
266{ 271{
267 int i; 272 int i;
268 273
@@ -300,7 +305,8 @@ static int __init tgfx_init(void)
300 305
301 if (err) { 306 if (err) {
302 while (--i >= 0) 307 while (--i >= 0)
303 tgfx_remove(tgfx_base[i]); 308 if (tgfx_base[i])
309 tgfx_remove(tgfx_base[i]);
304 return err; 310 return err;
305 } 311 }
306 312
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
index cd3a1e742a30..7f8b0093c5bc 100644
--- a/drivers/input/joystick/twidjoy.c
+++ b/drivers/input/joystick/twidjoy.c
@@ -265,13 +265,13 @@ static struct serio_driver twidjoy_drv = {
265 * The functions for inserting/removing us as a module. 265 * The functions for inserting/removing us as a module.
266 */ 266 */
267 267
268int __init twidjoy_init(void) 268static int __init twidjoy_init(void)
269{ 269{
270 serio_register_driver(&twidjoy_drv); 270 serio_register_driver(&twidjoy_drv);
271 return 0; 271 return 0;
272} 272}
273 273
274void __exit twidjoy_exit(void) 274static void __exit twidjoy_exit(void)
275{ 275{
276 serio_unregister_driver(&twidjoy_drv); 276 serio_unregister_driver(&twidjoy_drv);
277} 277}
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index e08dbe08f46d..4bad588d0e5d 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -50,6 +50,18 @@ config INPUT_WISTRON_BTNS
50 To compile this driver as a module, choose M here: the module will 50 To compile this driver as a module, choose M here: the module will
51 be called wistron_btns. 51 be called wistron_btns.
52 52
53config INPUT_IXP4XX_BEEPER
54 tristate "IXP4XX Beeper support"
55 depends on ARCH_IXP4XX
56 help
57 If you say yes here, you can connect a beeper to the
58 ixp4xx gpio pins. This is used by the LinkSys NSLU2.
59
60 If unsure, say Y.
61
62 To compile this driver as a module, choose M here: the
63 module will be called ixp4xx-beeper.
64
53config INPUT_UINPUT 65config INPUT_UINPUT
54 tristate "User level driver support" 66 tristate "User level driver support"
55 help 67 help
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index ce44cce01285..184c4129470d 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_INPUT_98SPKR) += 98spkr.o
11obj-$(CONFIG_INPUT_UINPUT) += uinput.o 11obj-$(CONFIG_INPUT_UINPUT) += uinput.o
12obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o 12obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
13obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 13obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
14obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c
new file mode 100644
index 000000000000..d448bb5e4869
--- /dev/null
+++ b/drivers/input/misc/ixp4xx-beeper.c
@@ -0,0 +1,183 @@
1/*
2 * Generic IXP4xx beeper driver
3 *
4 * Copyright (C) 2005 Tower Technologies
5 *
6 * based on nslu2-io.c
7 * Copyright (C) 2004 Karen Spearel
8 *
9 * Author: Alessandro Zummo <a.zummo@towertech.it>
10 * Maintainers: http://www.nslu2-linux.org/
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 *
16 */
17
18#include <linux/module.h>
19#include <linux/input.h>
20#include <linux/delay.h>
21#include <linux/platform_device.h>
22#include <asm/hardware.h>
23
24MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
25MODULE_DESCRIPTION("ixp4xx beeper driver");
26MODULE_LICENSE("GPL");
27
28static DEFINE_SPINLOCK(beep_lock);
29
30static void ixp4xx_spkr_control(unsigned int pin, unsigned int count)
31{
32 unsigned long flags;
33
34 spin_lock_irqsave(&beep_lock, flags);
35
36 if (count) {
37 gpio_line_config(pin, IXP4XX_GPIO_OUT);
38 gpio_line_set(pin, IXP4XX_GPIO_LOW);
39
40 *IXP4XX_OSRT2 = (count & ~IXP4XX_OST_RELOAD_MASK) | IXP4XX_OST_ENABLE;
41 } else {
42 gpio_line_config(pin, IXP4XX_GPIO_IN);
43 gpio_line_set(pin, IXP4XX_GPIO_HIGH);
44
45 *IXP4XX_OSRT2 = 0;
46 }
47
48 spin_unlock_irqrestore(&beep_lock, flags);
49}
50
51static int ixp4xx_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
52{
53 unsigned int pin = (unsigned int) dev->private;
54 unsigned int count = 0;
55
56 if (type != EV_SND)
57 return -1;
58
59 switch (code) {
60 case SND_BELL:
61 if (value)
62 value = 1000;
63 case SND_TONE:
64 break;
65 default:
66 return -1;
67 }
68
69 if (value > 20 && value < 32767)
70#ifndef FREQ
71 count = (ixp4xx_get_board_tick_rate() / (value * 4)) - 1;
72#else
73 count = (FREQ / (value * 4)) - 1;
74#endif
75
76 ixp4xx_spkr_control(pin, count);
77
78 return 0;
79}
80
81static irqreturn_t ixp4xx_spkr_interrupt(int irq, void *dev_id, struct pt_regs *regs)
82{
83 /* clear interrupt */
84 *IXP4XX_OSST = IXP4XX_OSST_TIMER_2_PEND;
85
86 /* flip the beeper output */
87 *IXP4XX_GPIO_GPOUTR ^= (1 << (unsigned int) dev_id);
88
89 return IRQ_HANDLED;
90}
91
92static int __devinit ixp4xx_spkr_probe(struct platform_device *dev)
93{
94 struct input_dev *input_dev;
95 int err;
96
97 input_dev = input_allocate_device();
98 if (!input_dev)
99 return -ENOMEM;
100
101 input_dev->private = (void *) dev->id;
102 input_dev->name = "ixp4xx beeper",
103 input_dev->phys = "ixp4xx/gpio";
104 input_dev->id.bustype = BUS_HOST;
105 input_dev->id.vendor = 0x001f;
106 input_dev->id.product = 0x0001;
107 input_dev->id.version = 0x0100;
108 input_dev->cdev.dev = &dev->dev;
109
110 input_dev->evbit[0] = BIT(EV_SND);
111 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
112 input_dev->event = ixp4xx_spkr_event;
113
114 err = request_irq(IRQ_IXP4XX_TIMER2, &ixp4xx_spkr_interrupt,
115 SA_INTERRUPT | SA_TIMER, "ixp4xx-beeper", (void *) dev->id);
116 if (err)
117 goto err_free_device;
118
119 err = input_register_device(input_dev);
120 if (err)
121 goto err_free_irq;
122
123 platform_set_drvdata(dev, input_dev);
124
125 return 0;
126
127 err_free_irq:
128 free_irq(IRQ_IXP4XX_TIMER2, dev);
129 err_free_device:
130 input_free_device(input_dev);
131
132 return err;
133}
134
135static int __devexit ixp4xx_spkr_remove(struct platform_device *dev)
136{
137 struct input_dev *input_dev = platform_get_drvdata(dev);
138 unsigned int pin = (unsigned int) input_dev->private;
139
140 input_unregister_device(input_dev);
141 platform_set_drvdata(dev, NULL);
142
143 /* turn the speaker off */
144 disable_irq(IRQ_IXP4XX_TIMER2);
145 ixp4xx_spkr_control(pin, 0);
146
147 free_irq(IRQ_IXP4XX_TIMER2, dev);
148
149 return 0;
150}
151
152static void ixp4xx_spkr_shutdown(struct platform_device *dev)
153{
154 struct input_dev *input_dev = platform_get_drvdata(dev);
155 unsigned int pin = (unsigned int) input_dev->private;
156
157 /* turn off the speaker */
158 disable_irq(IRQ_IXP4XX_TIMER2);
159 ixp4xx_spkr_control(pin, 0);
160}
161
162static struct platform_driver ixp4xx_spkr_platform_driver = {
163 .driver = {
164 .name = "ixp4xx-beeper",
165 .owner = THIS_MODULE,
166 },
167 .probe = ixp4xx_spkr_probe,
168 .remove = __devexit_p(ixp4xx_spkr_remove),
169 .shutdown = ixp4xx_spkr_shutdown,
170};
171
172static int __init ixp4xx_spkr_init(void)
173{
174 return platform_driver_register(&ixp4xx_spkr_platform_driver);
175}
176
177static void __exit ixp4xx_spkr_exit(void)
178{
179 platform_driver_unregister(&ixp4xx_spkr_platform_driver);
180}
181
182module_init(ixp4xx_spkr_init);
183module_exit(ixp4xx_spkr_exit);
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 7665fd9ce559..19b1b0121726 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -403,6 +403,7 @@ static int genius_detect(struct psmouse *psmouse, int set_properties)
403 set_bit(REL_WHEEL, psmouse->dev->relbit); 403 set_bit(REL_WHEEL, psmouse->dev->relbit);
404 404
405 psmouse->vendor = "Genius"; 405 psmouse->vendor = "Genius";
406 psmouse->name = "Mouse";
406 psmouse->pktsize = 4; 407 psmouse->pktsize = 4;
407 } 408 }
408 409
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 81fd7a97a93d..9abed18d2ecf 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -356,7 +356,7 @@ static void mousedev_free(struct mousedev *mousedev)
356 kfree(mousedev); 356 kfree(mousedev);
357} 357}
358 358
359static int mixdev_release(void) 359static void mixdev_release(void)
360{ 360{
361 struct input_handle *handle; 361 struct input_handle *handle;
362 362
@@ -370,8 +370,6 @@ static int mixdev_release(void)
370 mousedev_free(mousedev); 370 mousedev_free(mousedev);
371 } 371 }
372 } 372 }
373
374 return 0;
375} 373}
376 374
377static int mousedev_release(struct inode * inode, struct file * file) 375static int mousedev_release(struct inode * inode, struct file * file)
@@ -384,9 +382,8 @@ static int mousedev_release(struct inode * inode, struct file * file)
384 382
385 if (!--list->mousedev->open) { 383 if (!--list->mousedev->open) {
386 if (list->mousedev->minor == MOUSEDEV_MIX) 384 if (list->mousedev->minor == MOUSEDEV_MIX)
387 return mixdev_release(); 385 mixdev_release();
388 386 else if (!mousedev_mix.open) {
389 if (!mousedev_mix.open) {
390 if (list->mousedev->exist) 387 if (list->mousedev->exist)
391 input_close_device(&list->mousedev->handle); 388 input_close_device(&list->mousedev->handle);
392 else 389 else
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index dd8c6a9ffc76..b45a45ca7cc9 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -29,9 +29,6 @@
29#ifdef CONFIG_ARCH_OMAP 29#ifdef CONFIG_ARCH_OMAP
30#include <asm/arch/gpio.h> 30#include <asm/arch/gpio.h>
31#endif 31#endif
32
33#else
34#define set_irq_type(irq,type) do{}while(0)
35#endif 32#endif
36 33
37 34
@@ -509,14 +506,14 @@ static int __devinit ads7846_probe(struct spi_device *spi)
509 ts->msg.complete = ads7846_rx; 506 ts->msg.complete = ads7846_rx;
510 ts->msg.context = ts; 507 ts->msg.context = ts;
511 508
512 if (request_irq(spi->irq, ads7846_irq, SA_SAMPLE_RANDOM, 509 if (request_irq(spi->irq, ads7846_irq,
513 spi->dev.bus_id, ts)) { 510 SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING,
511 spi->dev.bus_id, ts)) {
514 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 512 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
515 input_unregister_device(&ts->input); 513 input_unregister_device(&ts->input);
516 kfree(ts); 514 kfree(ts);
517 return -EBUSY; 515 return -EBUSY;
518 } 516 }
519 set_irq_type(spi->irq, IRQT_FALLING);
520 517
521 dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq); 518 dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq);
522 519
diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c
index 4844d250a5eb..3226830eea08 100644
--- a/drivers/input/touchscreen/mk712.c
+++ b/drivers/input/touchscreen/mk712.c
@@ -154,7 +154,7 @@ static void mk712_close(struct input_dev *dev)
154 spin_unlock_irqrestore(&mk712_lock, flags); 154 spin_unlock_irqrestore(&mk712_lock, flags);
155} 155}
156 156
157int __init mk712_init(void) 157static int __init mk712_init(void)
158{ 158{
159 int err; 159 int err;
160 160
diff --git a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h
index 1b85ce166af8..11fe537e2f6f 100644
--- a/drivers/isdn/hisax/hisax.h
+++ b/drivers/isdn/hisax/hisax.h
@@ -216,7 +216,7 @@ struct Layer1 {
216#define GROUP_TEI 127 216#define GROUP_TEI 127
217#define TEI_SAPI 63 217#define TEI_SAPI 63
218#define CTRL_SAPI 0 218#define CTRL_SAPI 0
219#define PACKET_NOACK 250 219#define PACKET_NOACK 7
220 220
221/* Layer2 Flags */ 221/* Layer2 Flags */
222 222
diff --git a/drivers/isdn/sc/ioctl.c b/drivers/isdn/sc/ioctl.c
index 3314a5a19854..94c9afb7017c 100644
--- a/drivers/isdn/sc/ioctl.c
+++ b/drivers/isdn/sc/ioctl.c
@@ -71,14 +71,14 @@ int sc_ioctl(int card, scs_ioctl *data)
71 /* 71 /*
72 * Get the SRec from user space 72 * Get the SRec from user space
73 */ 73 */
74 if (copy_from_user(srec, data->dataptr, sizeof(srec))) { 74 if (copy_from_user(srec, data->dataptr, SCIOC_SRECSIZE)) {
75 kfree(rcvmsg); 75 kfree(rcvmsg);
76 kfree(srec); 76 kfree(srec);
77 return -EFAULT; 77 return -EFAULT;
78 } 78 }
79 79
80 status = send_and_receive(card, CMPID, cmReqType2, cmReqClass0, cmReqLoadProc, 80 status = send_and_receive(card, CMPID, cmReqType2, cmReqClass0, cmReqLoadProc,
81 0, sizeof(srec), srec, rcvmsg, SAR_TIMEOUT); 81 0, SCIOC_SRECSIZE, srec, rcvmsg, SAR_TIMEOUT);
82 kfree(rcvmsg); 82 kfree(rcvmsg);
83 kfree(srec); 83 kfree(srec);
84 84
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index ed6d3174d660..69596f6438e9 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -140,10 +140,9 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
140{ 140{
141 struct macio_dev * macio_dev; 141 struct macio_dev * macio_dev;
142 struct of_device * of; 142 struct of_device * of;
143 char *scratch, *compat; 143 char *scratch, *compat, *compat2;
144 int i = 0; 144 int i = 0;
145 int length = 0; 145 int length, cplen, cplen2, seen = 0;
146 int cplen, seen = 0;
147 146
148 if (!dev) 147 if (!dev)
149 return -ENODEV; 148 return -ENODEV;
@@ -153,23 +152,22 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
153 return -ENODEV; 152 return -ENODEV;
154 153
155 of = &macio_dev->ofdev; 154 of = &macio_dev->ofdev;
156 scratch = buffer;
157 155
158 /* stuff we want to pass to /sbin/hotplug */ 156 /* stuff we want to pass to /sbin/hotplug */
159 envp[i++] = scratch; 157 envp[i++] = scratch = buffer;
160 length += scnprintf (scratch, buffer_size - length, "OF_NAME=%s", 158 length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name);
161 of->node->name);
162 if ((buffer_size - length <= 0) || (i >= num_envp))
163 return -ENOMEM;
164 ++length; 159 ++length;
160 buffer_size -= length;
161 if ((buffer_size <= 0) || (i >= num_envp))
162 return -ENOMEM;
165 scratch += length; 163 scratch += length;
166 164
167 envp[i++] = scratch; 165 envp[i++] = scratch;
168 length += scnprintf (scratch, buffer_size - length, "OF_TYPE=%s", 166 length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type);
169 of->node->type);
170 if ((buffer_size - length <= 0) || (i >= num_envp))
171 return -ENOMEM;
172 ++length; 167 ++length;
168 buffer_size -= length;
169 if ((buffer_size <= 0) || (i >= num_envp))
170 return -ENOMEM;
173 scratch += length; 171 scratch += length;
174 172
175 /* Since the compatible field can contain pretty much anything 173 /* Since the compatible field can contain pretty much anything
@@ -177,29 +175,55 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
177 * up using a number of environment variables instead. */ 175 * up using a number of environment variables instead. */
178 176
179 compat = (char *) get_property(of->node, "compatible", &cplen); 177 compat = (char *) get_property(of->node, "compatible", &cplen);
178 compat2 = compat;
179 cplen2= cplen;
180 while (compat && cplen > 0) { 180 while (compat && cplen > 0) {
181 int l;
182 envp[i++] = scratch; 181 envp[i++] = scratch;
183 length += scnprintf (scratch, buffer_size - length, 182 length = scnprintf (scratch, buffer_size,
184 "OF_COMPATIBLE_%d=%s", seen, compat); 183 "OF_COMPATIBLE_%d=%s", seen, compat);
185 if ((buffer_size - length <= 0) || (i >= num_envp)) 184 ++length;
185 buffer_size -= length;
186 if ((buffer_size <= 0) || (i >= num_envp))
186 return -ENOMEM; 187 return -ENOMEM;
187 length++;
188 scratch += length; 188 scratch += length;
189 l = strlen (compat) + 1; 189 length = strlen (compat) + 1;
190 compat += l; 190 compat += length;
191 cplen -= l; 191 cplen -= length;
192 seen++; 192 seen++;
193 } 193 }
194 194
195 envp[i++] = scratch; 195 envp[i++] = scratch;
196 length += scnprintf (scratch, buffer_size - length, 196 length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen);
197 "OF_COMPATIBLE_N=%d", seen);
198 if ((buffer_size - length <= 0) || (i >= num_envp))
199 return -ENOMEM;
200 ++length; 197 ++length;
198 buffer_size -= length;
199 if ((buffer_size <= 0) || (i >= num_envp))
200 return -ENOMEM;
201 scratch += length;
202
203 envp[i++] = scratch;
204 length = scnprintf (scratch, buffer_size, "MODALIAS=of:N%sT%s",
205 of->node->name, of->node->type);
206 /* overwrite '\0' */
207 buffer_size -= length;
208 if ((buffer_size <= 0) || (i >= num_envp))
209 return -ENOMEM;
201 scratch += length; 210 scratch += length;
202 211
212 if (!compat2) {
213 compat2 = "";
214 cplen2 = 1;
215 }
216 while (cplen2 > 0) {
217 length = snprintf (scratch, buffer_size, "C%s", compat2);
218 buffer_size -= length;
219 if (buffer_size <= 0)
220 return -ENOMEM;
221 scratch += length;
222 length = strlen (compat2) + 1;
223 compat2 += length;
224 cplen2 -= length;
225 }
226
203 envp[i] = NULL; 227 envp[i] = NULL;
204 228
205 return 0; 229 return 0;
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 1235135b384b..442e2be6052e 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1359,16 +1359,11 @@ static int ctl_ioctl(struct inode *inode, struct file *file,
1359 * Copy the parameters into kernel space. 1359 * Copy the parameters into kernel space.
1360 */ 1360 */
1361 r = copy_params(user, &param); 1361 r = copy_params(user, &param);
1362 if (r) {
1363 current->flags &= ~PF_MEMALLOC;
1364 return r;
1365 }
1366 1362
1367 /* 1363 current->flags &= ~PF_MEMALLOC;
1368 * FIXME: eventually we will remove the PF_MEMALLOC flag 1364
1369 * here. However the tools still do nasty things like 1365 if (r)
1370 * 'load' while a device is suspended. 1366 return r;
1371 */
1372 1367
1373 r = validate_params(cmd, param); 1368 r = validate_params(cmd, param);
1374 if (r) 1369 if (r)
@@ -1386,7 +1381,6 @@ static int ctl_ioctl(struct inode *inode, struct file *file,
1386 1381
1387 out: 1382 out:
1388 free_params(param); 1383 free_params(param);
1389 current->flags &= ~PF_MEMALLOC;
1390 return r; 1384 return r;
1391} 1385}
1392 1386
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index efe4adf78530..d73779a42417 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -112,7 +112,7 @@ void dm_destroy_dirty_log(struct dirty_log *log)
112/* 112/*
113 * The on-disk version of the metadata. 113 * The on-disk version of the metadata.
114 */ 114 */
115#define MIRROR_DISK_VERSION 1 115#define MIRROR_DISK_VERSION 2
116#define LOG_OFFSET 2 116#define LOG_OFFSET 2
117 117
118struct log_header { 118struct log_header {
@@ -157,7 +157,6 @@ struct log_c {
157 struct log_header *disk_header; 157 struct log_header *disk_header;
158 158
159 struct io_region bits_location; 159 struct io_region bits_location;
160 uint32_t *disk_bits;
161}; 160};
162 161
163/* 162/*
@@ -166,20 +165,20 @@ struct log_c {
166 */ 165 */
167static inline int log_test_bit(uint32_t *bs, unsigned bit) 166static inline int log_test_bit(uint32_t *bs, unsigned bit)
168{ 167{
169 return test_bit(bit, (unsigned long *) bs) ? 1 : 0; 168 return ext2_test_bit(bit, (unsigned long *) bs) ? 1 : 0;
170} 169}
171 170
172static inline void log_set_bit(struct log_c *l, 171static inline void log_set_bit(struct log_c *l,
173 uint32_t *bs, unsigned bit) 172 uint32_t *bs, unsigned bit)
174{ 173{
175 set_bit(bit, (unsigned long *) bs); 174 ext2_set_bit(bit, (unsigned long *) bs);
176 l->touched = 1; 175 l->touched = 1;
177} 176}
178 177
179static inline void log_clear_bit(struct log_c *l, 178static inline void log_clear_bit(struct log_c *l,
180 uint32_t *bs, unsigned bit) 179 uint32_t *bs, unsigned bit)
181{ 180{
182 clear_bit(bit, (unsigned long *) bs); 181 ext2_clear_bit(bit, (unsigned long *) bs);
183 l->touched = 1; 182 l->touched = 1;
184} 183}
185 184
@@ -219,6 +218,11 @@ static int read_header(struct log_c *log)
219 log->header.nr_regions = 0; 218 log->header.nr_regions = 0;
220 } 219 }
221 220
221#ifdef __LITTLE_ENDIAN
222 if (log->header.version == 1)
223 log->header.version = 2;
224#endif
225
222 if (log->header.version != MIRROR_DISK_VERSION) { 226 if (log->header.version != MIRROR_DISK_VERSION) {
223 DMWARN("incompatible disk log version"); 227 DMWARN("incompatible disk log version");
224 return -EINVAL; 228 return -EINVAL;
@@ -239,45 +243,24 @@ static inline int write_header(struct log_c *log)
239/*---------------------------------------------------------------- 243/*----------------------------------------------------------------
240 * Bits IO 244 * Bits IO
241 *--------------------------------------------------------------*/ 245 *--------------------------------------------------------------*/
242static inline void bits_to_core(uint32_t *core, uint32_t *disk, unsigned count)
243{
244 unsigned i;
245
246 for (i = 0; i < count; i++)
247 core[i] = le32_to_cpu(disk[i]);
248}
249
250static inline void bits_to_disk(uint32_t *core, uint32_t *disk, unsigned count)
251{
252 unsigned i;
253
254 /* copy across the clean/dirty bitset */
255 for (i = 0; i < count; i++)
256 disk[i] = cpu_to_le32(core[i]);
257}
258
259static int read_bits(struct log_c *log) 246static int read_bits(struct log_c *log)
260{ 247{
261 int r; 248 int r;
262 unsigned long ebits; 249 unsigned long ebits;
263 250
264 r = dm_io_sync_vm(1, &log->bits_location, READ, 251 r = dm_io_sync_vm(1, &log->bits_location, READ,
265 log->disk_bits, &ebits); 252 log->clean_bits, &ebits);
266 if (r) 253 if (r)
267 return r; 254 return r;
268 255
269 bits_to_core(log->clean_bits, log->disk_bits,
270 log->bitset_uint32_count);
271 return 0; 256 return 0;
272} 257}
273 258
274static int write_bits(struct log_c *log) 259static int write_bits(struct log_c *log)
275{ 260{
276 unsigned long ebits; 261 unsigned long ebits;
277 bits_to_disk(log->clean_bits, log->disk_bits,
278 log->bitset_uint32_count);
279 return dm_io_sync_vm(1, &log->bits_location, WRITE, 262 return dm_io_sync_vm(1, &log->bits_location, WRITE,
280 log->disk_bits, &ebits); 263 log->clean_bits, &ebits);
281} 264}
282 265
283/*---------------------------------------------------------------- 266/*----------------------------------------------------------------
@@ -433,11 +416,6 @@ static int disk_ctr(struct dirty_log *log, struct dm_target *ti,
433 size = dm_round_up(lc->bitset_uint32_count * sizeof(uint32_t), 416 size = dm_round_up(lc->bitset_uint32_count * sizeof(uint32_t),
434 1 << SECTOR_SHIFT); 417 1 << SECTOR_SHIFT);
435 lc->bits_location.count = size >> SECTOR_SHIFT; 418 lc->bits_location.count = size >> SECTOR_SHIFT;
436 lc->disk_bits = vmalloc(size);
437 if (!lc->disk_bits) {
438 vfree(lc->disk_header);
439 goto bad;
440 }
441 return 0; 419 return 0;
442 420
443 bad: 421 bad:
@@ -451,7 +429,6 @@ static void disk_dtr(struct dirty_log *log)
451 struct log_c *lc = (struct log_c *) log->context; 429 struct log_c *lc = (struct log_c *) log->context;
452 dm_put_device(lc->ti, lc->log_dev); 430 dm_put_device(lc->ti, lc->log_dev);
453 vfree(lc->disk_header); 431 vfree(lc->disk_header);
454 vfree(lc->disk_bits);
455 core_dtr(log); 432 core_dtr(log);
456} 433}
457 434
@@ -568,7 +545,8 @@ static int core_get_resync_work(struct dirty_log *log, region_t *region)
568 return 0; 545 return 0;
569 546
570 do { 547 do {
571 *region = find_next_zero_bit((unsigned long *) lc->sync_bits, 548 *region = ext2_find_next_zero_bit(
549 (unsigned long *) lc->sync_bits,
572 lc->region_count, 550 lc->region_count,
573 lc->sync_search); 551 lc->sync_search);
574 lc->sync_search = *region + 1; 552 lc->sync_search = *region + 1;
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 87727d84dbba..f3759dd7828e 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -373,16 +373,11 @@ static inline ulong round_up(ulong n, ulong size)
373 373
374static void read_snapshot_metadata(struct dm_snapshot *s) 374static void read_snapshot_metadata(struct dm_snapshot *s)
375{ 375{
376 if (s->have_metadata)
377 return;
378
379 if (s->store.read_metadata(&s->store)) { 376 if (s->store.read_metadata(&s->store)) {
380 down_write(&s->lock); 377 down_write(&s->lock);
381 s->valid = 0; 378 s->valid = 0;
382 up_write(&s->lock); 379 up_write(&s->lock);
383 } 380 }
384
385 s->have_metadata = 1;
386} 381}
387 382
388/* 383/*
@@ -471,7 +466,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
471 s->chunk_shift = ffs(chunk_size) - 1; 466 s->chunk_shift = ffs(chunk_size) - 1;
472 467
473 s->valid = 1; 468 s->valid = 1;
474 s->have_metadata = 0; 469 s->active = 0;
475 s->last_percent = 0; 470 s->last_percent = 0;
476 init_rwsem(&s->lock); 471 init_rwsem(&s->lock);
477 s->table = ti->table; 472 s->table = ti->table;
@@ -506,7 +501,11 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
506 goto bad5; 501 goto bad5;
507 } 502 }
508 503
504 /* Metadata must only be loaded into one table at once */
505 read_snapshot_metadata(s);
506
509 /* Add snapshot to the list of snapshots for this origin */ 507 /* Add snapshot to the list of snapshots for this origin */
508 /* Exceptions aren't triggered till snapshot_resume() is called */
510 if (register_snapshot(s)) { 509 if (register_snapshot(s)) {
511 r = -EINVAL; 510 r = -EINVAL;
512 ti->error = "Cannot register snapshot origin"; 511 ti->error = "Cannot register snapshot origin";
@@ -793,6 +792,9 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
793 if (!s->valid) 792 if (!s->valid)
794 return -EIO; 793 return -EIO;
795 794
795 if (unlikely(bio_barrier(bio)))
796 return -EOPNOTSUPP;
797
796 /* 798 /*
797 * Write to snapshot - higher level takes care of RW/RO 799 * Write to snapshot - higher level takes care of RW/RO
798 * flags so we should only get this if we are 800 * flags so we should only get this if we are
@@ -862,7 +864,9 @@ static void snapshot_resume(struct dm_target *ti)
862{ 864{
863 struct dm_snapshot *s = (struct dm_snapshot *) ti->private; 865 struct dm_snapshot *s = (struct dm_snapshot *) ti->private;
864 866
865 read_snapshot_metadata(s); 867 down_write(&s->lock);
868 s->active = 1;
869 up_write(&s->lock);
866} 870}
867 871
868static int snapshot_status(struct dm_target *ti, status_type_t type, 872static int snapshot_status(struct dm_target *ti, status_type_t type,
@@ -932,8 +936,8 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
932 /* Do all the snapshots on this origin */ 936 /* Do all the snapshots on this origin */
933 list_for_each_entry (snap, snapshots, list) { 937 list_for_each_entry (snap, snapshots, list) {
934 938
935 /* Only deal with valid snapshots */ 939 /* Only deal with valid and active snapshots */
936 if (!snap->valid) 940 if (!snap->valid || !snap->active)
937 continue; 941 continue;
938 942
939 /* Nothing to do if writing beyond end of snapshot */ 943 /* Nothing to do if writing beyond end of snapshot */
@@ -1057,6 +1061,9 @@ static int origin_map(struct dm_target *ti, struct bio *bio,
1057 struct dm_dev *dev = (struct dm_dev *) ti->private; 1061 struct dm_dev *dev = (struct dm_dev *) ti->private;
1058 bio->bi_bdev = dev->bdev; 1062 bio->bi_bdev = dev->bdev;
1059 1063
1064 if (unlikely(bio_barrier(bio)))
1065 return -EOPNOTSUPP;
1066
1060 /* Only tell snapshots if this is a write */ 1067 /* Only tell snapshots if this is a write */
1061 return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : 1; 1068 return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : 1;
1062} 1069}
@@ -1104,7 +1111,7 @@ static int origin_status(struct dm_target *ti, status_type_t type, char *result,
1104 1111
1105static struct target_type origin_target = { 1112static struct target_type origin_target = {
1106 .name = "snapshot-origin", 1113 .name = "snapshot-origin",
1107 .version = {1, 0, 1}, 1114 .version = {1, 1, 0},
1108 .module = THIS_MODULE, 1115 .module = THIS_MODULE,
1109 .ctr = origin_ctr, 1116 .ctr = origin_ctr,
1110 .dtr = origin_dtr, 1117 .dtr = origin_dtr,
@@ -1115,7 +1122,7 @@ static struct target_type origin_target = {
1115 1122
1116static struct target_type snapshot_target = { 1123static struct target_type snapshot_target = {
1117 .name = "snapshot", 1124 .name = "snapshot",
1118 .version = {1, 0, 1}, 1125 .version = {1, 1, 0},
1119 .module = THIS_MODULE, 1126 .module = THIS_MODULE,
1120 .ctr = snapshot_ctr, 1127 .ctr = snapshot_ctr,
1121 .dtr = snapshot_dtr, 1128 .dtr = snapshot_dtr,
diff --git a/drivers/md/dm-snap.h b/drivers/md/dm-snap.h
index 375aa24d4d7d..fdec1e2dc871 100644
--- a/drivers/md/dm-snap.h
+++ b/drivers/md/dm-snap.h
@@ -99,7 +99,9 @@ struct dm_snapshot {
99 99
100 /* You can't use a snapshot if this is 0 (e.g. if full) */ 100 /* You can't use a snapshot if this is 0 (e.g. if full) */
101 int valid; 101 int valid;
102 int have_metadata; 102
103 /* Origin writes don't trigger exceptions until this is set */
104 int active;
103 105
104 /* Used for display of table */ 106 /* Used for display of table */
105 char type; 107 char type;
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index a6f2dc66c3db..9b1e2f5ca630 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -508,7 +508,7 @@ int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
508 if (q->merge_bvec_fn) 508 if (q->merge_bvec_fn)
509 rs->max_sectors = 509 rs->max_sectors =
510 min_not_zero(rs->max_sectors, 510 min_not_zero(rs->max_sectors,
511 (unsigned short)(PAGE_SIZE >> 9)); 511 (unsigned int) (PAGE_SIZE >> 9));
512 512
513 rs->max_phys_segments = 513 rs->max_phys_segments =
514 min_not_zero(rs->max_phys_segments, 514 min_not_zero(rs->max_phys_segments,
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 8c16359f8b01..e9adeb9d172f 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -31,6 +31,7 @@ struct dm_io {
31 int error; 31 int error;
32 struct bio *bio; 32 struct bio *bio;
33 atomic_t io_count; 33 atomic_t io_count;
34 unsigned long start_time;
34}; 35};
35 36
36/* 37/*
@@ -244,6 +245,36 @@ static inline void free_tio(struct mapped_device *md, struct target_io *tio)
244 mempool_free(tio, md->tio_pool); 245 mempool_free(tio, md->tio_pool);
245} 246}
246 247
248static void start_io_acct(struct dm_io *io)
249{
250 struct mapped_device *md = io->md;
251
252 io->start_time = jiffies;
253
254 preempt_disable();
255 disk_round_stats(dm_disk(md));
256 preempt_enable();
257 dm_disk(md)->in_flight = atomic_inc_return(&md->pending);
258}
259
260static int end_io_acct(struct dm_io *io)
261{
262 struct mapped_device *md = io->md;
263 struct bio *bio = io->bio;
264 unsigned long duration = jiffies - io->start_time;
265 int pending;
266 int rw = bio_data_dir(bio);
267
268 preempt_disable();
269 disk_round_stats(dm_disk(md));
270 preempt_enable();
271 dm_disk(md)->in_flight = pending = atomic_dec_return(&md->pending);
272
273 disk_stat_add(dm_disk(md), ticks[rw], duration);
274
275 return !pending;
276}
277
247/* 278/*
248 * Add the bio to the list of deferred io. 279 * Add the bio to the list of deferred io.
249 */ 280 */
@@ -299,7 +330,7 @@ static void dec_pending(struct dm_io *io, int error)
299 io->error = error; 330 io->error = error;
300 331
301 if (atomic_dec_and_test(&io->io_count)) { 332 if (atomic_dec_and_test(&io->io_count)) {
302 if (atomic_dec_and_test(&io->md->pending)) 333 if (end_io_acct(io))
303 /* nudge anyone waiting on suspend queue */ 334 /* nudge anyone waiting on suspend queue */
304 wake_up(&io->md->wait); 335 wake_up(&io->md->wait);
305 336
@@ -554,7 +585,7 @@ static void __split_bio(struct mapped_device *md, struct bio *bio)
554 ci.sector_count = bio_sectors(bio); 585 ci.sector_count = bio_sectors(bio);
555 ci.idx = bio->bi_idx; 586 ci.idx = bio->bi_idx;
556 587
557 atomic_inc(&md->pending); 588 start_io_acct(ci.io);
558 while (ci.sector_count) 589 while (ci.sector_count)
559 __clone_and_map(&ci); 590 __clone_and_map(&ci);
560 591
@@ -573,10 +604,14 @@ static void __split_bio(struct mapped_device *md, struct bio *bio)
573static int dm_request(request_queue_t *q, struct bio *bio) 604static int dm_request(request_queue_t *q, struct bio *bio)
574{ 605{
575 int r; 606 int r;
607 int rw = bio_data_dir(bio);
576 struct mapped_device *md = q->queuedata; 608 struct mapped_device *md = q->queuedata;
577 609
578 down_read(&md->io_lock); 610 down_read(&md->io_lock);
579 611
612 disk_stat_inc(dm_disk(md), ios[rw]);
613 disk_stat_add(dm_disk(md), sectors[rw], bio_sectors(bio));
614
580 /* 615 /*
581 * If we're suspended we have to queue 616 * If we're suspended we have to queue
582 * this io for later. 617 * this io for later.
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7145cd150f7b..d05e3125d298 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1024,7 +1024,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1024 rdev-> sb_size = (rdev->sb_size | bmask)+1; 1024 rdev-> sb_size = (rdev->sb_size | bmask)+1;
1025 1025
1026 if (refdev == 0) 1026 if (refdev == 0)
1027 return 1; 1027 ret = 1;
1028 else { 1028 else {
1029 __u64 ev1, ev2; 1029 __u64 ev1, ev2;
1030 struct mdp_superblock_1 *refsb = 1030 struct mdp_superblock_1 *refsb =
@@ -1044,7 +1044,9 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1044 ev2 = le64_to_cpu(refsb->events); 1044 ev2 = le64_to_cpu(refsb->events);
1045 1045
1046 if (ev1 > ev2) 1046 if (ev1 > ev2)
1047 return 1; 1047 ret = 1;
1048 else
1049 ret = 0;
1048 } 1050 }
1049 if (minor_version) 1051 if (minor_version)
1050 rdev->size = ((rdev->bdev->bd_inode->i_size>>9) - le64_to_cpu(sb->data_offset)) / 2; 1052 rdev->size = ((rdev->bdev->bd_inode->i_size>>9) - le64_to_cpu(sb->data_offset)) / 2;
@@ -1058,7 +1060,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1058 1060
1059 if (le32_to_cpu(sb->size) > rdev->size*2) 1061 if (le32_to_cpu(sb->size) > rdev->size*2)
1060 return -EINVAL; 1062 return -EINVAL;
1061 return 0; 1063 return ret;
1062} 1064}
1063 1065
1064static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) 1066static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
@@ -1081,7 +1083,7 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1081 mddev->size = le64_to_cpu(sb->size)/2; 1083 mddev->size = le64_to_cpu(sb->size)/2;
1082 mddev->events = le64_to_cpu(sb->events); 1084 mddev->events = le64_to_cpu(sb->events);
1083 mddev->bitmap_offset = 0; 1085 mddev->bitmap_offset = 0;
1084 mddev->default_bitmap_offset = 1024; 1086 mddev->default_bitmap_offset = 1024 >> 9;
1085 1087
1086 mddev->recovery_cp = le64_to_cpu(sb->resync_offset); 1088 mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
1087 memcpy(mddev->uuid, sb->set_uuid, 16); 1089 memcpy(mddev->uuid, sb->set_uuid, 16);
@@ -1161,6 +1163,9 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1161 1163
1162 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors); 1164 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors);
1163 1165
1166 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
1167 sb->size = cpu_to_le64(mddev->size<<1);
1168
1164 if (mddev->bitmap && mddev->bitmap_file == NULL) { 1169 if (mddev->bitmap && mddev->bitmap_file == NULL) {
1165 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset); 1170 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset);
1166 sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); 1171 sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET);
@@ -2686,14 +2691,6 @@ static int do_md_stop(mddev_t * mddev, int ro)
2686 set_disk_ro(disk, 1); 2691 set_disk_ro(disk, 1);
2687 } 2692 }
2688 2693
2689 bitmap_destroy(mddev);
2690 if (mddev->bitmap_file) {
2691 atomic_set(&mddev->bitmap_file->f_dentry->d_inode->i_writecount, 1);
2692 fput(mddev->bitmap_file);
2693 mddev->bitmap_file = NULL;
2694 }
2695 mddev->bitmap_offset = 0;
2696
2697 /* 2694 /*
2698 * Free resources if final stop 2695 * Free resources if final stop
2699 */ 2696 */
@@ -2703,6 +2700,14 @@ static int do_md_stop(mddev_t * mddev, int ro)
2703 struct gendisk *disk; 2700 struct gendisk *disk;
2704 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); 2701 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
2705 2702
2703 bitmap_destroy(mddev);
2704 if (mddev->bitmap_file) {
2705 atomic_set(&mddev->bitmap_file->f_dentry->d_inode->i_writecount, 1);
2706 fput(mddev->bitmap_file);
2707 mddev->bitmap_file = NULL;
2708 }
2709 mddev->bitmap_offset = 0;
2710
2706 ITERATE_RDEV(mddev,rdev,tmp) 2711 ITERATE_RDEV(mddev,rdev,tmp)
2707 if (rdev->raid_disk >= 0) { 2712 if (rdev->raid_disk >= 0) {
2708 char nm[20]; 2713 char nm[20];
@@ -2939,6 +2944,8 @@ static int get_array_info(mddev_t * mddev, void __user * arg)
2939 info.ctime = mddev->ctime; 2944 info.ctime = mddev->ctime;
2940 info.level = mddev->level; 2945 info.level = mddev->level;
2941 info.size = mddev->size; 2946 info.size = mddev->size;
2947 if (info.size != mddev->size) /* overflow */
2948 info.size = -1;
2942 info.nr_disks = nr; 2949 info.nr_disks = nr;
2943 info.raid_disks = mddev->raid_disks; 2950 info.raid_disks = mddev->raid_disks;
2944 info.md_minor = mddev->md_minor; 2951 info.md_minor = mddev->md_minor;
@@ -3465,7 +3472,7 @@ static int update_size(mddev_t *mddev, unsigned long size)
3465 bdev = bdget_disk(mddev->gendisk, 0); 3472 bdev = bdget_disk(mddev->gendisk, 0);
3466 if (bdev) { 3473 if (bdev) {
3467 mutex_lock(&bdev->bd_inode->i_mutex); 3474 mutex_lock(&bdev->bd_inode->i_mutex);
3468 i_size_write(bdev->bd_inode, mddev->array_size << 10); 3475 i_size_write(bdev->bd_inode, (loff_t)mddev->array_size << 10);
3469 mutex_unlock(&bdev->bd_inode->i_mutex); 3476 mutex_unlock(&bdev->bd_inode->i_mutex);
3470 bdput(bdev); 3477 bdput(bdev);
3471 } 3478 }
@@ -3485,17 +3492,6 @@ static int update_raid_disks(mddev_t *mddev, int raid_disks)
3485 if (mddev->sync_thread) 3492 if (mddev->sync_thread)
3486 return -EBUSY; 3493 return -EBUSY;
3487 rv = mddev->pers->reshape(mddev, raid_disks); 3494 rv = mddev->pers->reshape(mddev, raid_disks);
3488 if (!rv) {
3489 struct block_device *bdev;
3490
3491 bdev = bdget_disk(mddev->gendisk, 0);
3492 if (bdev) {
3493 mutex_lock(&bdev->bd_inode->i_mutex);
3494 i_size_write(bdev->bd_inode, mddev->array_size << 10);
3495 mutex_unlock(&bdev->bd_inode->i_mutex);
3496 bdput(bdev);
3497 }
3498 }
3499 return rv; 3495 return rv;
3500} 3496}
3501 3497
@@ -3531,7 +3527,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
3531 ) 3527 )
3532 return -EINVAL; 3528 return -EINVAL;
3533 /* Check there is only one change */ 3529 /* Check there is only one change */
3534 if (mddev->size != info->size) cnt++; 3530 if (info->size >= 0 && mddev->size != info->size) cnt++;
3535 if (mddev->raid_disks != info->raid_disks) cnt++; 3531 if (mddev->raid_disks != info->raid_disks) cnt++;
3536 if (mddev->layout != info->layout) cnt++; 3532 if (mddev->layout != info->layout) cnt++;
3537 if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++; 3533 if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++;
@@ -3548,7 +3544,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
3548 else 3544 else
3549 return mddev->pers->reconfig(mddev, info->layout, -1); 3545 return mddev->pers->reconfig(mddev, info->layout, -1);
3550 } 3546 }
3551 if (mddev->size != info->size) 3547 if (info->size >= 0 && mddev->size != info->size)
3552 rv = update_size(mddev, info->size); 3548 rv = update_size(mddev, info->size);
3553 3549
3554 if (mddev->raid_disks != info->raid_disks) 3550 if (mddev->raid_disks != info->raid_disks)
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index d03f99cf4b7d..678f4dbbea1d 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -372,7 +372,7 @@ out_free_conf:
372 kfree(conf); 372 kfree(conf);
373 mddev->private = NULL; 373 mddev->private = NULL;
374out: 374out:
375 return 1; 375 return -ENOMEM;
376} 376}
377 377
378static int raid0_stop (mddev_t *mddev) 378static int raid0_stop (mddev_t *mddev)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 9130d051b474..ab90a6d12020 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -565,6 +565,8 @@ rb_out:
565 565
566 if (disk >= 0 && (rdev=rcu_dereference(conf->mirrors[disk].rdev))!= NULL) 566 if (disk >= 0 && (rdev=rcu_dereference(conf->mirrors[disk].rdev))!= NULL)
567 atomic_inc(&conf->mirrors[disk].rdev->nr_pending); 567 atomic_inc(&conf->mirrors[disk].rdev->nr_pending);
568 else
569 disk = -1;
568 rcu_read_unlock(); 570 rcu_read_unlock();
569 571
570 return disk; 572 return disk;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 25976bfb6f9c..2dba305daf3c 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -350,7 +350,8 @@ static void shrink_stripes(raid5_conf_t *conf)
350 while (drop_one_stripe(conf)) 350 while (drop_one_stripe(conf))
351 ; 351 ;
352 352
353 kmem_cache_destroy(conf->slab_cache); 353 if (conf->slab_cache)
354 kmem_cache_destroy(conf->slab_cache);
354 conf->slab_cache = NULL; 355 conf->slab_cache = NULL;
355} 356}
356 357
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index f618a53b98be..cd477ebf2ee4 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -115,7 +115,7 @@ static void __release_stripe(raid6_conf_t *conf, struct stripe_head *sh)
115 list_add_tail(&sh->lru, &conf->inactive_list); 115 list_add_tail(&sh->lru, &conf->inactive_list);
116 atomic_dec(&conf->active_stripes); 116 atomic_dec(&conf->active_stripes);
117 if (!conf->inactive_blocked || 117 if (!conf->inactive_blocked ||
118 atomic_read(&conf->active_stripes) < (NR_STRIPES*3/4)) 118 atomic_read(&conf->active_stripes) < (conf->max_nr_stripes*3/4))
119 wake_up(&conf->wait_for_stripe); 119 wake_up(&conf->wait_for_stripe);
120 } 120 }
121 } 121 }
@@ -273,7 +273,8 @@ static struct stripe_head *get_active_stripe(raid6_conf_t *conf, sector_t sector
273 conf->inactive_blocked = 1; 273 conf->inactive_blocked = 1;
274 wait_event_lock_irq(conf->wait_for_stripe, 274 wait_event_lock_irq(conf->wait_for_stripe,
275 !list_empty(&conf->inactive_list) && 275 !list_empty(&conf->inactive_list) &&
276 (atomic_read(&conf->active_stripes) < (NR_STRIPES *3/4) 276 (atomic_read(&conf->active_stripes)
277 < (conf->max_nr_stripes *3/4)
277 || !conf->inactive_blocked), 278 || !conf->inactive_blocked),
278 conf->device_lock, 279 conf->device_lock,
279 unplug_slaves(conf->mddev); 280 unplug_slaves(conf->mddev);
@@ -302,9 +303,31 @@ static struct stripe_head *get_active_stripe(raid6_conf_t *conf, sector_t sector
302 return sh; 303 return sh;
303} 304}
304 305
305static int grow_stripes(raid6_conf_t *conf, int num) 306static int grow_one_stripe(raid6_conf_t *conf)
306{ 307{
307 struct stripe_head *sh; 308 struct stripe_head *sh;
309 sh = kmem_cache_alloc(conf->slab_cache, GFP_KERNEL);
310 if (!sh)
311 return 0;
312 memset(sh, 0, sizeof(*sh) + (conf->raid_disks-1)*sizeof(struct r5dev));
313 sh->raid_conf = conf;
314 spin_lock_init(&sh->lock);
315
316 if (grow_buffers(sh, conf->raid_disks)) {
317 shrink_buffers(sh, conf->raid_disks);
318 kmem_cache_free(conf->slab_cache, sh);
319 return 0;
320 }
321 /* we just created an active stripe so... */
322 atomic_set(&sh->count, 1);
323 atomic_inc(&conf->active_stripes);
324 INIT_LIST_HEAD(&sh->lru);
325 release_stripe(sh);
326 return 1;
327}
328
329static int grow_stripes(raid6_conf_t *conf, int num)
330{
308 kmem_cache_t *sc; 331 kmem_cache_t *sc;
309 int devs = conf->raid_disks; 332 int devs = conf->raid_disks;
310 333
@@ -316,45 +339,35 @@ static int grow_stripes(raid6_conf_t *conf, int num)
316 if (!sc) 339 if (!sc)
317 return 1; 340 return 1;
318 conf->slab_cache = sc; 341 conf->slab_cache = sc;
319 while (num--) { 342 while (num--)
320 sh = kmem_cache_alloc(sc, GFP_KERNEL); 343 if (!grow_one_stripe(conf))
321 if (!sh)
322 return 1;
323 memset(sh, 0, sizeof(*sh) + (devs-1)*sizeof(struct r5dev));
324 sh->raid_conf = conf;
325 spin_lock_init(&sh->lock);
326
327 if (grow_buffers(sh, conf->raid_disks)) {
328 shrink_buffers(sh, conf->raid_disks);
329 kmem_cache_free(sc, sh);
330 return 1; 344 return 1;
331 }
332 /* we just created an active stripe so... */
333 atomic_set(&sh->count, 1);
334 atomic_inc(&conf->active_stripes);
335 INIT_LIST_HEAD(&sh->lru);
336 release_stripe(sh);
337 }
338 return 0; 345 return 0;
339} 346}
340 347
341static void shrink_stripes(raid6_conf_t *conf) 348static int drop_one_stripe(raid6_conf_t *conf)
342{ 349{
343 struct stripe_head *sh; 350 struct stripe_head *sh;
351 spin_lock_irq(&conf->device_lock);
352 sh = get_free_stripe(conf);
353 spin_unlock_irq(&conf->device_lock);
354 if (!sh)
355 return 0;
356 if (atomic_read(&sh->count))
357 BUG();
358 shrink_buffers(sh, conf->raid_disks);
359 kmem_cache_free(conf->slab_cache, sh);
360 atomic_dec(&conf->active_stripes);
361 return 1;
362}
344 363
345 while (1) { 364static void shrink_stripes(raid6_conf_t *conf)
346 spin_lock_irq(&conf->device_lock); 365{
347 sh = get_free_stripe(conf); 366 while (drop_one_stripe(conf))
348 spin_unlock_irq(&conf->device_lock); 367 ;
349 if (!sh) 368
350 break; 369 if (conf->slab_cache)
351 if (atomic_read(&sh->count)) 370 kmem_cache_destroy(conf->slab_cache);
352 BUG();
353 shrink_buffers(sh, conf->raid_disks);
354 kmem_cache_free(conf->slab_cache, sh);
355 atomic_dec(&conf->active_stripes);
356 }
357 kmem_cache_destroy(conf->slab_cache);
358 conf->slab_cache = NULL; 371 conf->slab_cache = NULL;
359} 372}
360 373
@@ -1912,6 +1925,74 @@ static void raid6d (mddev_t *mddev)
1912 PRINTK("--- raid6d inactive\n"); 1925 PRINTK("--- raid6d inactive\n");
1913} 1926}
1914 1927
1928static ssize_t
1929raid6_show_stripe_cache_size(mddev_t *mddev, char *page)
1930{
1931 raid6_conf_t *conf = mddev_to_conf(mddev);
1932 if (conf)
1933 return sprintf(page, "%d\n", conf->max_nr_stripes);
1934 else
1935 return 0;
1936}
1937
1938static ssize_t
1939raid6_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
1940{
1941 raid6_conf_t *conf = mddev_to_conf(mddev);
1942 char *end;
1943 int new;
1944 if (len >= PAGE_SIZE)
1945 return -EINVAL;
1946 if (!conf)
1947 return -ENODEV;
1948
1949 new = simple_strtoul(page, &end, 10);
1950 if (!*page || (*end && *end != '\n') )
1951 return -EINVAL;
1952 if (new <= 16 || new > 32768)
1953 return -EINVAL;
1954 while (new < conf->max_nr_stripes) {
1955 if (drop_one_stripe(conf))
1956 conf->max_nr_stripes--;
1957 else
1958 break;
1959 }
1960 while (new > conf->max_nr_stripes) {
1961 if (grow_one_stripe(conf))
1962 conf->max_nr_stripes++;
1963 else break;
1964 }
1965 return len;
1966}
1967
1968static struct md_sysfs_entry
1969raid6_stripecache_size = __ATTR(stripe_cache_size, S_IRUGO | S_IWUSR,
1970 raid6_show_stripe_cache_size,
1971 raid6_store_stripe_cache_size);
1972
1973static ssize_t
1974stripe_cache_active_show(mddev_t *mddev, char *page)
1975{
1976 raid6_conf_t *conf = mddev_to_conf(mddev);
1977 if (conf)
1978 return sprintf(page, "%d\n", atomic_read(&conf->active_stripes));
1979 else
1980 return 0;
1981}
1982
1983static struct md_sysfs_entry
1984raid6_stripecache_active = __ATTR_RO(stripe_cache_active);
1985
1986static struct attribute *raid6_attrs[] = {
1987 &raid6_stripecache_size.attr,
1988 &raid6_stripecache_active.attr,
1989 NULL,
1990};
1991static struct attribute_group raid6_attrs_group = {
1992 .name = NULL,
1993 .attrs = raid6_attrs,
1994};
1995
1915static int run(mddev_t *mddev) 1996static int run(mddev_t *mddev)
1916{ 1997{
1917 raid6_conf_t *conf; 1998 raid6_conf_t *conf;
@@ -2095,6 +2176,7 @@ static int stop (mddev_t *mddev)
2095 shrink_stripes(conf); 2176 shrink_stripes(conf);
2096 kfree(conf->stripe_hashtbl); 2177 kfree(conf->stripe_hashtbl);
2097 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 2178 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
2179 sysfs_remove_group(&mddev->kobj, &raid6_attrs_group);
2098 kfree(conf); 2180 kfree(conf);
2099 mddev->private = NULL; 2181 mddev->private = NULL;
2100 return 0; 2182 return 0;
diff --git a/drivers/media/video/hexium_orion.c b/drivers/media/video/hexium_orion.c
index 0b6c2096ec66..aad4a18aafd6 100644
--- a/drivers/media/video/hexium_orion.c
+++ b/drivers/media/video/hexium_orion.c
@@ -484,7 +484,7 @@ static struct saa7146_ext_vv vv_data = {
484}; 484};
485 485
486static struct saa7146_extension extension = { 486static struct saa7146_extension extension = {
487 .name = "hexium HV-PCI6/Orion", 487 .name = "hexium HV-PCI6 Orion",
488 .flags = 0, // SAA7146_USE_I2C_IRQ, 488 .flags = 0, // SAA7146_USE_I2C_IRQ,
489 489
490 .pci_tbl = &pci_tbl[0], 490 .pci_tbl = &pci_tbl[0],
diff --git a/drivers/message/fusion/Makefile b/drivers/message/fusion/Makefile
index 8a2e2657f4c2..33ace373241c 100644
--- a/drivers/message/fusion/Makefile
+++ b/drivers/message/fusion/Makefile
@@ -29,6 +29,8 @@
29# For mptctl: 29# For mptctl:
30#CFLAGS_mptctl.o += -DMPT_DEBUG_IOCTL 30#CFLAGS_mptctl.o += -DMPT_DEBUG_IOCTL
31# 31#
32# For mptfc:
33#CFLAGS_mptfc.o += -DMPT_DEBUG_FC
32 34
33#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC 35#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC
34 36
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index d890b2b8a93e..9a2c7605d49c 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -81,6 +81,10 @@ MODULE_LICENSE("GPL");
81/* 81/*
82 * cmd line parameters 82 * cmd line parameters
83 */ 83 */
84static int mpt_msi_enable;
85module_param(mpt_msi_enable, int, 0);
86MODULE_PARM_DESC(mpt_msi_enable, " MSI Support Enable (default=0)");
87
84#ifdef MFCNT 88#ifdef MFCNT
85static int mfcounter = 0; 89static int mfcounter = 0;
86#define PRINT_MF_COUNT 20000 90#define PRINT_MF_COUNT 20000
@@ -174,7 +178,7 @@ static void mpt_get_fw_exp_ver(char *buf, MPT_ADAPTER *ioc);
174static int ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *evReply, int *evHandlers); 178static int ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *evReply, int *evHandlers);
175static void mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf); 179static void mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf);
176static void mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info); 180static void mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info);
177static void mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info); 181static void mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info);
178static void mpt_sas_log_info(MPT_ADAPTER *ioc, u32 log_info); 182static void mpt_sas_log_info(MPT_ADAPTER *ioc, u32 log_info);
179 183
180/* module entry point */ 184/* module entry point */
@@ -313,7 +317,7 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
313 if (ioc->bus_type == FC) 317 if (ioc->bus_type == FC)
314 mpt_fc_log_info(ioc, log_info); 318 mpt_fc_log_info(ioc, log_info);
315 else if (ioc->bus_type == SPI) 319 else if (ioc->bus_type == SPI)
316 mpt_sp_log_info(ioc, log_info); 320 mpt_spi_log_info(ioc, log_info);
317 else if (ioc->bus_type == SAS) 321 else if (ioc->bus_type == SAS)
318 mpt_sas_log_info(ioc, log_info); 322 mpt_sas_log_info(ioc, log_info);
319 } 323 }
@@ -1444,6 +1448,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1444 1448
1445 ioc->pci_irq = -1; 1449 ioc->pci_irq = -1;
1446 if (pdev->irq) { 1450 if (pdev->irq) {
1451 if (mpt_msi_enable && !pci_enable_msi(pdev))
1452 printk(MYIOC_s_INFO_FMT "PCI-MSI enabled\n", ioc->name);
1453
1447 r = request_irq(pdev->irq, mpt_interrupt, SA_SHIRQ, ioc->name, ioc); 1454 r = request_irq(pdev->irq, mpt_interrupt, SA_SHIRQ, ioc->name, ioc);
1448 1455
1449 if (r < 0) { 1456 if (r < 0) {
@@ -1483,6 +1490,10 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1483 1490
1484 list_del(&ioc->list); 1491 list_del(&ioc->list);
1485 free_irq(ioc->pci_irq, ioc); 1492 free_irq(ioc->pci_irq, ioc);
1493 if (mpt_msi_enable)
1494 pci_disable_msi(pdev);
1495 if (ioc->alt_ioc)
1496 ioc->alt_ioc->alt_ioc = NULL;
1486 iounmap(mem); 1497 iounmap(mem);
1487 kfree(ioc); 1498 kfree(ioc);
1488 pci_set_drvdata(pdev, NULL); 1499 pci_set_drvdata(pdev, NULL);
@@ -2136,6 +2147,8 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
2136 2147
2137 if (ioc->pci_irq != -1) { 2148 if (ioc->pci_irq != -1) {
2138 free_irq(ioc->pci_irq, ioc); 2149 free_irq(ioc->pci_irq, ioc);
2150 if (mpt_msi_enable)
2151 pci_disable_msi(ioc->pcidev);
2139 ioc->pci_irq = -1; 2152 ioc->pci_irq = -1;
2140 } 2153 }
2141 2154
@@ -2157,6 +2170,10 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
2157 sz_last = ioc->alloc_total; 2170 sz_last = ioc->alloc_total;
2158 dprintk((KERN_INFO MYNAM ": %s: free'd %d of %d bytes\n", 2171 dprintk((KERN_INFO MYNAM ": %s: free'd %d of %d bytes\n",
2159 ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first)); 2172 ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first));
2173
2174 if (ioc->alt_ioc)
2175 ioc->alt_ioc->alt_ioc = NULL;
2176
2160 kfree(ioc); 2177 kfree(ioc);
2161} 2178}
2162 2179
@@ -2770,13 +2787,16 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2770 2787
2771 /* RAID FW may take a long time to enable 2788 /* RAID FW may take a long time to enable
2772 */ 2789 */
2773 if ( (ioc->facts.ProductID & MPI_FW_HEADER_PID_PROD_MASK) 2790 if (((ioc->facts.ProductID & MPI_FW_HEADER_PID_PROD_MASK)
2774 > MPI_FW_HEADER_PID_PROD_TARGET_SCSI ) { 2791 > MPI_FW_HEADER_PID_PROD_TARGET_SCSI) ||
2775 rc = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable, 2792 (ioc->bus_type == SAS)) {
2776 reply_sz, (u16*)&reply_buf, 300 /*seconds*/, sleepFlag); 2793 rc = mpt_handshake_req_reply_wait(ioc, req_sz,
2794 (u32*)&port_enable, reply_sz, (u16*)&reply_buf,
2795 300 /*seconds*/, sleepFlag);
2777 } else { 2796 } else {
2778 rc = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable, 2797 rc = mpt_handshake_req_reply_wait(ioc, req_sz,
2779 reply_sz, (u16*)&reply_buf, 30 /*seconds*/, sleepFlag); 2798 (u32*)&port_enable, reply_sz, (u16*)&reply_buf,
2799 30 /*seconds*/, sleepFlag);
2780 } 2800 }
2781 return rc; 2801 return rc;
2782} 2802}
@@ -4387,6 +4407,138 @@ mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode)
4387} 4407}
4388 4408
4389/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4409/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4410
4411static void
4412mptbase_raid_process_event_data(MPT_ADAPTER *ioc,
4413 MpiEventDataRaid_t * pRaidEventData)
4414{
4415 int volume;
4416 int reason;
4417 int disk;
4418 int status;
4419 int flags;
4420 int state;
4421
4422 volume = pRaidEventData->VolumeID;
4423 reason = pRaidEventData->ReasonCode;
4424 disk = pRaidEventData->PhysDiskNum;
4425 status = le32_to_cpu(pRaidEventData->SettingsStatus);
4426 flags = (status >> 0) & 0xff;
4427 state = (status >> 8) & 0xff;
4428
4429 if (reason == MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) {
4430 return;
4431 }
4432
4433 if ((reason >= MPI_EVENT_RAID_RC_PHYSDISK_CREATED &&
4434 reason <= MPI_EVENT_RAID_RC_PHYSDISK_STATUS_CHANGED) ||
4435 (reason == MPI_EVENT_RAID_RC_SMART_DATA)) {
4436 printk(MYIOC_s_INFO_FMT "RAID STATUS CHANGE for PhysDisk %d\n",
4437 ioc->name, disk);
4438 } else {
4439 printk(MYIOC_s_INFO_FMT "RAID STATUS CHANGE for VolumeID %d\n",
4440 ioc->name, volume);
4441 }
4442
4443 switch(reason) {
4444 case MPI_EVENT_RAID_RC_VOLUME_CREATED:
4445 printk(MYIOC_s_INFO_FMT " volume has been created\n",
4446 ioc->name);
4447 break;
4448
4449 case MPI_EVENT_RAID_RC_VOLUME_DELETED:
4450
4451 printk(MYIOC_s_INFO_FMT " volume has been deleted\n",
4452 ioc->name);
4453 break;
4454
4455 case MPI_EVENT_RAID_RC_VOLUME_SETTINGS_CHANGED:
4456 printk(MYIOC_s_INFO_FMT " volume settings have been changed\n",
4457 ioc->name);
4458 break;
4459
4460 case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED:
4461 printk(MYIOC_s_INFO_FMT " volume is now %s%s%s%s\n",
4462 ioc->name,
4463 state == MPI_RAIDVOL0_STATUS_STATE_OPTIMAL
4464 ? "optimal"
4465 : state == MPI_RAIDVOL0_STATUS_STATE_DEGRADED
4466 ? "degraded"
4467 : state == MPI_RAIDVOL0_STATUS_STATE_FAILED
4468 ? "failed"
4469 : "state unknown",
4470 flags & MPI_RAIDVOL0_STATUS_FLAG_ENABLED
4471 ? ", enabled" : "",
4472 flags & MPI_RAIDVOL0_STATUS_FLAG_QUIESCED
4473 ? ", quiesced" : "",
4474 flags & MPI_RAIDVOL0_STATUS_FLAG_RESYNC_IN_PROGRESS
4475 ? ", resync in progress" : "" );
4476 break;
4477
4478 case MPI_EVENT_RAID_RC_VOLUME_PHYSDISK_CHANGED:
4479 printk(MYIOC_s_INFO_FMT " volume membership of PhysDisk %d has changed\n",
4480 ioc->name, disk);
4481 break;
4482
4483 case MPI_EVENT_RAID_RC_PHYSDISK_CREATED:
4484 printk(MYIOC_s_INFO_FMT " PhysDisk has been created\n",
4485 ioc->name);
4486 break;
4487
4488 case MPI_EVENT_RAID_RC_PHYSDISK_DELETED:
4489 printk(MYIOC_s_INFO_FMT " PhysDisk has been deleted\n",
4490 ioc->name);
4491 break;
4492
4493 case MPI_EVENT_RAID_RC_PHYSDISK_SETTINGS_CHANGED:
4494 printk(MYIOC_s_INFO_FMT " PhysDisk settings have been changed\n",
4495 ioc->name);
4496 break;
4497
4498 case MPI_EVENT_RAID_RC_PHYSDISK_STATUS_CHANGED:
4499 printk(MYIOC_s_INFO_FMT " PhysDisk is now %s%s%s\n",
4500 ioc->name,
4501 state == MPI_PHYSDISK0_STATUS_ONLINE
4502 ? "online"
4503 : state == MPI_PHYSDISK0_STATUS_MISSING
4504 ? "missing"
4505 : state == MPI_PHYSDISK0_STATUS_NOT_COMPATIBLE
4506 ? "not compatible"
4507 : state == MPI_PHYSDISK0_STATUS_FAILED
4508 ? "failed"
4509 : state == MPI_PHYSDISK0_STATUS_INITIALIZING
4510 ? "initializing"
4511 : state == MPI_PHYSDISK0_STATUS_OFFLINE_REQUESTED
4512 ? "offline requested"
4513 : state == MPI_PHYSDISK0_STATUS_FAILED_REQUESTED
4514 ? "failed requested"
4515 : state == MPI_PHYSDISK0_STATUS_OTHER_OFFLINE
4516 ? "offline"
4517 : "state unknown",
4518 flags & MPI_PHYSDISK0_STATUS_FLAG_OUT_OF_SYNC
4519 ? ", out of sync" : "",
4520 flags & MPI_PHYSDISK0_STATUS_FLAG_QUIESCED
4521 ? ", quiesced" : "" );
4522 break;
4523
4524 case MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED:
4525 printk(MYIOC_s_INFO_FMT " Domain Validation needed for PhysDisk %d\n",
4526 ioc->name, disk);
4527 break;
4528
4529 case MPI_EVENT_RAID_RC_SMART_DATA:
4530 printk(MYIOC_s_INFO_FMT " SMART data received, ASC/ASCQ = %02xh/%02xh\n",
4531 ioc->name, pRaidEventData->ASC, pRaidEventData->ASCQ);
4532 break;
4533
4534 case MPI_EVENT_RAID_RC_REPLACE_ACTION_STARTED:
4535 printk(MYIOC_s_INFO_FMT " replacement of PhysDisk %d has started\n",
4536 ioc->name, disk);
4537 break;
4538 }
4539}
4540
4541/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4390/* 4542/*
4391 * GetIoUnitPage2 - Retrieve BIOS version and boot order information. 4543 * GetIoUnitPage2 - Retrieve BIOS version and boot order information.
4392 * @ioc: Pointer to MPT_ADAPTER structure 4544 * @ioc: Pointer to MPT_ADAPTER structure
@@ -4598,6 +4750,14 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4598 SCSIPortPage2_t *pPP2 = (SCSIPortPage2_t *) pbuf; 4750 SCSIPortPage2_t *pPP2 = (SCSIPortPage2_t *) pbuf;
4599 MpiDeviceInfo_t *pdevice = NULL; 4751 MpiDeviceInfo_t *pdevice = NULL;
4600 4752
4753 /*
4754 * Save "Set to Avoid SCSI Bus Resets" flag
4755 */
4756 ioc->spi_data.bus_reset =
4757 (le32_to_cpu(pPP2->PortFlags) &
4758 MPI_SCSIPORTPAGE2_PORT_FLAGS_AVOID_SCSI_RESET) ?
4759 0 : 1 ;
4760
4601 /* Save the Port Page 2 data 4761 /* Save the Port Page 2 data
4602 * (reformat into a 32bit quantity) 4762 * (reformat into a 32bit quantity)
4603 */ 4763 */
@@ -5967,6 +6127,10 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
5967 } 6127 }
5968 } 6128 }
5969 break; 6129 break;
6130 case MPI_EVENT_INTEGRATED_RAID:
6131 mptbase_raid_process_event_data(ioc,
6132 (MpiEventDataRaid_t *)pEventReply->Data);
6133 break;
5970 default: 6134 default:
5971 break; 6135 break;
5972 } 6136 }
@@ -6046,7 +6210,7 @@ mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info)
6046 6210
6047/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6211/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6048/* 6212/*
6049 * mpt_sp_log_info - Log information returned from SCSI Parallel IOC. 6213 * mpt_spi_log_info - Log information returned from SCSI Parallel IOC.
6050 * @ioc: Pointer to MPT_ADAPTER structure 6214 * @ioc: Pointer to MPT_ADAPTER structure
6051 * @mr: Pointer to MPT reply frame 6215 * @mr: Pointer to MPT reply frame
6052 * @log_info: U32 LogInfo word from the IOC 6216 * @log_info: U32 LogInfo word from the IOC
@@ -6054,7 +6218,7 @@ mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info)
6054 * Refer to lsi/sp_log.h. 6218 * Refer to lsi/sp_log.h.
6055 */ 6219 */
6056static void 6220static void
6057mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info) 6221mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
6058{ 6222{
6059 u32 info = log_info & 0x00FF0000; 6223 u32 info = log_info & 0x00FF0000;
6060 char *desc = "unknown"; 6224 char *desc = "unknown";
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 47053ac65068..ea2649ecad1f 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -76,8 +76,8 @@
76#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 76#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
77#endif 77#endif
78 78
79#define MPT_LINUX_VERSION_COMMON "3.03.06" 79#define MPT_LINUX_VERSION_COMMON "3.03.07"
80#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.06" 80#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.07"
81#define WHAT_MAGIC_STRING "@" "(" "#" ")" 81#define WHAT_MAGIC_STRING "@" "(" "#" ")"
82 82
83#define show_mptmod_ver(s,ver) \ 83#define show_mptmod_ver(s,ver) \
@@ -123,7 +123,7 @@
123#define MPT_MAX_FRAME_SIZE 128 123#define MPT_MAX_FRAME_SIZE 128
124#define MPT_DEFAULT_FRAME_SIZE 128 124#define MPT_DEFAULT_FRAME_SIZE 128
125 125
126#define MPT_REPLY_FRAME_SIZE 0x40 /* Must be a multiple of 8 */ 126#define MPT_REPLY_FRAME_SIZE 0x50 /* Must be a multiple of 8 */
127 127
128#define MPT_SG_REQ_128_SCALE 1 128#define MPT_SG_REQ_128_SCALE 1
129#define MPT_SG_REQ_96_SCALE 2 129#define MPT_SG_REQ_96_SCALE 2
@@ -510,9 +510,10 @@ struct mptfc_rport_info
510{ 510{
511 struct list_head list; 511 struct list_head list;
512 struct fc_rport *rport; 512 struct fc_rport *rport;
513 VirtDevice *vdev; 513 struct scsi_target *starget;
514 FCDevicePage0_t pg0; 514 FCDevicePage0_t pg0;
515 u8 flags; 515 u8 flags;
516 u8 remap_needed;
516}; 517};
517 518
518/* 519/*
@@ -631,6 +632,7 @@ typedef struct _MPT_ADAPTER
631 struct mutex sas_topology_mutex; 632 struct mutex sas_topology_mutex;
632 MPT_SAS_MGMT sas_mgmt; 633 MPT_SAS_MGMT sas_mgmt;
633 int num_ports; 634 int num_ports;
635 struct work_struct mptscsih_persistTask;
634 636
635 struct list_head fc_rports; 637 struct list_head fc_rports;
636 spinlock_t fc_rport_lock; /* list and ri flags */ 638 spinlock_t fc_rport_lock; /* list and ri flags */
@@ -803,6 +805,12 @@ typedef struct _mpt_sge {
803#define dreplyprintk(x) 805#define dreplyprintk(x)
804#endif 806#endif
805 807
808#ifdef DMPT_DEBUG_FC
809#define dfcprintk(x) printk x
810#else
811#define dfcprintk(x)
812#endif
813
806#ifdef MPT_DEBUG_TM 814#ifdef MPT_DEBUG_TM
807#define dtmprintk(x) printk x 815#define dtmprintk(x) printk x
808#define DBG_DUMP_TM_REQUEST_FRAME(mfp) \ 816#define DBG_DUMP_TM_REQUEST_FRAME(mfp) \
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index b102c7666d0e..c3a3499bce2a 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -93,10 +93,11 @@ static int mptfcDoneCtx = -1;
93static int mptfcTaskCtx = -1; 93static int mptfcTaskCtx = -1;
94static int mptfcInternalCtx = -1; /* Used only for internal commands */ 94static int mptfcInternalCtx = -1; /* Used only for internal commands */
95 95
96int mptfc_slave_alloc(struct scsi_device *device); 96static int mptfc_target_alloc(struct scsi_target *starget);
97static int mptfc_slave_alloc(struct scsi_device *sdev);
97static int mptfc_qcmd(struct scsi_cmnd *SCpnt, 98static int mptfc_qcmd(struct scsi_cmnd *SCpnt,
98 void (*done)(struct scsi_cmnd *)); 99 void (*done)(struct scsi_cmnd *));
99 100static void mptfc_target_destroy(struct scsi_target *starget);
100static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout); 101static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
101static void __devexit mptfc_remove(struct pci_dev *pdev); 102static void __devexit mptfc_remove(struct pci_dev *pdev);
102 103
@@ -107,10 +108,10 @@ static struct scsi_host_template mptfc_driver_template = {
107 .name = "MPT FC Host", 108 .name = "MPT FC Host",
108 .info = mptscsih_info, 109 .info = mptscsih_info,
109 .queuecommand = mptfc_qcmd, 110 .queuecommand = mptfc_qcmd,
110 .target_alloc = mptscsih_target_alloc, 111 .target_alloc = mptfc_target_alloc,
111 .slave_alloc = mptfc_slave_alloc, 112 .slave_alloc = mptfc_slave_alloc,
112 .slave_configure = mptscsih_slave_configure, 113 .slave_configure = mptscsih_slave_configure,
113 .target_destroy = mptscsih_target_destroy, 114 .target_destroy = mptfc_target_destroy,
114 .slave_destroy = mptscsih_slave_destroy, 115 .slave_destroy = mptscsih_slave_destroy,
115 .change_queue_depth = mptscsih_change_queue_depth, 116 .change_queue_depth = mptscsih_change_queue_depth,
116 .eh_abort_handler = mptscsih_abort, 117 .eh_abort_handler = mptscsih_abort,
@@ -348,14 +349,33 @@ mptfc_generate_rport_ids(FCDevicePage0_t *pg0, struct fc_rport_identifiers *rid)
348} 349}
349 350
350static void 351static void
352mptfc_remap_sdev(struct scsi_device *sdev, void *arg)
353{
354 VirtDevice *vdev;
355 VirtTarget *vtarget;
356 struct scsi_target *starget;
357
358 starget = scsi_target(sdev);
359 if (starget->hostdata == arg) {
360 vtarget = arg;
361 vdev = sdev->hostdata;
362 if (vdev) {
363 vdev->bus_id = vtarget->bus_id;
364 vdev->target_id = vtarget->target_id;
365 }
366 }
367}
368
369static void
351mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0) 370mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0)
352{ 371{
353 struct fc_rport_identifiers rport_ids; 372 struct fc_rport_identifiers rport_ids;
354 struct fc_rport *rport; 373 struct fc_rport *rport;
355 struct mptfc_rport_info *ri; 374 struct mptfc_rport_info *ri;
356 int match = 0; 375 int new_ri = 1;
357 u64 port_name; 376 u64 pn;
358 unsigned long flags; 377 unsigned long flags;
378 VirtTarget *vtarget;
359 379
360 if (mptfc_generate_rport_ids(pg0, &rport_ids) < 0) 380 if (mptfc_generate_rport_ids(pg0, &rport_ids) < 0)
361 return; 381 return;
@@ -363,14 +383,14 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0)
363 /* scan list looking for a match */ 383 /* scan list looking for a match */
364 spin_lock_irqsave(&ioc->fc_rport_lock, flags); 384 spin_lock_irqsave(&ioc->fc_rport_lock, flags);
365 list_for_each_entry(ri, &ioc->fc_rports, list) { 385 list_for_each_entry(ri, &ioc->fc_rports, list) {
366 port_name = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; 386 pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low;
367 if (port_name == rport_ids.port_name) { /* match */ 387 if (pn == rport_ids.port_name) { /* match */
368 list_move_tail(&ri->list, &ioc->fc_rports); 388 list_move_tail(&ri->list, &ioc->fc_rports);
369 match = 1; 389 new_ri = 0;
370 break; 390 break;
371 } 391 }
372 } 392 }
373 if (!match) { /* allocate one */ 393 if (new_ri) { /* allocate one */
374 spin_unlock_irqrestore(&ioc->fc_rport_lock, flags); 394 spin_unlock_irqrestore(&ioc->fc_rport_lock, flags);
375 ri = kzalloc(sizeof(struct mptfc_rport_info), GFP_KERNEL); 395 ri = kzalloc(sizeof(struct mptfc_rport_info), GFP_KERNEL);
376 if (!ri) 396 if (!ri)
@@ -382,40 +402,43 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0)
382 ri->pg0 = *pg0; /* add/update pg0 data */ 402 ri->pg0 = *pg0; /* add/update pg0 data */
383 ri->flags &= ~MPT_RPORT_INFO_FLAGS_MISSING; 403 ri->flags &= ~MPT_RPORT_INFO_FLAGS_MISSING;
384 404
405 /* MPT_RPORT_INFO_FLAGS_REGISTERED - rport not previously deleted */
385 if (!(ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED)) { 406 if (!(ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED)) {
386 ri->flags |= MPT_RPORT_INFO_FLAGS_REGISTERED; 407 ri->flags |= MPT_RPORT_INFO_FLAGS_REGISTERED;
387 spin_unlock_irqrestore(&ioc->fc_rport_lock, flags); 408 spin_unlock_irqrestore(&ioc->fc_rport_lock, flags);
388 rport = fc_remote_port_add(ioc->sh,channel, &rport_ids); 409 rport = fc_remote_port_add(ioc->sh, channel, &rport_ids);
389 spin_lock_irqsave(&ioc->fc_rport_lock, flags); 410 spin_lock_irqsave(&ioc->fc_rport_lock, flags);
390 if (rport) { 411 if (rport) {
391 if (*((struct mptfc_rport_info **)rport->dd_data) != ri) { 412 ri->rport = rport;
392 ri->flags &= ~MPT_RPORT_INFO_FLAGS_MAPPED_VDEV; 413 if (new_ri) /* may have been reset by user */
393 ri->vdev = NULL; 414 rport->dev_loss_tmo = mptfc_dev_loss_tmo;
394 ri->rport = rport; 415 *((struct mptfc_rport_info **)rport->dd_data) = ri;
395 *((struct mptfc_rport_info **)rport->dd_data) = ri;
396 }
397 rport->dev_loss_tmo = mptfc_dev_loss_tmo;
398 /* 416 /*
399 * if already mapped, remap here. If not mapped, 417 * if already mapped, remap here. If not mapped,
400 * slave_alloc will allocate vdev and map 418 * target_alloc will allocate vtarget and map,
419 * slave_alloc will fill in vdev from vtarget.
401 */ 420 */
402 if (ri->flags & MPT_RPORT_INFO_FLAGS_MAPPED_VDEV) { 421 if (ri->starget) {
403 ri->vdev->target_id = ri->pg0.CurrentTargetID; 422 vtarget = ri->starget->hostdata;
404 ri->vdev->bus_id = ri->pg0.CurrentBus; 423 if (vtarget) {
405 ri->vdev->vtarget->target_id = ri->vdev->target_id; 424 vtarget->target_id = pg0->CurrentTargetID;
406 ri->vdev->vtarget->bus_id = ri->vdev->bus_id; 425 vtarget->bus_id = pg0->CurrentBus;
426 starget_for_each_device(ri->starget,
427 vtarget,mptfc_remap_sdev);
428 }
429 ri->remap_needed = 0;
407 } 430 }
408 #ifdef MPT_DEBUG 431 dfcprintk ((MYIOC_s_INFO_FMT
409 printk ("mptfc_reg_dev.%d: %x, %llx / %llx, tid %d, " 432 "mptfc_reg_dev.%d: %x, %llx / %llx, tid %d, "
410 "rport tid %d, tmo %d\n", 433 "rport tid %d, tmo %d\n",
411 ioc->sh->host_no, 434 ioc->name,
435 oc->sh->host_no,
412 pg0->PortIdentifier, 436 pg0->PortIdentifier,
413 pg0->WWNN, 437 pg0->WWNN,
414 pg0->WWPN, 438 pg0->WWPN,
415 pg0->CurrentTargetID, 439 pg0->CurrentTargetID,
416 ri->rport->scsi_target_id, 440 ri->rport->scsi_target_id,
417 ri->rport->dev_loss_tmo); 441 ri->rport->dev_loss_tmo));
418 #endif
419 } else { 442 } else {
420 list_del(&ri->list); 443 list_del(&ri->list);
421 kfree(ri); 444 kfree(ri);
@@ -427,6 +450,65 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0)
427} 450}
428 451
429/* 452/*
453 * OS entry point to allow for host driver to free allocated memory
454 * Called if no device present or device being unloaded
455 */
456static void
457mptfc_target_destroy(struct scsi_target *starget)
458{
459 struct fc_rport *rport;
460 struct mptfc_rport_info *ri;
461
462 rport = starget_to_rport(starget);
463 if (rport) {
464 ri = *((struct mptfc_rport_info **)rport->dd_data);
465 if (ri) /* better be! */
466 ri->starget = NULL;
467 }
468 if (starget->hostdata)
469 kfree(starget->hostdata);
470 starget->hostdata = NULL;
471}
472
473/*
474 * OS entry point to allow host driver to alloc memory
475 * for each scsi target. Called once per device the bus scan.
476 * Return non-zero if allocation fails.
477 */
478static int
479mptfc_target_alloc(struct scsi_target *starget)
480{
481 VirtTarget *vtarget;
482 struct fc_rport *rport;
483 struct mptfc_rport_info *ri;
484 int rc;
485
486 vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL);
487 if (!vtarget)
488 return -ENOMEM;
489 starget->hostdata = vtarget;
490
491 rc = -ENODEV;
492 rport = starget_to_rport(starget);
493 if (rport) {
494 ri = *((struct mptfc_rport_info **)rport->dd_data);
495 if (ri) { /* better be! */
496 vtarget->target_id = ri->pg0.CurrentTargetID;
497 vtarget->bus_id = ri->pg0.CurrentBus;
498 ri->starget = starget;
499 ri->remap_needed = 0;
500 rc = 0;
501 }
502 }
503 if (rc != 0) {
504 kfree(vtarget);
505 starget->hostdata = NULL;
506 }
507
508 return rc;
509}
510
511/*
430 * OS entry point to allow host driver to alloc memory 512 * OS entry point to allow host driver to alloc memory
431 * for each scsi device. Called once per device the bus scan. 513 * for each scsi device. Called once per device the bus scan.
432 * Return non-zero if allocation fails. 514 * Return non-zero if allocation fails.
@@ -440,7 +522,6 @@ mptfc_slave_alloc(struct scsi_device *sdev)
440 VirtDevice *vdev; 522 VirtDevice *vdev;
441 struct scsi_target *starget; 523 struct scsi_target *starget;
442 struct fc_rport *rport; 524 struct fc_rport *rport;
443 struct mptfc_rport_info *ri;
444 unsigned long flags; 525 unsigned long flags;
445 526
446 527
@@ -451,55 +532,44 @@ mptfc_slave_alloc(struct scsi_device *sdev)
451 532
452 hd = (MPT_SCSI_HOST *)sdev->host->hostdata; 533 hd = (MPT_SCSI_HOST *)sdev->host->hostdata;
453 534
454 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); 535 vdev = kzalloc(sizeof(VirtDevice), GFP_KERNEL);
455 if (!vdev) { 536 if (!vdev) {
456 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", 537 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
457 hd->ioc->name, sizeof(VirtDevice)); 538 hd->ioc->name, sizeof(VirtDevice));
458 return -ENOMEM; 539 return -ENOMEM;
459 } 540 }
460 memset(vdev, 0, sizeof(VirtDevice));
461 541
462 spin_lock_irqsave(&hd->ioc->fc_rport_lock,flags); 542 spin_lock_irqsave(&hd->ioc->fc_rport_lock,flags);
463 543
464 if (!(ri = *((struct mptfc_rport_info **)rport->dd_data))) {
465 spin_unlock_irqrestore(&hd->ioc->fc_rport_lock,flags);
466 kfree(vdev);
467 return -ENODEV;
468 }
469
470 sdev->hostdata = vdev; 544 sdev->hostdata = vdev;
471 starget = scsi_target(sdev); 545 starget = scsi_target(sdev);
472 vtarget = starget->hostdata; 546 vtarget = starget->hostdata;
547
473 if (vtarget->num_luns == 0) { 548 if (vtarget->num_luns == 0) {
549 vtarget->ioc_id = hd->ioc->id;
474 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES | 550 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES |
475 MPT_TARGET_FLAGS_VALID_INQUIRY; 551 MPT_TARGET_FLAGS_VALID_INQUIRY;
476 hd->Targets[sdev->id] = vtarget; 552 hd->Targets[sdev->id] = vtarget;
477 } 553 }
478 554
479 vtarget->target_id = vdev->target_id;
480 vtarget->bus_id = vdev->bus_id;
481
482 vdev->vtarget = vtarget; 555 vdev->vtarget = vtarget;
483 vdev->ioc_id = hd->ioc->id; 556 vdev->ioc_id = hd->ioc->id;
484 vdev->lun = sdev->lun; 557 vdev->lun = sdev->lun;
485 vdev->target_id = ri->pg0.CurrentTargetID; 558 vdev->target_id = vtarget->target_id;
486 vdev->bus_id = ri->pg0.CurrentBus; 559 vdev->bus_id = vtarget->bus_id;
487
488 ri->flags |= MPT_RPORT_INFO_FLAGS_MAPPED_VDEV;
489 ri->vdev = vdev;
490 560
491 spin_unlock_irqrestore(&hd->ioc->fc_rport_lock,flags); 561 spin_unlock_irqrestore(&hd->ioc->fc_rport_lock,flags);
492 562
493 vtarget->num_luns++; 563 vtarget->num_luns++;
494 564
495#ifdef MPT_DEBUG 565 dfcprintk ((MYIOC_s_INFO_FMT
496 printk ("mptfc_slv_alloc.%d: num_luns %d, sdev.id %d, " 566 "mptfc_slv_alloc.%d: num_luns %d, sdev.id %d, "
497 "CurrentTargetID %d, %x %llx %llx\n", 567 "CurrentTargetID %d, %x %llx %llx\n",
498 sdev->host->host_no, 568 ioc->name,
499 vtarget->num_luns, 569 sdev->host->host_no,
500 sdev->id, ri->pg0.CurrentTargetID, 570 vtarget->num_luns,
501 ri->pg0.PortIdentifier, ri->pg0.WWPN, ri->pg0.WWNN); 571 sdev->id, ri->pg0.CurrentTargetID,
502#endif 572 ri->pg0.PortIdentifier, ri->pg0.WWPN, ri->pg0.WWNN));
503 573
504 return 0; 574 return 0;
505} 575}
@@ -507,6 +577,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
507static int 577static int
508mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 578mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
509{ 579{
580 struct mptfc_rport_info *ri;
510 struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); 581 struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device));
511 int err; 582 int err;
512 583
@@ -516,6 +587,10 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
516 done(SCpnt); 587 done(SCpnt);
517 return 0; 588 return 0;
518 } 589 }
590 ri = *((struct mptfc_rport_info **)rport->dd_data);
591 if (unlikely(ri->remap_needed))
592 return SCSI_MLQUEUE_HOST_BUSY;
593
519 return mptscsih_qcmd(SCpnt,done); 594 return mptscsih_qcmd(SCpnt,done);
520} 595}
521 596
@@ -591,16 +666,20 @@ mptfc_rescan_devices(void *arg)
591 666
592 ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED| 667 ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED|
593 MPT_RPORT_INFO_FLAGS_MISSING); 668 MPT_RPORT_INFO_FLAGS_MISSING);
669 ri->remap_needed = 1;
594 fc_remote_port_delete(ri->rport); 670 fc_remote_port_delete(ri->rport);
595 /* 671 /*
596 * remote port not really deleted 'cause 672 * remote port not really deleted 'cause
597 * binding is by WWPN and driver only 673 * binding is by WWPN and driver only
598 * registers FCP_TARGETs 674 * registers FCP_TARGETs but cannot trust
675 * data structures.
599 */ 676 */
600 #ifdef MPT_DEBUG 677 ri->rport = NULL;
601 printk ("mptfc_rescan.%d: %llx deleted\n", 678 dfcprintk ((MYIOC_s_INFO_FMT
602 ioc->sh->host_no, ri->pg0.WWPN); 679 "mptfc_rescan.%d: %llx deleted\n",
603 #endif 680 ioc->name,
681 ioc->sh->host_no,
682 ri->pg0.WWPN));
604 } 683 }
605 } 684 }
606 spin_unlock_irqrestore(&ioc->fc_rport_lock,flags); 685 spin_unlock_irqrestore(&ioc->fc_rport_lock,flags);
@@ -872,9 +951,8 @@ mptfc_init(void)
872 } 951 }
873 952
874 error = pci_register_driver(&mptfc_driver); 953 error = pci_register_driver(&mptfc_driver);
875 if (error) { 954 if (error)
876 fc_release_transport(mptfc_transport_template); 955 fc_release_transport(mptfc_transport_template);
877 }
878 956
879 return error; 957 return error;
880} 958}
@@ -885,7 +963,8 @@ mptfc_init(void)
885 * @pdev: Pointer to pci_dev structure 963 * @pdev: Pointer to pci_dev structure
886 * 964 *
887 */ 965 */
888static void __devexit mptfc_remove(struct pci_dev *pdev) 966static void __devexit
967mptfc_remove(struct pci_dev *pdev)
889{ 968{
890 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 969 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
891 struct mptfc_rport_info *p, *n; 970 struct mptfc_rport_info *p, *n;
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 5a06d8d8694e..2512d0e6155e 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -89,6 +89,8 @@ static int mptsasMgmtCtx = -1;
89enum mptsas_hotplug_action { 89enum mptsas_hotplug_action {
90 MPTSAS_ADD_DEVICE, 90 MPTSAS_ADD_DEVICE,
91 MPTSAS_DEL_DEVICE, 91 MPTSAS_DEL_DEVICE,
92 MPTSAS_ADD_RAID,
93 MPTSAS_DEL_RAID,
92}; 94};
93 95
94struct mptsas_hotplug_event { 96struct mptsas_hotplug_event {
@@ -114,6 +116,7 @@ struct mptsas_hotplug_event {
114 116
115struct mptsas_devinfo { 117struct mptsas_devinfo {
116 u16 handle; /* unique id to address this device */ 118 u16 handle; /* unique id to address this device */
119 u16 handle_parent; /* unique id to address parent device */
117 u8 phy_id; /* phy number of parent device */ 120 u8 phy_id; /* phy number of parent device */
118 u8 port_id; /* sas physical port this device 121 u8 port_id; /* sas physical port this device
119 is assoc'd with */ 122 is assoc'd with */
@@ -301,9 +304,8 @@ mptsas_slave_alloc(struct scsi_device *sdev)
301 } 304 }
302 mutex_unlock(&hd->ioc->sas_topology_mutex); 305 mutex_unlock(&hd->ioc->sas_topology_mutex);
303 306
304 printk("No matching SAS device found!!\n");
305 kfree(vdev); 307 kfree(vdev);
306 return -ENODEV; 308 return -ENXIO;
307 309
308 out: 310 out:
309 vtarget->ioc_id = vdev->ioc_id; 311 vtarget->ioc_id = vdev->ioc_id;
@@ -321,6 +323,7 @@ mptsas_slave_destroy(struct scsi_device *sdev)
321 struct sas_rphy *rphy; 323 struct sas_rphy *rphy;
322 struct mptsas_portinfo *p; 324 struct mptsas_portinfo *p;
323 int i; 325 int i;
326 VirtDevice *vdev;
324 327
325 /* 328 /*
326 * Handle hotplug removal case. 329 * Handle hotplug removal case.
@@ -344,8 +347,29 @@ mptsas_slave_destroy(struct scsi_device *sdev)
344 out: 347 out:
345 mutex_unlock(&hd->ioc->sas_topology_mutex); 348 mutex_unlock(&hd->ioc->sas_topology_mutex);
346 /* 349 /*
347 * TODO: Issue target reset to flush firmware outstanding commands. 350 * Issue target reset to flush firmware outstanding commands.
348 */ 351 */
352 vdev = sdev->hostdata;
353 if (vdev->configured_lun){
354 if (mptscsih_TMHandler(hd,
355 MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
356 vdev->bus_id,
357 vdev->target_id,
358 0, 0, 5 /* 5 second timeout */)
359 < 0){
360
361 /* The TM request failed!
362 * Fatal error case.
363 */
364 printk(MYIOC_s_WARN_FMT
365 "Error processing TaskMgmt id=%d TARGET_RESET\n",
366 hd->ioc->name,
367 vdev->target_id);
368
369 hd->tmPending = 0;
370 hd->tmState = TM_STATE_NONE;
371 }
372 }
349 mptscsih_slave_destroy(sdev); 373 mptscsih_slave_destroy(sdev);
350} 374}
351 375
@@ -714,6 +738,7 @@ mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info,
714 mptsas_print_device_pg0(buffer); 738 mptsas_print_device_pg0(buffer);
715 739
716 device_info->handle = le16_to_cpu(buffer->DevHandle); 740 device_info->handle = le16_to_cpu(buffer->DevHandle);
741 device_info->handle_parent = le16_to_cpu(buffer->ParentDevHandle);
717 device_info->phy_id = buffer->PhyNum; 742 device_info->phy_id = buffer->PhyNum;
718 device_info->port_id = buffer->PhysicalPort; 743 device_info->port_id = buffer->PhysicalPort;
719 device_info->id = buffer->TargetID; 744 device_info->id = buffer->TargetID;
@@ -863,6 +888,26 @@ mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
863 return error; 888 return error;
864} 889}
865 890
891/*
892 * Returns true if there is a scsi end device
893 */
894static inline int
895mptsas_is_end_device(struct mptsas_devinfo * attached)
896{
897 if ((attached->handle) &&
898 (attached->device_info &
899 MPI_SAS_DEVICE_INFO_END_DEVICE) &&
900 ((attached->device_info &
901 MPI_SAS_DEVICE_INFO_SSP_TARGET) |
902 (attached->device_info &
903 MPI_SAS_DEVICE_INFO_STP_TARGET) |
904 (attached->device_info &
905 MPI_SAS_DEVICE_INFO_SATA_DEVICE)))
906 return 1;
907 else
908 return 0;
909}
910
866static void 911static void
867mptsas_parse_device_info(struct sas_identify *identify, 912mptsas_parse_device_info(struct sas_identify *identify,
868 struct mptsas_devinfo *device_info) 913 struct mptsas_devinfo *device_info)
@@ -1227,7 +1272,7 @@ mptsas_find_phyinfo_by_parent(MPT_ADAPTER *ioc, u16 parent_handle, u8 phy_id)
1227} 1272}
1228 1273
1229static struct mptsas_phyinfo * 1274static struct mptsas_phyinfo *
1230mptsas_find_phyinfo_by_handle(MPT_ADAPTER *ioc, u16 handle) 1275mptsas_find_phyinfo_by_target(MPT_ADAPTER *ioc, u32 id)
1231{ 1276{
1232 struct mptsas_portinfo *port_info; 1277 struct mptsas_portinfo *port_info;
1233 struct mptsas_phyinfo *phy_info = NULL; 1278 struct mptsas_phyinfo *phy_info = NULL;
@@ -1239,12 +1284,12 @@ mptsas_find_phyinfo_by_handle(MPT_ADAPTER *ioc, u16 handle)
1239 */ 1284 */
1240 mutex_lock(&ioc->sas_topology_mutex); 1285 mutex_lock(&ioc->sas_topology_mutex);
1241 list_for_each_entry(port_info, &ioc->sas_topology, list) { 1286 list_for_each_entry(port_info, &ioc->sas_topology, list) {
1242 for (i = 0; i < port_info->num_phys; i++) { 1287 for (i = 0; i < port_info->num_phys; i++)
1243 if (port_info->phy_info[i].attached.handle == handle) { 1288 if (mptsas_is_end_device(&port_info->phy_info[i].attached))
1244 phy_info = &port_info->phy_info[i]; 1289 if (port_info->phy_info[i].attached.id == id) {
1245 break; 1290 phy_info = &port_info->phy_info[i];
1246 } 1291 break;
1247 } 1292 }
1248 } 1293 }
1249 mutex_unlock(&ioc->sas_topology_mutex); 1294 mutex_unlock(&ioc->sas_topology_mutex);
1250 1295
@@ -1258,36 +1303,58 @@ mptsas_hotplug_work(void *arg)
1258 MPT_ADAPTER *ioc = ev->ioc; 1303 MPT_ADAPTER *ioc = ev->ioc;
1259 struct mptsas_phyinfo *phy_info; 1304 struct mptsas_phyinfo *phy_info;
1260 struct sas_rphy *rphy; 1305 struct sas_rphy *rphy;
1306 struct scsi_device *sdev;
1261 char *ds = NULL; 1307 char *ds = NULL;
1262 1308 struct mptsas_devinfo sas_device;
1263 if (ev->device_info & MPI_SAS_DEVICE_INFO_SSP_TARGET)
1264 ds = "ssp";
1265 if (ev->device_info & MPI_SAS_DEVICE_INFO_STP_TARGET)
1266 ds = "stp";
1267 if (ev->device_info & MPI_SAS_DEVICE_INFO_SATA_DEVICE)
1268 ds = "sata";
1269 1309
1270 switch (ev->event_type) { 1310 switch (ev->event_type) {
1271 case MPTSAS_DEL_DEVICE: 1311 case MPTSAS_DEL_DEVICE:
1272 printk(MYIOC_s_INFO_FMT
1273 "removing %s device, channel %d, id %d, phy %d\n",
1274 ioc->name, ds, ev->channel, ev->id, ev->phy_id);
1275 1312
1276 phy_info = mptsas_find_phyinfo_by_handle(ioc, ev->handle); 1313 phy_info = mptsas_find_phyinfo_by_target(ioc, ev->id);
1277 if (!phy_info) { 1314 if (!phy_info) {
1278 printk("mptsas: remove event for non-existant PHY.\n"); 1315 printk("mptsas: remove event for non-existant PHY.\n");
1279 break; 1316 break;
1280 } 1317 }
1281 1318
1319 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SSP_TARGET)
1320 ds = "ssp";
1321 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_STP_TARGET)
1322 ds = "stp";
1323 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SATA_DEVICE)
1324 ds = "sata";
1325
1326 printk(MYIOC_s_INFO_FMT
1327 "removing %s device, channel %d, id %d, phy %d\n",
1328 ioc->name, ds, ev->channel, ev->id, phy_info->phy_id);
1329
1282 if (phy_info->rphy) { 1330 if (phy_info->rphy) {
1283 sas_rphy_delete(phy_info->rphy); 1331 sas_rphy_delete(phy_info->rphy);
1284 phy_info->rphy = NULL; 1332 phy_info->rphy = NULL;
1285 } 1333 }
1286 break; 1334 break;
1287 case MPTSAS_ADD_DEVICE: 1335 case MPTSAS_ADD_DEVICE:
1288 printk(MYIOC_s_INFO_FMT 1336
1289 "attaching %s device, channel %d, id %d, phy %d\n", 1337 /*
1290 ioc->name, ds, ev->channel, ev->id, ev->phy_id); 1338 * When there is no sas address,
1339 * RAID volumes are being deleted,
1340 * and hidden phy disk are being added.
1341 * We don't know the SAS data yet,
1342 * so lookup sas device page to get
1343 * pertaining info
1344 */
1345 if (!ev->sas_address) {
1346 if (mptsas_sas_device_pg0(ioc,
1347 &sas_device, ev->id,
1348 (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
1349 MPI_SAS_DEVICE_PGAD_FORM_SHIFT)))
1350 break;
1351 ev->handle = sas_device.handle;
1352 ev->parent_handle = sas_device.handle_parent;
1353 ev->channel = sas_device.channel;
1354 ev->phy_id = sas_device.phy_id;
1355 ev->sas_address = sas_device.sas_address;
1356 ev->device_info = sas_device.device_info;
1357 }
1291 1358
1292 phy_info = mptsas_find_phyinfo_by_parent(ioc, 1359 phy_info = mptsas_find_phyinfo_by_parent(ioc,
1293 ev->parent_handle, ev->phy_id); 1360 ev->parent_handle, ev->phy_id);
@@ -1310,10 +1377,23 @@ mptsas_hotplug_work(void *arg)
1310 phy_info->attached.sas_address = ev->sas_address; 1377 phy_info->attached.sas_address = ev->sas_address;
1311 phy_info->attached.device_info = ev->device_info; 1378 phy_info->attached.device_info = ev->device_info;
1312 1379
1380 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SSP_TARGET)
1381 ds = "ssp";
1382 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_STP_TARGET)
1383 ds = "stp";
1384 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SATA_DEVICE)
1385 ds = "sata";
1386
1387 printk(MYIOC_s_INFO_FMT
1388 "attaching %s device, channel %d, id %d, phy %d\n",
1389 ioc->name, ds, ev->channel, ev->id, ev->phy_id);
1390
1391
1313 rphy = sas_rphy_alloc(phy_info->phy); 1392 rphy = sas_rphy_alloc(phy_info->phy);
1314 if (!rphy) 1393 if (!rphy)
1315 break; /* non-fatal: an rphy can be added later */ 1394 break; /* non-fatal: an rphy can be added later */
1316 1395
1396 rphy->scsi_target_id = phy_info->attached.id;
1317 mptsas_parse_device_info(&rphy->identify, &phy_info->attached); 1397 mptsas_parse_device_info(&rphy->identify, &phy_info->attached);
1318 if (sas_rphy_add(rphy)) { 1398 if (sas_rphy_add(rphy)) {
1319 sas_rphy_free(rphy); 1399 sas_rphy_free(rphy);
@@ -1322,6 +1402,40 @@ mptsas_hotplug_work(void *arg)
1322 1402
1323 phy_info->rphy = rphy; 1403 phy_info->rphy = rphy;
1324 break; 1404 break;
1405 case MPTSAS_ADD_RAID:
1406 sdev = scsi_device_lookup(
1407 ioc->sh,
1408 ioc->num_ports,
1409 ev->id,
1410 0);
1411 if (sdev) {
1412 scsi_device_put(sdev);
1413 break;
1414 }
1415 printk(MYIOC_s_INFO_FMT
1416 "attaching device, channel %d, id %d\n",
1417 ioc->name, ioc->num_ports, ev->id);
1418 scsi_add_device(ioc->sh,
1419 ioc->num_ports,
1420 ev->id,
1421 0);
1422 mpt_findImVolumes(ioc);
1423 break;
1424 case MPTSAS_DEL_RAID:
1425 sdev = scsi_device_lookup(
1426 ioc->sh,
1427 ioc->num_ports,
1428 ev->id,
1429 0);
1430 if (!sdev)
1431 break;
1432 printk(MYIOC_s_INFO_FMT
1433 "removing device, channel %d, id %d\n",
1434 ioc->name, ioc->num_ports, ev->id);
1435 scsi_remove_device(sdev);
1436 scsi_device_put(sdev);
1437 mpt_findImVolumes(ioc);
1438 break;
1325 } 1439 }
1326 1440
1327 kfree(ev); 1441 kfree(ev);
@@ -1372,23 +1486,94 @@ mptscsih_send_sas_event(MPT_ADAPTER *ioc,
1372 schedule_work(&ev->work); 1486 schedule_work(&ev->work);
1373} 1487}
1374 1488
1489static void
1490mptscsih_send_raid_event(MPT_ADAPTER *ioc,
1491 EVENT_DATA_RAID *raid_event_data)
1492{
1493 struct mptsas_hotplug_event *ev;
1494 RAID_VOL0_STATUS * volumeStatus;
1495
1496 if (ioc->bus_type != SAS)
1497 return;
1498
1499 ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
1500 if (!ev) {
1501 printk(KERN_WARNING "mptsas: lost hotplug event\n");
1502 return;
1503 }
1504
1505 memset(ev,0,sizeof(struct mptsas_hotplug_event));
1506 INIT_WORK(&ev->work, mptsas_hotplug_work, ev);
1507 ev->ioc = ioc;
1508 ev->id = raid_event_data->VolumeID;
1509
1510 switch (raid_event_data->ReasonCode) {
1511 case MPI_EVENT_RAID_RC_PHYSDISK_DELETED:
1512 ev->event_type = MPTSAS_ADD_DEVICE;
1513 break;
1514 case MPI_EVENT_RAID_RC_PHYSDISK_CREATED:
1515 ev->event_type = MPTSAS_DEL_DEVICE;
1516 break;
1517 case MPI_EVENT_RAID_RC_VOLUME_DELETED:
1518 ev->event_type = MPTSAS_DEL_RAID;
1519 break;
1520 case MPI_EVENT_RAID_RC_VOLUME_CREATED:
1521 ev->event_type = MPTSAS_ADD_RAID;
1522 break;
1523 case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED:
1524 volumeStatus = (RAID_VOL0_STATUS *) &
1525 raid_event_data->SettingsStatus;
1526 ev->event_type = (volumeStatus->State ==
1527 MPI_RAIDVOL0_STATUS_STATE_FAILED) ?
1528 MPTSAS_DEL_RAID : MPTSAS_ADD_RAID;
1529 break;
1530 default:
1531 break;
1532 }
1533 schedule_work(&ev->work);
1534}
1535
1536/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1537/* work queue thread to clear the persitency table */
1538static void
1539mptscsih_sas_persist_clear_table(void * arg)
1540{
1541 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;
1542
1543 mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT);
1544}
1545
1375static int 1546static int
1376mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply) 1547mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
1377{ 1548{
1549 int rc=1;
1378 u8 event = le32_to_cpu(reply->Event) & 0xFF; 1550 u8 event = le32_to_cpu(reply->Event) & 0xFF;
1379 1551
1380 if (!ioc->sh) 1552 if (!ioc->sh)
1381 return 1; 1553 goto out;
1382 1554
1383 switch (event) { 1555 switch (event) {
1384 case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE: 1556 case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
1385 mptscsih_send_sas_event(ioc, 1557 mptscsih_send_sas_event(ioc,
1386 (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data); 1558 (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data);
1387 return 1; /* currently means nothing really */ 1559 break;
1388 1560 case MPI_EVENT_INTEGRATED_RAID:
1561 mptscsih_send_raid_event(ioc,
1562 (EVENT_DATA_RAID *)reply->Data);
1563 break;
1564 case MPI_EVENT_PERSISTENT_TABLE_FULL:
1565 INIT_WORK(&ioc->mptscsih_persistTask,
1566 mptscsih_sas_persist_clear_table,
1567 (void *)ioc);
1568 schedule_work(&ioc->mptscsih_persistTask);
1569 break;
1389 default: 1570 default:
1390 return mptscsih_event_process(ioc, reply); 1571 rc = mptscsih_event_process(ioc, reply);
1572 break;
1391 } 1573 }
1574 out:
1575
1576 return rc;
1392} 1577}
1393 1578
1394static int 1579static int
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index cdac5578fdf2..05789e505464 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -144,7 +144,6 @@ static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd);
144static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ); 144static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout );
145static u32 SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc); 145static u32 SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc);
146 146
147static int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout);
148static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout); 147static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout);
149 148
150int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset); 149int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
@@ -159,11 +158,9 @@ static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus);
159int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); 158int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
160static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); 159static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd);
161static void mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice); 160static void mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice);
162static void mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget); 161static void mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtDevice *vdevice);
163static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id); 162static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id);
164 163
165static struct work_struct mptscsih_persistTask;
166
167#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 164#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
168static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io); 165static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io);
169static void mptscsih_domainValidation(void *hd); 166static void mptscsih_domainValidation(void *hd);
@@ -563,11 +560,24 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
563 MPT_SCSI_HOST *hd; 560 MPT_SCSI_HOST *hd;
564 SCSIIORequest_t *pScsiReq; 561 SCSIIORequest_t *pScsiReq;
565 SCSIIOReply_t *pScsiReply; 562 SCSIIOReply_t *pScsiReply;
566 u16 req_idx; 563 u16 req_idx, req_idx_MR;
567 564
568 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; 565 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
569 566
570 req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); 567 req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
568 req_idx_MR = (mr != NULL) ?
569 le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx) : req_idx;
570 if ((req_idx != req_idx_MR) ||
571 (mf->u.frame.linkage.arg1 == 0xdeadbeaf)) {
572 printk(MYIOC_s_ERR_FMT "Received a mf that was already freed\n",
573 ioc->name);
574 printk (MYIOC_s_ERR_FMT
575 "req_idx=%x req_idx_MR=%x mf=%p mr=%p sc=%p\n",
576 ioc->name, req_idx, req_idx_MR, mf, mr,
577 hd->ScsiLookup[req_idx_MR]);
578 return 0;
579 }
580
571 sc = hd->ScsiLookup[req_idx]; 581 sc = hd->ScsiLookup[req_idx];
572 if (sc == NULL) { 582 if (sc == NULL) {
573 MPIHeader_t *hdr = (MPIHeader_t *)mf; 583 MPIHeader_t *hdr = (MPIHeader_t *)mf;
@@ -730,6 +740,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
730 740
731 break; 741 break;
732 742
743 case MPI_IOCSTATUS_SCSI_DATA_OVERRUN: /* 0x0044 */
744 sc->resid=0;
733 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */ 745 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */
734 case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */ 746 case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */
735 if (scsi_status == MPI_SCSI_STATUS_BUSY) 747 if (scsi_status == MPI_SCSI_STATUS_BUSY)
@@ -789,7 +801,6 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
789 case MPI_IOCSTATUS_INSUFFICIENT_RESOURCES: /* 0x0006 */ 801 case MPI_IOCSTATUS_INSUFFICIENT_RESOURCES: /* 0x0006 */
790 case MPI_IOCSTATUS_INVALID_FIELD: /* 0x0007 */ 802 case MPI_IOCSTATUS_INVALID_FIELD: /* 0x0007 */
791 case MPI_IOCSTATUS_INVALID_STATE: /* 0x0008 */ 803 case MPI_IOCSTATUS_INVALID_STATE: /* 0x0008 */
792 case MPI_IOCSTATUS_SCSI_DATA_OVERRUN: /* 0x0044 */
793 case MPI_IOCSTATUS_SCSI_IO_DATA_ERROR: /* 0x0046 */ 804 case MPI_IOCSTATUS_SCSI_IO_DATA_ERROR: /* 0x0046 */
794 case MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED: /* 0x004A */ 805 case MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED: /* 0x004A */
795 default: 806 default:
@@ -1530,7 +1541,7 @@ mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx)
1530 * 1541 *
1531 * Returns 0 for SUCCESS or -1 if FAILED. 1542 * Returns 0 for SUCCESS or -1 if FAILED.
1532 */ 1543 */
1533static int 1544int
1534mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout) 1545mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout)
1535{ 1546{
1536 MPT_ADAPTER *ioc; 1547 MPT_ADAPTER *ioc;
@@ -1721,6 +1732,20 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun
1721 return retval; 1732 return retval;
1722} 1733}
1723 1734
1735static int
1736mptscsih_get_tm_timeout(MPT_ADAPTER *ioc)
1737{
1738 switch (ioc->bus_type) {
1739 case FC:
1740 return 40;
1741 case SAS:
1742 return 10;
1743 case SPI:
1744 default:
1745 return 2;
1746 }
1747}
1748
1724/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1749/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1725/** 1750/**
1726 * mptscsih_abort - Abort linux scsi_cmnd routine, new_eh variant 1751 * mptscsih_abort - Abort linux scsi_cmnd routine, new_eh variant
@@ -1792,7 +1817,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1792 vdev = SCpnt->device->hostdata; 1817 vdev = SCpnt->device->hostdata;
1793 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, 1818 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
1794 vdev->bus_id, vdev->target_id, vdev->lun, 1819 vdev->bus_id, vdev->target_id, vdev->lun,
1795 ctx2abort, 2 /* 2 second timeout */); 1820 ctx2abort, mptscsih_get_tm_timeout(ioc));
1796 1821
1797 printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n", 1822 printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n",
1798 hd->ioc->name, 1823 hd->ioc->name,
@@ -1843,7 +1868,7 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1843 vdev = SCpnt->device->hostdata; 1868 vdev = SCpnt->device->hostdata;
1844 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 1869 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
1845 vdev->bus_id, vdev->target_id, 1870 vdev->bus_id, vdev->target_id,
1846 0, 0, 5 /* 5 second timeout */); 1871 0, 0, mptscsih_get_tm_timeout(hd->ioc));
1847 1872
1848 printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n", 1873 printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n",
1849 hd->ioc->name, 1874 hd->ioc->name,
@@ -1893,7 +1918,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1893 1918
1894 vdev = SCpnt->device->hostdata; 1919 vdev = SCpnt->device->hostdata;
1895 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, 1920 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
1896 vdev->bus_id, 0, 0, 0, 5 /* 5 second timeout */); 1921 vdev->bus_id, 0, 0, 0, mptscsih_get_tm_timeout(hd->ioc));
1897 1922
1898 printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n", 1923 printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n",
1899 hd->ioc->name, 1924 hd->ioc->name,
@@ -2016,6 +2041,42 @@ mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout )
2016} 2041}
2017 2042
2018/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2043/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2044static void
2045mptscsih_taskmgmt_response_code(MPT_ADAPTER *ioc, u8 response_code)
2046{
2047 char *desc;
2048
2049 switch (response_code) {
2050 case MPI_SCSITASKMGMT_RSP_TM_COMPLETE:
2051 desc = "The task completed.";
2052 break;
2053 case MPI_SCSITASKMGMT_RSP_INVALID_FRAME:
2054 desc = "The IOC received an invalid frame status.";
2055 break;
2056 case MPI_SCSITASKMGMT_RSP_TM_NOT_SUPPORTED:
2057 desc = "The task type is not supported.";
2058 break;
2059 case MPI_SCSITASKMGMT_RSP_TM_FAILED:
2060 desc = "The requested task failed.";
2061 break;
2062 case MPI_SCSITASKMGMT_RSP_TM_SUCCEEDED:
2063 desc = "The task completed successfully.";
2064 break;
2065 case MPI_SCSITASKMGMT_RSP_TM_INVALID_LUN:
2066 desc = "The LUN request is invalid.";
2067 break;
2068 case MPI_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC:
2069 desc = "The task is in the IOC queue and has not been sent to target.";
2070 break;
2071 default:
2072 desc = "unknown";
2073 break;
2074 }
2075 printk(MYIOC_s_INFO_FMT "Response Code(0x%08x): F/W: %s\n",
2076 ioc->name, response_code, desc);
2077}
2078
2079/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2019/** 2080/**
2020 * mptscsih_taskmgmt_complete - Registered with Fusion MPT base driver 2081 * mptscsih_taskmgmt_complete - Registered with Fusion MPT base driver
2021 * @ioc: Pointer to MPT_ADAPTER structure 2082 * @ioc: Pointer to MPT_ADAPTER structure
@@ -2064,6 +2125,11 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
2064 /* Figure out if this was ABORT_TASK, TARGET_RESET, or BUS_RESET! */ 2125 /* Figure out if this was ABORT_TASK, TARGET_RESET, or BUS_RESET! */
2065 tmType = pScsiTmReq->TaskType; 2126 tmType = pScsiTmReq->TaskType;
2066 2127
2128 if (ioc->facts.MsgVersion >= MPI_VERSION_01_05 &&
2129 pScsiTmReply->ResponseCode)
2130 mptscsih_taskmgmt_response_code(ioc,
2131 pScsiTmReply->ResponseCode);
2132
2067 dtmprintk((MYIOC_s_WARN_FMT " TaskType = %d, TerminationCount=%d\n", 2133 dtmprintk((MYIOC_s_WARN_FMT " TaskType = %d, TerminationCount=%d\n",
2068 ioc->name, tmType, le32_to_cpu(pScsiTmReply->TerminationCount))); 2134 ioc->name, tmType, le32_to_cpu(pScsiTmReply->TerminationCount)));
2069 DBG_DUMP_TM_REPLY_FRAME((u32 *)pScsiTmReply); 2135 DBG_DUMP_TM_REPLY_FRAME((u32 *)pScsiTmReply);
@@ -2255,7 +2321,7 @@ mptscsih_slave_destroy(struct scsi_device *sdev)
2255 vtarget->luns[0] &= ~(1 << vdevice->lun); 2321 vtarget->luns[0] &= ~(1 << vdevice->lun);
2256 vtarget->num_luns--; 2322 vtarget->num_luns--;
2257 if (vtarget->num_luns == 0) { 2323 if (vtarget->num_luns == 0) {
2258 mptscsih_negotiate_to_asyn_narrow(hd, vtarget); 2324 mptscsih_negotiate_to_asyn_narrow(hd, vdevice);
2259 if (hd->ioc->bus_type == SPI) { 2325 if (hd->ioc->bus_type == SPI) {
2260 if (mptscsih_is_phys_disk(hd->ioc, vtarget->target_id)) { 2326 if (mptscsih_is_phys_disk(hd->ioc, vtarget->target_id)) {
2261 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; 2327 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
@@ -2585,16 +2651,6 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2585} 2651}
2586 2652
2587/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2653/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2588/* work queue thread to clear the persitency table */
2589static void
2590mptscsih_sas_persist_clear_table(void * arg)
2591{
2592 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;
2593
2594 mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT);
2595}
2596
2597/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2598int 2654int
2599mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) 2655mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2600{ 2656{
@@ -2656,13 +2712,6 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2656 break; 2712 break;
2657 } 2713 }
2658 2714
2659 /* Persistent table is full. */
2660 case MPI_EVENT_PERSISTENT_TABLE_FULL:
2661 INIT_WORK(&mptscsih_persistTask,
2662 mptscsih_sas_persist_clear_table,(void *)ioc);
2663 schedule_work(&mptscsih_persistTask);
2664 break;
2665
2666 case MPI_EVENT_NONE: /* 00 */ 2715 case MPI_EVENT_NONE: /* 00 */
2667 case MPI_EVENT_LOG_DATA: /* 01 */ 2716 case MPI_EVENT_LOG_DATA: /* 01 */
2668 case MPI_EVENT_STATE_CHANGE: /* 02 */ 2717 case MPI_EVENT_STATE_CHANGE: /* 02 */
@@ -3863,8 +3912,9 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3863 * 3912 *
3864 */ 3913 */
3865static void 3914static void
3866mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget) 3915mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
3867{ 3916{
3917 VirtTarget *vtarget = vdevice->vtarget;
3868 MPT_ADAPTER *ioc= hd->ioc; 3918 MPT_ADAPTER *ioc= hd->ioc;
3869 SCSIDevicePage1_t *pcfg1Data; 3919 SCSIDevicePage1_t *pcfg1Data;
3870 CONFIGPARMS cfg; 3920 CONFIGPARMS cfg;
@@ -3874,7 +3924,8 @@ mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget)
3874 int requested, configuration, data,i; 3924 int requested, configuration, data,i;
3875 u8 flags, factor; 3925 u8 flags, factor;
3876 3926
3877 if (ioc->bus_type != SPI) 3927 if ((ioc->bus_type != SPI) ||
3928 (!vdevice->configured_lun))
3878 return; 3929 return;
3879 3930
3880 if (!ioc->spi_data.sdp1length) 3931 if (!ioc->spi_data.sdp1length)
@@ -3910,7 +3961,7 @@ mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget)
3910 } 3961 }
3911 mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested, 3962 mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested,
3912 &configuration, flags); 3963 &configuration, flags);
3913 dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC " 3964 dnegoprintk(("nego asyn narrow: id=%d width=0 factor=MPT_ASYNC "
3914 "offset=0 negoFlags=%x request=%x config=%x\n", 3965 "offset=0 negoFlags=%x request=%x config=%x\n",
3915 id, flags, requested, configuration)); 3966 id, flags, requested, configuration));
3916 pcfg1Data->RequestedParameters = cpu_to_le32(requested); 3967 pcfg1Data->RequestedParameters = cpu_to_le32(requested);
@@ -3923,7 +3974,7 @@ mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget)
3923 flags = vtarget->negoFlags; 3974 flags = vtarget->negoFlags;
3924 mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested, 3975 mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested,
3925 &configuration, flags); 3976 &configuration, flags);
3926 dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC " 3977 dnegoprintk(("nego asyn narrow: id=%d width=0 factor=MPT_ASYNC "
3927 "offset=0 negoFlags=%x request=%x config=%x\n", 3978 "offset=0 negoFlags=%x request=%x config=%x\n",
3928 vtarget->target_id, flags, requested, configuration)); 3979 vtarget->target_id, flags, requested, configuration));
3929 pcfg1Data->RequestedParameters = cpu_to_le32(requested); 3980 pcfg1Data->RequestedParameters = cpu_to_le32(requested);
@@ -5620,5 +5671,6 @@ EXPORT_SYMBOL(mptscsih_event_process);
5620EXPORT_SYMBOL(mptscsih_ioc_reset); 5671EXPORT_SYMBOL(mptscsih_ioc_reset);
5621EXPORT_SYMBOL(mptscsih_change_queue_depth); 5672EXPORT_SYMBOL(mptscsih_change_queue_depth);
5622EXPORT_SYMBOL(mptscsih_timer_expired); 5673EXPORT_SYMBOL(mptscsih_timer_expired);
5674EXPORT_SYMBOL(mptscsih_TMHandler);
5623 5675
5624/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5676/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index d3cba12f4bd9..44b248d51ea3 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -108,3 +108,4 @@ extern int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pE
108extern int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset); 108extern int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
109extern int mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth); 109extern int mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth);
110extern void mptscsih_timer_expired(unsigned long data); 110extern void mptscsih_timer_expired(unsigned long data);
111extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout);
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 7dce29277cb7..f148dfa39117 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -384,6 +384,14 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
384 goto out_mptspi_probe; 384 goto out_mptspi_probe;
385 } 385 }
386 386
387 /*
388 * issue internal bus reset
389 */
390 if (ioc->spi_data.bus_reset)
391 mptscsih_TMHandler(hd,
392 MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
393 0, 0, 0, 0, 5);
394
387 scsi_scan_host(sh); 395 scsi_scan_host(sh);
388 return 0; 396 return 0;
389 397
@@ -445,7 +453,7 @@ static void __exit
445mptspi_exit(void) 453mptspi_exit(void)
446{ 454{
447 pci_unregister_driver(&mptspi_driver); 455 pci_unregister_driver(&mptspi_driver);
448 456
449 mpt_reset_deregister(mptspiDoneCtx); 457 mpt_reset_deregister(mptspiDoneCtx);
450 dprintk((KERN_INFO MYNAM 458 dprintk((KERN_INFO MYNAM
451 ": Deregistered for IOC reset notifications\n")); 459 ": Deregistered for IOC reset notifications\n"));
diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h
index 90628562851e..184974cc734d 100644
--- a/drivers/message/i2o/core.h
+++ b/drivers/message/i2o/core.h
@@ -60,4 +60,7 @@ extern void i2o_iop_remove(struct i2o_controller *);
60#define I2O_IN_PORT 0x40 60#define I2O_IN_PORT 0x40
61#define I2O_OUT_PORT 0x44 61#define I2O_OUT_PORT 0x44
62 62
63/* Motorola/Freescale specific register offset */
64#define I2O_MOTOROLA_PORT_OFFSET 0x10400
65
63#define I2O_IRQ_OUTBOUND_POST 0x00000008 66#define I2O_IRQ_OUTBOUND_POST 0x00000008
diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c
index f9e5a23697a1..c08ddac3717d 100644
--- a/drivers/message/i2o/i2o_scsi.c
+++ b/drivers/message/i2o/i2o_scsi.c
@@ -732,7 +732,7 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
732 cpu_to_le32(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid); 732 cpu_to_le32(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid);
733 msg->body[0] = cpu_to_le32(i2o_cntxt_list_get_ptr(c, SCpnt)); 733 msg->body[0] = cpu_to_le32(i2o_cntxt_list_get_ptr(c, SCpnt));
734 734
735 if (i2o_msg_post_wait(c, msg, I2O_TIMEOUT_SCSI_SCB_ABORT)) 735 if (!i2o_msg_post_wait(c, msg, I2O_TIMEOUT_SCSI_SCB_ABORT))
736 status = SUCCESS; 736 status = SUCCESS;
737 737
738 return status; 738 return status;
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index d698d7709c31..4f1515cae5dc 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -88,6 +88,11 @@ static int __devinit i2o_pci_alloc(struct i2o_controller *c)
88 struct device *dev = &pdev->dev; 88 struct device *dev = &pdev->dev;
89 int i; 89 int i;
90 90
91 if (pci_request_regions(pdev, OSM_DESCRIPTION)) {
92 printk(KERN_ERR "%s: device already claimed\n", c->name);
93 return -ENODEV;
94 }
95
91 for (i = 0; i < 6; i++) { 96 for (i = 0; i < 6; i++) {
92 /* Skip I/O spaces */ 97 /* Skip I/O spaces */
93 if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) { 98 if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
@@ -163,6 +168,24 @@ static int __devinit i2o_pci_alloc(struct i2o_controller *c)
163 c->in_port = c->base.virt + I2O_IN_PORT; 168 c->in_port = c->base.virt + I2O_IN_PORT;
164 c->out_port = c->base.virt + I2O_OUT_PORT; 169 c->out_port = c->base.virt + I2O_OUT_PORT;
165 170
171 /* Motorola/Freescale chip does not follow spec */
172 if (pdev->vendor == PCI_VENDOR_ID_MOTOROLA && pdev->device == 0x18c0) {
173 /* Check if CPU is enabled */
174 if (be32_to_cpu(readl(c->base.virt + 0x10000)) & 0x10000000) {
175 printk(KERN_INFO "%s: MPC82XX needs CPU running to "
176 "service I2O.\n", c->name);
177 i2o_pci_free(c);
178 return -ENODEV;
179 } else {
180 c->irq_status += I2O_MOTOROLA_PORT_OFFSET;
181 c->irq_mask += I2O_MOTOROLA_PORT_OFFSET;
182 c->in_port += I2O_MOTOROLA_PORT_OFFSET;
183 c->out_port += I2O_MOTOROLA_PORT_OFFSET;
184 printk(KERN_INFO "%s: MPC82XX workarounds activated.\n",
185 c->name);
186 }
187 }
188
166 if (i2o_dma_alloc(dev, &c->status, 8, GFP_KERNEL)) { 189 if (i2o_dma_alloc(dev, &c->status, 8, GFP_KERNEL)) {
167 i2o_pci_free(c); 190 i2o_pci_free(c);
168 return -ENOMEM; 191 return -ENOMEM;
@@ -298,7 +321,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
298 struct i2o_controller *c; 321 struct i2o_controller *c;
299 int rc; 322 int rc;
300 struct pci_dev *i960 = NULL; 323 struct pci_dev *i960 = NULL;
301 int pci_dev_busy = 0; 324 int enabled = pdev->is_enabled;
302 325
303 printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n"); 326 printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n");
304 327
@@ -308,16 +331,12 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
308 return -ENODEV; 331 return -ENODEV;
309 } 332 }
310 333
311 if ((rc = pci_enable_device(pdev))) { 334 if (!enabled)
312 printk(KERN_WARNING "i2o: couldn't enable device %s\n", 335 if ((rc = pci_enable_device(pdev))) {
313 pci_name(pdev)); 336 printk(KERN_WARNING "i2o: couldn't enable device %s\n",
314 return rc; 337 pci_name(pdev));
315 } 338 return rc;
316 339 }
317 if (pci_request_regions(pdev, OSM_DESCRIPTION)) {
318 printk(KERN_ERR "i2o: device already claimed\n");
319 return -ENODEV;
320 }
321 340
322 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 341 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
323 printk(KERN_WARNING "i2o: no suitable DMA found for %s\n", 342 printk(KERN_WARNING "i2o: no suitable DMA found for %s\n",
@@ -395,9 +414,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
395 414
396 if ((rc = i2o_pci_alloc(c))) { 415 if ((rc = i2o_pci_alloc(c))) {
397 printk(KERN_ERR "%s: DMA / IO allocation for I2O controller " 416 printk(KERN_ERR "%s: DMA / IO allocation for I2O controller "
398 " failed\n", c->name); 417 "failed\n", c->name);
399 if (rc == -ENODEV)
400 pci_dev_busy = 1;
401 goto free_controller; 418 goto free_controller;
402 } 419 }
403 420
@@ -425,7 +442,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
425 i2o_iop_free(c); 442 i2o_iop_free(c);
426 443
427 disable: 444 disable:
428 if (!pci_dev_busy) 445 if (!enabled)
429 pci_disable_device(pdev); 446 pci_disable_device(pdev);
430 447
431 return rc; 448 return rc;
diff --git a/drivers/misc/ibmasm/uart.c b/drivers/misc/ibmasm/uart.c
index 7e98434cfa37..9783caf49696 100644
--- a/drivers/misc/ibmasm/uart.c
+++ b/drivers/misc/ibmasm/uart.c
@@ -50,7 +50,7 @@ void ibmasm_register_uart(struct service_processor *sp)
50 memset(&uport, 0, sizeof(struct uart_port)); 50 memset(&uport, 0, sizeof(struct uart_port));
51 uport.irq = sp->irq; 51 uport.irq = sp->irq;
52 uport.uartclk = 3686400; 52 uport.uartclk = 3686400;
53 uport.flags = UPF_AUTOPROBE | UPF_SHARE_IRQ; 53 uport.flags = UPF_SHARE_IRQ;
54 uport.iotype = UPIO_MEM; 54 uport.iotype = UPIO_MEM;
55 uport.membase = iomem_base; 55 uport.membase = iomem_base;
56 56
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c
index aaf04638054e..227c39a7c1b4 100644
--- a/drivers/mmc/au1xmmc.c
+++ b/drivers/mmc/au1xmmc.c
@@ -194,7 +194,7 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait,
194 194
195 u32 mmccmd = (cmd->opcode << SD_CMD_CI_SHIFT); 195 u32 mmccmd = (cmd->opcode << SD_CMD_CI_SHIFT);
196 196
197 switch(cmd->flags) { 197 switch (mmc_rsp_type(cmd->flags)) {
198 case MMC_RSP_R1: 198 case MMC_RSP_R1:
199 mmccmd |= SD_CMD_RT_1; 199 mmccmd |= SD_CMD_RT_1;
200 break; 200 break;
@@ -483,34 +483,35 @@ static void au1xmmc_cmd_complete(struct au1xmmc_host *host, u32 status)
483 cmd = mrq->cmd; 483 cmd = mrq->cmd;
484 cmd->error = MMC_ERR_NONE; 484 cmd->error = MMC_ERR_NONE;
485 485
486 if ((cmd->flags & MMC_RSP_MASK) == MMC_RSP_SHORT) { 486 if (cmd->flags & MMC_RSP_PRESENT) {
487 487 if (cmd->flags & MMC_RSP_136) {
488 /* Techincally, we should be getting all 48 bits of the response 488 u32 r[4];
489 * (SD_RESP1 + SD_RESP2), but because our response omits the CRC, 489 int i;
490 * our data ends up being shifted 8 bits to the right. In this case, 490
491 * that means that the OSR data starts at bit 31, so we can just 491 r[0] = au_readl(host->iobase + SD_RESP3);
492 * read RESP0 and return that 492 r[1] = au_readl(host->iobase + SD_RESP2);
493 */ 493 r[2] = au_readl(host->iobase + SD_RESP1);
494 494 r[3] = au_readl(host->iobase + SD_RESP0);
495 cmd->resp[0] = au_readl(host->iobase + SD_RESP0); 495
496 } 496 /* The CRC is omitted from the response, so really
497 else if ((cmd->flags & MMC_RSP_MASK) == MMC_RSP_LONG) { 497 * we only got 120 bytes, but the engine expects
498 u32 r[4]; 498 * 128 bits, so we have to shift things up
499 int i; 499 */
500 500
501 r[0] = au_readl(host->iobase + SD_RESP3); 501 for(i = 0; i < 4; i++) {
502 r[1] = au_readl(host->iobase + SD_RESP2); 502 cmd->resp[i] = (r[i] & 0x00FFFFFF) << 8;
503 r[2] = au_readl(host->iobase + SD_RESP1); 503 if (i != 3)
504 r[3] = au_readl(host->iobase + SD_RESP0); 504 cmd->resp[i] |= (r[i + 1] & 0xFF000000) >> 24;
505 505 }
506 /* The CRC is omitted from the response, so really we only got 506 } else {
507 * 120 bytes, but the engine expects 128 bits, so we have to shift 507 /* Techincally, we should be getting all 48 bits of
508 * things up 508 * the response (SD_RESP1 + SD_RESP2), but because
509 */ 509 * our response omits the CRC, our data ends up
510 510 * being shifted 8 bits to the right. In this case,
511 for(i = 0; i < 4; i++) { 511 * that means that the OSR data starts at bit 31,
512 cmd->resp[i] = (r[i] & 0x00FFFFFF) << 8; 512 * so we can just read RESP0 and return that
513 if (i != 3) cmd->resp[i] |= (r[i + 1] & 0xFF000000) >> 24; 513 */
514 cmd->resp[0] = au_readl(host->iobase + SD_RESP0);
514 } 515 }
515 } 516 }
516 517
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index bfca5c176e88..1888060c5e0c 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -211,7 +211,7 @@ int mmc_wait_for_app_cmd(struct mmc_host *host, unsigned int rca,
211 211
212 appcmd.opcode = MMC_APP_CMD; 212 appcmd.opcode = MMC_APP_CMD;
213 appcmd.arg = rca << 16; 213 appcmd.arg = rca << 16;
214 appcmd.flags = MMC_RSP_R1; 214 appcmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
215 appcmd.retries = 0; 215 appcmd.retries = 0;
216 memset(appcmd.resp, 0, sizeof(appcmd.resp)); 216 memset(appcmd.resp, 0, sizeof(appcmd.resp));
217 appcmd.data = NULL; 217 appcmd.data = NULL;
@@ -331,7 +331,7 @@ static int mmc_select_card(struct mmc_host *host, struct mmc_card *card)
331 331
332 cmd.opcode = MMC_SELECT_CARD; 332 cmd.opcode = MMC_SELECT_CARD;
333 cmd.arg = card->rca << 16; 333 cmd.arg = card->rca << 16;
334 cmd.flags = MMC_RSP_R1; 334 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
335 335
336 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES); 336 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
337 if (err != MMC_ERR_NONE) 337 if (err != MMC_ERR_NONE)
@@ -358,7 +358,7 @@ static int mmc_select_card(struct mmc_host *host, struct mmc_card *card)
358 struct mmc_command cmd; 358 struct mmc_command cmd;
359 cmd.opcode = SD_APP_SET_BUS_WIDTH; 359 cmd.opcode = SD_APP_SET_BUS_WIDTH;
360 cmd.arg = SD_BUS_WIDTH_4; 360 cmd.arg = SD_BUS_WIDTH_4;
361 cmd.flags = MMC_RSP_R1; 361 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
362 362
363 err = mmc_wait_for_app_cmd(host, card->rca, &cmd, 363 err = mmc_wait_for_app_cmd(host, card->rca, &cmd,
364 CMD_RETRIES); 364 CMD_RETRIES);
@@ -386,7 +386,7 @@ static void mmc_deselect_cards(struct mmc_host *host)
386 386
387 cmd.opcode = MMC_SELECT_CARD; 387 cmd.opcode = MMC_SELECT_CARD;
388 cmd.arg = 0; 388 cmd.arg = 0;
389 cmd.flags = MMC_RSP_NONE; 389 cmd.flags = MMC_RSP_NONE | MMC_CMD_AC;
390 390
391 mmc_wait_for_cmd(host, &cmd, 0); 391 mmc_wait_for_cmd(host, &cmd, 0);
392 } 392 }
@@ -677,7 +677,7 @@ static void mmc_idle_cards(struct mmc_host *host)
677 677
678 cmd.opcode = MMC_GO_IDLE_STATE; 678 cmd.opcode = MMC_GO_IDLE_STATE;
679 cmd.arg = 0; 679 cmd.arg = 0;
680 cmd.flags = MMC_RSP_NONE; 680 cmd.flags = MMC_RSP_NONE | MMC_CMD_BC;
681 681
682 mmc_wait_for_cmd(host, &cmd, 0); 682 mmc_wait_for_cmd(host, &cmd, 0);
683 683
@@ -738,7 +738,7 @@ static int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
738 738
739 cmd.opcode = MMC_SEND_OP_COND; 739 cmd.opcode = MMC_SEND_OP_COND;
740 cmd.arg = ocr; 740 cmd.arg = ocr;
741 cmd.flags = MMC_RSP_R3; 741 cmd.flags = MMC_RSP_R3 | MMC_CMD_BCR;
742 742
743 for (i = 100; i; i--) { 743 for (i = 100; i; i--) {
744 err = mmc_wait_for_cmd(host, &cmd, 0); 744 err = mmc_wait_for_cmd(host, &cmd, 0);
@@ -766,7 +766,7 @@ static int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
766 766
767 cmd.opcode = SD_APP_OP_COND; 767 cmd.opcode = SD_APP_OP_COND;
768 cmd.arg = ocr; 768 cmd.arg = ocr;
769 cmd.flags = MMC_RSP_R3; 769 cmd.flags = MMC_RSP_R3 | MMC_CMD_BCR;
770 770
771 for (i = 100; i; i--) { 771 for (i = 100; i; i--) {
772 err = mmc_wait_for_app_cmd(host, 0, &cmd, CMD_RETRIES); 772 err = mmc_wait_for_app_cmd(host, 0, &cmd, CMD_RETRIES);
@@ -805,7 +805,7 @@ static void mmc_discover_cards(struct mmc_host *host)
805 805
806 cmd.opcode = MMC_ALL_SEND_CID; 806 cmd.opcode = MMC_ALL_SEND_CID;
807 cmd.arg = 0; 807 cmd.arg = 0;
808 cmd.flags = MMC_RSP_R2; 808 cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
809 809
810 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES); 810 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
811 if (err == MMC_ERR_TIMEOUT) { 811 if (err == MMC_ERR_TIMEOUT) {
@@ -835,7 +835,7 @@ static void mmc_discover_cards(struct mmc_host *host)
835 835
836 cmd.opcode = SD_SEND_RELATIVE_ADDR; 836 cmd.opcode = SD_SEND_RELATIVE_ADDR;
837 cmd.arg = 0; 837 cmd.arg = 0;
838 cmd.flags = MMC_RSP_R6; 838 cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR;
839 839
840 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES); 840 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
841 if (err != MMC_ERR_NONE) 841 if (err != MMC_ERR_NONE)
@@ -856,7 +856,7 @@ static void mmc_discover_cards(struct mmc_host *host)
856 } else { 856 } else {
857 cmd.opcode = MMC_SET_RELATIVE_ADDR; 857 cmd.opcode = MMC_SET_RELATIVE_ADDR;
858 cmd.arg = card->rca << 16; 858 cmd.arg = card->rca << 16;
859 cmd.flags = MMC_RSP_R1; 859 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
860 860
861 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES); 861 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
862 if (err != MMC_ERR_NONE) 862 if (err != MMC_ERR_NONE)
@@ -878,7 +878,7 @@ static void mmc_read_csds(struct mmc_host *host)
878 878
879 cmd.opcode = MMC_SEND_CSD; 879 cmd.opcode = MMC_SEND_CSD;
880 cmd.arg = card->rca << 16; 880 cmd.arg = card->rca << 16;
881 cmd.flags = MMC_RSP_R2; 881 cmd.flags = MMC_RSP_R2 | MMC_CMD_AC;
882 882
883 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES); 883 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
884 if (err != MMC_ERR_NONE) { 884 if (err != MMC_ERR_NONE) {
@@ -920,7 +920,7 @@ static void mmc_read_scrs(struct mmc_host *host)
920 920
921 cmd.opcode = MMC_APP_CMD; 921 cmd.opcode = MMC_APP_CMD;
922 cmd.arg = card->rca << 16; 922 cmd.arg = card->rca << 16;
923 cmd.flags = MMC_RSP_R1; 923 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
924 924
925 err = mmc_wait_for_cmd(host, &cmd, 0); 925 err = mmc_wait_for_cmd(host, &cmd, 0);
926 if ((err != MMC_ERR_NONE) || !(cmd.resp[0] & R1_APP_CMD)) { 926 if ((err != MMC_ERR_NONE) || !(cmd.resp[0] & R1_APP_CMD)) {
@@ -932,7 +932,7 @@ static void mmc_read_scrs(struct mmc_host *host)
932 932
933 cmd.opcode = SD_APP_SEND_SCR; 933 cmd.opcode = SD_APP_SEND_SCR;
934 cmd.arg = 0; 934 cmd.arg = 0;
935 cmd.flags = MMC_RSP_R1; 935 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
936 936
937 memset(&data, 0, sizeof(struct mmc_data)); 937 memset(&data, 0, sizeof(struct mmc_data));
938 938
@@ -1003,7 +1003,7 @@ static void mmc_check_cards(struct mmc_host *host)
1003 1003
1004 cmd.opcode = MMC_SEND_STATUS; 1004 cmd.opcode = MMC_SEND_STATUS;
1005 cmd.arg = card->rca << 16; 1005 cmd.arg = card->rca << 16;
1006 cmd.flags = MMC_RSP_R1; 1006 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
1007 1007
1008 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES); 1008 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1009 if (err == MMC_ERR_NONE) 1009 if (err == MMC_ERR_NONE)
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
index 5b014c370e80..8eb2a2ede64b 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -171,14 +171,14 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
171 brq.mrq.data = &brq.data; 171 brq.mrq.data = &brq.data;
172 172
173 brq.cmd.arg = req->sector << 9; 173 brq.cmd.arg = req->sector << 9;
174 brq.cmd.flags = MMC_RSP_R1; 174 brq.cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
175 brq.data.timeout_ns = card->csd.tacc_ns * 10; 175 brq.data.timeout_ns = card->csd.tacc_ns * 10;
176 brq.data.timeout_clks = card->csd.tacc_clks * 10; 176 brq.data.timeout_clks = card->csd.tacc_clks * 10;
177 brq.data.blksz_bits = md->block_bits; 177 brq.data.blksz_bits = md->block_bits;
178 brq.data.blocks = req->nr_sectors >> (md->block_bits - 9); 178 brq.data.blocks = req->nr_sectors >> (md->block_bits - 9);
179 brq.stop.opcode = MMC_STOP_TRANSMISSION; 179 brq.stop.opcode = MMC_STOP_TRANSMISSION;
180 brq.stop.arg = 0; 180 brq.stop.arg = 0;
181 brq.stop.flags = MMC_RSP_R1B; 181 brq.stop.flags = MMC_RSP_R1B | MMC_CMD_AC;
182 182
183 if (rq_data_dir(req) == READ) { 183 if (rq_data_dir(req) == READ) {
184 brq.cmd.opcode = brq.data.blocks > 1 ? MMC_READ_MULTIPLE_BLOCK : MMC_READ_SINGLE_BLOCK; 184 brq.cmd.opcode = brq.data.blocks > 1 ? MMC_READ_MULTIPLE_BLOCK : MMC_READ_SINGLE_BLOCK;
@@ -223,7 +223,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
223 223
224 cmd.opcode = MMC_SEND_STATUS; 224 cmd.opcode = MMC_SEND_STATUS;
225 cmd.arg = card->rca << 16; 225 cmd.arg = card->rca << 16;
226 cmd.flags = MMC_RSP_R1; 226 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
227 err = mmc_wait_for_cmd(card->host, &cmd, 5); 227 err = mmc_wait_for_cmd(card->host, &cmd, 5);
228 if (err) { 228 if (err) {
229 printk(KERN_ERR "%s: error %d requesting status\n", 229 printk(KERN_ERR "%s: error %d requesting status\n",
@@ -430,7 +430,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
430 mmc_card_claim_host(card); 430 mmc_card_claim_host(card);
431 cmd.opcode = MMC_SET_BLOCKLEN; 431 cmd.opcode = MMC_SET_BLOCKLEN;
432 cmd.arg = 1 << md->block_bits; 432 cmd.arg = 1 << md->block_bits;
433 cmd.flags = MMC_RSP_R1; 433 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
434 err = mmc_wait_for_cmd(card->host, &cmd, 5); 434 err = mmc_wait_for_cmd(card->host, &cmd, 5);
435 mmc_card_release_host(card); 435 mmc_card_release_host(card);
436 436
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c
index 634ef53e85a5..37ee7f8dc82f 100644
--- a/drivers/mmc/mmci.c
+++ b/drivers/mmc/mmci.c
@@ -124,15 +124,10 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
124 } 124 }
125 125
126 c |= cmd->opcode | MCI_CPSM_ENABLE; 126 c |= cmd->opcode | MCI_CPSM_ENABLE;
127 switch (cmd->flags & MMC_RSP_MASK) { 127 if (cmd->flags & MMC_RSP_PRESENT) {
128 case MMC_RSP_NONE: 128 if (cmd->flags & MMC_RSP_136)
129 default: 129 c |= MCI_CPSM_LONGRSP;
130 break;
131 case MMC_RSP_LONG:
132 c |= MCI_CPSM_LONGRSP;
133 case MMC_RSP_SHORT:
134 c |= MCI_CPSM_RESPONSE; 130 c |= MCI_CPSM_RESPONSE;
135 break;
136 } 131 }
137 if (/*interrupt*/0) 132 if (/*interrupt*/0)
138 c |= MCI_CPSM_INTERRUPT; 133 c |= MCI_CPSM_INTERRUPT;
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c
index ee8f8a0420d1..285d7d068097 100644
--- a/drivers/mmc/pxamci.c
+++ b/drivers/mmc/pxamci.c
@@ -178,14 +178,15 @@ static void pxamci_start_cmd(struct pxamci_host *host, struct mmc_command *cmd,
178 if (cmd->flags & MMC_RSP_BUSY) 178 if (cmd->flags & MMC_RSP_BUSY)
179 cmdat |= CMDAT_BUSY; 179 cmdat |= CMDAT_BUSY;
180 180
181 switch (cmd->flags & (MMC_RSP_MASK | MMC_RSP_CRC)) { 181#define RSP_TYPE(x) ((x) & ~(MMC_RSP_BUSY|MMC_RSP_OPCODE))
182 case MMC_RSP_SHORT | MMC_RSP_CRC: 182 switch (RSP_TYPE(mmc_resp_type(cmd))) {
183 case RSP_TYPE(MMC_RSP_R1): /* r1, r1b, r6 */
183 cmdat |= CMDAT_RESP_SHORT; 184 cmdat |= CMDAT_RESP_SHORT;
184 break; 185 break;
185 case MMC_RSP_SHORT: 186 case RSP_TYPE(MMC_RSP_R3):
186 cmdat |= CMDAT_RESP_R3; 187 cmdat |= CMDAT_RESP_R3;
187 break; 188 break;
188 case MMC_RSP_LONG | MMC_RSP_CRC: 189 case RSP_TYPE(MMC_RSP_R2):
189 cmdat |= CMDAT_RESP_R2; 190 cmdat |= CMDAT_RESP_R2;
190 break; 191 break;
191 default: 192 default:
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index f25757625361..3be397d436fa 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -459,7 +459,7 @@ static void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd)
459 /* 459 /*
460 * Do we expect a reply? 460 * Do we expect a reply?
461 */ 461 */
462 if ((cmd->flags & MMC_RSP_MASK) != MMC_RSP_NONE) { 462 if (cmd->flags & MMC_RSP_PRESENT) {
463 /* 463 /*
464 * Read back status. 464 * Read back status.
465 */ 465 */
@@ -476,10 +476,10 @@ static void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd)
476 cmd->error = MMC_ERR_BADCRC; 476 cmd->error = MMC_ERR_BADCRC;
477 /* All ok */ 477 /* All ok */
478 else { 478 else {
479 if ((cmd->flags & MMC_RSP_MASK) == MMC_RSP_SHORT) 479 if (cmd->flags & MMC_RSP_136)
480 wbsd_get_short_reply(host, cmd);
481 else
482 wbsd_get_long_reply(host, cmd); 480 wbsd_get_long_reply(host, cmd);
481 else
482 wbsd_get_short_reply(host, cmd);
483 } 483 }
484 } 484 }
485 485
diff --git a/drivers/mtd/maps/dc21285.c b/drivers/mtd/maps/dc21285.c
index 701620b6baed..8b3784e2de89 100644
--- a/drivers/mtd/maps/dc21285.c
+++ b/drivers/mtd/maps/dc21285.c
@@ -110,8 +110,9 @@ static void dc21285_copy_to_32(struct map_info *map, unsigned long to, const voi
110{ 110{
111 while (len > 0) { 111 while (len > 0) {
112 map_word d; 112 map_word d;
113 d.x[0] = *((uint32_t*)from)++; 113 d.x[0] = *((uint32_t*)from);
114 dc21285_write32(map, d, to); 114 dc21285_write32(map, d, to);
115 from += 4;
115 to += 4; 116 to += 4;
116 len -= 4; 117 len -= 4;
117 } 118 }
@@ -121,8 +122,9 @@ static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const voi
121{ 122{
122 while (len > 0) { 123 while (len > 0) {
123 map_word d; 124 map_word d;
124 d.x[0] = *((uint16_t*)from)++; 125 d.x[0] = *((uint16_t*)from);
125 dc21285_write16(map, d, to); 126 dc21285_write16(map, d, to);
127 from += 2;
126 to += 2; 128 to += 2;
127 len -= 2; 129 len -= 2;
128 } 130 }
@@ -131,8 +133,9 @@ static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const voi
131static void dc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len) 133static void dc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len)
132{ 134{
133 map_word d; 135 map_word d;
134 d.x[0] = *((uint8_t*)from)++; 136 d.x[0] = *((uint8_t*)from);
135 dc21285_write8(map, d, to); 137 dc21285_write8(map, d, to);
138 from++;
136 to++; 139 to++;
137 len--; 140 len--;
138} 141}
diff --git a/drivers/mtd/maps/tsunami_flash.c b/drivers/mtd/maps/tsunami_flash.c
index 9e21e6c02f80..0f915ac3102e 100644
--- a/drivers/mtd/maps/tsunami_flash.c
+++ b/drivers/mtd/maps/tsunami_flash.c
@@ -62,7 +62,7 @@ static void tsunami_flash_copy_to(
62static struct map_info tsunami_flash_map = { 62static struct map_info tsunami_flash_map = {
63 .name = "flash chip on the Tsunami TIG bus", 63 .name = "flash chip on the Tsunami TIG bus",
64 .size = MAX_TIG_FLASH_SIZE, 64 .size = MAX_TIG_FLASH_SIZE,
65 .phys = NO_XIP; 65 .phys = NO_XIP,
66 .bankwidth = 1, 66 .bankwidth = 1,
67 .read = tsunami_flash_read8, 67 .read = tsunami_flash_read8,
68 .copy_from = tsunami_flash_copy_from, 68 .copy_from = tsunami_flash_copy_from,
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 3dde1df33487..9e8897976a69 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -754,9 +754,11 @@ enum tx_desc_status {
754enum ChipCaps { CapBusMaster=0x20, CapPwrMgmt=0x2000 }; 754enum ChipCaps { CapBusMaster=0x20, CapPwrMgmt=0x2000 };
755 755
756struct vortex_extra_stats { 756struct vortex_extra_stats {
757 unsigned long tx_deferred; 757 unsigned long tx_deferred;
758 unsigned long tx_multiple_collisions; 758 unsigned long tx_max_collisions;
759 unsigned long rx_bad_ssd; 759 unsigned long tx_multiple_collisions;
760 unsigned long tx_single_collisions;
761 unsigned long rx_bad_ssd;
760}; 762};
761 763
762struct vortex_private { 764struct vortex_private {
@@ -864,12 +866,14 @@ static struct {
864 const char str[ETH_GSTRING_LEN]; 866 const char str[ETH_GSTRING_LEN];
865} ethtool_stats_keys[] = { 867} ethtool_stats_keys[] = {
866 { "tx_deferred" }, 868 { "tx_deferred" },
869 { "tx_max_collisions" },
867 { "tx_multiple_collisions" }, 870 { "tx_multiple_collisions" },
871 { "tx_single_collisions" },
868 { "rx_bad_ssd" }, 872 { "rx_bad_ssd" },
869}; 873};
870 874
871/* number of ETHTOOL_GSTATS u64's */ 875/* number of ETHTOOL_GSTATS u64's */
872#define VORTEX_NUM_STATS 3 876#define VORTEX_NUM_STATS 5
873 877
874static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq, 878static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
875 int chip_idx, int card_idx); 879 int chip_idx, int card_idx);
@@ -2109,9 +2113,12 @@ vortex_error(struct net_device *dev, int status)
2109 iowrite8(0, ioaddr + TxStatus); 2113 iowrite8(0, ioaddr + TxStatus);
2110 if (tx_status & 0x30) { /* txJabber or txUnderrun */ 2114 if (tx_status & 0x30) { /* txJabber or txUnderrun */
2111 do_tx_reset = 1; 2115 do_tx_reset = 1;
2112 } else if ((tx_status & 0x08) && (vp->drv_flags & MAX_COLLISION_RESET)) { /* maxCollisions */ 2116 } else if (tx_status & 0x08) { /* maxCollisions */
2113 do_tx_reset = 1; 2117 vp->xstats.tx_max_collisions++;
2114 reset_mask = 0x0108; /* Reset interface logic, but not download logic */ 2118 if (vp->drv_flags & MAX_COLLISION_RESET) {
2119 do_tx_reset = 1;
2120 reset_mask = 0x0108; /* Reset interface logic, but not download logic */
2121 }
2115 } else { /* Merely re-enable the transmitter. */ 2122 } else { /* Merely re-enable the transmitter. */
2116 iowrite16(TxEnable, ioaddr + EL3_CMD); 2123 iowrite16(TxEnable, ioaddr + EL3_CMD);
2117 } 2124 }
@@ -2927,7 +2934,6 @@ static void update_stats(void __iomem *ioaddr, struct net_device *dev)
2927 EL3WINDOW(6); 2934 EL3WINDOW(6);
2928 vp->stats.tx_carrier_errors += ioread8(ioaddr + 0); 2935 vp->stats.tx_carrier_errors += ioread8(ioaddr + 0);
2929 vp->stats.tx_heartbeat_errors += ioread8(ioaddr + 1); 2936 vp->stats.tx_heartbeat_errors += ioread8(ioaddr + 1);
2930 vp->stats.collisions += ioread8(ioaddr + 3);
2931 vp->stats.tx_window_errors += ioread8(ioaddr + 4); 2937 vp->stats.tx_window_errors += ioread8(ioaddr + 4);
2932 vp->stats.rx_fifo_errors += ioread8(ioaddr + 5); 2938 vp->stats.rx_fifo_errors += ioread8(ioaddr + 5);
2933 vp->stats.tx_packets += ioread8(ioaddr + 6); 2939 vp->stats.tx_packets += ioread8(ioaddr + 6);
@@ -2940,10 +2946,15 @@ static void update_stats(void __iomem *ioaddr, struct net_device *dev)
2940 vp->stats.tx_bytes += ioread16(ioaddr + 12); 2946 vp->stats.tx_bytes += ioread16(ioaddr + 12);
2941 /* Extra stats for get_ethtool_stats() */ 2947 /* Extra stats for get_ethtool_stats() */
2942 vp->xstats.tx_multiple_collisions += ioread8(ioaddr + 2); 2948 vp->xstats.tx_multiple_collisions += ioread8(ioaddr + 2);
2949 vp->xstats.tx_single_collisions += ioread8(ioaddr + 3);
2943 vp->xstats.tx_deferred += ioread8(ioaddr + 8); 2950 vp->xstats.tx_deferred += ioread8(ioaddr + 8);
2944 EL3WINDOW(4); 2951 EL3WINDOW(4);
2945 vp->xstats.rx_bad_ssd += ioread8(ioaddr + 12); 2952 vp->xstats.rx_bad_ssd += ioread8(ioaddr + 12);
2946 2953
2954 vp->stats.collisions = vp->xstats.tx_multiple_collisions
2955 + vp->xstats.tx_single_collisions
2956 + vp->xstats.tx_max_collisions;
2957
2947 { 2958 {
2948 u8 up = ioread8(ioaddr + 13); 2959 u8 up = ioread8(ioaddr + 13);
2949 vp->stats.rx_bytes += (up & 0x0f) << 16; 2960 vp->stats.rx_bytes += (up & 0x0f) << 16;
@@ -3037,8 +3048,10 @@ static void vortex_get_ethtool_stats(struct net_device *dev,
3037 spin_unlock_irqrestore(&vp->lock, flags); 3048 spin_unlock_irqrestore(&vp->lock, flags);
3038 3049
3039 data[0] = vp->xstats.tx_deferred; 3050 data[0] = vp->xstats.tx_deferred;
3040 data[1] = vp->xstats.tx_multiple_collisions; 3051 data[1] = vp->xstats.tx_max_collisions;
3041 data[2] = vp->xstats.rx_bad_ssd; 3052 data[2] = vp->xstats.tx_multiple_collisions;
3053 data[3] = vp->xstats.tx_single_collisions;
3054 data[4] = vp->xstats.rx_bad_ssd;
3042} 3055}
3043 3056
3044 3057
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 49fa1e4413fa..a24200d0a616 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -1,6 +1,6 @@
1/* bnx2.c: Broadcom NX2 network driver. 1/* bnx2.c: Broadcom NX2 network driver.
2 * 2 *
3 * Copyright (c) 2004, 2005 Broadcom Corporation 3 * Copyright (c) 2004, 2005, 2006 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -14,8 +14,8 @@
14 14
15#define DRV_MODULE_NAME "bnx2" 15#define DRV_MODULE_NAME "bnx2"
16#define PFX DRV_MODULE_NAME ": " 16#define PFX DRV_MODULE_NAME ": "
17#define DRV_MODULE_VERSION "1.4.30" 17#define DRV_MODULE_VERSION "1.4.31"
18#define DRV_MODULE_RELDATE "October 11, 2005" 18#define DRV_MODULE_RELDATE "January 19, 2006"
19 19
20#define RUN_AT(x) (jiffies + (x)) 20#define RUN_AT(x) (jiffies + (x))
21 21
@@ -316,6 +316,10 @@ bnx2_enable_int(struct bnx2 *bp)
316 u32 val; 316 u32 val;
317 317
318 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, 318 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
319 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
320 BNX2_PCICFG_INT_ACK_CMD_MASK_INT | bp->last_status_idx);
321
322 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
319 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | bp->last_status_idx); 323 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | bp->last_status_idx);
320 324
321 val = REG_RD(bp, BNX2_HC_COMMAND); 325 val = REG_RD(bp, BNX2_HC_COMMAND);
@@ -1171,7 +1175,8 @@ bnx2_init_5708s_phy(struct bnx2 *bp)
1171 } 1175 }
1172 1176
1173 if ((CHIP_ID(bp) == CHIP_ID_5708_A0) || 1177 if ((CHIP_ID(bp) == CHIP_ID_5708_A0) ||
1174 (CHIP_ID(bp) == CHIP_ID_5708_B0)) { 1178 (CHIP_ID(bp) == CHIP_ID_5708_B0) ||
1179 (CHIP_ID(bp) == CHIP_ID_5708_B1)) {
1175 /* increase tx signal amplitude */ 1180 /* increase tx signal amplitude */
1176 bnx2_write_phy(bp, BCM5708S_BLK_ADDR, 1181 bnx2_write_phy(bp, BCM5708S_BLK_ADDR,
1177 BCM5708S_BLK_ADDR_TX_MISC); 1182 BCM5708S_BLK_ADDR_TX_MISC);
@@ -1326,44 +1331,78 @@ bnx2_set_mac_loopback(struct bnx2 *bp)
1326 return 0; 1331 return 0;
1327} 1332}
1328 1333
1334static int bnx2_test_link(struct bnx2 *);
1335
1336static int
1337bnx2_set_phy_loopback(struct bnx2 *bp)
1338{
1339 u32 mac_mode;
1340 int rc, i;
1341
1342 spin_lock_bh(&bp->phy_lock);
1343 rc = bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK | BMCR_FULLDPLX |
1344 BMCR_SPEED1000);
1345 spin_unlock_bh(&bp->phy_lock);
1346 if (rc)
1347 return rc;
1348
1349 for (i = 0; i < 10; i++) {
1350 if (bnx2_test_link(bp) == 0)
1351 break;
1352 udelay(10);
1353 }
1354
1355 mac_mode = REG_RD(bp, BNX2_EMAC_MODE);
1356 mac_mode &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX |
1357 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK |
1358 BNX2_EMAC_MODE_25G);
1359
1360 mac_mode |= BNX2_EMAC_MODE_PORT_GMII;
1361 REG_WR(bp, BNX2_EMAC_MODE, mac_mode);
1362 bp->link_up = 1;
1363 return 0;
1364}
1365
1329static int 1366static int
1330bnx2_fw_sync(struct bnx2 *bp, u32 msg_data) 1367bnx2_fw_sync(struct bnx2 *bp, u32 msg_data, int silent)
1331{ 1368{
1332 int i; 1369 int i;
1333 u32 val; 1370 u32 val;
1334 1371
1335 if (bp->fw_timed_out)
1336 return -EBUSY;
1337
1338 bp->fw_wr_seq++; 1372 bp->fw_wr_seq++;
1339 msg_data |= bp->fw_wr_seq; 1373 msg_data |= bp->fw_wr_seq;
1340 1374
1341 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_MB, msg_data); 1375 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_MB, msg_data);
1342 1376
1343 /* wait for an acknowledgement. */ 1377 /* wait for an acknowledgement. */
1344 for (i = 0; i < (FW_ACK_TIME_OUT_MS * 1000)/5; i++) { 1378 for (i = 0; i < (FW_ACK_TIME_OUT_MS / 10); i++) {
1345 udelay(5); 1379 msleep(10);
1346 1380
1347 val = REG_RD_IND(bp, bp->shmem_base + BNX2_FW_MB); 1381 val = REG_RD_IND(bp, bp->shmem_base + BNX2_FW_MB);
1348 1382
1349 if ((val & BNX2_FW_MSG_ACK) == (msg_data & BNX2_DRV_MSG_SEQ)) 1383 if ((val & BNX2_FW_MSG_ACK) == (msg_data & BNX2_DRV_MSG_SEQ))
1350 break; 1384 break;
1351 } 1385 }
1386 if ((msg_data & BNX2_DRV_MSG_DATA) == BNX2_DRV_MSG_DATA_WAIT0)
1387 return 0;
1352 1388
1353 /* If we timed out, inform the firmware that this is the case. */ 1389 /* If we timed out, inform the firmware that this is the case. */
1354 if (((val & BNX2_FW_MSG_ACK) != (msg_data & BNX2_DRV_MSG_SEQ)) && 1390 if ((val & BNX2_FW_MSG_ACK) != (msg_data & BNX2_DRV_MSG_SEQ)) {
1355 ((msg_data & BNX2_DRV_MSG_DATA) != BNX2_DRV_MSG_DATA_WAIT0)) { 1391 if (!silent)
1392 printk(KERN_ERR PFX "fw sync timeout, reset code = "
1393 "%x\n", msg_data);
1356 1394
1357 msg_data &= ~BNX2_DRV_MSG_CODE; 1395 msg_data &= ~BNX2_DRV_MSG_CODE;
1358 msg_data |= BNX2_DRV_MSG_CODE_FW_TIMEOUT; 1396 msg_data |= BNX2_DRV_MSG_CODE_FW_TIMEOUT;
1359 1397
1360 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_MB, msg_data); 1398 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_MB, msg_data);
1361 1399
1362 bp->fw_timed_out = 1;
1363
1364 return -EBUSY; 1400 return -EBUSY;
1365 } 1401 }
1366 1402
1403 if ((val & BNX2_FW_MSG_STATUS_MASK) != BNX2_FW_MSG_STATUS_OK)
1404 return -EIO;
1405
1367 return 0; 1406 return 0;
1368} 1407}
1369 1408
@@ -1657,7 +1696,7 @@ bnx2_rx_int(struct bnx2 *bp, int budget)
1657 rmb(); 1696 rmb();
1658 while (sw_cons != hw_cons) { 1697 while (sw_cons != hw_cons) {
1659 unsigned int len; 1698 unsigned int len;
1660 u16 status; 1699 u32 status;
1661 struct sw_bd *rx_buf; 1700 struct sw_bd *rx_buf;
1662 struct sk_buff *skb; 1701 struct sk_buff *skb;
1663 1702
@@ -1673,7 +1712,7 @@ bnx2_rx_int(struct bnx2 *bp, int budget)
1673 rx_hdr = (struct l2_fhdr *) skb->data; 1712 rx_hdr = (struct l2_fhdr *) skb->data;
1674 len = rx_hdr->l2_fhdr_pkt_len - 4; 1713 len = rx_hdr->l2_fhdr_pkt_len - 4;
1675 1714
1676 if (rx_hdr->l2_fhdr_errors & 1715 if ((status = rx_hdr->l2_fhdr_status) &
1677 (L2_FHDR_ERRORS_BAD_CRC | 1716 (L2_FHDR_ERRORS_BAD_CRC |
1678 L2_FHDR_ERRORS_PHY_DECODE | 1717 L2_FHDR_ERRORS_PHY_DECODE |
1679 L2_FHDR_ERRORS_ALIGNMENT | 1718 L2_FHDR_ERRORS_ALIGNMENT |
@@ -1732,15 +1771,13 @@ reuse_rx:
1732 1771
1733 } 1772 }
1734 1773
1735 status = rx_hdr->l2_fhdr_status;
1736 skb->ip_summed = CHECKSUM_NONE; 1774 skb->ip_summed = CHECKSUM_NONE;
1737 if (bp->rx_csum && 1775 if (bp->rx_csum &&
1738 (status & (L2_FHDR_STATUS_TCP_SEGMENT | 1776 (status & (L2_FHDR_STATUS_TCP_SEGMENT |
1739 L2_FHDR_STATUS_UDP_DATAGRAM))) { 1777 L2_FHDR_STATUS_UDP_DATAGRAM))) {
1740 1778
1741 u16 cksum = rx_hdr->l2_fhdr_tcp_udp_xsum; 1779 if (likely((status & (L2_FHDR_ERRORS_TCP_XSUM |
1742 1780 L2_FHDR_ERRORS_UDP_XSUM)) == 0))
1743 if (cksum == 0xffff)
1744 skb->ip_summed = CHECKSUM_UNNECESSARY; 1781 skb->ip_summed = CHECKSUM_UNNECESSARY;
1745 } 1782 }
1746 1783
@@ -1794,7 +1831,7 @@ static irqreturn_t
1794bnx2_msi(int irq, void *dev_instance, struct pt_regs *regs) 1831bnx2_msi(int irq, void *dev_instance, struct pt_regs *regs)
1795{ 1832{
1796 struct net_device *dev = dev_instance; 1833 struct net_device *dev = dev_instance;
1797 struct bnx2 *bp = dev->priv; 1834 struct bnx2 *bp = netdev_priv(dev);
1798 1835
1799 prefetch(bp->status_blk); 1836 prefetch(bp->status_blk);
1800 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, 1837 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
@@ -1814,7 +1851,7 @@ static irqreturn_t
1814bnx2_interrupt(int irq, void *dev_instance, struct pt_regs *regs) 1851bnx2_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
1815{ 1852{
1816 struct net_device *dev = dev_instance; 1853 struct net_device *dev = dev_instance;
1817 struct bnx2 *bp = dev->priv; 1854 struct bnx2 *bp = netdev_priv(dev);
1818 1855
1819 /* When using INTx, it is possible for the interrupt to arrive 1856 /* When using INTx, it is possible for the interrupt to arrive
1820 * at the CPU before the status block posted prior to the 1857 * at the CPU before the status block posted prior to the
@@ -1859,7 +1896,7 @@ bnx2_has_work(struct bnx2 *bp)
1859static int 1896static int
1860bnx2_poll(struct net_device *dev, int *budget) 1897bnx2_poll(struct net_device *dev, int *budget)
1861{ 1898{
1862 struct bnx2 *bp = dev->priv; 1899 struct bnx2 *bp = netdev_priv(dev);
1863 1900
1864 if ((bp->status_blk->status_attn_bits & 1901 if ((bp->status_blk->status_attn_bits &
1865 STATUS_ATTN_BITS_LINK_STATE) != 1902 STATUS_ATTN_BITS_LINK_STATE) !=
@@ -1891,9 +1928,20 @@ bnx2_poll(struct net_device *dev, int *budget)
1891 1928
1892 if (!bnx2_has_work(bp)) { 1929 if (!bnx2_has_work(bp)) {
1893 netif_rx_complete(dev); 1930 netif_rx_complete(dev);
1931 if (likely(bp->flags & USING_MSI_FLAG)) {
1932 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
1933 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
1934 bp->last_status_idx);
1935 return 0;
1936 }
1937 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
1938 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
1939 BNX2_PCICFG_INT_ACK_CMD_MASK_INT |
1940 bp->last_status_idx);
1941
1894 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, 1942 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
1895 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | 1943 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
1896 bp->last_status_idx); 1944 bp->last_status_idx);
1897 return 0; 1945 return 0;
1898 } 1946 }
1899 1947
@@ -1906,7 +1954,7 @@ bnx2_poll(struct net_device *dev, int *budget)
1906static void 1954static void
1907bnx2_set_rx_mode(struct net_device *dev) 1955bnx2_set_rx_mode(struct net_device *dev)
1908{ 1956{
1909 struct bnx2 *bp = dev->priv; 1957 struct bnx2 *bp = netdev_priv(dev);
1910 u32 rx_mode, sort_mode; 1958 u32 rx_mode, sort_mode;
1911 int i; 1959 int i;
1912 1960
@@ -1916,11 +1964,11 @@ bnx2_set_rx_mode(struct net_device *dev)
1916 BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG); 1964 BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG);
1917 sort_mode = 1 | BNX2_RPM_SORT_USER0_BC_EN; 1965 sort_mode = 1 | BNX2_RPM_SORT_USER0_BC_EN;
1918#ifdef BCM_VLAN 1966#ifdef BCM_VLAN
1919 if (!bp->vlgrp) { 1967 if (!bp->vlgrp && !(bp->flags & ASF_ENABLE_FLAG))
1920 rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG; 1968 rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG;
1921 }
1922#else 1969#else
1923 rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG; 1970 if (!(bp->flags & ASF_ENABLE_FLAG))
1971 rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG;
1924#endif 1972#endif
1925 if (dev->flags & IFF_PROMISC) { 1973 if (dev->flags & IFF_PROMISC) {
1926 /* Promiscuous mode. */ 1974 /* Promiscuous mode. */
@@ -2338,7 +2386,6 @@ bnx2_set_power_state(struct bnx2 *bp, pci_power_t state)
2338 val |= BNX2_EMAC_MODE_PORT_MII | 2386 val |= BNX2_EMAC_MODE_PORT_MII |
2339 BNX2_EMAC_MODE_MPKT_RCVD | 2387 BNX2_EMAC_MODE_MPKT_RCVD |
2340 BNX2_EMAC_MODE_ACPI_RCVD | 2388 BNX2_EMAC_MODE_ACPI_RCVD |
2341 BNX2_EMAC_MODE_FORCE_LINK |
2342 BNX2_EMAC_MODE_MPKT; 2389 BNX2_EMAC_MODE_MPKT;
2343 2390
2344 REG_WR(bp, BNX2_EMAC_MODE, val); 2391 REG_WR(bp, BNX2_EMAC_MODE, val);
@@ -2374,7 +2421,8 @@ bnx2_set_power_state(struct bnx2 *bp, pci_power_t state)
2374 wol_msg = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL; 2421 wol_msg = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
2375 } 2422 }
2376 2423
2377 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT3 | wol_msg); 2424 if (!(bp->flags & NO_WOL_FLAG))
2425 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT3 | wol_msg, 0);
2378 2426
2379 pmcsr &= ~PCI_PM_CTRL_STATE_MASK; 2427 pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
2380 if ((CHIP_ID(bp) == CHIP_ID_5706_A0) || 2428 if ((CHIP_ID(bp) == CHIP_ID_5706_A0) ||
@@ -2708,9 +2756,16 @@ bnx2_init_nvram(struct bnx2 *bp)
2708 if (j == entry_count) { 2756 if (j == entry_count) {
2709 bp->flash_info = NULL; 2757 bp->flash_info = NULL;
2710 printk(KERN_ALERT PFX "Unknown flash/EEPROM type.\n"); 2758 printk(KERN_ALERT PFX "Unknown flash/EEPROM type.\n");
2711 rc = -ENODEV; 2759 return -ENODEV;
2712 } 2760 }
2713 2761
2762 val = REG_RD_IND(bp, bp->shmem_base + BNX2_SHARED_HW_CFG_CONFIG2);
2763 val &= BNX2_SHARED_HW_CFG2_NVM_SIZE_MASK;
2764 if (val)
2765 bp->flash_size = val;
2766 else
2767 bp->flash_size = bp->flash_info->total_size;
2768
2714 return rc; 2769 return rc;
2715} 2770}
2716 2771
@@ -3014,16 +3069,14 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
3014 val = REG_RD(bp, BNX2_MISC_ENABLE_CLR_BITS); 3069 val = REG_RD(bp, BNX2_MISC_ENABLE_CLR_BITS);
3015 udelay(5); 3070 udelay(5);
3016 3071
3072 /* Wait for the firmware to tell us it is ok to issue a reset. */
3073 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT0 | reset_code, 1);
3074
3017 /* Deposit a driver reset signature so the firmware knows that 3075 /* Deposit a driver reset signature so the firmware knows that
3018 * this is a soft reset. */ 3076 * this is a soft reset. */
3019 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_RESET_SIGNATURE, 3077 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_RESET_SIGNATURE,
3020 BNX2_DRV_RESET_SIGNATURE_MAGIC); 3078 BNX2_DRV_RESET_SIGNATURE_MAGIC);
3021 3079
3022 bp->fw_timed_out = 0;
3023
3024 /* Wait for the firmware to tell us it is ok to issue a reset. */
3025 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT0 | reset_code);
3026
3027 /* Do a dummy read to force the chip to complete all current transaction 3080 /* Do a dummy read to force the chip to complete all current transaction
3028 * before we issue a reset. */ 3081 * before we issue a reset. */
3029 val = REG_RD(bp, BNX2_MISC_ID); 3082 val = REG_RD(bp, BNX2_MISC_ID);
@@ -3062,10 +3115,10 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
3062 return -ENODEV; 3115 return -ENODEV;
3063 } 3116 }
3064 3117
3065 bp->fw_timed_out = 0;
3066
3067 /* Wait for the firmware to finish its initialization. */ 3118 /* Wait for the firmware to finish its initialization. */
3068 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT1 | reset_code); 3119 rc = bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT1 | reset_code, 0);
3120 if (rc)
3121 return rc;
3069 3122
3070 if (CHIP_ID(bp) == CHIP_ID_5706_A0) { 3123 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
3071 /* Adjust the voltage regular to two steps lower. The default 3124 /* Adjust the voltage regular to two steps lower. The default
@@ -3083,6 +3136,7 @@ static int
3083bnx2_init_chip(struct bnx2 *bp) 3136bnx2_init_chip(struct bnx2 *bp)
3084{ 3137{
3085 u32 val; 3138 u32 val;
3139 int rc;
3086 3140
3087 /* Make sure the interrupt is not active. */ 3141 /* Make sure the interrupt is not active. */
3088 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, BNX2_PCICFG_INT_ACK_CMD_MASK_INT); 3142 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, BNX2_PCICFG_INT_ACK_CMD_MASK_INT);
@@ -3098,7 +3152,7 @@ bnx2_init_chip(struct bnx2 *bp)
3098 3152
3099 val |= (0x2 << 20) | (1 << 11); 3153 val |= (0x2 << 20) | (1 << 11);
3100 3154
3101 if ((bp->flags & PCIX_FLAG) && (bp->bus_speed_mhz = 133)) 3155 if ((bp->flags & PCIX_FLAG) && (bp->bus_speed_mhz == 133))
3102 val |= (1 << 23); 3156 val |= (1 << 23);
3103 3157
3104 if ((CHIP_NUM(bp) == CHIP_NUM_5706) && 3158 if ((CHIP_NUM(bp) == CHIP_NUM_5706) &&
@@ -3218,17 +3272,22 @@ bnx2_init_chip(struct bnx2 *bp)
3218 3272
3219 REG_WR(bp, BNX2_HC_ATTN_BITS_ENABLE, STATUS_ATTN_BITS_LINK_STATE); 3273 REG_WR(bp, BNX2_HC_ATTN_BITS_ENABLE, STATUS_ATTN_BITS_LINK_STATE);
3220 3274
3275 if (REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_FEATURE) &
3276 BNX2_PORT_FEATURE_ASF_ENABLED)
3277 bp->flags |= ASF_ENABLE_FLAG;
3278
3221 /* Initialize the receive filter. */ 3279 /* Initialize the receive filter. */
3222 bnx2_set_rx_mode(bp->dev); 3280 bnx2_set_rx_mode(bp->dev);
3223 3281
3224 bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT2 | BNX2_DRV_MSG_CODE_RESET); 3282 rc = bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT2 | BNX2_DRV_MSG_CODE_RESET,
3283 0);
3225 3284
3226 REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS, 0x5ffffff); 3285 REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS, 0x5ffffff);
3227 REG_RD(bp, BNX2_MISC_ENABLE_SET_BITS); 3286 REG_RD(bp, BNX2_MISC_ENABLE_SET_BITS);
3228 3287
3229 udelay(20); 3288 udelay(20);
3230 3289
3231 return 0; 3290 return rc;
3232} 3291}
3233 3292
3234 3293
@@ -3880,26 +3939,33 @@ bnx2_test_memory(struct bnx2 *bp)
3880 return ret; 3939 return ret;
3881} 3940}
3882 3941
3942#define BNX2_MAC_LOOPBACK 0
3943#define BNX2_PHY_LOOPBACK 1
3944
3883static int 3945static int
3884bnx2_test_loopback(struct bnx2 *bp) 3946bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
3885{ 3947{
3886 unsigned int pkt_size, num_pkts, i; 3948 unsigned int pkt_size, num_pkts, i;
3887 struct sk_buff *skb, *rx_skb; 3949 struct sk_buff *skb, *rx_skb;
3888 unsigned char *packet; 3950 unsigned char *packet;
3889 u16 rx_start_idx, rx_idx, send_idx; 3951 u16 rx_start_idx, rx_idx;
3890 u32 send_bseq, val; 3952 u32 val;
3891 dma_addr_t map; 3953 dma_addr_t map;
3892 struct tx_bd *txbd; 3954 struct tx_bd *txbd;
3893 struct sw_bd *rx_buf; 3955 struct sw_bd *rx_buf;
3894 struct l2_fhdr *rx_hdr; 3956 struct l2_fhdr *rx_hdr;
3895 int ret = -ENODEV; 3957 int ret = -ENODEV;
3896 3958
3897 if (!netif_running(bp->dev)) 3959 if (loopback_mode == BNX2_MAC_LOOPBACK) {
3898 return -ENODEV; 3960 bp->loopback = MAC_LOOPBACK;
3899 3961 bnx2_set_mac_loopback(bp);
3900 bp->loopback = MAC_LOOPBACK; 3962 }
3901 bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_DIAG); 3963 else if (loopback_mode == BNX2_PHY_LOOPBACK) {
3902 bnx2_set_mac_loopback(bp); 3964 bp->loopback = 0;
3965 bnx2_set_phy_loopback(bp);
3966 }
3967 else
3968 return -EINVAL;
3903 3969
3904 pkt_size = 1514; 3970 pkt_size = 1514;
3905 skb = dev_alloc_skb(pkt_size); 3971 skb = dev_alloc_skb(pkt_size);
@@ -3921,11 +3987,9 @@ bnx2_test_loopback(struct bnx2 *bp)
3921 udelay(5); 3987 udelay(5);
3922 rx_start_idx = bp->status_blk->status_rx_quick_consumer_index0; 3988 rx_start_idx = bp->status_blk->status_rx_quick_consumer_index0;
3923 3989
3924 send_idx = 0;
3925 send_bseq = 0;
3926 num_pkts = 0; 3990 num_pkts = 0;
3927 3991
3928 txbd = &bp->tx_desc_ring[send_idx]; 3992 txbd = &bp->tx_desc_ring[TX_RING_IDX(bp->tx_prod)];
3929 3993
3930 txbd->tx_bd_haddr_hi = (u64) map >> 32; 3994 txbd->tx_bd_haddr_hi = (u64) map >> 32;
3931 txbd->tx_bd_haddr_lo = (u64) map & 0xffffffff; 3995 txbd->tx_bd_haddr_lo = (u64) map & 0xffffffff;
@@ -3933,13 +3997,11 @@ bnx2_test_loopback(struct bnx2 *bp)
3933 txbd->tx_bd_vlan_tag_flags = TX_BD_FLAGS_START | TX_BD_FLAGS_END; 3997 txbd->tx_bd_vlan_tag_flags = TX_BD_FLAGS_START | TX_BD_FLAGS_END;
3934 3998
3935 num_pkts++; 3999 num_pkts++;
3936 send_idx = NEXT_TX_BD(send_idx); 4000 bp->tx_prod = NEXT_TX_BD(bp->tx_prod);
3937 4001 bp->tx_prod_bseq += pkt_size;
3938 send_bseq += pkt_size;
3939
3940 REG_WR16(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BIDX, send_idx);
3941 REG_WR(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BSEQ, send_bseq);
3942 4002
4003 REG_WR16(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BIDX, bp->tx_prod);
4004 REG_WR(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BSEQ, bp->tx_prod_bseq);
3943 4005
3944 udelay(100); 4006 udelay(100);
3945 4007
@@ -3952,7 +4014,7 @@ bnx2_test_loopback(struct bnx2 *bp)
3952 pci_unmap_single(bp->pdev, map, pkt_size, PCI_DMA_TODEVICE); 4014 pci_unmap_single(bp->pdev, map, pkt_size, PCI_DMA_TODEVICE);
3953 dev_kfree_skb_irq(skb); 4015 dev_kfree_skb_irq(skb);
3954 4016
3955 if (bp->status_blk->status_tx_quick_consumer_index0 != send_idx) { 4017 if (bp->status_blk->status_tx_quick_consumer_index0 != bp->tx_prod) {
3956 goto loopback_test_done; 4018 goto loopback_test_done;
3957 } 4019 }
3958 4020
@@ -3971,7 +4033,7 @@ bnx2_test_loopback(struct bnx2 *bp)
3971 pci_unmap_addr(rx_buf, mapping), 4033 pci_unmap_addr(rx_buf, mapping),
3972 bp->rx_buf_size, PCI_DMA_FROMDEVICE); 4034 bp->rx_buf_size, PCI_DMA_FROMDEVICE);
3973 4035
3974 if (rx_hdr->l2_fhdr_errors & 4036 if (rx_hdr->l2_fhdr_status &
3975 (L2_FHDR_ERRORS_BAD_CRC | 4037 (L2_FHDR_ERRORS_BAD_CRC |
3976 L2_FHDR_ERRORS_PHY_DECODE | 4038 L2_FHDR_ERRORS_PHY_DECODE |
3977 L2_FHDR_ERRORS_ALIGNMENT | 4039 L2_FHDR_ERRORS_ALIGNMENT |
@@ -3998,6 +4060,30 @@ loopback_test_done:
3998 return ret; 4060 return ret;
3999} 4061}
4000 4062
4063#define BNX2_MAC_LOOPBACK_FAILED 1
4064#define BNX2_PHY_LOOPBACK_FAILED 2
4065#define BNX2_LOOPBACK_FAILED (BNX2_MAC_LOOPBACK_FAILED | \
4066 BNX2_PHY_LOOPBACK_FAILED)
4067
4068static int
4069bnx2_test_loopback(struct bnx2 *bp)
4070{
4071 int rc = 0;
4072
4073 if (!netif_running(bp->dev))
4074 return BNX2_LOOPBACK_FAILED;
4075
4076 bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET);
4077 spin_lock_bh(&bp->phy_lock);
4078 bnx2_init_phy(bp);
4079 spin_unlock_bh(&bp->phy_lock);
4080 if (bnx2_run_loopback(bp, BNX2_MAC_LOOPBACK))
4081 rc |= BNX2_MAC_LOOPBACK_FAILED;
4082 if (bnx2_run_loopback(bp, BNX2_PHY_LOOPBACK))
4083 rc |= BNX2_PHY_LOOPBACK_FAILED;
4084 return rc;
4085}
4086
4001#define NVRAM_SIZE 0x200 4087#define NVRAM_SIZE 0x200
4002#define CRC32_RESIDUAL 0xdebb20e3 4088#define CRC32_RESIDUAL 0xdebb20e3
4003 4089
@@ -4167,7 +4253,7 @@ bnx2_restart_timer:
4167static int 4253static int
4168bnx2_open(struct net_device *dev) 4254bnx2_open(struct net_device *dev)
4169{ 4255{
4170 struct bnx2 *bp = dev->priv; 4256 struct bnx2 *bp = netdev_priv(dev);
4171 int rc; 4257 int rc;
4172 4258
4173 bnx2_set_power_state(bp, PCI_D0); 4259 bnx2_set_power_state(bp, PCI_D0);
@@ -4280,7 +4366,7 @@ bnx2_reset_task(void *data)
4280static void 4366static void
4281bnx2_tx_timeout(struct net_device *dev) 4367bnx2_tx_timeout(struct net_device *dev)
4282{ 4368{
4283 struct bnx2 *bp = dev->priv; 4369 struct bnx2 *bp = netdev_priv(dev);
4284 4370
4285 /* This allows the netif to be shutdown gracefully before resetting */ 4371 /* This allows the netif to be shutdown gracefully before resetting */
4286 schedule_work(&bp->reset_task); 4372 schedule_work(&bp->reset_task);
@@ -4291,7 +4377,7 @@ bnx2_tx_timeout(struct net_device *dev)
4291static void 4377static void
4292bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp) 4378bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
4293{ 4379{
4294 struct bnx2 *bp = dev->priv; 4380 struct bnx2 *bp = netdev_priv(dev);
4295 4381
4296 bnx2_netif_stop(bp); 4382 bnx2_netif_stop(bp);
4297 4383
@@ -4305,7 +4391,7 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
4305static void 4391static void
4306bnx2_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid) 4392bnx2_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid)
4307{ 4393{
4308 struct bnx2 *bp = dev->priv; 4394 struct bnx2 *bp = netdev_priv(dev);
4309 4395
4310 bnx2_netif_stop(bp); 4396 bnx2_netif_stop(bp);
4311 4397
@@ -4326,7 +4412,7 @@ bnx2_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid)
4326static int 4412static int
4327bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev) 4413bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
4328{ 4414{
4329 struct bnx2 *bp = dev->priv; 4415 struct bnx2 *bp = netdev_priv(dev);
4330 dma_addr_t mapping; 4416 dma_addr_t mapping;
4331 struct tx_bd *txbd; 4417 struct tx_bd *txbd;
4332 struct sw_bd *tx_buf; 4418 struct sw_bd *tx_buf;
@@ -4455,7 +4541,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
4455static int 4541static int
4456bnx2_close(struct net_device *dev) 4542bnx2_close(struct net_device *dev)
4457{ 4543{
4458 struct bnx2 *bp = dev->priv; 4544 struct bnx2 *bp = netdev_priv(dev);
4459 u32 reset_code; 4545 u32 reset_code;
4460 4546
4461 /* Calling flush_scheduled_work() may deadlock because 4547 /* Calling flush_scheduled_work() may deadlock because
@@ -4467,7 +4553,9 @@ bnx2_close(struct net_device *dev)
4467 4553
4468 bnx2_netif_stop(bp); 4554 bnx2_netif_stop(bp);
4469 del_timer_sync(&bp->timer); 4555 del_timer_sync(&bp->timer);
4470 if (bp->wol) 4556 if (bp->flags & NO_WOL_FLAG)
4557 reset_code = BNX2_DRV_MSG_CODE_UNLOAD;
4558 else if (bp->wol)
4471 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL; 4559 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
4472 else 4560 else
4473 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL; 4561 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
@@ -4501,7 +4589,7 @@ bnx2_close(struct net_device *dev)
4501static struct net_device_stats * 4589static struct net_device_stats *
4502bnx2_get_stats(struct net_device *dev) 4590bnx2_get_stats(struct net_device *dev)
4503{ 4591{
4504 struct bnx2 *bp = dev->priv; 4592 struct bnx2 *bp = netdev_priv(dev);
4505 struct statistics_block *stats_blk = bp->stats_blk; 4593 struct statistics_block *stats_blk = bp->stats_blk;
4506 struct net_device_stats *net_stats = &bp->net_stats; 4594 struct net_device_stats *net_stats = &bp->net_stats;
4507 4595
@@ -4575,7 +4663,7 @@ bnx2_get_stats(struct net_device *dev)
4575static int 4663static int
4576bnx2_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 4664bnx2_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4577{ 4665{
4578 struct bnx2 *bp = dev->priv; 4666 struct bnx2 *bp = netdev_priv(dev);
4579 4667
4580 cmd->supported = SUPPORTED_Autoneg; 4668 cmd->supported = SUPPORTED_Autoneg;
4581 if (bp->phy_flags & PHY_SERDES_FLAG) { 4669 if (bp->phy_flags & PHY_SERDES_FLAG) {
@@ -4622,7 +4710,7 @@ bnx2_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4622static int 4710static int
4623bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 4711bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4624{ 4712{
4625 struct bnx2 *bp = dev->priv; 4713 struct bnx2 *bp = netdev_priv(dev);
4626 u8 autoneg = bp->autoneg; 4714 u8 autoneg = bp->autoneg;
4627 u8 req_duplex = bp->req_duplex; 4715 u8 req_duplex = bp->req_duplex;
4628 u16 req_line_speed = bp->req_line_speed; 4716 u16 req_line_speed = bp->req_line_speed;
@@ -4694,7 +4782,7 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4694static void 4782static void
4695bnx2_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 4783bnx2_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
4696{ 4784{
4697 struct bnx2 *bp = dev->priv; 4785 struct bnx2 *bp = netdev_priv(dev);
4698 4786
4699 strcpy(info->driver, DRV_MODULE_NAME); 4787 strcpy(info->driver, DRV_MODULE_NAME);
4700 strcpy(info->version, DRV_MODULE_VERSION); 4788 strcpy(info->version, DRV_MODULE_VERSION);
@@ -4702,15 +4790,14 @@ bnx2_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
4702 info->fw_version[0] = ((bp->fw_ver & 0xff000000) >> 24) + '0'; 4790 info->fw_version[0] = ((bp->fw_ver & 0xff000000) >> 24) + '0';
4703 info->fw_version[2] = ((bp->fw_ver & 0xff0000) >> 16) + '0'; 4791 info->fw_version[2] = ((bp->fw_ver & 0xff0000) >> 16) + '0';
4704 info->fw_version[4] = ((bp->fw_ver & 0xff00) >> 8) + '0'; 4792 info->fw_version[4] = ((bp->fw_ver & 0xff00) >> 8) + '0';
4705 info->fw_version[6] = (bp->fw_ver & 0xff) + '0'; 4793 info->fw_version[1] = info->fw_version[3] = '.';
4706 info->fw_version[1] = info->fw_version[3] = info->fw_version[5] = '.'; 4794 info->fw_version[5] = 0;
4707 info->fw_version[7] = 0;
4708} 4795}
4709 4796
4710static void 4797static void
4711bnx2_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 4798bnx2_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
4712{ 4799{
4713 struct bnx2 *bp = dev->priv; 4800 struct bnx2 *bp = netdev_priv(dev);
4714 4801
4715 if (bp->flags & NO_WOL_FLAG) { 4802 if (bp->flags & NO_WOL_FLAG) {
4716 wol->supported = 0; 4803 wol->supported = 0;
@@ -4729,7 +4816,7 @@ bnx2_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
4729static int 4816static int
4730bnx2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 4817bnx2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
4731{ 4818{
4732 struct bnx2 *bp = dev->priv; 4819 struct bnx2 *bp = netdev_priv(dev);
4733 4820
4734 if (wol->wolopts & ~WAKE_MAGIC) 4821 if (wol->wolopts & ~WAKE_MAGIC)
4735 return -EINVAL; 4822 return -EINVAL;
@@ -4749,7 +4836,7 @@ bnx2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
4749static int 4836static int
4750bnx2_nway_reset(struct net_device *dev) 4837bnx2_nway_reset(struct net_device *dev)
4751{ 4838{
4752 struct bnx2 *bp = dev->priv; 4839 struct bnx2 *bp = netdev_priv(dev);
4753 u32 bmcr; 4840 u32 bmcr;
4754 4841
4755 if (!(bp->autoneg & AUTONEG_SPEED)) { 4842 if (!(bp->autoneg & AUTONEG_SPEED)) {
@@ -4785,19 +4872,19 @@ bnx2_nway_reset(struct net_device *dev)
4785static int 4872static int
4786bnx2_get_eeprom_len(struct net_device *dev) 4873bnx2_get_eeprom_len(struct net_device *dev)
4787{ 4874{
4788 struct bnx2 *bp = dev->priv; 4875 struct bnx2 *bp = netdev_priv(dev);
4789 4876
4790 if (bp->flash_info == 0) 4877 if (bp->flash_info == NULL)
4791 return 0; 4878 return 0;
4792 4879
4793 return (int) bp->flash_info->total_size; 4880 return (int) bp->flash_size;
4794} 4881}
4795 4882
4796static int 4883static int
4797bnx2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, 4884bnx2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
4798 u8 *eebuf) 4885 u8 *eebuf)
4799{ 4886{
4800 struct bnx2 *bp = dev->priv; 4887 struct bnx2 *bp = netdev_priv(dev);
4801 int rc; 4888 int rc;
4802 4889
4803 /* parameters already validated in ethtool_get_eeprom */ 4890 /* parameters already validated in ethtool_get_eeprom */
@@ -4811,7 +4898,7 @@ static int
4811bnx2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, 4898bnx2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
4812 u8 *eebuf) 4899 u8 *eebuf)
4813{ 4900{
4814 struct bnx2 *bp = dev->priv; 4901 struct bnx2 *bp = netdev_priv(dev);
4815 int rc; 4902 int rc;
4816 4903
4817 /* parameters already validated in ethtool_set_eeprom */ 4904 /* parameters already validated in ethtool_set_eeprom */
@@ -4824,7 +4911,7 @@ bnx2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
4824static int 4911static int
4825bnx2_get_coalesce(struct net_device *dev, struct ethtool_coalesce *coal) 4912bnx2_get_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
4826{ 4913{
4827 struct bnx2 *bp = dev->priv; 4914 struct bnx2 *bp = netdev_priv(dev);
4828 4915
4829 memset(coal, 0, sizeof(struct ethtool_coalesce)); 4916 memset(coal, 0, sizeof(struct ethtool_coalesce));
4830 4917
@@ -4846,7 +4933,7 @@ bnx2_get_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
4846static int 4933static int
4847bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal) 4934bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
4848{ 4935{
4849 struct bnx2 *bp = dev->priv; 4936 struct bnx2 *bp = netdev_priv(dev);
4850 4937
4851 bp->rx_ticks = (u16) coal->rx_coalesce_usecs; 4938 bp->rx_ticks = (u16) coal->rx_coalesce_usecs;
4852 if (bp->rx_ticks > 0x3ff) bp->rx_ticks = 0x3ff; 4939 if (bp->rx_ticks > 0x3ff) bp->rx_ticks = 0x3ff;
@@ -4890,7 +4977,7 @@ bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
4890static void 4977static void
4891bnx2_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ering) 4978bnx2_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
4892{ 4979{
4893 struct bnx2 *bp = dev->priv; 4980 struct bnx2 *bp = netdev_priv(dev);
4894 4981
4895 ering->rx_max_pending = MAX_RX_DESC_CNT; 4982 ering->rx_max_pending = MAX_RX_DESC_CNT;
4896 ering->rx_mini_max_pending = 0; 4983 ering->rx_mini_max_pending = 0;
@@ -4907,7 +4994,7 @@ bnx2_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
4907static int 4994static int
4908bnx2_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ering) 4995bnx2_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
4909{ 4996{
4910 struct bnx2 *bp = dev->priv; 4997 struct bnx2 *bp = netdev_priv(dev);
4911 4998
4912 if ((ering->rx_pending > MAX_RX_DESC_CNT) || 4999 if ((ering->rx_pending > MAX_RX_DESC_CNT) ||
4913 (ering->tx_pending > MAX_TX_DESC_CNT) || 5000 (ering->tx_pending > MAX_TX_DESC_CNT) ||
@@ -4930,7 +5017,7 @@ bnx2_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
4930static void 5017static void
4931bnx2_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause) 5018bnx2_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
4932{ 5019{
4933 struct bnx2 *bp = dev->priv; 5020 struct bnx2 *bp = netdev_priv(dev);
4934 5021
4935 epause->autoneg = ((bp->autoneg & AUTONEG_FLOW_CTRL) != 0); 5022 epause->autoneg = ((bp->autoneg & AUTONEG_FLOW_CTRL) != 0);
4936 epause->rx_pause = ((bp->flow_ctrl & FLOW_CTRL_RX) != 0); 5023 epause->rx_pause = ((bp->flow_ctrl & FLOW_CTRL_RX) != 0);
@@ -4940,7 +5027,7 @@ bnx2_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
4940static int 5027static int
4941bnx2_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause) 5028bnx2_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
4942{ 5029{
4943 struct bnx2 *bp = dev->priv; 5030 struct bnx2 *bp = netdev_priv(dev);
4944 5031
4945 bp->req_flow_ctrl = 0; 5032 bp->req_flow_ctrl = 0;
4946 if (epause->rx_pause) 5033 if (epause->rx_pause)
@@ -4967,7 +5054,7 @@ bnx2_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
4967static u32 5054static u32
4968bnx2_get_rx_csum(struct net_device *dev) 5055bnx2_get_rx_csum(struct net_device *dev)
4969{ 5056{
4970 struct bnx2 *bp = dev->priv; 5057 struct bnx2 *bp = netdev_priv(dev);
4971 5058
4972 return bp->rx_csum; 5059 return bp->rx_csum;
4973} 5060}
@@ -4975,7 +5062,7 @@ bnx2_get_rx_csum(struct net_device *dev)
4975static int 5062static int
4976bnx2_set_rx_csum(struct net_device *dev, u32 data) 5063bnx2_set_rx_csum(struct net_device *dev, u32 data)
4977{ 5064{
4978 struct bnx2 *bp = dev->priv; 5065 struct bnx2 *bp = netdev_priv(dev);
4979 5066
4980 bp->rx_csum = data; 5067 bp->rx_csum = data;
4981 return 0; 5068 return 0;
@@ -5124,7 +5211,7 @@ bnx2_self_test_count(struct net_device *dev)
5124static void 5211static void
5125bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf) 5212bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
5126{ 5213{
5127 struct bnx2 *bp = dev->priv; 5214 struct bnx2 *bp = netdev_priv(dev);
5128 5215
5129 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS); 5216 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
5130 if (etest->flags & ETH_TEST_FL_OFFLINE) { 5217 if (etest->flags & ETH_TEST_FL_OFFLINE) {
@@ -5140,10 +5227,8 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
5140 buf[1] = 1; 5227 buf[1] = 1;
5141 etest->flags |= ETH_TEST_FL_FAILED; 5228 etest->flags |= ETH_TEST_FL_FAILED;
5142 } 5229 }
5143 if (bnx2_test_loopback(bp) != 0) { 5230 if ((buf[2] = bnx2_test_loopback(bp)) != 0)
5144 buf[2] = 1;
5145 etest->flags |= ETH_TEST_FL_FAILED; 5231 etest->flags |= ETH_TEST_FL_FAILED;
5146 }
5147 5232
5148 if (!netif_running(bp->dev)) { 5233 if (!netif_running(bp->dev)) {
5149 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); 5234 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET);
@@ -5200,7 +5285,7 @@ static void
5200bnx2_get_ethtool_stats(struct net_device *dev, 5285bnx2_get_ethtool_stats(struct net_device *dev,
5201 struct ethtool_stats *stats, u64 *buf) 5286 struct ethtool_stats *stats, u64 *buf)
5202{ 5287{
5203 struct bnx2 *bp = dev->priv; 5288 struct bnx2 *bp = netdev_priv(dev);
5204 int i; 5289 int i;
5205 u32 *hw_stats = (u32 *) bp->stats_blk; 5290 u32 *hw_stats = (u32 *) bp->stats_blk;
5206 u8 *stats_len_arr = NULL; 5291 u8 *stats_len_arr = NULL;
@@ -5240,7 +5325,7 @@ bnx2_get_ethtool_stats(struct net_device *dev,
5240static int 5325static int
5241bnx2_phys_id(struct net_device *dev, u32 data) 5326bnx2_phys_id(struct net_device *dev, u32 data)
5242{ 5327{
5243 struct bnx2 *bp = dev->priv; 5328 struct bnx2 *bp = netdev_priv(dev);
5244 int i; 5329 int i;
5245 u32 save; 5330 u32 save;
5246 5331
@@ -5312,7 +5397,7 @@ static int
5312bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 5397bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
5313{ 5398{
5314 struct mii_ioctl_data *data = if_mii(ifr); 5399 struct mii_ioctl_data *data = if_mii(ifr);
5315 struct bnx2 *bp = dev->priv; 5400 struct bnx2 *bp = netdev_priv(dev);
5316 int err; 5401 int err;
5317 5402
5318 switch(cmd) { 5403 switch(cmd) {
@@ -5354,7 +5439,7 @@ static int
5354bnx2_change_mac_addr(struct net_device *dev, void *p) 5439bnx2_change_mac_addr(struct net_device *dev, void *p)
5355{ 5440{
5356 struct sockaddr *addr = p; 5441 struct sockaddr *addr = p;
5357 struct bnx2 *bp = dev->priv; 5442 struct bnx2 *bp = netdev_priv(dev);
5358 5443
5359 if (!is_valid_ether_addr(addr->sa_data)) 5444 if (!is_valid_ether_addr(addr->sa_data))
5360 return -EINVAL; 5445 return -EINVAL;
@@ -5370,7 +5455,7 @@ bnx2_change_mac_addr(struct net_device *dev, void *p)
5370static int 5455static int
5371bnx2_change_mtu(struct net_device *dev, int new_mtu) 5456bnx2_change_mtu(struct net_device *dev, int new_mtu)
5372{ 5457{
5373 struct bnx2 *bp = dev->priv; 5458 struct bnx2 *bp = netdev_priv(dev);
5374 5459
5375 if (((new_mtu + ETH_HLEN) > MAX_ETHERNET_JUMBO_PACKET_SIZE) || 5460 if (((new_mtu + ETH_HLEN) > MAX_ETHERNET_JUMBO_PACKET_SIZE) ||
5376 ((new_mtu + ETH_HLEN) < MIN_ETHERNET_PACKET_SIZE)) 5461 ((new_mtu + ETH_HLEN) < MIN_ETHERNET_PACKET_SIZE))
@@ -5391,7 +5476,7 @@ bnx2_change_mtu(struct net_device *dev, int new_mtu)
5391static void 5476static void
5392poll_bnx2(struct net_device *dev) 5477poll_bnx2(struct net_device *dev)
5393{ 5478{
5394 struct bnx2 *bp = dev->priv; 5479 struct bnx2 *bp = netdev_priv(dev);
5395 5480
5396 disable_irq(bp->pdev->irq); 5481 disable_irq(bp->pdev->irq);
5397 bnx2_interrupt(bp->pdev->irq, dev, NULL); 5482 bnx2_interrupt(bp->pdev->irq, dev, NULL);
@@ -5409,7 +5494,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5409 5494
5410 SET_MODULE_OWNER(dev); 5495 SET_MODULE_OWNER(dev);
5411 SET_NETDEV_DEV(dev, &pdev->dev); 5496 SET_NETDEV_DEV(dev, &pdev->dev);
5412 bp = dev->priv; 5497 bp = netdev_priv(dev);
5413 5498
5414 bp->flags = 0; 5499 bp->flags = 0;
5415 bp->phy_flags = 0; 5500 bp->phy_flags = 0;
@@ -5629,6 +5714,9 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5629 } 5714 }
5630 } 5715 }
5631 5716
5717 if (CHIP_NUM(bp) == CHIP_NUM_5708)
5718 bp->flags |= NO_WOL_FLAG;
5719
5632 if (CHIP_ID(bp) == CHIP_ID_5706_A0) { 5720 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
5633 bp->tx_quick_cons_trip_int = 5721 bp->tx_quick_cons_trip_int =
5634 bp->tx_quick_cons_trip; 5722 bp->tx_quick_cons_trip;
@@ -5725,7 +5813,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
5725 dev->ethtool_ops = &bnx2_ethtool_ops; 5813 dev->ethtool_ops = &bnx2_ethtool_ops;
5726 dev->weight = 64; 5814 dev->weight = 64;
5727 5815
5728 bp = dev->priv; 5816 bp = netdev_priv(dev);
5729 5817
5730#if defined(HAVE_POLL_CONTROLLER) || defined(CONFIG_NET_POLL_CONTROLLER) 5818#if defined(HAVE_POLL_CONTROLLER) || defined(CONFIG_NET_POLL_CONTROLLER)
5731 dev->poll_controller = poll_bnx2; 5819 dev->poll_controller = poll_bnx2;
@@ -5784,7 +5872,7 @@ static void __devexit
5784bnx2_remove_one(struct pci_dev *pdev) 5872bnx2_remove_one(struct pci_dev *pdev)
5785{ 5873{
5786 struct net_device *dev = pci_get_drvdata(pdev); 5874 struct net_device *dev = pci_get_drvdata(pdev);
5787 struct bnx2 *bp = dev->priv; 5875 struct bnx2 *bp = netdev_priv(dev);
5788 5876
5789 flush_scheduled_work(); 5877 flush_scheduled_work();
5790 5878
@@ -5803,7 +5891,7 @@ static int
5803bnx2_suspend(struct pci_dev *pdev, pm_message_t state) 5891bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
5804{ 5892{
5805 struct net_device *dev = pci_get_drvdata(pdev); 5893 struct net_device *dev = pci_get_drvdata(pdev);
5806 struct bnx2 *bp = dev->priv; 5894 struct bnx2 *bp = netdev_priv(dev);
5807 u32 reset_code; 5895 u32 reset_code;
5808 5896
5809 if (!netif_running(dev)) 5897 if (!netif_running(dev))
@@ -5812,7 +5900,9 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
5812 bnx2_netif_stop(bp); 5900 bnx2_netif_stop(bp);
5813 netif_device_detach(dev); 5901 netif_device_detach(dev);
5814 del_timer_sync(&bp->timer); 5902 del_timer_sync(&bp->timer);
5815 if (bp->wol) 5903 if (bp->flags & NO_WOL_FLAG)
5904 reset_code = BNX2_DRV_MSG_CODE_UNLOAD;
5905 else if (bp->wol)
5816 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL; 5906 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
5817 else 5907 else
5818 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL; 5908 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
@@ -5826,7 +5916,7 @@ static int
5826bnx2_resume(struct pci_dev *pdev) 5916bnx2_resume(struct pci_dev *pdev)
5827{ 5917{
5828 struct net_device *dev = pci_get_drvdata(pdev); 5918 struct net_device *dev = pci_get_drvdata(pdev);
5829 struct bnx2 *bp = dev->priv; 5919 struct bnx2 *bp = netdev_priv(dev);
5830 5920
5831 if (!netif_running(dev)) 5921 if (!netif_running(dev))
5832 return 0; 5922 return 0;
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 76bb5f1a250b..9f691cbd666b 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -1,6 +1,6 @@
1/* bnx2.h: Broadcom NX2 network driver. 1/* bnx2.h: Broadcom NX2 network driver.
2 * 2 *
3 * Copyright (c) 2004, 2005 Broadcom Corporation 3 * Copyright (c) 2004, 2005, 2006 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -277,19 +277,7 @@ struct statistics_block {
277 * l2_fhdr definition 277 * l2_fhdr definition
278 */ 278 */
279struct l2_fhdr { 279struct l2_fhdr {
280#if defined(__BIG_ENDIAN) 280 u32 l2_fhdr_status;
281 u16 l2_fhdr_errors;
282 u16 l2_fhdr_status;
283#elif defined(__LITTLE_ENDIAN)
284 u16 l2_fhdr_status;
285 u16 l2_fhdr_errors;
286#endif
287 #define L2_FHDR_ERRORS_BAD_CRC (1<<1)
288 #define L2_FHDR_ERRORS_PHY_DECODE (1<<2)
289 #define L2_FHDR_ERRORS_ALIGNMENT (1<<3)
290 #define L2_FHDR_ERRORS_TOO_SHORT (1<<4)
291 #define L2_FHDR_ERRORS_GIANT_FRAME (1<<5)
292
293 #define L2_FHDR_STATUS_RULE_CLASS (0x7<<0) 281 #define L2_FHDR_STATUS_RULE_CLASS (0x7<<0)
294 #define L2_FHDR_STATUS_RULE_P2 (1<<3) 282 #define L2_FHDR_STATUS_RULE_P2 (1<<3)
295 #define L2_FHDR_STATUS_RULE_P3 (1<<4) 283 #define L2_FHDR_STATUS_RULE_P3 (1<<4)
@@ -301,6 +289,14 @@ struct l2_fhdr {
301 #define L2_FHDR_STATUS_TCP_SEGMENT (1<<14) 289 #define L2_FHDR_STATUS_TCP_SEGMENT (1<<14)
302 #define L2_FHDR_STATUS_UDP_DATAGRAM (1<<15) 290 #define L2_FHDR_STATUS_UDP_DATAGRAM (1<<15)
303 291
292 #define L2_FHDR_ERRORS_BAD_CRC (1<<17)
293 #define L2_FHDR_ERRORS_PHY_DECODE (1<<18)
294 #define L2_FHDR_ERRORS_ALIGNMENT (1<<19)
295 #define L2_FHDR_ERRORS_TOO_SHORT (1<<20)
296 #define L2_FHDR_ERRORS_GIANT_FRAME (1<<21)
297 #define L2_FHDR_ERRORS_TCP_XSUM (1<<28)
298 #define L2_FHDR_ERRORS_UDP_XSUM (1<<31)
299
304 u32 l2_fhdr_hash; 300 u32 l2_fhdr_hash;
305#if defined(__BIG_ENDIAN) 301#if defined(__BIG_ENDIAN)
306 u16 l2_fhdr_pkt_len; 302 u16 l2_fhdr_pkt_len;
@@ -3956,6 +3952,7 @@ struct bnx2 {
3956#define NO_WOL_FLAG 8 3952#define NO_WOL_FLAG 8
3957#define USING_DAC_FLAG 0x10 3953#define USING_DAC_FLAG 0x10
3958#define USING_MSI_FLAG 0x20 3954#define USING_MSI_FLAG 0x20
3955#define ASF_ENABLE_FLAG 0x40
3959 3956
3960 u32 phy_flags; 3957 u32 phy_flags;
3961#define PHY_SERDES_FLAG 1 3958#define PHY_SERDES_FLAG 1
@@ -3986,6 +3983,7 @@ struct bnx2 {
3986#define CHIP_ID_5706_A2 0x57060020 3983#define CHIP_ID_5706_A2 0x57060020
3987#define CHIP_ID_5708_A0 0x57080000 3984#define CHIP_ID_5708_A0 0x57080000
3988#define CHIP_ID_5708_B0 0x57081000 3985#define CHIP_ID_5708_B0 0x57081000
3986#define CHIP_ID_5708_B1 0x57081010
3989 3987
3990#define CHIP_BOND_ID(bp) (((bp)->chip_id) & 0xf) 3988#define CHIP_BOND_ID(bp) (((bp)->chip_id) & 0xf)
3991 3989
@@ -3998,7 +3996,7 @@ struct bnx2 {
3998 u16 bus_speed_mhz; 3996 u16 bus_speed_mhz;
3999 u8 wol; 3997 u8 wol;
4000 3998
4001 u8 fw_timed_out; 3999 u8 pad;
4002 4000
4003 u16 fw_wr_seq; 4001 u16 fw_wr_seq;
4004 u16 fw_drv_pulse_wr_seq; 4002 u16 fw_drv_pulse_wr_seq;
@@ -4074,6 +4072,7 @@ struct bnx2 {
4074 struct net_device_stats net_stats; 4072 struct net_device_stats net_stats;
4075 4073
4076 struct flash_spec *flash_info; 4074 struct flash_spec *flash_info;
4075 u32 flash_size;
4077}; 4076};
4078 4077
4079static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset); 4078static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset);
@@ -4172,7 +4171,7 @@ struct fw_info {
4172 * the firmware has timed out, the driver will assume there is no firmware 4171 * the firmware has timed out, the driver will assume there is no firmware
4173 * running and there won't be any firmware-driver synchronization during a 4172 * running and there won't be any firmware-driver synchronization during a
4174 * driver reset. */ 4173 * driver reset. */
4175#define FW_ACK_TIME_OUT_MS 50 4174#define FW_ACK_TIME_OUT_MS 100
4176 4175
4177 4176
4178#define BNX2_DRV_RESET_SIGNATURE 0x00000000 4177#define BNX2_DRV_RESET_SIGNATURE 0x00000000
@@ -4275,6 +4274,9 @@ struct fw_info {
4275#define BNX2_SHARED_HW_CFG_LED_MODE_GPHY1 0x100 4274#define BNX2_SHARED_HW_CFG_LED_MODE_GPHY1 0x100
4276#define BNX2_SHARED_HW_CFG_LED_MODE_GPHY2 0x200 4275#define BNX2_SHARED_HW_CFG_LED_MODE_GPHY2 0x200
4277 4276
4277#define BNX2_SHARED_HW_CFG_CONFIG2 0x00000040
4278#define BNX2_SHARED_HW_CFG2_NVM_SIZE_MASK 0x00fff000
4279
4278#define BNX2_DEV_INFO_BC_REV 0x0000004c 4280#define BNX2_DEV_INFO_BC_REV 0x0000004c
4279 4281
4280#define BNX2_PORT_HW_CFG_MAC_UPPER 0x00000050 4282#define BNX2_PORT_HW_CFG_MAC_UPPER 0x00000050
diff --git a/drivers/net/bnx2_fw.h b/drivers/net/bnx2_fw.h
index ab07a4900e9a..0c21bd849814 100644
--- a/drivers/net/bnx2_fw.h
+++ b/drivers/net/bnx2_fw.h
@@ -1,6 +1,6 @@
1/* bnx2_fw.h: Broadcom NX2 network driver. 1/* bnx2_fw.h: Broadcom NX2 network driver.
2 * 2 *
3 * Copyright (c) 2004, 2005 Broadcom Corporation 3 * Copyright (c) 2004, 2005, 2006 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -978,20 +978,20 @@ static u32 bnx2_COM_b06FwSbss[(0x1c/4) + 1] = { 0x0 };
978static int bnx2_RXP_b06FwReleaseMajor = 0x1; 978static int bnx2_RXP_b06FwReleaseMajor = 0x1;
979static int bnx2_RXP_b06FwReleaseMinor = 0x0; 979static int bnx2_RXP_b06FwReleaseMinor = 0x0;
980static int bnx2_RXP_b06FwReleaseFix = 0x0; 980static int bnx2_RXP_b06FwReleaseFix = 0x0;
981static u32 bnx2_RXP_b06FwStartAddr = 0x08003104; 981static u32 bnx2_RXP_b06FwStartAddr = 0x08003184;
982static u32 bnx2_RXP_b06FwTextAddr = 0x08000000; 982static u32 bnx2_RXP_b06FwTextAddr = 0x08000000;
983static int bnx2_RXP_b06FwTextLen = 0x562c; 983static int bnx2_RXP_b06FwTextLen = 0x588c;
984static u32 bnx2_RXP_b06FwDataAddr = 0x08005660; 984static u32 bnx2_RXP_b06FwDataAddr = 0x080058e0;
985static int bnx2_RXP_b06FwDataLen = 0x0; 985static int bnx2_RXP_b06FwDataLen = 0x0;
986static u32 bnx2_RXP_b06FwRodataAddr = 0x00000000; 986static u32 bnx2_RXP_b06FwRodataAddr = 0x08005890;
987static int bnx2_RXP_b06FwRodataLen = 0x0; 987static int bnx2_RXP_b06FwRodataLen = 0x28;
988static u32 bnx2_RXP_b06FwBssAddr = 0x08005680; 988static u32 bnx2_RXP_b06FwBssAddr = 0x08005900;
989static int bnx2_RXP_b06FwBssLen = 0x1394; 989static int bnx2_RXP_b06FwBssLen = 0x13a4;
990static u32 bnx2_RXP_b06FwSbssAddr = 0x08005660; 990static u32 bnx2_RXP_b06FwSbssAddr = 0x080058e0;
991static int bnx2_RXP_b06FwSbssLen = 0x18; 991static int bnx2_RXP_b06FwSbssLen = 0x1c;
992static u32 bnx2_RXP_b06FwText[(0x562c/4) + 1] = { 992static u32 bnx2_RXP_b06FwText[(0x588c/4) + 1] = {
993 0x0a000c41, 0x00000000, 0x00000000, 0x0000000d, 0x72787020, 0x322e352e, 993 0x0a000c61, 0x00000000, 0x00000000, 0x0000000d, 0x72787020, 0x322e362e,
994 0x38000000, 0x02050803, 0x00000000, 0x0000000d, 0x00000000, 0x00000000, 994 0x31000000, 0x02060103, 0x00000000, 0x0000000d, 0x00000000, 0x00000000,
995 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 995 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
996 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 996 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
997 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 997 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -1513,408 +1513,435 @@ static u32 bnx2_RXP_b06FwText[(0x562c/4) + 1] = {
1513 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1513 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1514 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1514 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1515 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1515 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1516 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800, 0x24425660, 1516 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1517 0x3c030800, 0x24636a14, 0xac400000, 0x0043202b, 0x1480fffd, 0x24420004, 1517 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1518 0x3c1d0800, 0x37bd7ffc, 0x03a0f021, 0x3c100800, 0x26103104, 0x3c1c0800, 1518 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1519 0x279c5660, 0x0e001035, 0x00000000, 0x0000000d, 0x3c080800, 0x8d023100, 1519 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1520 0x2c420080, 0x50400001, 0xad003100, 0x8d073100, 0x3c040800, 0x24840100, 1520 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1521 0x8f460100, 0x00071840, 0x00671821, 0x00031940, 0x00641021, 0xac460000, 1521 0x00000000, 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d,
1522 0x8f450104, 0x00831021, 0xac450004, 0x8f460108, 0xac460008, 0x8f45010c, 1522 0x3c020800, 0x244258e0, 0x3c030800, 0x24636ca4, 0xac400000, 0x0043202b,
1523 0xac45000c, 0x8f460114, 0xac460010, 0x8f450118, 0xac450014, 0x8f460124, 1523 0x1480fffd, 0x24420004, 0x3c1d0800, 0x37bd7ffc, 0x03a0f021, 0x3c100800,
1524 0xac460018, 0x8f450128, 0xac45001c, 0x8f464010, 0xac460020, 0x8f454014, 1524 0x26103184, 0x3c1c0800, 0x279c58e0, 0x0e00104a, 0x00000000, 0x0000000d,
1525 0xac450024, 0x8f464018, 0xac460028, 0x8f45401c, 0xac45002c, 0x8f464020, 1525 0x27bdffe8, 0xafb00010, 0xafbf0014, 0x0e000f1d, 0x00808021, 0x1440000d,
1526 0xac460030, 0x8f454024, 0xac450034, 0x8f464028, 0xac460038, 0x8f45402c, 1526 0x00000000, 0x8f820010, 0x10400005, 0x00000000, 0x9743011c, 0x9742011e,
1527 0xac45003c, 0x8f464030, 0xac460040, 0x8f454034, 0xac450044, 0x8f464038, 1527 0x0a000c89, 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825,
1528 0xac460048, 0x8f45403c, 0xac45004c, 0x8f464040, 0xac460050, 0x8f454044, 1528 0xaf830004, 0x8f840008, 0x3c020020, 0x34424000, 0x00821824, 0x54620004,
1529 0xac450054, 0x8f464048, 0xac460058, 0x8f45404c, 0x24e70001, 0x00402021, 1529 0x3c020020, 0x8f820014, 0x0a000c9a, 0x34421000, 0x34428000, 0x00821824,
1530 0xad073100, 0x03e00008, 0xac85005c, 0x8f820004, 0x9743010c, 0x00804821, 1530 0x14620004, 0x00000000, 0x8f820014, 0x34428000, 0xaf820014, 0x8f820008,
1531 0x00403021, 0x30421000, 0x10400010, 0x306affff, 0x30c20020, 0x1440000e, 1531 0x9743010c, 0x00403021, 0x30421000, 0x10400010, 0x3069ffff, 0x30c20020,
1532 0x24070005, 0x3c021000, 0x00c21024, 0x10400009, 0x3c030dff, 0x3463ffff, 1532 0x1440000e, 0x24070005, 0x3c021000, 0x00c21024, 0x10400009, 0x3c030dff,
1533 0x3c020e00, 0x00c21024, 0x0062182b, 0x50600004, 0x24070001, 0x0a000cb1, 1533 0x3463ffff, 0x3c020e00, 0x00c21024, 0x0062182b, 0x50600004, 0x24070001,
1534 0x3c020800, 0x24070001, 0x3c020800, 0x8c430034, 0x1460001d, 0x00405821, 1534 0x0a000cb2, 0x3c020800, 0x24070001, 0x3c020800, 0x8c430034, 0x1460001d,
1535 0x8f820010, 0x30424000, 0x1440001a, 0x3c020001, 0x3c021f01, 0x00c24024, 1535 0x00405821, 0x8f820014, 0x30424000, 0x1440001a, 0x3c020001, 0x3c021f01,
1536 0x3c031000, 0x15030015, 0x3c020001, 0x31420200, 0x54400012, 0x3c020001, 1536 0x00c24024, 0x3c031000, 0x15030015, 0x3c020001, 0x31220200, 0x14400012,
1537 0x9744010e, 0x24020003, 0xa342018b, 0x97850012, 0x24020002, 0x34e30002, 1537 0x3c020001, 0x9744010e, 0x24020003, 0xa342018b, 0x97850016, 0x24020002,
1538 0xaf400180, 0xa742018c, 0xa7430188, 0x24840004, 0x30a5bfff, 0xa744018e, 1538 0x34e30002, 0xaf400180, 0xa742018c, 0xa7430188, 0x24840004, 0x30a5bfff,
1539 0xa74501a6, 0xaf4801b8, 0x03e00008, 0x00001021, 0x3c020001, 0x00c21024, 1539 0xa744018e, 0xa74501a6, 0xaf4801b8, 0x0a000f19, 0x00001021, 0x3c020001,
1540 0x10400039, 0x00000000, 0x9742010e, 0x3c038000, 0x3046ffff, 0x8f4201b8, 1540 0x00c21024, 0x1040002f, 0x00000000, 0x9742010e, 0x3c038000, 0x3046ffff,
1541 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x97840006, 0x8f85000c, 1541 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x9784000a,
1542 0x24020080, 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0x10a00005, 1542 0x8f850004, 0x8f870014, 0x24020080, 0x24030002, 0xaf420180, 0x24020003,
1543 0xa7440190, 0x9743011c, 0x9742011e, 0x0a000cec, 0x00021400, 0x9743011e, 1543 0xa743018c, 0xa746018e, 0xa7420188, 0x30e28000, 0xa7440190, 0x1040000c,
1544 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010, 0x24020003, 1544 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000,
1545 0x30838000, 0x1060000d, 0xa7420188, 0x93420116, 0x304200fc, 0x005a1021, 1545 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00e21024, 0xaf820014,
1546 0x24424004, 0x8c430000, 0x3063ffff, 0x14600005, 0x00000000, 0x3c02ffff, 1546 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff,
1547 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 1547 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x0a000f19,
1548 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 1548 0x00001021, 0x8f820014, 0x30434000, 0x10600016, 0x00404021, 0x3c020f00,
1549 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x8f820010, 0x30434000, 1549 0x00c21024, 0x14400012, 0x00000000, 0x93420116, 0x34424000, 0x03421821,
1550 0x10600016, 0x00404021, 0x3c020f00, 0x00c21024, 0x14400012, 0x00000000, 1550 0x94650002, 0x2ca21389, 0x1040000b, 0x3c020800, 0x24425900, 0x00051942,
1551 0x93420116, 0x34424000, 0x03421821, 0x94650002, 0x2ca21389, 0x1040000b, 1551 0x00031880, 0x00621821, 0x30a5001f, 0x8c640000, 0x24020001, 0x00a21004,
1552 0x3c020800, 0x24425680, 0x00051942, 0x00031880, 0x00621821, 0x30a5001f, 1552 0x00822024, 0x02048025, 0x12000030, 0x3c021000, 0x9742010e, 0x34e80002,
1553 0x8c640000, 0x24020001, 0x00a21004, 0x00822024, 0x01244825, 0x11200039, 1553 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
1554 0x3c021000, 0x9742010e, 0x34e70002, 0x3c038000, 0x24420004, 0x3046ffff, 1554 0x24020003, 0xa342018b, 0x9784000a, 0x8f850004, 0x8f870014, 0x24020180,
1555 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x97840006, 1555 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0xa7480188, 0x30e28000,
1556 0x8f85000c, 0x24020180, 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 1556 0xa7440190, 0x1040000c, 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021,
1557 0x10a00005, 0xa7440190, 0x9743011c, 0x9742011e, 0x0a000d41, 0x00021400,
1558 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010,
1559 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021,
1560 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 1557 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
1561 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 0x3042bfff, 1558 0x00e21024, 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff,
1562 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 1559 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
1563 0xaf4201b8, 0x03e00008, 0x00001021, 0x00c21024, 0x104000e3, 0x3c020800, 1560 0xaf4201b8, 0x0a000f19, 0x00001021, 0x00c21024, 0x104000c0, 0x3c020800,
1564 0x8c430030, 0x10600040, 0x31024000, 0x1040003e, 0x3c030f00, 0x00c31824, 1561 0x8c430030, 0x10600037, 0x31024000, 0x10400035, 0x3c030f00, 0x00c31824,
1565 0x3c020100, 0x0043102b, 0x1440003a, 0x3c030800, 0x9742010e, 0x34e70002, 1562 0x3c020100, 0x0043102b, 0x14400031, 0x3c030800, 0x9742010e, 0x34e80002,
1566 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 1563 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
1567 0x24020003, 0xa342018b, 0x97840006, 0x8f85000c, 0x24020080, 0x24030002, 1564 0x24020003, 0xa342018b, 0x9784000a, 0x8f850004, 0x8f870014, 0x24020080,
1568 0xaf420180, 0xa743018c, 0xa746018e, 0x10a00005, 0xa7440190, 0x9743011c, 1565 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0xa7480188, 0x30e28000,
1569 0x9742011e, 0x0a000d86, 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 1566 0xa7440190, 0x1040000c, 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021,
1570 0x00621825, 0xaf4301a8, 0x8f840010, 0x30828000, 0x1040000c, 0xa7470188, 1567 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
1568 0x00e21024, 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff,
1569 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
1570 0xaf4201b8, 0x0a000f19, 0x00001021, 0x3c030800, 0x8c620024, 0x30420008,
1571 0x10400035, 0x34ea0002, 0x3c020f00, 0x00c21024, 0x14400032, 0x8d620034,
1572 0x31220200, 0x1040002f, 0x8d620034, 0x9742010e, 0x30e8fffb, 0x3c038000,
1573 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
1574 0xa342018b, 0x9784000a, 0x8f850004, 0x8f870014, 0x24020180, 0x24030002,
1575 0xaf420180, 0xa743018c, 0xa746018e, 0xa7480188, 0x30e28000, 0xa7440190,
1576 0x1040000c, 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
1577 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00e21024,
1578 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
1579 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
1580 0x8d620034, 0x8f860008, 0x10400012, 0x30c20100, 0x10400010, 0x3c020f00,
1581 0x00c21024, 0x3c030200, 0x1043000c, 0x3c020800, 0x8c430038, 0x8f840004,
1582 0x3c020800, 0x2442003c, 0x2463ffff, 0x00832024, 0x00822021, 0x90830000,
1583 0x24630004, 0x0a000de1, 0x000329c0, 0x00000000, 0x00061602, 0x3042000f,
1584 0x000229c0, 0x3c04fc00, 0x00441021, 0x3c030300, 0x0062182b, 0x50600001,
1585 0x24050800, 0x9742010e, 0x3148ffff, 0x3c038000, 0x24420004, 0x3046ffff,
1586 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x9783000a,
1587 0x8f840004, 0x8f870014, 0x24020002, 0xaf450180, 0xa742018c, 0xa746018e,
1588 0xa7480188, 0x30e28000, 0xa7430190, 0x1040000c, 0xaf4401a8, 0x93420116,
1589 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004,
1590 0x3c02ffff, 0x34427fff, 0x00e21024, 0xaf820014, 0x97820016, 0x9743010c,
1591 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6,
1592 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x0a000f19, 0x00001021, 0x8f424000,
1593 0x30420100, 0x104000d5, 0x3c020800, 0x8c440024, 0x24030001, 0x1483002f,
1594 0x00405021, 0x9742010e, 0x34e70002, 0x3c038000, 0x24420004, 0x3045ffff,
1595 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x9783000a,
1596 0x8f840004, 0x8f860014, 0x24020002, 0xaf400180, 0xa742018c, 0xa745018e,
1597 0xa7470188, 0x30c28000, 0xa7430190, 0x1040000c, 0xaf4401a8, 0x93420116,
1598 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004,
1599 0x3c02ffff, 0x34427fff, 0x00c21024, 0xaf820014, 0x97820016, 0x9743010c,
1600 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6,
1601 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x0a000f19, 0x00001021, 0x30820001,
1602 0x1040002e, 0x30eb0004, 0x9742010e, 0x30e9fffb, 0x3c038000, 0x24420004,
1603 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b,
1604 0x9783000a, 0x8f840004, 0x8f860014, 0x24020002, 0xaf400180, 0xa742018c,
1605 0xa745018e, 0xa7470188, 0x30c28000, 0xa7430190, 0x1040000c, 0xaf4401a8,
1571 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 1606 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff,
1572 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 1607 0x14600004, 0x3c02ffff, 0x34427fff, 0x00c21024, 0xaf820014, 0x97820016,
1573 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 1608 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825,
1574 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 1609 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x3127ffff, 0x8d420024,
1575 0x3c030800, 0x8c620024, 0x30420008, 0x1040003e, 0x34e80002, 0x3c020f00, 1610 0x30420004, 0x10400030, 0x8d420024, 0x9742010e, 0x30e9fffb, 0x3c038000,
1576 0x00c21024, 0x1440003b, 0x8d620034, 0x31420200, 0x10400038, 0x8d620034,
1577 0x9742010e, 0x30e7fffb, 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8,
1578 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x97840006, 0x8f85000c,
1579 0x24020180, 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0x10a00005,
1580 0xa7440190, 0x9743011c, 0x9742011e, 0x0a000dca, 0x00021400, 0x9743011e,
1581 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010, 0x30828000,
1582 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
1583 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024,
1584 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
1585 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
1586 0x8d620034, 0x8f860004, 0x1040001a, 0x30c20100, 0x10400018, 0x3c020f00,
1587 0x00c21024, 0x3c030200, 0x10430014, 0x00000000, 0x8f82000c, 0x10400004,
1588 0x00000000, 0x9742011c, 0x0a000df8, 0x3044ffff, 0x9742011e, 0x3044ffff,
1589 0x3c030800, 0x8c620038, 0x3c030800, 0x2463003c, 0x2442ffff, 0x00822024,
1590 0x00831821, 0x90620000, 0x24420004, 0x0a000e0d, 0x000229c0, 0x00000000,
1591 0x00061602, 0x3042000f, 0x000229c0, 0x3c04fc00, 0x00441021, 0x3c030300,
1592 0x0062182b, 0x50600001, 0x24050800, 0x9742010e, 0x3107ffff, 0x3c038000,
1593 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 1611 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
1594 0xa342018b, 0x97830006, 0x8f84000c, 0x24020002, 0xaf450180, 0xa742018c, 1612 0xa342018b, 0x9784000a, 0x8f850004, 0x8f880014, 0x24020100, 0x24030002,
1595 0xa746018e, 0x10800005, 0xa7430190, 0x9743011c, 0x9742011e, 0x0a000e26, 1613 0xaf420180, 0xa743018c, 0xa746018e, 0xa7470188, 0x31028000, 0xa7440190,
1596 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 1614 0x1040000c, 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
1597 0x8f840010, 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 1615 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x01021024,
1598 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 1616 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
1599 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 1617 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
1600 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 1618 0x3127ffff, 0x8d420024, 0x30420008, 0x1040002d, 0x00000000, 0x9742010e,
1601 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x8f424000, 0x30420100, 1619 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
1602 0x104000f9, 0x3c020800, 0x8c440024, 0x24030001, 0x14830038, 0x00404821, 1620 0x24020003, 0xa342018b, 0x9784000a, 0x8f850004, 0x8f880014, 0x24020180,
1603 0x9742010e, 0x34e60002, 0x3c038000, 0x24420004, 0x3045ffff, 0x8f4201b8, 1621 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0xa7470188, 0x31028000,
1604 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x97830006, 0x8f84000c, 1622 0xa7440190, 0x1040000c, 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021,
1605 0x24020002, 0xaf400180, 0xa742018c, 0xa745018e, 0x10800005, 0xa7430190, 1623 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
1606 0x9743011c, 0x9742011e, 0x0a000e65, 0x00021400, 0x9743011e, 0x9742011c, 1624 0x01021024, 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff,
1607 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010, 0x30828000, 0x1040000c, 1625 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
1608 0xa7460188, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 1626 0xaf4201b8, 0x15600041, 0x00001021, 0x27440180, 0x3c038000, 0x8f4201b8,
1609 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf820010, 1627 0x00431024, 0x1440fffd, 0x24022000, 0x24030002, 0xa4820008, 0xa083000b,
1610 0x97820012, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 1628 0xa4800010, 0x3c021000, 0xaf4201b8, 0x0a000f19, 0x00001021, 0x3c030800,
1611 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x03e00008, 1629 0x8c620024, 0x30420001, 0x1040002e, 0x00001021, 0x9742010e, 0x34e70002,
1612 0x00001021, 0x30820001, 0x10400037, 0x30ea0004, 0x9742010e, 0x30e8fffb,
1613 0x3c038000, 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 1630 0x3c038000, 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
1614 0x24020003, 0xa342018b, 0x97830006, 0x8f84000c, 0x24020002, 0xaf400180, 1631 0x24020003, 0xa342018b, 0x9783000a, 0x8f840004, 0x8f860014, 0x24020002,
1615 0xa742018c, 0xa745018e, 0x10800005, 0xa7430190, 0x9743011c, 0x9742011e, 1632 0xaf400180, 0xa742018c, 0xa745018e, 0xa7470188, 0x30c28000, 0xa7430190,
1616 0x0a000e9f, 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 1633 0x1040000c, 0xaf4401a8, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
1617 0xaf4301a8, 0x8f840010, 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 1634 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00c21024,
1618 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 1635 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
1619 0x3c02ffff, 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 0x9743010c,
1620 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6,
1621 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x3107ffff, 0x8d220024, 0x30420004,
1622 0x10400039, 0x8d220024, 0x9742010e, 0x30e8fffb, 0x3c038000, 0x24420004,
1623 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b,
1624 0x97840006, 0x8f85000c, 0x24020100, 0x24030002, 0xaf420180, 0xa743018c,
1625 0xa746018e, 0x10a00005, 0xa7440190, 0x9743011c, 0x9742011e, 0x0a000eda,
1626 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8,
1627 0x8f840010, 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc,
1628 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff,
1629 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104,
1630 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac,
1631 0x3c021000, 0xaf4201b8, 0x3107ffff, 0x8d220024, 0x30420008, 0x10400036,
1632 0x00000000, 0x9742010e, 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8,
1633 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x97840006, 0x8f85000c,
1634 0x24020180, 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0x10a00005,
1635 0xa7440190, 0x9743011c, 0x9742011e, 0x0a000f14, 0x00021400, 0x9743011e,
1636 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010, 0x30828000,
1637 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
1638 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00821024,
1639 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
1640 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 1636 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
1641 0x1540004a, 0x00001021, 0x27440180, 0x3c038000, 0x8f4201b8, 0x00431024, 1637 0x00001021, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x8f4b0070,
1642 0x1440fffd, 0x24022000, 0x24030002, 0xa4820008, 0xa083000b, 0xa4800010, 1638 0x93420112, 0x8f840008, 0x00022882, 0x30820100, 0x14400003, 0x24a30003,
1643 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00001021, 0x3c030800, 0x8c620024, 1639 0x03e00008, 0x00001021, 0x30824000, 0x10400010, 0x27424000, 0x00031880,
1644 0x30420001, 0x10400037, 0x00001021, 0x9742010e, 0x34e60002, 0x3c038000, 1640 0x00431021, 0x8c470000, 0x24a30004, 0x00031880, 0x27424000, 0x00431021,
1645 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 1641 0x8c490000, 0x93430116, 0x27424000, 0x306300fc, 0x00431021, 0x8c4a0000,
1646 0xa342018b, 0x97830006, 0x8f84000c, 0x24020002, 0xaf400180, 0xa742018c, 1642 0x0a000f45, 0x3c030800, 0x30822000, 0x1040ffea, 0x00031880, 0x27424000,
1647 0xa745018e, 0x10800005, 0xa7430190, 0x9743011c, 0x9742011e, 0x0a000f5e, 1643 0x00431021, 0x8c470000, 0x24a30004, 0x00031880, 0x27424000, 0x00431021,
1648 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 1644 0x8c490000, 0x00005021, 0x3c030800, 0x24680100, 0x00071602, 0x00021080,
1649 0x8f840010, 0x30828000, 0x1040000c, 0xa7460188, 0x93420116, 0x304200fc, 1645 0x00481021, 0x8c460000, 0x00071b82, 0x306303fc, 0x01031821, 0x8c640400,
1646 0x00071182, 0x304203fc, 0x01021021, 0x8c450800, 0x30e300ff, 0x00031880,
1647 0x01031821, 0x00091602, 0x00021080, 0x01021021, 0x00c43026, 0x8c640c00,
1648 0x8c431000, 0x00c53026, 0x00091382, 0x304203fc, 0x01021021, 0x8c451400,
1649 0x312200ff, 0x00021080, 0x01021021, 0x00c43026, 0x00c33026, 0x00091982,
1650 0x306303fc, 0x01031821, 0x8c641800, 0x8c431c00, 0x00c53026, 0x00c43026,
1651 0x11400015, 0x00c33026, 0x000a1602, 0x00021080, 0x01021021, 0x8c432000,
1652 0x000a1382, 0x304203fc, 0x01021021, 0x8c452400, 0x314200ff, 0x00021080,
1653 0x01021021, 0x00c33026, 0x000a1982, 0x306303fc, 0x01031821, 0x8c642800,
1654 0x8c432c00, 0x00c53026, 0x00c43026, 0x00c33026, 0x8f430070, 0x3c050800,
1655 0x8ca43100, 0x2c820020, 0x10400008, 0x006b5823, 0x3c020800, 0x24423104,
1656 0x00041880, 0x00621821, 0x24820001, 0xac6b0000, 0xaca23100, 0xaf860004,
1657 0x03e00008, 0x24020001, 0x27bdffe8, 0xafbf0010, 0x8f460128, 0x8f840010,
1658 0xaf460020, 0x8f450104, 0x8f420100, 0x24030800, 0xaf850008, 0xaf820014,
1659 0xaf4301b8, 0x1080000a, 0x3c020800, 0x8c430034, 0x10600007, 0x30a22000,
1660 0x10400005, 0x34a30100, 0x8f82000c, 0xaf830008, 0x24420001, 0xaf82000c,
1661 0x3c020800, 0x8c4300c0, 0x10600006, 0x3c030800, 0x8c6200c4, 0x24040001,
1662 0x24420001, 0x0a000fd5, 0xac6200c4, 0x8f820008, 0x3c030010, 0x00431024,
1663 0x14400009, 0x3c02001f, 0x3c030800, 0x8c620020, 0x00002021, 0x24420001,
1664 0x0e000c78, 0xac620020, 0x0a000fd5, 0x00402021, 0x3442ff00, 0x14c20009,
1665 0x2403bfff, 0x3c030800, 0x8c620020, 0x24040001, 0x24420001, 0x0e000c78,
1666 0xac620020, 0x0a000fd5, 0x00402021, 0x8f820014, 0x00431024, 0x14400006,
1667 0x00000000, 0xaf400048, 0x0e0011a9, 0xaf400040, 0x0a000fd5, 0x00402021,
1668 0x0e001563, 0x00000000, 0x00402021, 0x10800005, 0x3c024000, 0x8f430124,
1669 0x3c026020, 0xac430014, 0x3c024000, 0xaf420138, 0x00000000, 0x8fbf0010,
1670 0x03e00008, 0x27bd0018, 0x27bdffe0, 0xafbf0018, 0xafb10014, 0xafb00010,
1671 0x8f420140, 0xaf420020, 0x8f430148, 0x3c027000, 0x00621824, 0x3c023000,
1672 0x10620021, 0x0043102b, 0x14400006, 0x3c024000, 0x3c022000, 0x10620009,
1673 0x3c024000, 0x0a001040, 0x00000000, 0x10620045, 0x3c025000, 0x10620047,
1674 0x3c024000, 0x0a001040, 0x00000000, 0x27440180, 0x3c038000, 0x8f4201b8,
1675 0x00431024, 0x1440fffd, 0x00000000, 0x8f420148, 0x24030002, 0xa083000b,
1676 0x00021402, 0xa4820008, 0x8f430148, 0xa4830010, 0x8f420144, 0x3c031000,
1677 0xac820024, 0xaf4301b8, 0x0a001040, 0x3c024000, 0x8f420148, 0x24030002,
1678 0x3044ffff, 0x00021402, 0x305000ff, 0x1203000c, 0x27510180, 0x2a020003,
1679 0x10400005, 0x24020003, 0x0600001d, 0x36053000, 0x0a001027, 0x3c038000,
1680 0x12020007, 0x00000000, 0x0a001034, 0x00000000, 0x0e00112c, 0x00000000,
1681 0x0a001025, 0x00402021, 0x0e00113e, 0x00000000, 0x00402021, 0x36053000,
1682 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002, 0xa6250008,
1683 0xa222000b, 0xa6240010, 0x8f420144, 0x3c031000, 0xae220024, 0xaf4301b8,
1684 0x0a001040, 0x3c024000, 0x0000000d, 0x00000000, 0x240002bf, 0x0a001040,
1685 0x3c024000, 0x0e001441, 0x00000000, 0x0a001040, 0x3c024000, 0x0e0015ea,
1686 0x00000000, 0x3c024000, 0xaf420178, 0x00000000, 0x8fbf0018, 0x8fb10014,
1687 0x8fb00010, 0x03e00008, 0x27bd0020, 0x24020800, 0x03e00008, 0xaf4201b8,
1688 0x27bdffe8, 0x3c04600c, 0xafbf0014, 0xafb00010, 0x8c825000, 0x3c1a8000,
1689 0x2403ff7f, 0x3c106000, 0x00431024, 0x3442380c, 0x24030003, 0xac825000,
1690 0x3c020008, 0xaf430008, 0x8e040808, 0x0342d825, 0x8e020808, 0x3c030800,
1691 0xac600020, 0x3084fff0, 0x2c840001, 0x3042fff0, 0x38420010, 0x2c420001,
1692 0xaf840010, 0xaf820000, 0x0e00160c, 0x00000000, 0x0e001561, 0x00000000,
1693 0x3c020400, 0x3442000c, 0x3c03ffff, 0x34630806, 0xae021948, 0xae03194c,
1694 0x8e021980, 0x34420200, 0xae021980, 0x8f500000, 0x32020003, 0x1040fffd,
1695 0x32020001, 0x10400004, 0x32020002, 0x0e000f92, 0x00000000, 0x32020002,
1696 0x1040fff6, 0x00000000, 0x0e000fe0, 0x00000000, 0x0a001071, 0x00000000,
1697 0x27bdffe8, 0x3c04600c, 0xafbf0014, 0xafb00010, 0x8c825000, 0x3c1a8000,
1698 0x2403ff7f, 0x3c106000, 0x00431024, 0x3442380c, 0x24030003, 0xac825000,
1699 0x3c020008, 0xaf430008, 0x8e040808, 0x0342d825, 0x8e020808, 0x3c030800,
1700 0xac600020, 0x3084fff0, 0x2c840001, 0x3042fff0, 0x38420010, 0x2c420001,
1701 0xaf840010, 0xaf820000, 0x0e00160c, 0x00000000, 0x0e001561, 0x00000000,
1702 0x3c020400, 0x3442000c, 0x3c03ffff, 0x34630806, 0xae021948, 0xae03194c,
1703 0x8e021980, 0x8fbf0014, 0x34420200, 0xae021980, 0x8fb00010, 0x03e00008,
1704 0x27bd0018, 0x00804821, 0x30a5ffff, 0x30c6ffff, 0x30e7ffff, 0x3c038000,
1705 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x9783000a,
1706 0x8f840004, 0x8f880014, 0xaf490180, 0xa745018c, 0xa746018e, 0xa7470188,
1707 0x31028000, 0xa7430190, 0x1040000c, 0xaf4401a8, 0x93420116, 0x304200fc,
1650 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 1708 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff,
1651 0x34427fff, 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 1709 0x34427fff, 0x01021024, 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104,
1652 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 1710 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac,
1653 0x3c021000, 0xaf4201b8, 0x00001021, 0x03e00008, 0x00000000, 0x27bdffe8, 1711 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00000000, 0x27440180, 0x3c038000,
1654 0xafbf0010, 0x8f460128, 0x8f84000c, 0xaf460020, 0x8f450104, 0x8f420100, 1712 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24022000, 0x24030002, 0xa4820008,
1655 0x24030800, 0xaf850004, 0xaf820010, 0xaf4301b8, 0x1080000a, 0x3c020800, 1713 0xa083000b, 0xa4800010, 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00000000,
1656 0x8c430034, 0x10600007, 0x30a22000, 0x10400005, 0x34a30100, 0x8f820008,
1657 0xaf830004, 0x24420001, 0xaf820008, 0x3c020800, 0x8c4300c0, 0x10600006,
1658 0x3c030800, 0x8c6200c4, 0x24040001, 0x24420001, 0x0a000fc0, 0xac6200c4,
1659 0x8f820004, 0x3c030010, 0x00431024, 0x14400009, 0x3c02001f, 0x3c030800,
1660 0x8c620020, 0x00002021, 0x24420001, 0x0e000c99, 0xac620020, 0x0a000fc0,
1661 0x00402021, 0x3442ff00, 0x14c20009, 0x2403bfff, 0x3c030800, 0x8c620020,
1662 0x24040001, 0x24420001, 0x0e000c99, 0xac620020, 0x0a000fc0, 0x00402021,
1663 0x8f820010, 0x00431024, 0x14400006, 0x00000000, 0xaf400048, 0x0e001144,
1664 0xaf400040, 0x0a000fc0, 0x00402021, 0x0e0014c9, 0x00000000, 0x00402021,
1665 0x10800005, 0x3c024000, 0x8f430124, 0x3c026020, 0xac430014, 0x3c024000,
1666 0xaf420138, 0x00000000, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe0,
1667 0xafbf0018, 0xafb10014, 0xafb00010, 0x8f420140, 0xaf420020, 0x8f430148,
1668 0x3c027000, 0x00621824, 0x3c023000, 0x10620021, 0x0043102b, 0x14400006,
1669 0x3c024000, 0x3c022000, 0x10620009, 0x3c024000, 0x0a00102b, 0x00000000,
1670 0x10620045, 0x3c025000, 0x10620047, 0x3c024000, 0x0a00102b, 0x00000000,
1671 0x27440180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 1714 0x27440180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000,
1672 0x8f420148, 0x24030002, 0xa083000b, 0x00021402, 0xa4820008, 0x8f430148, 1715 0x8f420148, 0x24030002, 0xa083000b, 0x00021402, 0xa4820008, 0x8f430148,
1673 0xa4830010, 0x8f420144, 0x3c031000, 0xac820024, 0xaf4301b8, 0x0a00102b, 1716 0xa4830010, 0x8f420144, 0x3c031000, 0xac820024, 0x03e00008, 0xaf4301b8,
1674 0x3c024000, 0x8f420148, 0x24030002, 0x3044ffff, 0x00021402, 0x305000ff, 1717 0x27bdffe0, 0xafbf0018, 0xafb10014, 0xafb00010, 0x8f420148, 0x24030002,
1675 0x1203000c, 0x27510180, 0x2a020003, 0x10400005, 0x24020003, 0x0600001d, 1718 0x3044ffff, 0x00021402, 0x305000ff, 0x1203000c, 0x27510180, 0x2a020003,
1676 0x36053000, 0x0a001012, 0x3c038000, 0x12020007, 0x00000000, 0x0a00101f, 1719 0x10400005, 0x24020003, 0x0600001d, 0x36053000, 0x0a001117, 0x3c038000,
1677 0x00000000, 0x0e00111f, 0x00000000, 0x0a001010, 0x00402021, 0x0e001131, 1720 0x12020007, 0x00000000, 0x0a001124, 0x00000000, 0x0e00112c, 0x00000000,
1678 0x00000000, 0x00402021, 0x36053000, 0x3c038000, 0x8f4201b8, 0x00431024, 1721 0x0a001115, 0x00402021, 0x0e00113e, 0x00000000, 0x00402021, 0x36053000,
1679 0x1440fffd, 0x24020002, 0xa6250008, 0xa222000b, 0xa6240010, 0x8f420144, 1722 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002, 0xa6250008,
1680 0x3c031000, 0xae220024, 0xaf4301b8, 0x0a00102b, 0x3c024000, 0x0000000d, 1723 0xa222000b, 0xa6240010, 0x8f420144, 0x3c031000, 0xae220024, 0xaf4301b8,
1681 0x00000000, 0x24000295, 0x0a00102b, 0x3c024000, 0x0e0013a7, 0x00000000, 1724 0x0a001128, 0x8fbf0018, 0x0000000d, 0x00000000, 0x240002bf, 0x8fbf0018,
1682 0x0a00102b, 0x3c024000, 0x0e001552, 0x00000000, 0x3c024000, 0xaf420178, 1725 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3084ffff, 0x2c821389,
1683 0x00000000, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 1726 0x1040000d, 0x00001021, 0x3c030800, 0x24635900, 0x00042942, 0x00052880,
1684 0x24020800, 0x03e00008, 0xaf4201b8, 0x27bdffe8, 0x3c04600c, 0xafbf0014, 1727 0x00a32821, 0x3086001f, 0x8ca40000, 0x24030001, 0x00c31804, 0x00832025,
1685 0xafb00010, 0x8c825000, 0x3c1a8000, 0x2403ff7f, 0x3c106000, 0x00431024, 1728 0x03e00008, 0xaca40000, 0x03e00008, 0x24020091, 0x3084ffff, 0x2c821389,
1686 0x3442380c, 0x24030003, 0xac825000, 0x3c020008, 0xaf430008, 0x8e040808, 1729 0x1040000e, 0x00001021, 0x3c030800, 0x24635900, 0x00042942, 0x00052880,
1687 0x0342d825, 0x8e020808, 0x3c030800, 0xac600020, 0x3084fff0, 0x2c840001, 1730 0x00a32821, 0x3086001f, 0x24030001, 0x8ca40000, 0x00c31804, 0x00031827,
1688 0x3042fff0, 0x38420010, 0x2c420001, 0xaf84000c, 0xaf820000, 0x0e001574, 1731 0x00832024, 0x03e00008, 0xaca40000, 0x03e00008, 0x24020091, 0x9482000c,
1689 0x00000000, 0x0e0014c7, 0x00000000, 0x3c020400, 0x3442000c, 0x3c03ffff, 1732 0x24870014, 0x00021302, 0x00021080, 0x00824021, 0x00e8182b, 0x1060004f,
1690 0x34630806, 0xae021948, 0xae03194c, 0x8e021980, 0x34420200, 0xae021980, 1733 0x00000000, 0x90e30000, 0x2c620009, 0x10400047, 0x3c020800, 0x24425890,
1691 0x8f500000, 0x32020003, 0x1040fffd, 0x32020001, 0x10400004, 0x32020002, 1734 0x00031880, 0x00621821, 0x8c640000, 0x00800008, 0x00000000, 0x0a0011a4,
1692 0x0e000f7d, 0x00000000, 0x32020002, 0x1040fff6, 0x00000000, 0x0e000fcb, 1735 0x24e70001, 0x90e30001, 0x2402000a, 0x54620024, 0x01003821, 0x01071023,
1693 0x00000000, 0x0a00105c, 0x00000000, 0x27bdffe8, 0x3c04600c, 0xafbf0014, 1736 0x2c42000a, 0x54400020, 0x01003821, 0x3c050800, 0x8ca26c98, 0x24e70002,
1694 0xafb00010, 0x8c825000, 0x3c1a8000, 0x2403ff7f, 0x3c106000, 0x00431024, 1737 0x34420100, 0xaca26c98, 0x90e30000, 0x90e20001, 0x90e40002, 0x90e60003,
1695 0x3442380c, 0x24030003, 0xac825000, 0x3c020008, 0xaf430008, 0x8e040808, 1738 0x24e70004, 0x24a56c98, 0x00031e00, 0x00021400, 0x00621825, 0x00042200,
1696 0x0342d825, 0x8e020808, 0x3c030800, 0xac600020, 0x3084fff0, 0x2c840001, 1739 0x00641825, 0x00661825, 0xaca30004, 0x90e20000, 0x90e30001, 0x90e40002,
1697 0x3042fff0, 0x38420010, 0x2c420001, 0xaf84000c, 0xaf820000, 0x0e001574, 1740 0x90e60003, 0x24e70004, 0x00021600, 0x00031c00, 0x00431025, 0x00042200,
1698 0x00000000, 0x0e0014c7, 0x00000000, 0x3c020400, 0x3442000c, 0x3c03ffff, 1741 0x00441025, 0x00461025, 0x0a0011a4, 0xaca20008, 0x90e30001, 0x24020004,
1699 0x34630806, 0xae021948, 0xae03194c, 0x8e021980, 0x8fbf0014, 0x34420200, 1742 0x1062000e, 0x00601021, 0x0a00119e, 0x01001021, 0x90e30001, 0x24020003,
1700 0xae021980, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x30a5ffff, 0x30c6ffff, 1743 0x10620008, 0x00601021, 0x0a00119e, 0x01001021, 0x90e30001, 0x24020002,
1701 0x30e7ffff, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 1744 0x14620003, 0x01001021, 0x00601021, 0x00e21021, 0x0a0011a4, 0x00403821,
1702 0xa342018b, 0x97830006, 0x8f82000c, 0xaf440180, 0xa745018c, 0xa746018e, 1745 0x90e20001, 0x0a0011a4, 0x00e23821, 0x01003821, 0x00e8102b, 0x5440ffb4,
1703 0x10400005, 0xa7430190, 0x9743011c, 0x9742011e, 0x0a0010ad, 0x00021400, 1746 0x90e30000, 0x03e00008, 0x24020001, 0x27bdff90, 0x3c030800, 0xafbf006c,
1704 0x9743011e, 0x9742011c, 0x00021400, 0x00621825, 0xaf4301a8, 0x8f840010, 1747 0xafbe0068, 0xafb70064, 0xafb60060, 0xafb5005c, 0xafb40058, 0xafb30054,
1705 0x30828000, 0x1040000c, 0xa7470188, 0x93420116, 0x304200fc, 0x005a1021, 1748 0xafb20050, 0xafb1004c, 0xafb00048, 0xac606c98, 0x93620023, 0x30420010,
1706 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 1749 0x1440027c, 0x24020001, 0x93420116, 0x93630005, 0x34424000, 0x30630001,
1707 0x00821024, 0xaf820010, 0x97820012, 0x9743010c, 0x8f440104, 0x3042bfff, 1750 0x14600005, 0x0342b021, 0x0e0015e0, 0x00000000, 0x0a001436, 0x8fbf006c,
1708 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 1751 0x93420112, 0x8f430104, 0x3c040020, 0x34424000, 0x00641824, 0x10600012,
1709 0xaf4201b8, 0x03e00008, 0x00000000, 0x27440180, 0x3c038000, 0x8f4201b8, 1752 0x03422821, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd,
1710 0x00431024, 0x1440fffd, 0x24022000, 0x24030002, 0xa4820008, 0xa083000b, 1753 0x00000000, 0x8f420128, 0xaca20000, 0x8f640040, 0x24030008, 0x240240c1,
1711 0xa4800010, 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00000000, 0x27440180, 1754 0xa4a20008, 0x24020002, 0xa0a2000b, 0x3c021000, 0x0a0011f1, 0xa0a3000a,
1712 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x8f420148, 1755 0x8f420104, 0x3c030040, 0x00431024, 0x1040001d, 0x3c038000, 0x27450180,
1713 0x24030002, 0xa083000b, 0x00021402, 0xa4820008, 0x8f430148, 0xa4830010, 1756 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000,
1714 0x8f420144, 0x3c031000, 0xac820024, 0x03e00008, 0xaf4301b8, 0x27bdffe0, 1757 0x8f640040, 0x24030010, 0x240240c1, 0xa4a20008, 0x24020002, 0xa0a3000a,
1715 0xafbf0018, 0xafb10014, 0xafb00010, 0x8f420148, 0x24030002, 0x3044ffff, 1758 0x24030008, 0xa0a2000b, 0x3c021000, 0xa4a30010, 0xa0a00012, 0xa0a00013,
1716 0x00021402, 0x305000ff, 0x1203000c, 0x27510180, 0x2a020003, 0x10400005, 1759 0xaca00014, 0xaca00024, 0xaca00028, 0xaca0002c, 0xaca40018, 0x0e0015e0,
1717 0x24020003, 0x0600001d, 0x36053000, 0x0a00110a, 0x3c038000, 0x12020007, 1760 0xaf4201b8, 0x0a001436, 0x8fbf006c, 0x8f820000, 0x10400016, 0x00000000,
1718 0x00000000, 0x0a001117, 0x00000000, 0x0e00111f, 0x00000000, 0x0a001108, 1761 0x8f420104, 0x3c030001, 0x00431024, 0x10400011, 0x00000000, 0x8ca3000c,
1719 0x00402021, 0x0e001131, 0x00000000, 0x00402021, 0x36053000, 0x3c038000, 1762 0x8f620030, 0x1462022d, 0x24020001, 0x8ca30010, 0x8f62002c, 0x14620229,
1720 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002, 0xa6250008, 0xa222000b, 1763 0x24020001, 0x9763003a, 0x96c20000, 0x14430225, 0x24020001, 0x97630038,
1721 0xa6240010, 0x8f420144, 0x3c031000, 0xae220024, 0xaf4301b8, 0x0a00111b, 1764 0x96c20002, 0x14430221, 0x24020001, 0xaf400048, 0xaf400054, 0xaf400040,
1722 0x8fbf0018, 0x0000000d, 0x00000000, 0x24000295, 0x8fbf0018, 0x8fb10014, 1765 0x8f740040, 0x8f650048, 0x00b43023, 0x04c10004, 0x00000000, 0x0000000d,
1723 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3084ffff, 0x2c821389, 0x1040000d, 1766 0x00000000, 0x240001af, 0x9742011a, 0x3052ffff, 0x12400004, 0x8ed30004,
1724 0x00001021, 0x3c030800, 0x24635680, 0x00042942, 0x00052880, 0x00a32821, 1767 0x02721021, 0x0a001228, 0x2451ffff, 0x02608821, 0x92d7000d, 0xa7a00020,
1725 0x3086001f, 0x8ca40000, 0x24030001, 0x00c31804, 0x00832025, 0x03e00008, 1768 0xa3a0001a, 0xafa00028, 0x9362003f, 0x32e30004, 0x1060003a, 0x305000ff,
1726 0xaca40000, 0x03e00008, 0x24020091, 0x3084ffff, 0x2c821389, 0x1040000e, 1769 0x24040012, 0x16040006, 0x24020001, 0x3c040800, 0x8c830028, 0x24630001,
1727 0x00001021, 0x3c030800, 0x24635680, 0x00042942, 0x00052880, 0x00a32821, 1770 0x0a001328, 0xac830028, 0x8f620044, 0x16620010, 0x27a60010, 0x27450180,
1728 0x3086001f, 0x24030001, 0x8ca40000, 0x00c31804, 0x00031827, 0x00832024, 1771 0x3c038000, 0x2402001a, 0xa7a20020, 0x24020020, 0xafb40028, 0xa3b00022,
1729 0x03e00008, 0xaca40000, 0x03e00008, 0x24020091, 0x27bdffb0, 0xafbf0048, 1772 0xa3a40023, 0xa3a2001a, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000,
1730 0x93620023, 0x30420010, 0x1440025b, 0x24020001, 0x93420116, 0x93630005, 1773 0x0a00130d, 0x00000000, 0x8f620044, 0x02621023, 0x0440001a, 0x02651023,
1731 0x34424000, 0x30630001, 0x14600005, 0x03425821, 0x0e001548, 0x00000000, 1774 0x044100d9, 0x24020001, 0x3c020800, 0x8c4300d8, 0x10600004, 0x24020001,
1732 0x0a0013a5, 0x8fbf0048, 0x93420112, 0x8f430104, 0x3c040020, 0x34424000, 1775 0xa7a20020, 0x0a00125e, 0xafb40028, 0x2402001a, 0xa7a20020, 0x24020020,
1733 0x00641824, 0x10600012, 0x03422821, 0x27450180, 0x3c038000, 0x8f4201b8, 1776 0xafb40028, 0xa3b00022, 0xa3a40023, 0xa3a2001a, 0x27a60010, 0x27450180,
1777 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x0a00130d,
1778 0x00000000, 0x0a001328, 0x24020001, 0x0293f023, 0x1bc00016, 0x025e102a,
1779 0x54400007, 0x32f700fe, 0x57d2000f, 0x027e9821, 0x32e20001, 0x5440000c,
1780 0x027e9821, 0x32f700fe, 0x0240f021, 0x3c040800, 0x8c8300c8, 0x00009021,
1781 0x24020001, 0xa7a20020, 0xafb40028, 0x24630001, 0x0a001282, 0xac8300c8,
1782 0x025e1023, 0x0a001282, 0x3052ffff, 0x0000f021, 0x24a2ffff, 0x02221823,
1783 0x1860001f, 0x0072102a, 0x54400019, 0x00a08821, 0x97a20020, 0x3c040800,
1784 0x8c8300cc, 0xafb40028, 0x34420001, 0x24630001, 0xa7a20020, 0x02741026,
1785 0x2c420001, 0xac8300cc, 0x2cc30001, 0x00431024, 0x1440000a, 0x02401821,
1786 0x27a60010, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd,
1787 0x00000000, 0x0a00130d, 0x00000000, 0x00a08821, 0x02431023, 0x3052ffff,
1788 0x0a0012ae, 0x32f700f6, 0x02741023, 0x18400008, 0x97a20020, 0x3c040800,
1789 0x8c8300d4, 0xafb30028, 0x34420400, 0x24630001, 0xa7a20020, 0xac8300d4,
1790 0x32e20002, 0x1040001c, 0x32e20010, 0x8f620044, 0x1662000d, 0x27a60010,
1791 0x97a20020, 0x27450180, 0x3c038000, 0xafb40028, 0x34420001, 0xa7a20020,
1792 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x0a00130d, 0x00000000,
1793 0x97a20020, 0x27450180, 0x3c038000, 0xafb40028, 0x34420001, 0xa7a20020,
1794 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x0a00130d, 0x00000000,
1795 0x54400003, 0x8ed50008, 0x0a001328, 0x24020001, 0x8f630054, 0x26a2ffff,
1796 0x00431023, 0x18400011, 0x27a60010, 0x97a20020, 0x3c040800, 0x8c8300d0,
1797 0x27450180, 0x3c078000, 0xafb40028, 0x34420001, 0x24630001, 0xa7a20020,
1798 0xac8300d0, 0x8f4201b8, 0x00471024, 0x1440fffd, 0x00000000, 0x0a00130d,
1799 0x00000000, 0x32e20020, 0x10400011, 0x00000000, 0x96c20012, 0x0052102b,
1800 0x10400008, 0x97a20020, 0x96d20012, 0x12400003, 0x02721021, 0x0a0012f2,
1801 0x2451ffff, 0x02608821, 0x97a20020, 0x93a3001a, 0x34420008, 0x34630004,
1802 0xa7a20020, 0xa3a3001a, 0x8f420104, 0x3c030080, 0x00431024, 0x10400037,
1803 0x3a03000a, 0x0e001151, 0x02c02021, 0x24030002, 0x1443002b, 0x3c030800,
1804 0x27a60010, 0x97a20020, 0x27450180, 0x3c038000, 0xafb40028, 0x34420001,
1805 0xa7a20020, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128,
1806 0xaca20000, 0x8cc30018, 0x240240c1, 0xa4a20008, 0xaca30018, 0x90c4000a,
1807 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x94c20010, 0xa4a20010, 0x90c30012,
1808 0xa0a30012, 0x90c20013, 0xa0a20013, 0x8cc30014, 0xaca30014, 0x8cc20024,
1809 0xaca20024, 0x8cc30028, 0xaca30028, 0x8cc4002c, 0x24020001, 0x3c031000,
1810 0xaca4002c, 0xaf4301b8, 0xaf400044, 0xaf400050, 0x0a001436, 0x8fbf006c,
1811 0x8c626c98, 0x30420100, 0x10400003, 0x24636c98, 0x8c620004, 0xaf62017c,
1812 0x3a03000a, 0x2c630001, 0x3a02000c, 0x2c420001, 0x00621825, 0x14600003,
1813 0x2402000e, 0x56020030, 0x00009021, 0x52400008, 0x96c4000e, 0x12400004,
1814 0xa7b20040, 0x02721021, 0x0a001343, 0x2451ffff, 0x02608821, 0x96c4000e,
1815 0x93630035, 0x8f62004c, 0x00642004, 0x00952021, 0x00821023, 0x18400015,
1816 0x00000000, 0x8f620018, 0x02621023, 0x1c400015, 0x97a20020, 0x8f620018,
1817 0x1662001c, 0x00000000, 0x8f62001c, 0x02a21023, 0x1c40000e, 0x97a20020,
1818 0x8f62001c, 0x16a20015, 0x00000000, 0x8f620058, 0x00821023, 0x18400011,
1819 0x97a20020, 0x0a001364, 0xafb10028, 0x8f620058, 0x00821023, 0x0441000b,
1820 0x97a20020, 0xafb10028, 0xafb30034, 0xafb50038, 0xafa4003c, 0x34420020,
1821 0x0a00136d, 0xa7a20020, 0x02809821, 0x02608821, 0x8f640058, 0x8f62004c,
1822 0x02a21023, 0x18400009, 0x00000000, 0x8f620054, 0x02a21023, 0x1c400005,
1823 0x97a20020, 0xafb10028, 0xafb50024, 0x0a001385, 0x34420040, 0x9742011a,
1824 0x1440000c, 0x24020014, 0x8f620058, 0x14820009, 0x24020014, 0x8f63004c,
1825 0x8f620054, 0x10620004, 0x97a20020, 0xafb10028, 0x34420080, 0xa7a20020,
1826 0x24020014, 0x1202000a, 0x2a020015, 0x10400005, 0x2402000c, 0x12020006,
1827 0x32e20001, 0x0a0013c6, 0x00000000, 0x24020016, 0x16020035, 0x32e20001,
1828 0x8f620084, 0x24420001, 0x16a20031, 0x32e20001, 0x24020014, 0x12020021,
1829 0x2a020015, 0x10400005, 0x2402000c, 0x12020008, 0x32e20001, 0x0a0013c6,
1830 0x00000000, 0x24020016, 0x1202000c, 0x32e20001, 0x0a0013c6, 0x00000000,
1831 0x97a30020, 0x2402000e, 0xafb10028, 0xa3b00022, 0xa3a20023, 0xafb50024,
1832 0x34630054, 0x0a0013c5, 0xa7a30020, 0x97a20020, 0x93a4001a, 0x24030010,
1833 0xafb10028, 0xa3b00022, 0xa3a30023, 0xafb50024, 0x3442005d, 0x34840002,
1834 0xa7a20020, 0x0a0013c5, 0xa3a4001a, 0x97a20020, 0x24030012, 0xa3a30023,
1835 0x93a3001a, 0xafb10028, 0xa3b00022, 0xafb50024, 0x3042fffe, 0x3442005c,
1836 0x34630002, 0xa7a20020, 0xa3a3001a, 0x32e20001, 0x10400030, 0x2402000c,
1837 0x12020013, 0x2a02000d, 0x10400005, 0x2402000a, 0x12020008, 0x97a20020,
1838 0x0a0013f8, 0x32e20009, 0x2402000e, 0x1202001b, 0x32e20009, 0x0a0013f9,
1839 0x0002102b, 0x93a4001a, 0x24030008, 0xafb10028, 0xa3b00022, 0xa3a30023,
1840 0x0a0013f4, 0x34420013, 0x97a30020, 0x30620004, 0x14400005, 0x93a2001a,
1841 0x3463001b, 0xa7a30020, 0x0a0013e7, 0x24030016, 0x3463001b, 0xa7a30020,
1842 0x24030010, 0xafb10028, 0xa3b00022, 0xa3a30023, 0x34420002, 0x0a0013f7,
1843 0xa3a2001a, 0x97a20020, 0x93a4001a, 0x24030010, 0xafb10028, 0xa3b00022,
1844 0xa3a30023, 0x3442001b, 0x34840002, 0xa7a20020, 0xa3a4001a, 0x32e20009,
1845 0x0002102b, 0x00021023, 0x30420007, 0x12400015, 0x34450003, 0x8f820018,
1846 0x24030800, 0x27440180, 0x24420001, 0xaf820018, 0x24020004, 0xaf4301b8,
1847 0xa4850008, 0xa082000b, 0x93430120, 0x00003021, 0x3c021000, 0xa492000e,
1848 0xac950024, 0xac930028, 0x007e1821, 0xa483000c, 0xaf4201b8, 0x0a001413,
1849 0x97a20020, 0x24060001, 0x97a20020, 0x10400020, 0x27450180, 0x3c038000,
1850 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000,
1851 0x8fa30028, 0x240240c1, 0xa4a20008, 0xaca30018, 0x93a4001a, 0x24020002,
1852 0xa0a2000b, 0xa0a4000a, 0x97a20020, 0xa4a20010, 0x93a30022, 0xa0a30012,
1853 0x93a20023, 0xa0a20013, 0x8fa30024, 0xaca30014, 0x8fa20034, 0xaca20024,
1854 0x8fa30038, 0xaca30028, 0x8fa2003c, 0x3c031000, 0xaca2002c, 0xaf4301b8,
1855 0x00c01021, 0x8fbf006c, 0x8fbe0068, 0x8fb70064, 0x8fb60060, 0x8fb5005c,
1856 0x8fb40058, 0x8fb30054, 0x8fb20050, 0x8fb1004c, 0x8fb00048, 0x03e00008,
1857 0x27bd0070, 0x8f470140, 0x8f460148, 0x3c028000, 0x00c24024, 0x00062c02,
1858 0x30a300ff, 0x24020019, 0x106200e7, 0x27440180, 0x2862001a, 0x1040001f,
1859 0x24020008, 0x106200be, 0x28620009, 0x1040000d, 0x24020001, 0x10620046,
1860 0x28620002, 0x50400005, 0x24020006, 0x1060002e, 0x00a01821, 0x0a00155e,
1861 0x00000000, 0x1062005b, 0x00a01821, 0x0a00155e, 0x00000000, 0x2402000b,
1862 0x10620084, 0x2862000c, 0x10400005, 0x24020009, 0x106200bc, 0x00061c02,
1863 0x0a00155e, 0x00000000, 0x2402000e, 0x106200b7, 0x00061c02, 0x0a00155e,
1864 0x00000000, 0x28620021, 0x10400009, 0x2862001f, 0x104000c1, 0x2402001b,
1865 0x106200bf, 0x2402001c, 0x1062009a, 0x00061c02, 0x0a00155e, 0x00000000,
1866 0x240200c2, 0x106200ca, 0x286200c3, 0x10400005, 0x24020080, 0x1062005a,
1867 0x00a01821, 0x0a00155e, 0x00000000, 0x240200c9, 0x106200cd, 0x30c5ffff,
1868 0x0a00155e, 0x00000000, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd,
1869 0x24020001, 0xa4830008, 0x24030002, 0xac870000, 0xac800004, 0xa082000a,
1870 0xa083000b, 0xa4860010, 0x8f430144, 0x3c021000, 0xac800028, 0xac830024,
1871 0x3c036000, 0xaf4201b8, 0x03e00008, 0xac600808, 0x11000009, 0x00a01821,
1872 0x3c020800, 0x24030002, 0xa0436c88, 0x24426c88, 0xac470008, 0x8f430144,
1873 0x03e00008, 0xac430004, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd,
1874 0x24020002, 0xac800000, 0xac870004, 0xa4830008, 0xa082000a, 0xa082000b,
1875 0xa4860010, 0xac800024, 0x8f420144, 0x3c031000, 0xac820028, 0x3c026000,
1876 0xaf4301b8, 0x03e00008, 0xac400808, 0x3c080800, 0x3c058000, 0x8f4201b8,
1877 0x00451024, 0x1440fffd, 0x00000000, 0xac870000, 0x91026c88, 0x00002821,
1878 0x10400002, 0x25076c88, 0x8ce50008, 0xac850004, 0xa4830008, 0x91036c88,
1879 0x24020002, 0xa082000b, 0xa4860010, 0x34630001, 0xa083000a, 0x8f420144,
1880 0xac820024, 0x91036c88, 0x10600002, 0x00001021, 0x8ce20004, 0xac820028,
1881 0x3c021000, 0xaf4201b8, 0x3c026000, 0xa1006c88, 0x03e00008, 0xac400808,
1882 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020002, 0xa082000b,
1883 0xa4830008, 0xa4860010, 0x8f420144, 0x3c031000, 0xa4820012, 0x03e00008,
1884 0xaf4301b8, 0x30c2ffff, 0x14400028, 0x00061c02, 0x93620005, 0x30420004,
1885 0x14400020, 0x3c029000, 0x34420001, 0x00e21025, 0xaf420020, 0x3c038000,
1886 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620005, 0x3c038000,
1887 0x34630001, 0x00e31825, 0x34420004, 0xa3620005, 0xaf430020, 0x93620005,
1888 0x30420004, 0x14400003, 0x3c038000, 0x0000000d, 0x3c038000, 0x8f4201b8,
1889 0x00431024, 0x1440fffd, 0x24020005, 0x3c031000, 0xac870000, 0xa082000b,
1890 0xaf4301b8, 0x0a00150d, 0x00061c02, 0x0000000d, 0x03e00008, 0x00000000,
1891 0x00061c02, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020001,
1892 0xa4830008, 0x24030002, 0xac870000, 0xac800004, 0xa082000a, 0xa083000b,
1893 0xa4860010, 0x8f430144, 0x3c021000, 0xac800028, 0xac830024, 0x03e00008,
1894 0xaf4201b8, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020002,
1895 0xac800000, 0xac870004, 0xa4830008, 0xa082000a, 0xa082000b, 0xa4860010,
1896 0xac800024, 0x8f420144, 0x3c031000, 0xac820028, 0x03e00008, 0xaf4301b8,
1897 0x00061c02, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020001,
1898 0xa4830008, 0x24030002, 0xa082000a, 0x3c021000, 0xac870000, 0xac800004,
1899 0xa083000b, 0xa4860010, 0xac800024, 0xac800028, 0x03e00008, 0xaf4201b8,
1900 0x00a01821, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020002,
1901 0xac870000, 0xac800004, 0xa4830008, 0xa080000a, 0x0a001518, 0xa082000b,
1902 0x8f440144, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002,
1903 0x240340c9, 0xaf470180, 0xa342018b, 0x3c021000, 0xa7430188, 0xaf4401a4,
1904 0xaf4501a8, 0xaf4001ac, 0x03e00008, 0xaf4201b8, 0x0000000d, 0x03e00008,
1905 0x00000000, 0x03e00008, 0x00000000, 0x8f420100, 0x3042003e, 0x14400011,
1906 0x24020001, 0xaf400048, 0x8f420100, 0x304207c0, 0x10400005, 0x00000000,
1907 0xaf40004c, 0xaf400050, 0x03e00008, 0x24020001, 0xaf400054, 0xaf400040,
1908 0x8f420100, 0x30423800, 0x54400001, 0xaf400044, 0x24020001, 0x03e00008,
1909 0x00000000, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002,
1910 0x240340c9, 0xaf440180, 0xa342018b, 0x3c021000, 0xa7430188, 0xaf4501a4,
1911 0xaf4601a8, 0xaf4701ac, 0x03e00008, 0xaf4201b8, 0x3c029000, 0x34420001,
1912 0x00822025, 0xaf440020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
1913 0x00000000, 0x03e00008, 0x00000000, 0x3c028000, 0x34420001, 0x00822025,
1914 0x03e00008, 0xaf440020, 0x308600ff, 0x27450180, 0x3c038000, 0x8f4201b8,
1734 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000, 0x8f640040, 1915 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000, 0x8f640040,
1735 0x24030008, 0x240240c1, 0xa4a20008, 0x24020002, 0xa0a2000b, 0x3c021000, 1916 0x24030008, 0x240240c1, 0xa4a20008, 0x24020002, 0xa0a2000b, 0x3c021000,
1736 0x0a001181, 0xa0a3000a, 0x8f420104, 0x3c030040, 0x00431024, 0x1040001d, 1917 0xa0a6000a, 0xa4a30010, 0xa0a00012, 0xa0a00013, 0xaca00014, 0xaca00024,
1737 0x3c038000, 0x27450180, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 1918 0xaca00028, 0xaca0002c, 0xaca40018, 0x03e00008, 0xaf4201b8, 0x24020001,
1738 0x8f420128, 0xaca20000, 0x8f640040, 0x24030010, 0x240240c1, 0xa4a20008, 1919 0xacc40000, 0x03e00008, 0xa4e50000, 0x24020001, 0xaf400044, 0x03e00008,
1739 0x24020002, 0xa0a3000a, 0x24030008, 0xa0a2000b, 0x3c021000, 0xa4a30010, 1920 0xaf400050, 0x00803021, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024,
1740 0xa0a00012, 0xa0a00013, 0xaca00014, 0xaca00024, 0xaca00028, 0xaca0002c, 1921 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000, 0x8cc30018, 0x240240c1,
1741 0xaca40018, 0x0e001548, 0xaf4201b8, 0x0a0013a5, 0x8fbf0048, 0x8f820000, 1922 0xa4a20008, 0xaca30018, 0x90c4000a, 0x24020002, 0xa0a2000b, 0xa0a4000a,
1742 0x10400016, 0x00000000, 0x8f420104, 0x3c030001, 0x00431024, 0x10400011, 1923 0x94c20010, 0xa4a20010, 0x90c30012, 0xa0a30012, 0x90c20013, 0xa0a20013,
1743 0x00000000, 0x8ca3000c, 0x8f620030, 0x1462020c, 0x24020001, 0x8ca30010, 1924 0x8cc30014, 0xaca30014, 0x8cc20024, 0xaca20024, 0x8cc30028, 0xaca30028,
1744 0x8f62002c, 0x14620208, 0x24020001, 0x9763003a, 0x95620000, 0x14430204, 1925 0x8cc2002c, 0x3c031000, 0xaca2002c, 0x24020001, 0xaf4301b8, 0xaf400044,
1745 0x24020001, 0x97630038, 0x95620002, 0x14430200, 0x24020001, 0xaf400048, 1926 0x03e00008, 0xaf400050, 0x27bdffe8, 0xafbf0010, 0x0e001047, 0x00000000,
1746 0xaf400054, 0xaf400040, 0x8f690040, 0x8f6a0048, 0x01497023, 0x05c10004, 1927 0x00002021, 0x0e000c78, 0xaf400180, 0x8fbf0010, 0x03e00008, 0x27bd0018,
1747 0x00000000, 0x0000000d, 0x00000000, 0x24000169, 0x9742011a, 0x3046ffff, 1928 0x8f460148, 0x27450180, 0x3c038000, 0x00061402, 0x304700ff, 0x8f4201b8,
1748 0x10c00004, 0x8d680004, 0x01061021, 0x0a0011b8, 0x2445ffff, 0x01002821, 1929 0x00431024, 0x1440fffd, 0x00000000, 0x8f440140, 0x00061202, 0x304200ff,
1749 0x916c000d, 0xa7a00020, 0xa3a0001a, 0xafa00028, 0x9362003f, 0x31830004, 1930 0x00061c02, 0xaca20004, 0x24020002, 0xa4a30008, 0x30c300ff, 0xa0a2000b,
1750 0x1060003a, 0x304700ff, 0x24040012, 0x14e40006, 0x24020001, 0x3c040800, 1931 0xaca30024, 0x10e0000a, 0xaca40000, 0x28e20004, 0x14400005, 0x24020001,
1751 0x8c830028, 0x24630001, 0x0a00128d, 0xac830028, 0x8f620044, 0x15020010, 1932 0x24020005, 0x54e20005, 0xa0a0000a, 0x24020001, 0x0a001609, 0xa0a2000a,
1752 0x27a60010, 0x27450180, 0x3c038000, 0x2402001a, 0xa7a20020, 0x24020020, 1933 0xa0a0000a, 0x3c021000, 0x03e00008, 0xaf4201b8, 0x03e00008, 0x00001021,
1753 0xafa90028, 0xa3a70022, 0xa3a40023, 0xa3a2001a, 0x8f4201b8, 0x00431024, 1934 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000,
1754 0x1440fffd, 0x00000000, 0x0a001272, 0x00000000, 0x8f620044, 0x01021023, 1935 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000, 0x0a00161f, 0x00a01021,
1755 0x0440001a, 0x010a1023, 0x044100ae, 0x24020001, 0x3c020800, 0x8c4300d8, 1936 0xac860000, 0x00000000, 0x00000000, 0x24840004, 0x00a01021, 0x1440fffa,
1756 0x10600004, 0x24020001, 0xa7a20020, 0x0a0011ee, 0xafa90028, 0x2402001a, 1937 0x24a5ffff, 0x03e00008, 0x00000000, 0x00000000 };
1757 0xa7a20020, 0x24020020, 0xafa90028, 0xa3a70022, 0xa3a40023, 0xa3a2001a,
1758 0x27a60010, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd,
1759 0x00000000, 0x0a001272, 0x00000000, 0x0a00128d, 0x24020001, 0x01286823,
1760 0x19a00016, 0x00cd102a, 0x54400007, 0x318c00fe, 0x55a6000f, 0x010d4021,
1761 0x31820001, 0x5440000c, 0x010d4021, 0x318c00fe, 0x00c06821, 0x3c040800,
1762 0x8c8300c8, 0x00003021, 0x24020001, 0xa7a20020, 0xafa90028, 0x24630001,
1763 0x0a001212, 0xac8300c8, 0x00cd1023, 0x0a001212, 0x3046ffff, 0x00006821,
1764 0x2542ffff, 0x00a21823, 0x1860001e, 0x0066102a, 0x14400018, 0x01402821,
1765 0x97a20020, 0x3c040800, 0x8c8300cc, 0xafa90028, 0x34420001, 0x24630001,
1766 0xa7a20020, 0x01091026, 0x2c420001, 0xac8300cc, 0x2dc30001, 0x00431024,
1767 0x1440000a, 0x00c01821, 0x27a60010, 0x27450180, 0x3c038000, 0x8f4201b8,
1768 0x00431024, 0x1440fffd, 0x00000000, 0x0a001272, 0x00000000, 0x00c31023,
1769 0x3046ffff, 0x0a00123d, 0x318c00f6, 0x01091023, 0x18400008, 0x97a20020,
1770 0x3c040800, 0x8c8300d4, 0xafa80028, 0x34420400, 0x24630001, 0xa7a20020,
1771 0xac8300d4, 0x31820002, 0x1040001c, 0x31820010, 0x8f620044, 0x1502000d,
1772 0x27a60010, 0x97a20020, 0x27450180, 0x3c038000, 0xafa90028, 0x34420001,
1773 0xa7a20020, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x0a001272,
1774 0x00000000, 0x97a20020, 0x27450180, 0x3c038000, 0xafa90028, 0x34420001,
1775 0xa7a20020, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x0a001272,
1776 0x00000000, 0x54400003, 0x8d6a0008, 0x0a00128d, 0x24020001, 0x8f630054,
1777 0x2542ffff, 0x00431023, 0x1840002e, 0x97a20020, 0x27a60010, 0x3c040800,
1778 0x8c8300d0, 0x27450180, 0x3c078000, 0xafa90028, 0x34420001, 0x24630001,
1779 0xa7a20020, 0xac8300d0, 0x8f4201b8, 0x00471024, 0x1440fffd, 0x00000000,
1780 0x8f420128, 0xaca20000, 0x8cc30018, 0x240240c1, 0xa4a20008, 0xaca30018,
1781 0x90c4000a, 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x94c20010, 0xa4a20010,
1782 0x90c30012, 0xa0a30012, 0x90c20013, 0xa0a20013, 0x8cc30014, 0xaca30014,
1783 0x8cc20024, 0xaca20024, 0x8cc30028, 0xaca30028, 0x8cc4002c, 0x24020001,
1784 0x3c031000, 0xaca4002c, 0xaf4301b8, 0xaf400044, 0xaf400050, 0x0a0013a5,
1785 0x8fbf0048, 0x31820020, 0x10400011, 0x00000000, 0x95620012, 0x0046102b,
1786 0x10400008, 0x97a20020, 0x95660012, 0x10c00003, 0x01061021, 0x0a00129e,
1787 0x2445ffff, 0x01002821, 0x97a20020, 0x93a3001a, 0x34420008, 0x34630004,
1788 0xa7a20020, 0xa3a3001a, 0x8f420104, 0x38e3000a, 0x2c630001, 0x38e2000c,
1789 0x2c420001, 0x00621825, 0x14600003, 0x2402000e, 0x54e2002a, 0x00003021,
1790 0x50c00008, 0x9564000e, 0x10c00004, 0xa7a60040, 0x01061021, 0x0a0012b6,
1791 0x2445ffff, 0x01002821, 0x9564000e, 0x93630035, 0x8f62004c, 0x00642004,
1792 0x008a2021, 0x00821023, 0x1840001d, 0x00000000, 0x8f620018, 0x01021023,
1793 0x1c40000f, 0x97a20020, 0x8f620018, 0x15020016, 0x00000000, 0x8f62001c,
1794 0x01421023, 0x1c400008, 0x97a20020, 0x8f62001c, 0x1542000f, 0x00000000,
1795 0x8f620058, 0x00821023, 0x1840000b, 0x97a20020, 0xafa50028, 0xafa80034,
1796 0xafaa0038, 0xafa4003c, 0x34420020, 0x0a0012da, 0xa7a20020, 0x01204021,
1797 0x01002821, 0x8f640058, 0x8f62004c, 0x01421023, 0x18400009, 0x00000000,
1798 0x8f620054, 0x01421023, 0x1c400005, 0x97a20020, 0xafa50028, 0xafaa0024,
1799 0x0a0012f2, 0x34420040, 0x9742011a, 0x1440000c, 0x24020014, 0x8f620058,
1800 0x14820009, 0x24020014, 0x8f63004c, 0x8f620054, 0x10620004, 0x97a20020,
1801 0xafa50028, 0x34420080, 0xa7a20020, 0x24020014, 0x10e2000a, 0x28e20015,
1802 0x10400005, 0x2402000c, 0x10e20006, 0x31820001, 0x0a001333, 0x00000000,
1803 0x24020016, 0x14e20035, 0x31820001, 0x8f620084, 0x24420001, 0x15420031,
1804 0x31820001, 0x24020014, 0x10e20021, 0x28e20015, 0x10400005, 0x2402000c,
1805 0x10e20008, 0x31820001, 0x0a001333, 0x00000000, 0x24020016, 0x10e2000c,
1806 0x31820001, 0x0a001333, 0x00000000, 0x97a30020, 0x2402000e, 0xafa50028,
1807 0xa3a70022, 0xa3a20023, 0xafaa0024, 0x34630054, 0x0a001332, 0xa7a30020,
1808 0x97a20020, 0x93a4001a, 0x24030010, 0xafa50028, 0xa3a70022, 0xa3a30023,
1809 0xafaa0024, 0x3442005d, 0x34840002, 0xa7a20020, 0x0a001332, 0xa3a4001a,
1810 0x97a20020, 0x24030012, 0xa3a30023, 0x93a3001a, 0xafa50028, 0xa3a70022,
1811 0xafaa0024, 0x3042fffe, 0x3442005c, 0x34630002, 0xa7a20020, 0xa3a3001a,
1812 0x31820001, 0x10400030, 0x2402000c, 0x10e20013, 0x28e2000d, 0x10400005,
1813 0x2402000a, 0x10e20008, 0x97a20020, 0x0a001365, 0x31820009, 0x2402000e,
1814 0x10e2001b, 0x31820009, 0x0a001366, 0x0002102b, 0x93a4001a, 0x24030008,
1815 0xafa50028, 0xa3a70022, 0xa3a30023, 0x0a001361, 0x34420013, 0x97a30020,
1816 0x30620004, 0x14400005, 0x93a2001a, 0x3463001b, 0xa7a30020, 0x0a001354,
1817 0x24030016, 0x3463001b, 0xa7a30020, 0x24030010, 0xafa50028, 0xa3a70022,
1818 0xa3a30023, 0x34420002, 0x0a001364, 0xa3a2001a, 0x97a20020, 0x93a4001a,
1819 0x24030010, 0xafa50028, 0xa3a70022, 0xa3a30023, 0x3442001b, 0x34840002,
1820 0xa7a20020, 0xa3a4001a, 0x31820009, 0x0002102b, 0x00021023, 0x30420007,
1821 0x10c00017, 0x34440003, 0x8f820014, 0x24030800, 0x27450180, 0x24420001,
1822 0xaf820014, 0x24020004, 0xaf4301b8, 0xa4a40008, 0xa0a2000b, 0x93440120,
1823 0x3c031000, 0xa4a6000e, 0xacaa0024, 0xaca80028, 0x008d2021, 0xa4a4000c,
1824 0xaf4301b8, 0x97a20020, 0x00003021, 0x3042ffbf, 0x0a001381, 0xa7a20020,
1825 0x24060001, 0x97a20020, 0x10400020, 0x27450180, 0x3c038000, 0x8f4201b8,
1826 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000, 0x8fa30028,
1827 0x240240c1, 0xa4a20008, 0xaca30018, 0x93a4001a, 0x24020002, 0xa0a2000b,
1828 0xa0a4000a, 0x97a20020, 0xa4a20010, 0x93a30022, 0xa0a30012, 0x93a20023,
1829 0xa0a20013, 0x8fa30024, 0xaca30014, 0x8fa20034, 0xaca20024, 0x8fa30038,
1830 0xaca30028, 0x8fa2003c, 0x3c031000, 0xaca2002c, 0xaf4301b8, 0x00c01021,
1831 0x8fbf0048, 0x03e00008, 0x27bd0050, 0x8f470140, 0x8f460148, 0x3c028000,
1832 0x00c24024, 0x00062c02, 0x30a300ff, 0x24020019, 0x106200e7, 0x27440180,
1833 0x2862001a, 0x1040001f, 0x24020008, 0x106200be, 0x28620009, 0x1040000d,
1834 0x24020001, 0x10620046, 0x28620002, 0x50400005, 0x24020006, 0x1060002e,
1835 0x00a01821, 0x0a0014c4, 0x00000000, 0x1062005b, 0x00a01821, 0x0a0014c4,
1836 0x00000000, 0x2402000b, 0x10620084, 0x2862000c, 0x10400005, 0x24020009,
1837 0x106200bc, 0x00061c02, 0x0a0014c4, 0x00000000, 0x2402000e, 0x106200b7,
1838 0x00061c02, 0x0a0014c4, 0x00000000, 0x28620021, 0x10400009, 0x2862001f,
1839 0x104000c1, 0x2402001b, 0x106200bf, 0x2402001c, 0x1062009a, 0x00061c02,
1840 0x0a0014c4, 0x00000000, 0x240200c2, 0x106200ca, 0x286200c3, 0x10400005,
1841 0x24020080, 0x1062005a, 0x00a01821, 0x0a0014c4, 0x00000000, 0x240200c9,
1842 0x106200cd, 0x30c5ffff, 0x0a0014c4, 0x00000000, 0x3c058000, 0x8f4201b8,
1843 0x00451024, 0x1440fffd, 0x24020001, 0xa4830008, 0x24030002, 0xac870000,
1844 0xac800004, 0xa082000a, 0xa083000b, 0xa4860010, 0x8f430144, 0x3c021000,
1845 0xac800028, 0xac830024, 0x3c036000, 0xaf4201b8, 0x03e00008, 0xac600808,
1846 0x11000009, 0x00a01821, 0x3c020800, 0x24030002, 0xa0436a08, 0x24426a08,
1847 0xac470008, 0x8f430144, 0x03e00008, 0xac430004, 0x3c058000, 0x8f4201b8,
1848 0x00451024, 0x1440fffd, 0x24020002, 0xac800000, 0xac870004, 0xa4830008,
1849 0xa082000a, 0xa082000b, 0xa4860010, 0xac800024, 0x8f420144, 0x3c031000,
1850 0xac820028, 0x3c026000, 0xaf4301b8, 0x03e00008, 0xac400808, 0x3c080800,
1851 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x00000000, 0xac870000,
1852 0x91026a08, 0x00002821, 0x10400002, 0x25076a08, 0x8ce50008, 0xac850004,
1853 0xa4830008, 0x91036a08, 0x24020002, 0xa082000b, 0xa4860010, 0x34630001,
1854 0xa083000a, 0x8f420144, 0xac820024, 0x91036a08, 0x10600002, 0x00001021,
1855 0x8ce20004, 0xac820028, 0x3c021000, 0xaf4201b8, 0x3c026000, 0xa1006a08,
1856 0x03e00008, 0xac400808, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd,
1857 0x24020002, 0xa082000b, 0xa4830008, 0xa4860010, 0x8f420144, 0x3c031000,
1858 0xa4820012, 0x03e00008, 0xaf4301b8, 0x30c2ffff, 0x14400028, 0x00061c02,
1859 0x93620005, 0x30420004, 0x14400020, 0x3c029000, 0x34420001, 0x00e21025,
1860 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000,
1861 0x93620005, 0x3c038000, 0x34630001, 0x00e31825, 0x34420004, 0xa3620005,
1862 0xaf430020, 0x93620005, 0x30420004, 0x14400003, 0x3c038000, 0x0000000d,
1863 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020005, 0x3c031000,
1864 0xac870000, 0xa082000b, 0xaf4301b8, 0x0a001473, 0x00061c02, 0x0000000d,
1865 0x03e00008, 0x00000000, 0x00061c02, 0x3c058000, 0x8f4201b8, 0x00451024,
1866 0x1440fffd, 0x24020001, 0xa4830008, 0x24030002, 0xac870000, 0xac800004,
1867 0xa082000a, 0xa083000b, 0xa4860010, 0x8f430144, 0x3c021000, 0xac800028,
1868 0xac830024, 0x03e00008, 0xaf4201b8, 0x3c058000, 0x8f4201b8, 0x00451024,
1869 0x1440fffd, 0x24020002, 0xac800000, 0xac870004, 0xa4830008, 0xa082000a,
1870 0xa082000b, 0xa4860010, 0xac800024, 0x8f420144, 0x3c031000, 0xac820028,
1871 0x03e00008, 0xaf4301b8, 0x00061c02, 0x3c058000, 0x8f4201b8, 0x00451024,
1872 0x1440fffd, 0x24020001, 0xa4830008, 0x24030002, 0xa082000a, 0x3c021000,
1873 0xac870000, 0xac800004, 0xa083000b, 0xa4860010, 0xac800024, 0xac800028,
1874 0x03e00008, 0xaf4201b8, 0x00a01821, 0x3c058000, 0x8f4201b8, 0x00451024,
1875 0x1440fffd, 0x24020002, 0xac870000, 0xac800004, 0xa4830008, 0xa080000a,
1876 0x0a00147e, 0xa082000b, 0x8f440144, 0x3c038000, 0x8f4201b8, 0x00431024,
1877 0x1440fffd, 0x24020002, 0x240340c9, 0xaf470180, 0xa342018b, 0x3c021000,
1878 0xa7430188, 0xaf4401a4, 0xaf4501a8, 0xaf4001ac, 0x03e00008, 0xaf4201b8,
1879 0x0000000d, 0x03e00008, 0x00000000, 0x03e00008, 0x00000000, 0x8f420100,
1880 0x3042003e, 0x14400011, 0x24020001, 0xaf400048, 0x8f420100, 0x304207c0,
1881 0x10400005, 0x00000000, 0xaf40004c, 0xaf400050, 0x03e00008, 0x24020001,
1882 0xaf400054, 0xaf400040, 0x8f420100, 0x30423800, 0x54400001, 0xaf400044,
1883 0x24020001, 0x03e00008, 0x00000000, 0x3c038000, 0x8f4201b8, 0x00431024,
1884 0x1440fffd, 0x24020002, 0x240340c9, 0xaf440180, 0xa342018b, 0x3c021000,
1885 0xa7430188, 0xaf4501a4, 0xaf4601a8, 0xaf4701ac, 0x03e00008, 0xaf4201b8,
1886 0x3c029000, 0x34420001, 0x00822025, 0xaf440020, 0x3c038000, 0x8f420020,
1887 0x00431024, 0x1440fffd, 0x00000000, 0x03e00008, 0x00000000, 0x3c028000,
1888 0x34420001, 0x00822025, 0x03e00008, 0xaf440020, 0x308600ff, 0x27450180,
1889 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128,
1890 0xaca20000, 0x8f640040, 0x24030008, 0x240240c1, 0xa4a20008, 0x24020002,
1891 0xa0a2000b, 0x3c021000, 0xa0a6000a, 0xa4a30010, 0xa0a00012, 0xa0a00013,
1892 0xaca00014, 0xaca00024, 0xaca00028, 0xaca0002c, 0xaca40018, 0x03e00008,
1893 0xaf4201b8, 0x24020001, 0xacc40000, 0x03e00008, 0xa4e50000, 0x03e00008,
1894 0x24020001, 0x24020001, 0xaf400044, 0x03e00008, 0xaf400050, 0x00803021,
1895 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000,
1896 0x8f420128, 0xaca20000, 0x8cc30018, 0x240240c1, 0xa4a20008, 0xaca30018,
1897 0x90c4000a, 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x94c20010, 0xa4a20010,
1898 0x90c30012, 0xa0a30012, 0x90c20013, 0xa0a20013, 0x8cc30014, 0xaca30014,
1899 0x8cc20024, 0xaca20024, 0x8cc30028, 0xaca30028, 0x8cc2002c, 0x3c031000,
1900 0xaca2002c, 0x24020001, 0xaf4301b8, 0xaf400044, 0x03e00008, 0xaf400050,
1901 0x27bdffe8, 0xafbf0010, 0x0e001032, 0x00000000, 0x00002021, 0x0e000c99,
1902 0xaf400180, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x8f460148, 0x27450180,
1903 0x3c038000, 0x00061402, 0x304700ff, 0x8f4201b8, 0x00431024, 0x1440fffd,
1904 0x00000000, 0x8f440140, 0x00061202, 0x304200ff, 0x00061c02, 0xaca20004,
1905 0x24020002, 0xa4a30008, 0x30c300ff, 0xa0a2000b, 0xaca30024, 0x10e0000a,
1906 0xaca40000, 0x28e20004, 0x14400005, 0x24020001, 0x24020005, 0x54e20005,
1907 0xa0a0000a, 0x24020001, 0x0a001571, 0xa0a2000a, 0xa0a0000a, 0x3c021000,
1908 0x03e00008, 0xaf4201b8, 0x03e00008, 0x00001021, 0x10c00007, 0x00000000,
1909 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000, 0x14c0fffb, 0x24840004,
1910 0x03e00008, 0x00000000, 0x0a001587, 0x00a01021, 0xac860000, 0x00000000,
1911 0x00000000, 0x24840004, 0x00a01021, 0x1440fffa, 0x24a5ffff, 0x03e00008,
1912 0x00000000, 0x00000000 };
1913 1938
1914static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x0 }; 1939static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x0 };
1915static u32 bnx2_RXP_b06FwRodata[(0x0/4) + 1] = { 0x0 }; 1940static u32 bnx2_RXP_b06FwRodata[(0x28/4) + 1] = {
1916static u32 bnx2_RXP_b06FwBss[(0x1394/4) + 1] = { 0x0 }; 1941 0x0800468c, 0x0800458c, 0x08004630, 0x08004648, 0x08004660, 0x08004680,
1917static u32 bnx2_RXP_b06FwSbss[(0x18/4) + 1] = { 0x0 }; 1942 0x0800468c, 0x0800468c, 0x08004594, 0x00000000, 0x00000000 };
1943static u32 bnx2_RXP_b06FwBss[(0x13a4/4) + 1] = { 0x0 };
1944static u32 bnx2_RXP_b06FwSbss[(0x1c/4) + 1] = { 0x0 };
1918 1945
1919static u32 bnx2_rv2p_proc1[] = { 1946static u32 bnx2_rv2p_proc1[] = {
1920 0x00000008, 0xac000001, 0x0000000c, 0x2f800001, 0x00000010, 0x213f0004, 1947 0x00000008, 0xac000001, 0x0000000c, 0x2f800001, 0x00000010, 0x213f0004,
diff --git a/drivers/net/lp486e.c b/drivers/net/lp486e.c
index 6139f06d7d2b..94d5ea1ce8bd 100644
--- a/drivers/net/lp486e.c
+++ b/drivers/net/lp486e.c
@@ -56,8 +56,6 @@ PORT SIZE ACTION MEANING
56All other communication is through memory! 56All other communication is through memory!
57*/ 57*/
58 58
59#define SLOW_DOWN_IO udelay(5)
60
61#include <linux/module.h> 59#include <linux/module.h>
62#include <linux/init.h> 60#include <linux/init.h>
63#include <linux/delay.h> 61#include <linux/delay.h>
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 1c6d328165bb..0245e40b51a1 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1610,6 +1610,8 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1610 } 1610 }
1611 else if (!pskb_may_pull(skb, skb->len)) 1611 else if (!pskb_may_pull(skb, skb->len))
1612 goto err; 1612 goto err;
1613 else
1614 skb->ip_summed = CHECKSUM_NONE;
1613 1615
1614 len = slhc_uncompress(ppp->vj, skb->data + 2, skb->len - 2); 1616 len = slhc_uncompress(ppp->vj, skb->data + 2, skb->len - 2);
1615 if (len <= 0) { 1617 if (len <= 0) {
@@ -1690,6 +1692,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1690 kfree_skb(skb); 1692 kfree_skb(skb);
1691 } else { 1693 } else {
1692 skb_pull(skb, 2); /* chop off protocol */ 1694 skb_pull(skb, 2); /* chop off protocol */
1695 skb_postpull_rcsum(skb, skb->data - 2, 2);
1693 skb->dev = ppp->dev; 1696 skb->dev = ppp->dev;
1694 skb->protocol = htons(npindex_to_ethertype[npi]); 1697 skb->protocol = htons(npindex_to_ethertype[npi]);
1695 skb->mac.raw = skb->data; 1698 skb->mac.raw = skb->data;
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index f2d1dafde087..e7dc653d5bd6 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -69,8 +69,8 @@
69 69
70#define DRV_MODULE_NAME "tg3" 70#define DRV_MODULE_NAME "tg3"
71#define PFX DRV_MODULE_NAME ": " 71#define PFX DRV_MODULE_NAME ": "
72#define DRV_MODULE_VERSION "3.48" 72#define DRV_MODULE_VERSION "3.49"
73#define DRV_MODULE_RELDATE "Jan 16, 2006" 73#define DRV_MODULE_RELDATE "Feb 2, 2006"
74 74
75#define TG3_DEF_MAC_MODE 0 75#define TG3_DEF_MAC_MODE 0
76#define TG3_DEF_RX_MODE 0 76#define TG3_DEF_RX_MODE 0
@@ -3482,6 +3482,17 @@ static void tg3_reset_task(void *_data)
3482 struct tg3 *tp = _data; 3482 struct tg3 *tp = _data;
3483 unsigned int restart_timer; 3483 unsigned int restart_timer;
3484 3484
3485 tg3_full_lock(tp, 0);
3486 tp->tg3_flags |= TG3_FLAG_IN_RESET_TASK;
3487
3488 if (!netif_running(tp->dev)) {
3489 tp->tg3_flags &= ~TG3_FLAG_IN_RESET_TASK;
3490 tg3_full_unlock(tp);
3491 return;
3492 }
3493
3494 tg3_full_unlock(tp);
3495
3485 tg3_netif_stop(tp); 3496 tg3_netif_stop(tp);
3486 3497
3487 tg3_full_lock(tp, 1); 3498 tg3_full_lock(tp, 1);
@@ -3494,10 +3505,12 @@ static void tg3_reset_task(void *_data)
3494 3505
3495 tg3_netif_start(tp); 3506 tg3_netif_start(tp);
3496 3507
3497 tg3_full_unlock(tp);
3498
3499 if (restart_timer) 3508 if (restart_timer)
3500 mod_timer(&tp->timer, jiffies + 1); 3509 mod_timer(&tp->timer, jiffies + 1);
3510
3511 tp->tg3_flags &= ~TG3_FLAG_IN_RESET_TASK;
3512
3513 tg3_full_unlock(tp);
3501} 3514}
3502 3515
3503static void tg3_tx_timeout(struct net_device *dev) 3516static void tg3_tx_timeout(struct net_device *dev)
@@ -6786,6 +6799,13 @@ static int tg3_close(struct net_device *dev)
6786{ 6799{
6787 struct tg3 *tp = netdev_priv(dev); 6800 struct tg3 *tp = netdev_priv(dev);
6788 6801
6802 /* Calling flush_scheduled_work() may deadlock because
6803 * linkwatch_event() may be on the workqueue and it will try to get
6804 * the rtnl_lock which we are holding.
6805 */
6806 while (tp->tg3_flags & TG3_FLAG_IN_RESET_TASK)
6807 msleep(1);
6808
6789 netif_stop_queue(dev); 6809 netif_stop_queue(dev);
6790 6810
6791 del_timer_sync(&tp->timer); 6811 del_timer_sync(&tp->timer);
@@ -10880,6 +10900,7 @@ static void __devexit tg3_remove_one(struct pci_dev *pdev)
10880 if (dev) { 10900 if (dev) {
10881 struct tg3 *tp = netdev_priv(dev); 10901 struct tg3 *tp = netdev_priv(dev);
10882 10902
10903 flush_scheduled_work();
10883 unregister_netdev(dev); 10904 unregister_netdev(dev);
10884 if (tp->regs) { 10905 if (tp->regs) {
10885 iounmap(tp->regs); 10906 iounmap(tp->regs);
@@ -10901,6 +10922,7 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
10901 if (!netif_running(dev)) 10922 if (!netif_running(dev))
10902 return 0; 10923 return 0;
10903 10924
10925 flush_scheduled_work();
10904 tg3_netif_stop(tp); 10926 tg3_netif_stop(tp);
10905 10927
10906 del_timer_sync(&tp->timer); 10928 del_timer_sync(&tp->timer);
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index e8243305f0e8..7f4b7f6ac40d 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2162,6 +2162,7 @@ struct tg3 {
2162#define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000 2162#define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000
2163#define TG3_FLAG_10_100_ONLY 0x01000000 2163#define TG3_FLAG_10_100_ONLY 0x01000000
2164#define TG3_FLAG_PAUSE_AUTONEG 0x02000000 2164#define TG3_FLAG_PAUSE_AUTONEG 0x02000000
2165#define TG3_FLAG_IN_RESET_TASK 0x04000000
2165#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000 2166#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000
2166#define TG3_FLAG_GOT_SERDES_FLOWCTL 0x20000000 2167#define TG3_FLAG_GOT_SERDES_FLOWCTL 0x20000000
2167#define TG3_FLAG_SPLIT_MODE 0x40000000 2168#define TG3_FLAG_SPLIT_MODE 0x40000000
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 734d2cb1de06..0702f0eeb784 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -2463,7 +2463,7 @@ static void ipw_eeprom_init_sram(struct ipw_priv *priv)
2463 copy. Otherwise let the firmware know to perform the operation 2463 copy. Otherwise let the firmware know to perform the operation
2464 on its own. 2464 on its own.
2465 */ 2465 */
2466 if ((priv->eeprom + EEPROM_VERSION) != 0) { 2466 if (priv->eeprom[EEPROM_VERSION] != 0) {
2467 IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n"); 2467 IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n");
2468 2468
2469 /* write the eeprom data to sram */ 2469 /* write the eeprom data to sram */
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 9e0229f7e25f..f46e8438e0d2 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -1423,7 +1423,7 @@ static void __init ccio_init_resources(struct ioc *ioc)
1423 struct resource *res = ioc->mmio_region; 1423 struct resource *res = ioc->mmio_region;
1424 char *name = kmalloc(14, GFP_KERNEL); 1424 char *name = kmalloc(14, GFP_KERNEL);
1425 1425
1426 sprintf(name, "GSC Bus [%d/]", ioc->hw_path); 1426 snprintf(name, 14, "GSC Bus [%d/]", ioc->hw_path);
1427 1427
1428 ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low); 1428 ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low);
1429 ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv); 1429 ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv);
@@ -1557,12 +1557,11 @@ static int ccio_probe(struct parisc_device *dev)
1557 int i; 1557 int i;
1558 struct ioc *ioc, **ioc_p = &ioc_list; 1558 struct ioc *ioc, **ioc_p = &ioc_list;
1559 1559
1560 ioc = kmalloc(sizeof(struct ioc), GFP_KERNEL); 1560 ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL);
1561 if (ioc == NULL) { 1561 if (ioc == NULL) {
1562 printk(KERN_ERR MODULE_NAME ": memory allocation failure\n"); 1562 printk(KERN_ERR MODULE_NAME ": memory allocation failure\n");
1563 return 1; 1563 return 1;
1564 } 1564 }
1565 memset(ioc, 0, sizeof(struct ioc));
1566 1565
1567 ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn"; 1566 ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn";
1568 1567
@@ -1578,7 +1577,7 @@ static int ccio_probe(struct parisc_device *dev)
1578 ccio_ioc_init(ioc); 1577 ccio_ioc_init(ioc);
1579 ccio_init_resources(ioc); 1578 ccio_init_resources(ioc);
1580 hppa_dma_ops = &ccio_ops; 1579 hppa_dma_ops = &ccio_ops;
1581 dev->dev.platform_data = kmalloc(sizeof(struct pci_hba_data), GFP_KERNEL); 1580 dev->dev.platform_data = kzalloc(sizeof(struct pci_hba_data), GFP_KERNEL);
1582 1581
1583 /* if this fails, no I/O cards will work, so may as well bug */ 1582 /* if this fails, no I/O cards will work, so may as well bug */
1584 BUG_ON(dev->dev.platform_data == NULL); 1583 BUG_ON(dev->dev.platform_data == NULL);
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index 216d1d859326..3d1a7f98c676 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -989,14 +989,12 @@ static int __init dino_probe(struct parisc_device *dev)
989*/ 989*/
990 } 990 }
991 991
992 dino_dev = kmalloc(sizeof(struct dino_device), GFP_KERNEL); 992 dino_dev = kzalloc(sizeof(struct dino_device), GFP_KERNEL);
993 if (!dino_dev) { 993 if (!dino_dev) {
994 printk("dino_init_chip - couldn't alloc dino_device\n"); 994 printk("dino_init_chip - couldn't alloc dino_device\n");
995 return 1; 995 return 1;
996 } 996 }
997 997
998 memset(dino_dev, 0, sizeof(struct dino_device));
999
1000 dino_dev->hba.dev = dev; 998 dino_dev->hba.dev = dev;
1001 dino_dev->hba.base_addr = ioremap(hpa, 4096); 999 dino_dev->hba.base_addr = ioremap(hpa, 4096);
1002 dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */ 1000 dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */
diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c
index 5edf93f80757..07dc2b6d4e93 100644
--- a/drivers/parisc/hppb.c
+++ b/drivers/parisc/hppb.c
@@ -60,12 +60,11 @@ static int hppb_probe(struct parisc_device *dev)
60 } 60 }
61 61
62 if(card->hpa) { 62 if(card->hpa) {
63 card->next = kmalloc(sizeof(struct hppb_card), GFP_KERNEL); 63 card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL);
64 if(!card->next) { 64 if(!card->next) {
65 printk(KERN_ERR "HP-PB: Unable to allocate memory.\n"); 65 printk(KERN_ERR "HP-PB: Unable to allocate memory.\n");
66 return 1; 66 return 1;
67 } 67 }
68 memset(card->next, '\0', sizeof(struct hppb_card));
69 card = card->next; 68 card = card->next;
70 } 69 }
71 printk(KERN_INFO "Found GeckoBoa at 0x%lx\n", dev->hpa.start); 70 printk(KERN_INFO "Found GeckoBoa at 0x%lx\n", dev->hpa.start);
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 19657efa8dc3..8d7a36392eb8 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -873,28 +873,24 @@ void *iosapic_register(unsigned long hpa)
873 return NULL; 873 return NULL;
874 } 874 }
875 875
876 isi = (struct iosapic_info *)kmalloc(sizeof(struct iosapic_info), GFP_KERNEL); 876 isi = (struct iosapic_info *)kzalloc(sizeof(struct iosapic_info), GFP_KERNEL);
877 if (!isi) { 877 if (!isi) {
878 BUG(); 878 BUG();
879 return NULL; 879 return NULL;
880 } 880 }
881 881
882 memset(isi, 0, sizeof(struct iosapic_info));
883
884 isi->addr = ioremap(hpa, 4096); 882 isi->addr = ioremap(hpa, 4096);
885 isi->isi_hpa = hpa; 883 isi->isi_hpa = hpa;
886 isi->isi_version = iosapic_rd_version(isi); 884 isi->isi_version = iosapic_rd_version(isi);
887 isi->isi_num_vectors = IOSAPIC_IRDT_MAX_ENTRY(isi->isi_version) + 1; 885 isi->isi_num_vectors = IOSAPIC_IRDT_MAX_ENTRY(isi->isi_version) + 1;
888 886
889 vip = isi->isi_vector = (struct vector_info *) 887 vip = isi->isi_vector = (struct vector_info *)
890 kmalloc(sizeof(struct vector_info) * isi->isi_num_vectors, GFP_KERNEL); 888 kzalloc(sizeof(struct vector_info) * isi->isi_num_vectors, GFP_KERNEL);
891 if (vip == NULL) { 889 if (vip == NULL) {
892 kfree(isi); 890 kfree(isi);
893 return NULL; 891 return NULL;
894 } 892 }
895 893
896 memset(vip, 0, sizeof(struct vector_info) * isi->isi_num_vectors);
897
898 for (cnt=0; cnt < isi->isi_num_vectors; cnt++, vip++) { 894 for (cnt=0; cnt < isi->isi_num_vectors; cnt++, vip++) {
899 vip->irqline = (unsigned char) cnt; 895 vip->irqline = (unsigned char) cnt;
900 vip->iosapic = isi; 896 vip->iosapic = isi;
diff --git a/drivers/parisc/lasi.c b/drivers/parisc/lasi.c
index 2b3ba1dcf332..cb3d28176129 100644
--- a/drivers/parisc/lasi.c
+++ b/drivers/parisc/lasi.c
@@ -166,11 +166,12 @@ static void lasi_power_off(void)
166int __init 166int __init
167lasi_init_chip(struct parisc_device *dev) 167lasi_init_chip(struct parisc_device *dev)
168{ 168{
169 extern void (*chassis_power_off)(void);
169 struct gsc_asic *lasi; 170 struct gsc_asic *lasi;
170 struct gsc_irq gsc_irq; 171 struct gsc_irq gsc_irq;
171 int ret; 172 int ret;
172 173
173 lasi = kmalloc(sizeof(*lasi), GFP_KERNEL); 174 lasi = kzalloc(sizeof(*lasi), GFP_KERNEL);
174 if (!lasi) 175 if (!lasi)
175 return -ENOMEM; 176 return -ENOMEM;
176 177
@@ -222,7 +223,7 @@ lasi_init_chip(struct parisc_device *dev)
222 * ensure that only the first LASI (the one controlling the power off) 223 * ensure that only the first LASI (the one controlling the power off)
223 * should set the HPA here */ 224 * should set the HPA here */
224 lasi_power_off_hpa = lasi->hpa; 225 lasi_power_off_hpa = lasi->hpa;
225 pm_power_off = lasi_power_off; 226 chassis_power_off = lasi_power_off;
226 227
227 return ret; 228 return ret;
228} 229}
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index cbae8c8963fa..e8a2a4a852f5 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1565,7 +1565,7 @@ lba_driver_probe(struct parisc_device *dev)
1565 } else if (IS_MERCURY(dev) || IS_QUICKSILVER(dev)) { 1565 } else if (IS_MERCURY(dev) || IS_QUICKSILVER(dev)) {
1566 func_class &= 0xff; 1566 func_class &= 0xff;
1567 version = kmalloc(6, GFP_KERNEL); 1567 version = kmalloc(6, GFP_KERNEL);
1568 sprintf(version,"TR%d.%d",(func_class >> 4),(func_class & 0xf)); 1568 snprintf(version, 6, "TR%d.%d",(func_class >> 4),(func_class & 0xf));
1569 /* We could use one printk for both Elroy and Mercury, 1569 /* We could use one printk for both Elroy and Mercury,
1570 * but for the mask for func_class. 1570 * but for the mask for func_class.
1571 */ 1571 */
@@ -1586,14 +1586,12 @@ lba_driver_probe(struct parisc_device *dev)
1586 ** have an IRT entry will get NULL back from iosapic code. 1586 ** have an IRT entry will get NULL back from iosapic code.
1587 */ 1587 */
1588 1588
1589 lba_dev = kmalloc(sizeof(struct lba_device), GFP_KERNEL); 1589 lba_dev = kzalloc(sizeof(struct lba_device), GFP_KERNEL);
1590 if (!lba_dev) { 1590 if (!lba_dev) {
1591 printk(KERN_ERR "lba_init_chip - couldn't alloc lba_device\n"); 1591 printk(KERN_ERR "lba_init_chip - couldn't alloc lba_device\n");
1592 return(1); 1592 return(1);
1593 } 1593 }
1594 1594
1595 memset(lba_dev, 0, sizeof(struct lba_device));
1596
1597 1595
1598 /* ---------- First : initialize data we already have --------- */ 1596 /* ---------- First : initialize data we already have --------- */
1599 1597
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 42a3c54e8e6c..a28e17898fbd 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Interfaces to retrieve and set PDC Stable options (firmware) 2 * Interfaces to retrieve and set PDC Stable options (firmware)
3 * 3 *
4 * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org> 4 * Copyright (C) 2005-2006 Thibaut VARENE <varenet@parisc-linux.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -26,11 +26,19 @@
26 * 26 *
27 * Since locations between 96 and 192 are the various paths, most (if not 27 * Since locations between 96 and 192 are the various paths, most (if not
28 * all) PA-RISC machines should have them. Anyway, for safety reasons, the 28 * all) PA-RISC machines should have them. Anyway, for safety reasons, the
29 * following code can deal with only 96 bytes of Stable Storage, and all 29 * following code can deal with just 96 bytes of Stable Storage, and all
30 * sizes between 96 and 192 bytes (provided they are multiple of struct 30 * sizes between 96 and 192 bytes (provided they are multiple of struct
31 * device_path size, eg: 128, 160 and 192) to provide full information. 31 * device_path size, eg: 128, 160 and 192) to provide full information.
32 * The code makes no use of data above 192 bytes. One last word: there's one 32 * The code makes no use of data above 192 bytes. One last word: there's one
33 * path we can always count on: the primary path. 33 * path we can always count on: the primary path.
34 *
35 * The current policy wrt file permissions is:
36 * - write: root only
37 * - read: (reading triggers PDC calls) ? root only : everyone
38 * The rationale is that PDC calls could hog (DoS) the machine.
39 *
40 * TODO:
41 * - timer/fastsize write calls
34 */ 42 */
35 43
36#undef PDCS_DEBUG 44#undef PDCS_DEBUG
@@ -50,13 +58,15 @@
50#include <linux/kobject.h> 58#include <linux/kobject.h>
51#include <linux/device.h> 59#include <linux/device.h>
52#include <linux/errno.h> 60#include <linux/errno.h>
61#include <linux/spinlock.h>
53 62
54#include <asm/pdc.h> 63#include <asm/pdc.h>
55#include <asm/page.h> 64#include <asm/page.h>
56#include <asm/uaccess.h> 65#include <asm/uaccess.h>
57#include <asm/hardware.h> 66#include <asm/hardware.h>
58 67
59#define PDCS_VERSION "0.10" 68#define PDCS_VERSION "0.22"
69#define PDCS_PREFIX "PDC Stable Storage"
60 70
61#define PDCS_ADDR_PPRI 0x00 71#define PDCS_ADDR_PPRI 0x00
62#define PDCS_ADDR_OSID 0x40 72#define PDCS_ADDR_OSID 0x40
@@ -70,10 +80,12 @@ MODULE_DESCRIPTION("sysfs interface to HP PDC Stable Storage data");
70MODULE_LICENSE("GPL"); 80MODULE_LICENSE("GPL");
71MODULE_VERSION(PDCS_VERSION); 81MODULE_VERSION(PDCS_VERSION);
72 82
83/* holds Stable Storage size. Initialized once and for all, no lock needed */
73static unsigned long pdcs_size __read_mostly; 84static unsigned long pdcs_size __read_mostly;
74 85
75/* This struct defines what we need to deal with a parisc pdc path entry */ 86/* This struct defines what we need to deal with a parisc pdc path entry */
76struct pdcspath_entry { 87struct pdcspath_entry {
88 rwlock_t rw_lock; /* to protect path entry access */
77 short ready; /* entry record is valid if != 0 */ 89 short ready; /* entry record is valid if != 0 */
78 unsigned long addr; /* entry address in stable storage */ 90 unsigned long addr; /* entry address in stable storage */
79 char *name; /* entry name */ 91 char *name; /* entry name */
@@ -121,6 +133,8 @@ struct pdcspath_attribute paths_attr_##_name = { \
121 * content of the stable storage WRT various paths in these structs. We read 133 * content of the stable storage WRT various paths in these structs. We read
122 * these structs when reading the files, and we will write to these structs when 134 * these structs when reading the files, and we will write to these structs when
123 * writing to the files, and only then write them back to the Stable Storage. 135 * writing to the files, and only then write them back to the Stable Storage.
136 *
137 * This function expects to be called with @entry->rw_lock write-hold.
124 */ 138 */
125static int 139static int
126pdcspath_fetch(struct pdcspath_entry *entry) 140pdcspath_fetch(struct pdcspath_entry *entry)
@@ -160,14 +174,15 @@ pdcspath_fetch(struct pdcspath_entry *entry)
160 * pointer, from which it'll find out the corresponding hardware path. 174 * pointer, from which it'll find out the corresponding hardware path.
161 * For now we do not handle the case where there's an error in writing to the 175 * For now we do not handle the case where there's an error in writing to the
162 * Stable Storage area, so you'd better not mess up the data :P 176 * Stable Storage area, so you'd better not mess up the data :P
177 *
178 * This function expects to be called with @entry->rw_lock write-hold.
163 */ 179 */
164static int 180static void
165pdcspath_store(struct pdcspath_entry *entry) 181pdcspath_store(struct pdcspath_entry *entry)
166{ 182{
167 struct device_path *devpath; 183 struct device_path *devpath;
168 184
169 if (!entry) 185 BUG_ON(!entry);
170 return -EINVAL;
171 186
172 devpath = &entry->devpath; 187 devpath = &entry->devpath;
173 188
@@ -176,10 +191,8 @@ pdcspath_store(struct pdcspath_entry *entry)
176 First case, we don't have a preset hwpath... */ 191 First case, we don't have a preset hwpath... */
177 if (!entry->ready) { 192 if (!entry->ready) {
178 /* ...but we have a device, map it */ 193 /* ...but we have a device, map it */
179 if (entry->dev) 194 BUG_ON(!entry->dev);
180 device_to_hwpath(entry->dev, (struct hardware_path *)devpath); 195 device_to_hwpath(entry->dev, (struct hardware_path *)devpath);
181 else
182 return -EINVAL;
183 } 196 }
184 /* else, we expect the provided hwpath to be valid. */ 197 /* else, we expect the provided hwpath to be valid. */
185 198
@@ -191,15 +204,13 @@ pdcspath_store(struct pdcspath_entry *entry)
191 printk(KERN_ERR "%s: an error occured when writing to PDC.\n" 204 printk(KERN_ERR "%s: an error occured when writing to PDC.\n"
192 "It is likely that the Stable Storage data has been corrupted.\n" 205 "It is likely that the Stable Storage data has been corrupted.\n"
193 "Please check it carefully upon next reboot.\n", __func__); 206 "Please check it carefully upon next reboot.\n", __func__);
194 return -EIO; 207 WARN_ON(1);
195 } 208 }
196 209
197 /* kobject is already registered */ 210 /* kobject is already registered */
198 entry->ready = 2; 211 entry->ready = 2;
199 212
200 DPRINTK("%s: device: 0x%p\n", __func__, entry->dev); 213 DPRINTK("%s: device: 0x%p\n", __func__, entry->dev);
201
202 return 0;
203} 214}
204 215
205/** 216/**
@@ -214,14 +225,17 @@ pdcspath_hwpath_read(struct pdcspath_entry *entry, char *buf)
214{ 225{
215 char *out = buf; 226 char *out = buf;
216 struct device_path *devpath; 227 struct device_path *devpath;
217 unsigned short i; 228 short i;
218 229
219 if (!entry || !buf) 230 if (!entry || !buf)
220 return -EINVAL; 231 return -EINVAL;
221 232
233 read_lock(&entry->rw_lock);
222 devpath = &entry->devpath; 234 devpath = &entry->devpath;
235 i = entry->ready;
236 read_unlock(&entry->rw_lock);
223 237
224 if (!entry->ready) 238 if (!i) /* entry is not ready */
225 return -ENODATA; 239 return -ENODATA;
226 240
227 for (i = 0; i < 6; i++) { 241 for (i = 0; i < 6; i++) {
@@ -242,7 +256,7 @@ pdcspath_hwpath_read(struct pdcspath_entry *entry, char *buf)
242 * 256 *
243 * We will call this function to change the current hardware path. 257 * We will call this function to change the current hardware path.
244 * Hardware paths are to be given '/'-delimited, without brackets. 258 * Hardware paths are to be given '/'-delimited, without brackets.
245 * We take care to make sure that the provided path actually maps to an existing 259 * We make sure that the provided path actually maps to an existing
246 * device, BUT nothing would prevent some foolish user to set the path to some 260 * device, BUT nothing would prevent some foolish user to set the path to some
247 * PCI bridge or even a CPU... 261 * PCI bridge or even a CPU...
248 * A better work around would be to make sure we are at the end of a device tree 262 * A better work around would be to make sure we are at the end of a device tree
@@ -298,17 +312,19 @@ pdcspath_hwpath_write(struct pdcspath_entry *entry, const char *buf, size_t coun
298 } 312 }
299 313
300 /* So far so good, let's get in deep */ 314 /* So far so good, let's get in deep */
315 write_lock(&entry->rw_lock);
301 entry->ready = 0; 316 entry->ready = 0;
302 entry->dev = dev; 317 entry->dev = dev;
303 318
304 /* Now, dive in. Write back to the hardware */ 319 /* Now, dive in. Write back to the hardware */
305 WARN_ON(pdcspath_store(entry)); /* this warn should *NEVER* happen */ 320 pdcspath_store(entry);
306 321
307 /* Update the symlink to the real device */ 322 /* Update the symlink to the real device */
308 sysfs_remove_link(&entry->kobj, "device"); 323 sysfs_remove_link(&entry->kobj, "device");
309 sysfs_create_link(&entry->kobj, &entry->dev->kobj, "device"); 324 sysfs_create_link(&entry->kobj, &entry->dev->kobj, "device");
325 write_unlock(&entry->rw_lock);
310 326
311 printk(KERN_INFO "PDC Stable Storage: changed \"%s\" path to \"%s\"\n", 327 printk(KERN_INFO PDCS_PREFIX ": changed \"%s\" path to \"%s\"\n",
312 entry->name, buf); 328 entry->name, buf);
313 329
314 return count; 330 return count;
@@ -326,14 +342,17 @@ pdcspath_layer_read(struct pdcspath_entry *entry, char *buf)
326{ 342{
327 char *out = buf; 343 char *out = buf;
328 struct device_path *devpath; 344 struct device_path *devpath;
329 unsigned short i; 345 short i;
330 346
331 if (!entry || !buf) 347 if (!entry || !buf)
332 return -EINVAL; 348 return -EINVAL;
333 349
350 read_lock(&entry->rw_lock);
334 devpath = &entry->devpath; 351 devpath = &entry->devpath;
352 i = entry->ready;
353 read_unlock(&entry->rw_lock);
335 354
336 if (!entry->ready) 355 if (!i) /* entry is not ready */
337 return -ENODATA; 356 return -ENODATA;
338 357
339 for (i = 0; devpath->layers[i] && (likely(i < 6)); i++) 358 for (i = 0; devpath->layers[i] && (likely(i < 6)); i++)
@@ -388,15 +407,17 @@ pdcspath_layer_write(struct pdcspath_entry *entry, const char *buf, size_t count
388 } 407 }
389 408
390 /* So far so good, let's get in deep */ 409 /* So far so good, let's get in deep */
410 write_lock(&entry->rw_lock);
391 411
392 /* First, overwrite the current layers with the new ones, not touching 412 /* First, overwrite the current layers with the new ones, not touching
393 the hardware path. */ 413 the hardware path. */
394 memcpy(&entry->devpath.layers, &layers, sizeof(layers)); 414 memcpy(&entry->devpath.layers, &layers, sizeof(layers));
395 415
396 /* Now, dive in. Write back to the hardware */ 416 /* Now, dive in. Write back to the hardware */
397 WARN_ON(pdcspath_store(entry)); /* this warn should *NEVER* happen */ 417 pdcspath_store(entry);
418 write_unlock(&entry->rw_lock);
398 419
399 printk(KERN_INFO "PDC Stable Storage: changed \"%s\" layers to \"%s\"\n", 420 printk(KERN_INFO PDCS_PREFIX ": changed \"%s\" layers to \"%s\"\n",
400 entry->name, buf); 421 entry->name, buf);
401 422
402 return count; 423 return count;
@@ -415,9 +436,6 @@ pdcspath_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
415 struct pdcspath_attribute *pdcs_attr = to_pdcspath_attribute(attr); 436 struct pdcspath_attribute *pdcs_attr = to_pdcspath_attribute(attr);
416 ssize_t ret = 0; 437 ssize_t ret = 0;
417 438
418 if (!capable(CAP_SYS_ADMIN))
419 return -EACCES;
420
421 if (pdcs_attr->show) 439 if (pdcs_attr->show)
422 ret = pdcs_attr->show(entry, buf); 440 ret = pdcs_attr->show(entry, buf);
423 441
@@ -454,8 +472,8 @@ static struct sysfs_ops pdcspath_attr_ops = {
454}; 472};
455 473
456/* These are the two attributes of any PDC path. */ 474/* These are the two attributes of any PDC path. */
457static PATHS_ATTR(hwpath, 0600, pdcspath_hwpath_read, pdcspath_hwpath_write); 475static PATHS_ATTR(hwpath, 0644, pdcspath_hwpath_read, pdcspath_hwpath_write);
458static PATHS_ATTR(layer, 0600, pdcspath_layer_read, pdcspath_layer_write); 476static PATHS_ATTR(layer, 0644, pdcspath_layer_read, pdcspath_layer_write);
459 477
460static struct attribute *paths_subsys_attrs[] = { 478static struct attribute *paths_subsys_attrs[] = {
461 &paths_attr_hwpath.attr, 479 &paths_attr_hwpath.attr,
@@ -484,36 +502,119 @@ static struct pdcspath_entry *pdcspath_entries[] = {
484 NULL, 502 NULL,
485}; 503};
486 504
505
506/* For more insight of what's going on here, refer to PDC Procedures doc,
507 * Section PDC_STABLE */
508
487/** 509/**
488 * pdcs_info_read - Pretty printing of the remaining useful data. 510 * pdcs_size_read - Stable Storage size output.
489 * @entry: An allocated and populated subsytem struct. We don't use it tho. 511 * @entry: An allocated and populated subsytem struct. We don't use it tho.
490 * @buf: The output buffer to write to. 512 * @buf: The output buffer to write to.
491 *
492 * We will call this function to format the output of the 'info' attribute file.
493 * Please refer to PDC Procedures documentation, section PDC_STABLE to get a
494 * better insight of what we're doing here.
495 */ 513 */
496static ssize_t 514static ssize_t
497pdcs_info_read(struct subsystem *entry, char *buf) 515pdcs_size_read(struct subsystem *entry, char *buf)
498{ 516{
499 char *out = buf; 517 char *out = buf;
500 __u32 result;
501 struct device_path devpath;
502 char *tmpstr = NULL;
503 518
504 if (!entry || !buf) 519 if (!entry || !buf)
505 return -EINVAL; 520 return -EINVAL;
506 521
507 /* show the size of the stable storage */ 522 /* show the size of the stable storage */
508 out += sprintf(out, "Stable Storage size: %ld bytes\n", pdcs_size); 523 out += sprintf(out, "%ld\n", pdcs_size);
509 524
510 /* deal with flags */ 525 return out - buf;
511 if (pdc_stable_read(PDCS_ADDR_PPRI, &devpath, sizeof(devpath)) != PDC_OK) 526}
512 return -EIO; 527
528/**
529 * pdcs_auto_read - Stable Storage autoboot/search flag output.
530 * @entry: An allocated and populated subsytem struct. We don't use it tho.
531 * @buf: The output buffer to write to.
532 * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag
533 */
534static ssize_t
535pdcs_auto_read(struct subsystem *entry, char *buf, int knob)
536{
537 char *out = buf;
538 struct pdcspath_entry *pathentry;
513 539
514 out += sprintf(out, "Autoboot: %s\n", (devpath.flags & PF_AUTOBOOT) ? "On" : "Off"); 540 if (!entry || !buf)
515 out += sprintf(out, "Autosearch: %s\n", (devpath.flags & PF_AUTOSEARCH) ? "On" : "Off"); 541 return -EINVAL;
516 out += sprintf(out, "Timer: %u s\n", (devpath.flags & PF_TIMER) ? (1 << (devpath.flags & PF_TIMER)) : 0); 542
543 /* Current flags are stored in primary boot path entry */
544 pathentry = &pdcspath_entry_primary;
545
546 read_lock(&pathentry->rw_lock);
547 out += sprintf(out, "%s\n", (pathentry->devpath.flags & knob) ?
548 "On" : "Off");
549 read_unlock(&pathentry->rw_lock);
550
551 return out - buf;
552}
553
554/**
555 * pdcs_autoboot_read - Stable Storage autoboot flag output.
556 * @entry: An allocated and populated subsytem struct. We don't use it tho.
557 * @buf: The output buffer to write to.
558 */
559static inline ssize_t
560pdcs_autoboot_read(struct subsystem *entry, char *buf)
561{
562 return pdcs_auto_read(entry, buf, PF_AUTOBOOT);
563}
564
565/**
566 * pdcs_autosearch_read - Stable Storage autoboot flag output.
567 * @entry: An allocated and populated subsytem struct. We don't use it tho.
568 * @buf: The output buffer to write to.
569 */
570static inline ssize_t
571pdcs_autosearch_read(struct subsystem *entry, char *buf)
572{
573 return pdcs_auto_read(entry, buf, PF_AUTOSEARCH);
574}
575
576/**
577 * pdcs_timer_read - Stable Storage timer count output (in seconds).
578 * @entry: An allocated and populated subsytem struct. We don't use it tho.
579 * @buf: The output buffer to write to.
580 *
581 * The value of the timer field correponds to a number of seconds in powers of 2.
582 */
583static ssize_t
584pdcs_timer_read(struct subsystem *entry, char *buf)
585{
586 char *out = buf;
587 struct pdcspath_entry *pathentry;
588
589 if (!entry || !buf)
590 return -EINVAL;
591
592 /* Current flags are stored in primary boot path entry */
593 pathentry = &pdcspath_entry_primary;
594
595 /* print the timer value in seconds */
596 read_lock(&pathentry->rw_lock);
597 out += sprintf(out, "%u\n", (pathentry->devpath.flags & PF_TIMER) ?
598 (1 << (pathentry->devpath.flags & PF_TIMER)) : 0);
599 read_unlock(&pathentry->rw_lock);
600
601 return out - buf;
602}
603
604/**
605 * pdcs_osid_read - Stable Storage OS ID register output.
606 * @entry: An allocated and populated subsytem struct. We don't use it tho.
607 * @buf: The output buffer to write to.
608 */
609static ssize_t
610pdcs_osid_read(struct subsystem *entry, char *buf)
611{
612 char *out = buf;
613 __u32 result;
614 char *tmpstr = NULL;
615
616 if (!entry || !buf)
617 return -EINVAL;
517 618
518 /* get OSID */ 619 /* get OSID */
519 if (pdc_stable_read(PDCS_ADDR_OSID, &result, sizeof(result)) != PDC_OK) 620 if (pdc_stable_read(PDCS_ADDR_OSID, &result, sizeof(result)) != PDC_OK)
@@ -529,13 +630,31 @@ pdcs_info_read(struct subsystem *entry, char *buf)
529 case 0x0005: tmpstr = "Novell Netware dependent data"; break; 630 case 0x0005: tmpstr = "Novell Netware dependent data"; break;
530 default: tmpstr = "Unknown"; break; 631 default: tmpstr = "Unknown"; break;
531 } 632 }
532 out += sprintf(out, "OS ID: %s (0x%.4x)\n", tmpstr, (result >> 16)); 633 out += sprintf(out, "%s (0x%.4x)\n", tmpstr, (result >> 16));
634
635 return out - buf;
636}
637
638/**
639 * pdcs_fastsize_read - Stable Storage FastSize register output.
640 * @entry: An allocated and populated subsytem struct. We don't use it tho.
641 * @buf: The output buffer to write to.
642 *
643 * This register holds the amount of system RAM to be tested during boot sequence.
644 */
645static ssize_t
646pdcs_fastsize_read(struct subsystem *entry, char *buf)
647{
648 char *out = buf;
649 __u32 result;
650
651 if (!entry || !buf)
652 return -EINVAL;
533 653
534 /* get fast-size */ 654 /* get fast-size */
535 if (pdc_stable_read(PDCS_ADDR_FSIZ, &result, sizeof(result)) != PDC_OK) 655 if (pdc_stable_read(PDCS_ADDR_FSIZ, &result, sizeof(result)) != PDC_OK)
536 return -EIO; 656 return -EIO;
537 657
538 out += sprintf(out, "Memory tested: ");
539 if ((result & 0x0F) < 0x0E) 658 if ((result & 0x0F) < 0x0E)
540 out += sprintf(out, "%d kB", (1<<(result & 0x0F))*256); 659 out += sprintf(out, "%d kB", (1<<(result & 0x0F))*256);
541 else 660 else
@@ -546,22 +665,18 @@ pdcs_info_read(struct subsystem *entry, char *buf)
546} 665}
547 666
548/** 667/**
549 * pdcs_info_write - This function handles boot flag modifying. 668 * pdcs_auto_write - This function handles autoboot/search flag modifying.
550 * @entry: An allocated and populated subsytem struct. We don't use it tho. 669 * @entry: An allocated and populated subsytem struct. We don't use it tho.
551 * @buf: The input buffer to read from. 670 * @buf: The input buffer to read from.
552 * @count: The number of bytes to be read. 671 * @count: The number of bytes to be read.
672 * @knob: The PF_AUTOBOOT or PF_AUTOSEARCH flag
553 * 673 *
554 * We will call this function to change the current boot flags. 674 * We will call this function to change the current autoboot flag.
555 * We expect a precise syntax: 675 * We expect a precise syntax:
556 * \"n n\" (n == 0 or 1) to toggle respectively AutoBoot and AutoSearch 676 * \"n\" (n == 0 or 1) to toggle AutoBoot Off or On
557 *
558 * As of now there is no incentive on my side to provide more "knobs" to that
559 * interface, since modifying the rest of the data is pretty meaningless when
560 * the machine is running and for the expected use of that facility, such as
561 * PALO setting up the boot disk when installing a Linux distribution...
562 */ 677 */
563static ssize_t 678static ssize_t
564pdcs_info_write(struct subsystem *entry, const char *buf, size_t count) 679pdcs_auto_write(struct subsystem *entry, const char *buf, size_t count, int knob)
565{ 680{
566 struct pdcspath_entry *pathentry; 681 struct pdcspath_entry *pathentry;
567 unsigned char flags; 682 unsigned char flags;
@@ -582,7 +697,9 @@ pdcs_info_write(struct subsystem *entry, const char *buf, size_t count)
582 pathentry = &pdcspath_entry_primary; 697 pathentry = &pdcspath_entry_primary;
583 698
584 /* Be nice to the existing flag record */ 699 /* Be nice to the existing flag record */
700 read_lock(&pathentry->rw_lock);
585 flags = pathentry->devpath.flags; 701 flags = pathentry->devpath.flags;
702 read_unlock(&pathentry->rw_lock);
586 703
587 DPRINTK("%s: flags before: 0x%X\n", __func__, flags); 704 DPRINTK("%s: flags before: 0x%X\n", __func__, flags);
588 705
@@ -595,50 +712,85 @@ pdcs_info_write(struct subsystem *entry, const char *buf, size_t count)
595 if ((c != 0) && (c != 1)) 712 if ((c != 0) && (c != 1))
596 goto parse_error; 713 goto parse_error;
597 if (c == 0) 714 if (c == 0)
598 flags &= ~PF_AUTOBOOT; 715 flags &= ~knob;
599 else 716 else
600 flags |= PF_AUTOBOOT; 717 flags |= knob;
601
602 if (*temp++ != ' ')
603 goto parse_error;
604
605 c = *temp++ - '0';
606 if ((c != 0) && (c != 1))
607 goto parse_error;
608 if (c == 0)
609 flags &= ~PF_AUTOSEARCH;
610 else
611 flags |= PF_AUTOSEARCH;
612 718
613 DPRINTK("%s: flags after: 0x%X\n", __func__, flags); 719 DPRINTK("%s: flags after: 0x%X\n", __func__, flags);
614 720
615 /* So far so good, let's get in deep */ 721 /* So far so good, let's get in deep */
722 write_lock(&pathentry->rw_lock);
616 723
617 /* Change the path entry flags first */ 724 /* Change the path entry flags first */
618 pathentry->devpath.flags = flags; 725 pathentry->devpath.flags = flags;
619 726
620 /* Now, dive in. Write back to the hardware */ 727 /* Now, dive in. Write back to the hardware */
621 WARN_ON(pdcspath_store(pathentry)); /* this warn should *NEVER* happen */ 728 pdcspath_store(pathentry);
729 write_unlock(&pathentry->rw_lock);
622 730
623 printk(KERN_INFO "PDC Stable Storage: changed flags to \"%s\"\n", buf); 731 printk(KERN_INFO PDCS_PREFIX ": changed \"%s\" to \"%s\"\n",
732 (knob & PF_AUTOBOOT) ? "autoboot" : "autosearch",
733 (flags & knob) ? "On" : "Off");
624 734
625 return count; 735 return count;
626 736
627parse_error: 737parse_error:
628 printk(KERN_WARNING "%s: Parse error: expect \"n n\" (n == 0 or 1) for AB and AS\n", __func__); 738 printk(KERN_WARNING "%s: Parse error: expect \"n\" (n == 0 or 1)\n", __func__);
629 return -EINVAL; 739 return -EINVAL;
630} 740}
631 741
632/* The last attribute (the 'root' one actually) with all remaining data. */ 742/**
633static PDCS_ATTR(info, 0600, pdcs_info_read, pdcs_info_write); 743 * pdcs_autoboot_write - This function handles autoboot flag modifying.
744 * @entry: An allocated and populated subsytem struct. We don't use it tho.
745 * @buf: The input buffer to read from.
746 * @count: The number of bytes to be read.
747 *
748 * We will call this function to change the current boot flags.
749 * We expect a precise syntax:
750 * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On
751 */
752static inline ssize_t
753pdcs_autoboot_write(struct subsystem *entry, const char *buf, size_t count)
754{
755 return pdcs_auto_write(entry, buf, count, PF_AUTOBOOT);
756}
757
758/**
759 * pdcs_autosearch_write - This function handles autosearch flag modifying.
760 * @entry: An allocated and populated subsytem struct. We don't use it tho.
761 * @buf: The input buffer to read from.
762 * @count: The number of bytes to be read.
763 *
764 * We will call this function to change the current boot flags.
765 * We expect a precise syntax:
766 * \"n\" (n == 0 or 1) to toggle AutoSearch Off or On
767 */
768static inline ssize_t
769pdcs_autosearch_write(struct subsystem *entry, const char *buf, size_t count)
770{
771 return pdcs_auto_write(entry, buf, count, PF_AUTOSEARCH);
772}
773
774/* The remaining attributes. */
775static PDCS_ATTR(size, 0444, pdcs_size_read, NULL);
776static PDCS_ATTR(autoboot, 0644, pdcs_autoboot_read, pdcs_autoboot_write);
777static PDCS_ATTR(autosearch, 0644, pdcs_autosearch_read, pdcs_autosearch_write);
778static PDCS_ATTR(timer, 0444, pdcs_timer_read, NULL);
779static PDCS_ATTR(osid, 0400, pdcs_osid_read, NULL);
780static PDCS_ATTR(fastsize, 0400, pdcs_fastsize_read, NULL);
634 781
635static struct subsys_attribute *pdcs_subsys_attrs[] = { 782static struct subsys_attribute *pdcs_subsys_attrs[] = {
636 &pdcs_attr_info, 783 &pdcs_attr_size,
637 NULL, /* maybe more in the future? */ 784 &pdcs_attr_autoboot,
785 &pdcs_attr_autosearch,
786 &pdcs_attr_timer,
787 &pdcs_attr_osid,
788 &pdcs_attr_fastsize,
789 NULL,
638}; 790};
639 791
640static decl_subsys(paths, &ktype_pdcspath, NULL); 792static decl_subsys(paths, &ktype_pdcspath, NULL);
641static decl_subsys(pdc, NULL, NULL); 793static decl_subsys(stable, NULL, NULL);
642 794
643/** 795/**
644 * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage. 796 * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage.
@@ -656,8 +808,16 @@ pdcs_register_pathentries(void)
656 struct pdcspath_entry *entry; 808 struct pdcspath_entry *entry;
657 int err; 809 int err;
658 810
811 /* Initialize the entries rw_lock before anything else */
812 for (i = 0; (entry = pdcspath_entries[i]); i++)
813 rwlock_init(&entry->rw_lock);
814
659 for (i = 0; (entry = pdcspath_entries[i]); i++) { 815 for (i = 0; (entry = pdcspath_entries[i]); i++) {
660 if (pdcspath_fetch(entry) < 0) 816 write_lock(&entry->rw_lock);
817 err = pdcspath_fetch(entry);
818 write_unlock(&entry->rw_lock);
819
820 if (err < 0)
661 continue; 821 continue;
662 822
663 if ((err = kobject_set_name(&entry->kobj, "%s", entry->name))) 823 if ((err = kobject_set_name(&entry->kobj, "%s", entry->name)))
@@ -667,13 +827,14 @@ pdcs_register_pathentries(void)
667 return err; 827 return err;
668 828
669 /* kobject is now registered */ 829 /* kobject is now registered */
830 write_lock(&entry->rw_lock);
670 entry->ready = 2; 831 entry->ready = 2;
671 832
672 if (!entry->dev)
673 continue;
674
675 /* Add a nice symlink to the real device */ 833 /* Add a nice symlink to the real device */
676 sysfs_create_link(&entry->kobj, &entry->dev->kobj, "device"); 834 if (entry->dev)
835 sysfs_create_link(&entry->kobj, &entry->dev->kobj, "device");
836
837 write_unlock(&entry->rw_lock);
677 } 838 }
678 839
679 return 0; 840 return 0;
@@ -688,14 +849,17 @@ pdcs_unregister_pathentries(void)
688 unsigned short i; 849 unsigned short i;
689 struct pdcspath_entry *entry; 850 struct pdcspath_entry *entry;
690 851
691 for (i = 0; (entry = pdcspath_entries[i]); i++) 852 for (i = 0; (entry = pdcspath_entries[i]); i++) {
853 read_lock(&entry->rw_lock);
692 if (entry->ready >= 2) 854 if (entry->ready >= 2)
693 kobject_unregister(&entry->kobj); 855 kobject_unregister(&entry->kobj);
856 read_unlock(&entry->rw_lock);
857 }
694} 858}
695 859
696/* 860/*
697 * For now we register the pdc subsystem with the firmware subsystem 861 * For now we register the stable subsystem with the firmware subsystem
698 * and the paths subsystem with the pdc subsystem 862 * and the paths subsystem with the stable subsystem
699 */ 863 */
700static int __init 864static int __init
701pdc_stable_init(void) 865pdc_stable_init(void)
@@ -707,19 +871,23 @@ pdc_stable_init(void)
707 if (pdc_stable_get_size(&pdcs_size) != PDC_OK) 871 if (pdc_stable_get_size(&pdcs_size) != PDC_OK)
708 return -ENODEV; 872 return -ENODEV;
709 873
710 printk(KERN_INFO "PDC Stable Storage facility v%s\n", PDCS_VERSION); 874 /* make sure we have enough data */
875 if (pdcs_size < 96)
876 return -ENODATA;
877
878 printk(KERN_INFO PDCS_PREFIX " facility v%s\n", PDCS_VERSION);
711 879
712 /* For now we'll register the pdc subsys within this driver */ 880 /* For now we'll register the stable subsys within this driver */
713 if ((rc = firmware_register(&pdc_subsys))) 881 if ((rc = firmware_register(&stable_subsys)))
714 goto fail_firmreg; 882 goto fail_firmreg;
715 883
716 /* Don't forget the info entry */ 884 /* Don't forget the root entries */
717 for (i = 0; (attr = pdcs_subsys_attrs[i]) && !error; i++) 885 for (i = 0; (attr = pdcs_subsys_attrs[i]) && !error; i++)
718 if (attr->show) 886 if (attr->show)
719 error = subsys_create_file(&pdc_subsys, attr); 887 error = subsys_create_file(&stable_subsys, attr);
720 888
721 /* register the paths subsys as a subsystem of pdc subsys */ 889 /* register the paths subsys as a subsystem of stable subsys */
722 kset_set_kset_s(&paths_subsys, pdc_subsys); 890 kset_set_kset_s(&paths_subsys, stable_subsys);
723 if ((rc= subsystem_register(&paths_subsys))) 891 if ((rc= subsystem_register(&paths_subsys)))
724 goto fail_subsysreg; 892 goto fail_subsysreg;
725 893
@@ -734,10 +902,10 @@ fail_pdcsreg:
734 subsystem_unregister(&paths_subsys); 902 subsystem_unregister(&paths_subsys);
735 903
736fail_subsysreg: 904fail_subsysreg:
737 firmware_unregister(&pdc_subsys); 905 firmware_unregister(&stable_subsys);
738 906
739fail_firmreg: 907fail_firmreg:
740 printk(KERN_INFO "PDC Stable Storage bailing out\n"); 908 printk(KERN_INFO PDCS_PREFIX " bailing out\n");
741 return rc; 909 return rc;
742} 910}
743 911
@@ -747,7 +915,7 @@ pdc_stable_exit(void)
747 pdcs_unregister_pathentries(); 915 pdcs_unregister_pathentries();
748 subsystem_unregister(&paths_subsys); 916 subsystem_unregister(&paths_subsys);
749 917
750 firmware_unregister(&pdc_subsys); 918 firmware_unregister(&stable_subsys);
751} 919}
752 920
753 921
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index c85653f315aa..52f265e97729 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -2064,14 +2064,13 @@ sba_driver_callback(struct parisc_device *dev)
2064 printk(KERN_INFO "%s found %s at 0x%lx\n", 2064 printk(KERN_INFO "%s found %s at 0x%lx\n",
2065 MODULE_NAME, version, dev->hpa.start); 2065 MODULE_NAME, version, dev->hpa.start);
2066 2066
2067 sba_dev = kmalloc(sizeof(struct sba_device), GFP_KERNEL); 2067 sba_dev = kzalloc(sizeof(struct sba_device), GFP_KERNEL);
2068 if (!sba_dev) { 2068 if (!sba_dev) {
2069 printk(KERN_ERR MODULE_NAME " - couldn't alloc sba_device\n"); 2069 printk(KERN_ERR MODULE_NAME " - couldn't alloc sba_device\n");
2070 return -ENOMEM; 2070 return -ENOMEM;
2071 } 2071 }
2072 2072
2073 parisc_set_drvdata(dev, sba_dev); 2073 parisc_set_drvdata(dev, sba_dev);
2074 memset(sba_dev, 0, sizeof(struct sba_device));
2075 2074
2076 for(i=0; i<MAX_IOC; i++) 2075 for(i=0; i<MAX_IOC; i++)
2077 spin_lock_init(&(sba_dev->ioc[i].res_lock)); 2076 spin_lock_init(&(sba_dev->ioc[i].res_lock));
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index d14888e149bb..ba971fecd0d8 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -89,6 +89,9 @@ static struct superio_device sio_dev;
89#define DBG_INIT(x...) 89#define DBG_INIT(x...)
90#endif 90#endif
91 91
92#define SUPERIO "SuperIO"
93#define PFX SUPERIO ": "
94
92static irqreturn_t 95static irqreturn_t
93superio_interrupt(int parent_irq, void *devp, struct pt_regs *regs) 96superio_interrupt(int parent_irq, void *devp, struct pt_regs *regs)
94{ 97{
@@ -117,7 +120,7 @@ superio_interrupt(int parent_irq, void *devp, struct pt_regs *regs)
117 local_irq = results & 0x0f; 120 local_irq = results & 0x0f;
118 121
119 if (local_irq == 2 || local_irq > 7) { 122 if (local_irq == 2 || local_irq > 7) {
120 printk(KERN_ERR "SuperIO: slave interrupted!\n"); 123 printk(KERN_ERR PFX "slave interrupted!\n");
121 return IRQ_HANDLED; 124 return IRQ_HANDLED;
122 } 125 }
123 126
@@ -128,7 +131,7 @@ superio_interrupt(int parent_irq, void *devp, struct pt_regs *regs)
128 outb(OCW3_ISR,IC_PIC1+0); 131 outb(OCW3_ISR,IC_PIC1+0);
129 results = inb(IC_PIC1+0); 132 results = inb(IC_PIC1+0);
130 if ((results & 0x80) == 0) { /* if ISR7 not set: spurious */ 133 if ((results & 0x80) == 0) { /* if ISR7 not set: spurious */
131 printk(KERN_WARNING "SuperIO: spurious interrupt!\n"); 134 printk(KERN_WARNING PFX "spurious interrupt!\n");
132 return IRQ_HANDLED; 135 return IRQ_HANDLED;
133 } 136 }
134 } 137 }
@@ -163,27 +166,27 @@ superio_init(struct pci_dev *pcidev)
163 /* ...then properly fixup the USB to point at suckyio PIC */ 166 /* ...then properly fixup the USB to point at suckyio PIC */
164 sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev); 167 sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev);
165 168
166 printk(KERN_INFO "SuperIO: Found NS87560 Legacy I/O device at %s (IRQ %i) \n", 169 printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i) \n",
167 pci_name(pdev), pdev->irq); 170 pci_name(pdev), pdev->irq);
168 171
169 pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base); 172 pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);
170 sio->sp1_base &= ~1; 173 sio->sp1_base &= ~1;
171 printk (KERN_INFO "SuperIO: Serial port 1 at 0x%x\n", sio->sp1_base); 174 printk(KERN_INFO PFX "Serial port 1 at 0x%x\n", sio->sp1_base);
172 175
173 pci_read_config_dword (pdev, SIO_SP2BAR, &sio->sp2_base); 176 pci_read_config_dword (pdev, SIO_SP2BAR, &sio->sp2_base);
174 sio->sp2_base &= ~1; 177 sio->sp2_base &= ~1;
175 printk (KERN_INFO "SuperIO: Serial port 2 at 0x%x\n", sio->sp2_base); 178 printk(KERN_INFO PFX "Serial port 2 at 0x%x\n", sio->sp2_base);
176 179
177 pci_read_config_dword (pdev, SIO_PPBAR, &sio->pp_base); 180 pci_read_config_dword (pdev, SIO_PPBAR, &sio->pp_base);
178 sio->pp_base &= ~1; 181 sio->pp_base &= ~1;
179 printk (KERN_INFO "SuperIO: Parallel port at 0x%x\n", sio->pp_base); 182 printk(KERN_INFO PFX "Parallel port at 0x%x\n", sio->pp_base);
180 183
181 pci_read_config_dword (pdev, SIO_FDCBAR, &sio->fdc_base); 184 pci_read_config_dword (pdev, SIO_FDCBAR, &sio->fdc_base);
182 sio->fdc_base &= ~1; 185 sio->fdc_base &= ~1;
183 printk (KERN_INFO "SuperIO: Floppy controller at 0x%x\n", sio->fdc_base); 186 printk(KERN_INFO PFX "Floppy controller at 0x%x\n", sio->fdc_base);
184 pci_read_config_dword (pdev, SIO_ACPIBAR, &sio->acpi_base); 187 pci_read_config_dword (pdev, SIO_ACPIBAR, &sio->acpi_base);
185 sio->acpi_base &= ~1; 188 sio->acpi_base &= ~1;
186 printk (KERN_INFO "SuperIO: ACPI at 0x%x\n", sio->acpi_base); 189 printk(KERN_INFO PFX "ACPI at 0x%x\n", sio->acpi_base);
187 190
188 request_region (IC_PIC1, 0x1f, "pic1"); 191 request_region (IC_PIC1, 0x1f, "pic1");
189 request_region (IC_PIC2, 0x1f, "pic2"); 192 request_region (IC_PIC2, 0x1f, "pic2");
@@ -263,14 +266,14 @@ superio_init(struct pci_dev *pcidev)
263 /* Setup USB power regulation */ 266 /* Setup USB power regulation */
264 outb(1, sio->acpi_base + USB_REG_CR); 267 outb(1, sio->acpi_base + USB_REG_CR);
265 if (inb(sio->acpi_base + USB_REG_CR) & 1) 268 if (inb(sio->acpi_base + USB_REG_CR) & 1)
266 printk(KERN_INFO "SuperIO: USB regulator enabled\n"); 269 printk(KERN_INFO PFX "USB regulator enabled\n");
267 else 270 else
268 printk(KERN_ERR "USB regulator not initialized!\n"); 271 printk(KERN_ERR PFX "USB regulator not initialized!\n");
269 272
270 if (request_irq(pdev->irq, superio_interrupt, SA_INTERRUPT, 273 if (request_irq(pdev->irq, superio_interrupt, SA_INTERRUPT,
271 "SuperIO", (void *)sio)) { 274 SUPERIO, (void *)sio)) {
272 275
273 printk(KERN_ERR "SuperIO: could not get irq\n"); 276 printk(KERN_ERR PFX "could not get irq\n");
274 BUG(); 277 BUG();
275 return; 278 return;
276 } 279 }
@@ -284,7 +287,7 @@ static void superio_disable_irq(unsigned int irq)
284 u8 r8; 287 u8 r8;
285 288
286 if ((irq < 1) || (irq == 2) || (irq > 7)) { 289 if ((irq < 1) || (irq == 2) || (irq > 7)) {
287 printk(KERN_ERR "SuperIO: Illegal irq number.\n"); 290 printk(KERN_ERR PFX "Illegal irq number.\n");
288 BUG(); 291 BUG();
289 return; 292 return;
290 } 293 }
@@ -301,7 +304,7 @@ static void superio_enable_irq(unsigned int irq)
301 u8 r8; 304 u8 r8;
302 305
303 if ((irq < 1) || (irq == 2) || (irq > 7)) { 306 if ((irq < 1) || (irq == 2) || (irq > 7)) {
304 printk(KERN_ERR "SuperIO: Illegal irq number (%d).\n", irq); 307 printk(KERN_ERR PFX "Illegal irq number (%d).\n", irq);
305 BUG(); 308 BUG();
306 return; 309 return;
307 } 310 }
@@ -319,7 +322,7 @@ static unsigned int superio_startup_irq(unsigned int irq)
319} 322}
320 323
321static struct hw_interrupt_type superio_interrupt_type = { 324static struct hw_interrupt_type superio_interrupt_type = {
322 .typename = "SuperIO", 325 .typename = SUPERIO,
323 .startup = superio_startup_irq, 326 .startup = superio_startup_irq,
324 .shutdown = superio_disable_irq, 327 .shutdown = superio_disable_irq,
325 .enable = superio_enable_irq, 328 .enable = superio_enable_irq,
@@ -413,7 +416,7 @@ static void __devinit superio_serial_init(void)
413 416
414 retval = early_serial_setup(&serial[0]); 417 retval = early_serial_setup(&serial[0]);
415 if (retval < 0) { 418 if (retval < 0) {
416 printk(KERN_WARNING "SuperIO: Register Serial #0 failed.\n"); 419 printk(KERN_WARNING PFX "Register Serial #0 failed.\n");
417 return; 420 return;
418 } 421 }
419 422
@@ -423,7 +426,7 @@ static void __devinit superio_serial_init(void)
423 retval = early_serial_setup(&serial[1]); 426 retval = early_serial_setup(&serial[1]);
424 427
425 if (retval < 0) 428 if (retval < 0)
426 printk(KERN_WARNING "SuperIO: Register Serial #1 failed.\n"); 429 printk(KERN_WARNING PFX "Register Serial #1 failed.\n");
427#endif /* CONFIG_SERIAL_8250 */ 430#endif /* CONFIG_SERIAL_8250 */
428} 431}
429 432
@@ -437,7 +440,7 @@ static void __devinit superio_parport_init(void)
437 PARPORT_DMA_NONE /* dma */, 440 PARPORT_DMA_NONE /* dma */,
438 NULL /*struct pci_dev* */) ) 441 NULL /*struct pci_dev* */) )
439 442
440 printk(KERN_WARNING "SuperIO: Probing parallel port failed.\n"); 443 printk(KERN_WARNING PFX "Probing parallel port failed.\n");
441#endif /* CONFIG_PARPORT_PC */ 444#endif /* CONFIG_PARPORT_PC */
442} 445}
443 446
@@ -499,7 +502,7 @@ static struct pci_device_id superio_tbl[] = {
499}; 502};
500 503
501static struct pci_driver superio_driver = { 504static struct pci_driver superio_driver = {
502 .name = "SuperIO", 505 .name = SUPERIO,
503 .id_table = superio_tbl, 506 .id_table = superio_tbl,
504 .probe = superio_probe, 507 .probe = superio_probe,
505}; 508};
diff --git a/drivers/parisc/wax.c b/drivers/parisc/wax.c
index 17dce2adf7fe..813c2c24ab1e 100644
--- a/drivers/parisc/wax.c
+++ b/drivers/parisc/wax.c
@@ -76,7 +76,7 @@ wax_init_chip(struct parisc_device *dev)
76 struct gsc_irq gsc_irq; 76 struct gsc_irq gsc_irq;
77 int ret; 77 int ret;
78 78
79 wax = kmalloc(sizeof(*wax), GFP_KERNEL); 79 wax = kzalloc(sizeof(*wax), GFP_KERNEL);
80 if (!wax) 80 if (!wax)
81 return -ENOMEM; 81 return -ENOMEM;
82 82
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index f605dea57224..f63c387976cf 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -90,6 +90,15 @@ config PARPORT_ARC
90 depends on ARM && PARPORT 90 depends on ARM && PARPORT
91 select PARPORT_NOT_PC 91 select PARPORT_NOT_PC
92 92
93config PARPORT_IP32
94 tristate "SGI IP32 builtin port (EXPERIMENTAL)"
95 depends on SGI_IP32 && PARPORT && EXPERIMENTAL
96 select PARPORT_NOT_PC
97 help
98 Say Y here if you need support for the parallel port on
99 SGI O2 machines. This code is also available as a module (say M),
100 called parport_ip32. If in doubt, saying N is the safe plan.
101
93config PARPORT_AMIGA 102config PARPORT_AMIGA
94 tristate "Amiga builtin port" 103 tristate "Amiga builtin port"
95 depends on AMIGA && PARPORT 104 depends on AMIGA && PARPORT
diff --git a/drivers/parport/Makefile b/drivers/parport/Makefile
index 5372212bb9d9..a19de35f8de2 100644
--- a/drivers/parport/Makefile
+++ b/drivers/parport/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_PARPORT_MFC3) += parport_mfc3.o
17obj-$(CONFIG_PARPORT_ATARI) += parport_atari.o 17obj-$(CONFIG_PARPORT_ATARI) += parport_atari.o
18obj-$(CONFIG_PARPORT_SUNBPP) += parport_sunbpp.o 18obj-$(CONFIG_PARPORT_SUNBPP) += parport_sunbpp.o
19obj-$(CONFIG_PARPORT_GSC) += parport_gsc.o 19obj-$(CONFIG_PARPORT_GSC) += parport_gsc.o
20obj-$(CONFIG_PARPORT_IP32) += parport_ip32.o
diff --git a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c
index 5b887ba5aaf9..690b239ad3a7 100644
--- a/drivers/parport/ieee1284.c
+++ b/drivers/parport/ieee1284.c
@@ -61,10 +61,10 @@ static void timeout_waiting_on_port (unsigned long cookie)
61 * set to zero, it returns immediately. 61 * set to zero, it returns immediately.
62 * 62 *
63 * If an interrupt occurs before the timeout period elapses, this 63 * If an interrupt occurs before the timeout period elapses, this
64 * function returns one immediately. If it times out, it returns 64 * function returns zero immediately. If it times out, it returns
65 * a value greater than zero. An error code less than zero 65 * one. An error code less than zero indicates an error (most
66 * indicates an error (most likely a pending signal), and the 66 * likely a pending signal), and the calling code should finish
67 * calling code should finish what it's doing as soon as it can. 67 * what it's doing as soon as it can.
68 */ 68 */
69 69
70int parport_wait_event (struct parport *port, signed long timeout) 70int parport_wait_event (struct parport *port, signed long timeout)
@@ -110,7 +110,7 @@ int parport_wait_event (struct parport *port, signed long timeout)
110 * 110 *
111 * If the status lines take on the desired values before the 111 * If the status lines take on the desired values before the
112 * timeout period elapses, parport_poll_peripheral() returns zero 112 * timeout period elapses, parport_poll_peripheral() returns zero
113 * immediately. A zero return value greater than zero indicates 113 * immediately. A return value greater than zero indicates
114 * a timeout. An error code (less than zero) indicates an error, 114 * a timeout. An error code (less than zero) indicates an error,
115 * most likely a signal that arrived, and the caller should 115 * most likely a signal that arrived, and the caller should
116 * finish what it is doing as soon as possible. 116 * finish what it is doing as soon as possible.
diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c
index fde29a75f888..1de52d9febf9 100644
--- a/drivers/parport/parport_gsc.c
+++ b/drivers/parport/parport_gsc.c
@@ -249,7 +249,7 @@ struct parport *__devinit parport_gsc_probe_port (unsigned long base,
249 struct parport tmp; 249 struct parport tmp;
250 struct parport *p = &tmp; 250 struct parport *p = &tmp;
251 251
252 priv = kmalloc (sizeof (struct parport_gsc_private), GFP_KERNEL); 252 priv = kzalloc (sizeof (struct parport_gsc_private), GFP_KERNEL);
253 if (!priv) { 253 if (!priv) {
254 printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base); 254 printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base);
255 return NULL; 255 return NULL;
diff --git a/drivers/parport/parport_ip32.c b/drivers/parport/parport_ip32.c
new file mode 100644
index 000000000000..46e06e596d73
--- /dev/null
+++ b/drivers/parport/parport_ip32.c
@@ -0,0 +1,2253 @@
1/* Low-level parallel port routines for built-in port on SGI IP32
2 *
3 * Author: Arnaud Giersch <arnaud.giersch@free.fr>
4 *
5 * Based on parport_pc.c by
6 * Phil Blundell, Tim Waugh, Jose Renau, David Campbell,
7 * Andrea Arcangeli, et al.
8 *
9 * Thanks to Ilya A. Volynets-Evenbakh for his help.
10 *
11 * Copyright (C) 2005, 2006 Arnaud Giersch.
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free
15 * Software Foundation; either version 2 of the License, or (at your option)
16 * any later version.
17 *
18 * This program is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 * more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc., 59
25 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 */
27
28/* Current status:
29 *
30 * Basic SPP and PS2 modes are supported.
31 * Support for parallel port IRQ is present.
32 * Hardware SPP (a.k.a. compatibility), EPP, and ECP modes are
33 * supported.
34 * SPP/ECP FIFO can be driven in PIO or DMA mode. PIO mode can work with
35 * or without interrupt support.
36 *
37 * Hardware ECP mode is not fully implemented (ecp_read_data and
38 * ecp_write_addr are actually missing).
39 *
40 * To do:
41 *
42 * Fully implement ECP mode.
43 * EPP and ECP mode need to be tested. I currently do not own any
44 * peripheral supporting these extended mode, and cannot test them.
45 * If DMA mode works well, decide if support for PIO FIFO modes should be
46 * dropped.
47 * Use the io{read,write} family functions when they become available in
48 * the linux-mips.org tree. Note: the MIPS specific functions readsb()
49 * and writesb() are to be translated by ioread8_rep() and iowrite8_rep()
50 * respectively.
51 */
52
53/* The built-in parallel port on the SGI 02 workstation (a.k.a. IP32) is an
54 * IEEE 1284 parallel port driven by a Texas Instrument TL16PIR552PH chip[1].
55 * This chip supports SPP, bidirectional, EPP and ECP modes. It has a 16 byte
56 * FIFO buffer and supports DMA transfers.
57 *
58 * [1] http://focus.ti.com/docs/prod/folders/print/tl16pir552.html
59 *
60 * Theoretically, we could simply use the parport_pc module. It is however
61 * not so simple. The parport_pc code assumes that the parallel port
62 * registers are port-mapped. On the O2, they are memory-mapped.
63 * Furthermore, each register is replicated on 256 consecutive addresses (as
64 * it is for the built-in serial ports on the same chip).
65 */
66
67/*--- Some configuration defines ---------------------------------------*/
68
69/* DEBUG_PARPORT_IP32
70 * 0 disable debug
71 * 1 standard level: pr_debug1 is enabled
72 * 2 parport_ip32_dump_state is enabled
73 * >=3 verbose level: pr_debug is enabled
74 */
75#if !defined(DEBUG_PARPORT_IP32)
76# define DEBUG_PARPORT_IP32 0 /* 0 (disabled) for production */
77#endif
78
79/*----------------------------------------------------------------------*/
80
81/* Setup DEBUG macros. This is done before any includes, just in case we
82 * activate pr_debug() with DEBUG_PARPORT_IP32 >= 3.
83 */
84#if DEBUG_PARPORT_IP32 == 1
85# warning DEBUG_PARPORT_IP32 == 1
86#elif DEBUG_PARPORT_IP32 == 2
87# warning DEBUG_PARPORT_IP32 == 2
88#elif DEBUG_PARPORT_IP32 >= 3
89# warning DEBUG_PARPORT_IP32 >= 3
90# if !defined(DEBUG)
91# define DEBUG /* enable pr_debug() in kernel.h */
92# endif
93#endif
94
95#include <linux/completion.h>
96#include <linux/delay.h>
97#include <linux/dma-mapping.h>
98#include <linux/err.h>
99#include <linux/init.h>
100#include <linux/interrupt.h>
101#include <linux/jiffies.h>
102#include <linux/kernel.h>
103#include <linux/module.h>
104#include <linux/parport.h>
105#include <linux/sched.h>
106#include <linux/spinlock.h>
107#include <linux/stddef.h>
108#include <linux/types.h>
109#include <asm/io.h>
110#include <asm/ip32/ip32_ints.h>
111#include <asm/ip32/mace.h>
112
113/*--- Global variables -------------------------------------------------*/
114
115/* Verbose probing on by default for debugging. */
116#if DEBUG_PARPORT_IP32 >= 1
117# define DEFAULT_VERBOSE_PROBING 1
118#else
119# define DEFAULT_VERBOSE_PROBING 0
120#endif
121
122/* Default prefix for printk */
123#define PPIP32 "parport_ip32: "
124
125/*
126 * These are the module parameters:
127 * @features: bit mask of features to enable/disable
128 * (all enabled by default)
129 * @verbose_probing: log chit-chat during initialization
130 */
131#define PARPORT_IP32_ENABLE_IRQ (1U << 0)
132#define PARPORT_IP32_ENABLE_DMA (1U << 1)
133#define PARPORT_IP32_ENABLE_SPP (1U << 2)
134#define PARPORT_IP32_ENABLE_EPP (1U << 3)
135#define PARPORT_IP32_ENABLE_ECP (1U << 4)
136static unsigned int features = ~0U;
137static int verbose_probing = DEFAULT_VERBOSE_PROBING;
138
139/* We do not support more than one port. */
140static struct parport *this_port = NULL;
141
142/* Timing constants for FIFO modes. */
143#define FIFO_NFAULT_TIMEOUT 100 /* milliseconds */
144#define FIFO_POLLING_INTERVAL 50 /* microseconds */
145
146/*--- I/O register definitions -----------------------------------------*/
147
148/**
149 * struct parport_ip32_regs - virtual addresses of parallel port registers
150 * @data: Data Register
151 * @dsr: Device Status Register
152 * @dcr: Device Control Register
153 * @eppAddr: EPP Address Register
154 * @eppData0: EPP Data Register 0
155 * @eppData1: EPP Data Register 1
156 * @eppData2: EPP Data Register 2
157 * @eppData3: EPP Data Register 3
158 * @ecpAFifo: ECP Address FIFO
159 * @fifo: General FIFO register. The same address is used for:
160 * - cFifo, the Parallel Port DATA FIFO
161 * - ecpDFifo, the ECP Data FIFO
162 * - tFifo, the ECP Test FIFO
163 * @cnfgA: Configuration Register A
164 * @cnfgB: Configuration Register B
165 * @ecr: Extended Control Register
166 */
167struct parport_ip32_regs {
168 void __iomem *data;
169 void __iomem *dsr;
170 void __iomem *dcr;
171 void __iomem *eppAddr;
172 void __iomem *eppData0;
173 void __iomem *eppData1;
174 void __iomem *eppData2;
175 void __iomem *eppData3;
176 void __iomem *ecpAFifo;
177 void __iomem *fifo;
178 void __iomem *cnfgA;
179 void __iomem *cnfgB;
180 void __iomem *ecr;
181};
182
183/* Device Status Register */
184#define DSR_nBUSY (1U << 7) /* PARPORT_STATUS_BUSY */
185#define DSR_nACK (1U << 6) /* PARPORT_STATUS_ACK */
186#define DSR_PERROR (1U << 5) /* PARPORT_STATUS_PAPEROUT */
187#define DSR_SELECT (1U << 4) /* PARPORT_STATUS_SELECT */
188#define DSR_nFAULT (1U << 3) /* PARPORT_STATUS_ERROR */
189#define DSR_nPRINT (1U << 2) /* specific to TL16PIR552 */
190/* #define DSR_reserved (1U << 1) */
191#define DSR_TIMEOUT (1U << 0) /* EPP timeout */
192
193/* Device Control Register */
194/* #define DCR_reserved (1U << 7) | (1U << 6) */
195#define DCR_DIR (1U << 5) /* direction */
196#define DCR_IRQ (1U << 4) /* interrupt on nAck */
197#define DCR_SELECT (1U << 3) /* PARPORT_CONTROL_SELECT */
198#define DCR_nINIT (1U << 2) /* PARPORT_CONTROL_INIT */
199#define DCR_AUTOFD (1U << 1) /* PARPORT_CONTROL_AUTOFD */
200#define DCR_STROBE (1U << 0) /* PARPORT_CONTROL_STROBE */
201
202/* ECP Configuration Register A */
203#define CNFGA_IRQ (1U << 7)
204#define CNFGA_ID_MASK ((1U << 6) | (1U << 5) | (1U << 4))
205#define CNFGA_ID_SHIFT 4
206#define CNFGA_ID_16 (00U << CNFGA_ID_SHIFT)
207#define CNFGA_ID_8 (01U << CNFGA_ID_SHIFT)
208#define CNFGA_ID_32 (02U << CNFGA_ID_SHIFT)
209/* #define CNFGA_reserved (1U << 3) */
210#define CNFGA_nBYTEINTRANS (1U << 2)
211#define CNFGA_PWORDLEFT ((1U << 1) | (1U << 0))
212
213/* ECP Configuration Register B */
214#define CNFGB_COMPRESS (1U << 7)
215#define CNFGB_INTRVAL (1U << 6)
216#define CNFGB_IRQ_MASK ((1U << 5) | (1U << 4) | (1U << 3))
217#define CNFGB_IRQ_SHIFT 3
218#define CNFGB_DMA_MASK ((1U << 2) | (1U << 1) | (1U << 0))
219#define CNFGB_DMA_SHIFT 0
220
221/* Extended Control Register */
222#define ECR_MODE_MASK ((1U << 7) | (1U << 6) | (1U << 5))
223#define ECR_MODE_SHIFT 5
224#define ECR_MODE_SPP (00U << ECR_MODE_SHIFT)
225#define ECR_MODE_PS2 (01U << ECR_MODE_SHIFT)
226#define ECR_MODE_PPF (02U << ECR_MODE_SHIFT)
227#define ECR_MODE_ECP (03U << ECR_MODE_SHIFT)
228#define ECR_MODE_EPP (04U << ECR_MODE_SHIFT)
229/* #define ECR_MODE_reserved (05U << ECR_MODE_SHIFT) */
230#define ECR_MODE_TST (06U << ECR_MODE_SHIFT)
231#define ECR_MODE_CFG (07U << ECR_MODE_SHIFT)
232#define ECR_nERRINTR (1U << 4)
233#define ECR_DMAEN (1U << 3)
234#define ECR_SERVINTR (1U << 2)
235#define ECR_F_FULL (1U << 1)
236#define ECR_F_EMPTY (1U << 0)
237
238/*--- Private data -----------------------------------------------------*/
239
240/**
241 * enum parport_ip32_irq_mode - operation mode of interrupt handler
242 * @PARPORT_IP32_IRQ_FWD: forward interrupt to the upper parport layer
243 * @PARPORT_IP32_IRQ_HERE: interrupt is handled locally
244 */
245enum parport_ip32_irq_mode { PARPORT_IP32_IRQ_FWD, PARPORT_IP32_IRQ_HERE };
246
247/**
248 * struct parport_ip32_private - private stuff for &struct parport
249 * @regs: register addresses
250 * @dcr_cache: cached contents of DCR
251 * @dcr_writable: bit mask of writable DCR bits
252 * @pword: number of bytes per PWord
253 * @fifo_depth: number of PWords that FIFO will hold
254 * @readIntrThreshold: minimum number of PWords we can read
255 * if we get an interrupt
256 * @writeIntrThreshold: minimum number of PWords we can write
257 * if we get an interrupt
258 * @irq_mode: operation mode of interrupt handler for this port
259 * @irq_complete: mutex used to wait for an interrupt to occur
260 */
261struct parport_ip32_private {
262 struct parport_ip32_regs regs;
263 unsigned int dcr_cache;
264 unsigned int dcr_writable;
265 unsigned int pword;
266 unsigned int fifo_depth;
267 unsigned int readIntrThreshold;
268 unsigned int writeIntrThreshold;
269 enum parport_ip32_irq_mode irq_mode;
270 struct completion irq_complete;
271};
272
273/*--- Debug code -------------------------------------------------------*/
274
275/*
276 * pr_debug1 - print debug messages
277 *
278 * This is like pr_debug(), but is defined for %DEBUG_PARPORT_IP32 >= 1
279 */
280#if DEBUG_PARPORT_IP32 >= 1
281# define pr_debug1(...) printk(KERN_DEBUG __VA_ARGS__)
282#else /* DEBUG_PARPORT_IP32 < 1 */
283# define pr_debug1(...) do { } while (0)
284#endif
285
286/*
287 * pr_trace, pr_trace1 - trace function calls
288 * @p: pointer to &struct parport
289 * @fmt: printk format string
290 * @...: parameters for format string
291 *
292 * Macros used to trace function calls. The given string is formatted after
293 * function name. pr_trace() uses pr_debug(), and pr_trace1() uses
294 * pr_debug1(). __pr_trace() is the low-level macro and is not to be used
295 * directly.
296 */
297#define __pr_trace(pr, p, fmt, ...) \
298 pr("%s: %s" fmt "\n", \
299 ({ const struct parport *__p = (p); \
300 __p ? __p->name : "parport_ip32"; }), \
301 __func__ , ##__VA_ARGS__)
302#define pr_trace(p, fmt, ...) __pr_trace(pr_debug, p, fmt , ##__VA_ARGS__)
303#define pr_trace1(p, fmt, ...) __pr_trace(pr_debug1, p, fmt , ##__VA_ARGS__)
304
305/*
306 * __pr_probe, pr_probe - print message if @verbose_probing is true
307 * @p: pointer to &struct parport
308 * @fmt: printk format string
309 * @...: parameters for format string
310 *
311 * For new lines, use pr_probe(). Use __pr_probe() for continued lines.
312 */
313#define __pr_probe(...) \
314 do { if (verbose_probing) printk(__VA_ARGS__); } while (0)
315#define pr_probe(p, fmt, ...) \
316 __pr_probe(KERN_INFO PPIP32 "0x%lx: " fmt, (p)->base , ##__VA_ARGS__)
317
318/*
319 * parport_ip32_dump_state - print register status of parport
320 * @p: pointer to &struct parport
321 * @str: string to add in message
322 * @show_ecp_config: shall we dump ECP configuration registers too?
323 *
324 * This function is only here for debugging purpose, and should be used with
325 * care. Reading the parallel port registers may have undesired side effects.
326 * Especially if @show_ecp_config is true, the parallel port is resetted.
327 * This function is only defined if %DEBUG_PARPORT_IP32 >= 2.
328 */
329#if DEBUG_PARPORT_IP32 >= 2
330static void parport_ip32_dump_state(struct parport *p, char *str,
331 unsigned int show_ecp_config)
332{
333 struct parport_ip32_private * const priv = p->physport->private_data;
334 unsigned int i;
335
336 printk(KERN_DEBUG PPIP32 "%s: state (%s):\n", p->name, str);
337 {
338 static const char ecr_modes[8][4] = {"SPP", "PS2", "PPF",
339 "ECP", "EPP", "???",
340 "TST", "CFG"};
341 unsigned int ecr = readb(priv->regs.ecr);
342 printk(KERN_DEBUG PPIP32 " ecr=0x%02x", ecr);
343 printk(" %s",
344 ecr_modes[(ecr & ECR_MODE_MASK) >> ECR_MODE_SHIFT]);
345 if (ecr & ECR_nERRINTR)
346 printk(",nErrIntrEn");
347 if (ecr & ECR_DMAEN)
348 printk(",dmaEn");
349 if (ecr & ECR_SERVINTR)
350 printk(",serviceIntr");
351 if (ecr & ECR_F_FULL)
352 printk(",f_full");
353 if (ecr & ECR_F_EMPTY)
354 printk(",f_empty");
355 printk("\n");
356 }
357 if (show_ecp_config) {
358 unsigned int oecr, cnfgA, cnfgB;
359 oecr = readb(priv->regs.ecr);
360 writeb(ECR_MODE_PS2, priv->regs.ecr);
361 writeb(ECR_MODE_CFG, priv->regs.ecr);
362 cnfgA = readb(priv->regs.cnfgA);
363 cnfgB = readb(priv->regs.cnfgB);
364 writeb(ECR_MODE_PS2, priv->regs.ecr);
365 writeb(oecr, priv->regs.ecr);
366 printk(KERN_DEBUG PPIP32 " cnfgA=0x%02x", cnfgA);
367 printk(" ISA-%s", (cnfgA & CNFGA_IRQ) ? "Level" : "Pulses");
368 switch (cnfgA & CNFGA_ID_MASK) {
369 case CNFGA_ID_8:
370 printk(",8 bits");
371 break;
372 case CNFGA_ID_16:
373 printk(",16 bits");
374 break;
375 case CNFGA_ID_32:
376 printk(",32 bits");
377 break;
378 default:
379 printk(",unknown ID");
380 break;
381 }
382 if (!(cnfgA & CNFGA_nBYTEINTRANS))
383 printk(",ByteInTrans");
384 if ((cnfgA & CNFGA_ID_MASK) != CNFGA_ID_8)
385 printk(",%d byte%s left", cnfgA & CNFGA_PWORDLEFT,
386 ((cnfgA & CNFGA_PWORDLEFT) > 1) ? "s" : "");
387 printk("\n");
388 printk(KERN_DEBUG PPIP32 " cnfgB=0x%02x", cnfgB);
389 printk(" irq=%u,dma=%u",
390 (cnfgB & CNFGB_IRQ_MASK) >> CNFGB_IRQ_SHIFT,
391 (cnfgB & CNFGB_DMA_MASK) >> CNFGB_DMA_SHIFT);
392 printk(",intrValue=%d", !!(cnfgB & CNFGB_INTRVAL));
393 if (cnfgB & CNFGB_COMPRESS)
394 printk(",compress");
395 printk("\n");
396 }
397 for (i = 0; i < 2; i++) {
398 unsigned int dcr = i ? priv->dcr_cache : readb(priv->regs.dcr);
399 printk(KERN_DEBUG PPIP32 " dcr(%s)=0x%02x",
400 i ? "soft" : "hard", dcr);
401 printk(" %s", (dcr & DCR_DIR) ? "rev" : "fwd");
402 if (dcr & DCR_IRQ)
403 printk(",ackIntEn");
404 if (!(dcr & DCR_SELECT))
405 printk(",nSelectIn");
406 if (dcr & DCR_nINIT)
407 printk(",nInit");
408 if (!(dcr & DCR_AUTOFD))
409 printk(",nAutoFD");
410 if (!(dcr & DCR_STROBE))
411 printk(",nStrobe");
412 printk("\n");
413 }
414#define sep (f++ ? ',' : ' ')
415 {
416 unsigned int f = 0;
417 unsigned int dsr = readb(priv->regs.dsr);
418 printk(KERN_DEBUG PPIP32 " dsr=0x%02x", dsr);
419 if (!(dsr & DSR_nBUSY))
420 printk("%cBusy", sep);
421 if (dsr & DSR_nACK)
422 printk("%cnAck", sep);
423 if (dsr & DSR_PERROR)
424 printk("%cPError", sep);
425 if (dsr & DSR_SELECT)
426 printk("%cSelect", sep);
427 if (dsr & DSR_nFAULT)
428 printk("%cnFault", sep);
429 if (!(dsr & DSR_nPRINT))
430 printk("%c(Print)", sep);
431 if (dsr & DSR_TIMEOUT)
432 printk("%cTimeout", sep);
433 printk("\n");
434 }
435#undef sep
436}
437#else /* DEBUG_PARPORT_IP32 < 2 */
438#define parport_ip32_dump_state(...) do { } while (0)
439#endif
440
441/*
442 * CHECK_EXTRA_BITS - track and log extra bits
443 * @p: pointer to &struct parport
444 * @b: byte to inspect
445 * @m: bit mask of authorized bits
446 *
447 * This is used to track and log extra bits that should not be there in
448 * parport_ip32_write_control() and parport_ip32_frob_control(). It is only
449 * defined if %DEBUG_PARPORT_IP32 >= 1.
450 */
451#if DEBUG_PARPORT_IP32 >= 1
452#define CHECK_EXTRA_BITS(p, b, m) \
453 do { \
454 unsigned int __b = (b), __m = (m); \
455 if (__b & ~__m) \
456 pr_debug1(PPIP32 "%s: extra bits in %s(%s): " \
457 "0x%02x/0x%02x\n", \
458 (p)->name, __func__, #b, __b, __m); \
459 } while (0)
460#else /* DEBUG_PARPORT_IP32 < 1 */
461#define CHECK_EXTRA_BITS(...) do { } while (0)
462#endif
463
464/*--- IP32 parallel port DMA operations --------------------------------*/
465
466/**
467 * struct parport_ip32_dma_data - private data needed for DMA operation
468 * @dir: DMA direction (from or to device)
469 * @buf: buffer physical address
470 * @len: buffer length
471 * @next: address of next bytes to DMA transfer
472 * @left: number of bytes remaining
473 * @ctx: next context to write (0: context_a; 1: context_b)
474 * @irq_on: are the DMA IRQs currently enabled?
475 * @lock: spinlock to protect access to the structure
476 */
477struct parport_ip32_dma_data {
478 enum dma_data_direction dir;
479 dma_addr_t buf;
480 dma_addr_t next;
481 size_t len;
482 size_t left;
483 unsigned int ctx;
484 unsigned int irq_on;
485 spinlock_t lock;
486};
487static struct parport_ip32_dma_data parport_ip32_dma;
488
489/**
490 * parport_ip32_dma_setup_context - setup next DMA context
491 * @limit: maximum data size for the context
492 *
493 * The alignment constraints must be verified in caller function, and the
494 * parameter @limit must be set accordingly.
495 */
496static void parport_ip32_dma_setup_context(unsigned int limit)
497{
498 unsigned long flags;
499
500 spin_lock_irqsave(&parport_ip32_dma.lock, flags);
501 if (parport_ip32_dma.left > 0) {
502 /* Note: ctxreg is "volatile" here only because
503 * mace->perif.ctrl.parport.context_a and context_b are
504 * "volatile". */
505 volatile u64 __iomem *ctxreg = (parport_ip32_dma.ctx == 0) ?
506 &mace->perif.ctrl.parport.context_a :
507 &mace->perif.ctrl.parport.context_b;
508 u64 count;
509 u64 ctxval;
510 if (parport_ip32_dma.left <= limit) {
511 count = parport_ip32_dma.left;
512 ctxval = MACEPAR_CONTEXT_LASTFLAG;
513 } else {
514 count = limit;
515 ctxval = 0;
516 }
517
518 pr_trace(NULL,
519 "(%u): 0x%04x:0x%04x, %u -> %u%s",
520 limit,
521 (unsigned int)parport_ip32_dma.buf,
522 (unsigned int)parport_ip32_dma.next,
523 (unsigned int)count,
524 parport_ip32_dma.ctx, ctxval ? "*" : "");
525
526 ctxval |= parport_ip32_dma.next &
527 MACEPAR_CONTEXT_BASEADDR_MASK;
528 ctxval |= ((count - 1) << MACEPAR_CONTEXT_DATALEN_SHIFT) &
529 MACEPAR_CONTEXT_DATALEN_MASK;
530 writeq(ctxval, ctxreg);
531 parport_ip32_dma.next += count;
532 parport_ip32_dma.left -= count;
533 parport_ip32_dma.ctx ^= 1U;
534 }
535 /* If there is nothing more to send, disable IRQs to avoid to
536 * face an IRQ storm which can lock the machine. Disable them
537 * only once. */
538 if (parport_ip32_dma.left == 0 && parport_ip32_dma.irq_on) {
539 pr_debug(PPIP32 "IRQ off (ctx)\n");
540 disable_irq_nosync(MACEISA_PAR_CTXA_IRQ);
541 disable_irq_nosync(MACEISA_PAR_CTXB_IRQ);
542 parport_ip32_dma.irq_on = 0;
543 }
544 spin_unlock_irqrestore(&parport_ip32_dma.lock, flags);
545}
546
547/**
548 * parport_ip32_dma_interrupt - DMA interrupt handler
549 * @irq: interrupt number
550 * @dev_id: unused
551 * @regs: pointer to &struct pt_regs
552 */
553static irqreturn_t parport_ip32_dma_interrupt(int irq, void *dev_id,
554 struct pt_regs *regs)
555{
556 if (parport_ip32_dma.left)
557 pr_trace(NULL, "(%d): ctx=%d", irq, parport_ip32_dma.ctx);
558 parport_ip32_dma_setup_context(MACEPAR_CONTEXT_DATA_BOUND);
559 return IRQ_HANDLED;
560}
561
562#if DEBUG_PARPORT_IP32
563static irqreturn_t parport_ip32_merr_interrupt(int irq, void *dev_id,
564 struct pt_regs *regs)
565{
566 pr_trace1(NULL, "(%d)", irq);
567 return IRQ_HANDLED;
568}
569#endif
570
571/**
572 * parport_ip32_dma_start - begins a DMA transfer
573 * @dir: DMA direction: DMA_TO_DEVICE or DMA_FROM_DEVICE
574 * @addr: pointer to data buffer
575 * @count: buffer size
576 *
577 * Calls to parport_ip32_dma_start() and parport_ip32_dma_stop() must be
578 * correctly balanced.
579 */
580static int parport_ip32_dma_start(enum dma_data_direction dir,
581 void *addr, size_t count)
582{
583 unsigned int limit;
584 u64 ctrl;
585
586 pr_trace(NULL, "(%d, %lu)", dir, (unsigned long)count);
587
588 /* FIXME - add support for DMA_FROM_DEVICE. In this case, buffer must
589 * be 64 bytes aligned. */
590 BUG_ON(dir != DMA_TO_DEVICE);
591
592 /* Reset DMA controller */
593 ctrl = MACEPAR_CTLSTAT_RESET;
594 writeq(ctrl, &mace->perif.ctrl.parport.cntlstat);
595
596 /* DMA IRQs should normally be enabled */
597 if (!parport_ip32_dma.irq_on) {
598 WARN_ON(1);
599 enable_irq(MACEISA_PAR_CTXA_IRQ);
600 enable_irq(MACEISA_PAR_CTXB_IRQ);
601 parport_ip32_dma.irq_on = 1;
602 }
603
604 /* Prepare DMA pointers */
605 parport_ip32_dma.dir = dir;
606 parport_ip32_dma.buf = dma_map_single(NULL, addr, count, dir);
607 parport_ip32_dma.len = count;
608 parport_ip32_dma.next = parport_ip32_dma.buf;
609 parport_ip32_dma.left = parport_ip32_dma.len;
610 parport_ip32_dma.ctx = 0;
611
612 /* Setup DMA direction and first two contexts */
613 ctrl = (dir == DMA_TO_DEVICE) ? 0 : MACEPAR_CTLSTAT_DIRECTION;
614 writeq(ctrl, &mace->perif.ctrl.parport.cntlstat);
615 /* Single transfer should not cross a 4K page boundary */
616 limit = MACEPAR_CONTEXT_DATA_BOUND -
617 (parport_ip32_dma.next & (MACEPAR_CONTEXT_DATA_BOUND - 1));
618 parport_ip32_dma_setup_context(limit);
619 parport_ip32_dma_setup_context(MACEPAR_CONTEXT_DATA_BOUND);
620
621 /* Real start of DMA transfer */
622 ctrl |= MACEPAR_CTLSTAT_ENABLE;
623 writeq(ctrl, &mace->perif.ctrl.parport.cntlstat);
624
625 return 0;
626}
627
628/**
629 * parport_ip32_dma_stop - ends a running DMA transfer
630 *
631 * Calls to parport_ip32_dma_start() and parport_ip32_dma_stop() must be
632 * correctly balanced.
633 */
634static void parport_ip32_dma_stop(void)
635{
636 u64 ctx_a;
637 u64 ctx_b;
638 u64 ctrl;
639 u64 diag;
640 size_t res[2]; /* {[0] = res_a, [1] = res_b} */
641
642 pr_trace(NULL, "()");
643
644 /* Disable IRQs */
645 spin_lock_irq(&parport_ip32_dma.lock);
646 if (parport_ip32_dma.irq_on) {
647 pr_debug(PPIP32 "IRQ off (stop)\n");
648 disable_irq_nosync(MACEISA_PAR_CTXA_IRQ);
649 disable_irq_nosync(MACEISA_PAR_CTXB_IRQ);
650 parport_ip32_dma.irq_on = 0;
651 }
652 spin_unlock_irq(&parport_ip32_dma.lock);
653 /* Force IRQ synchronization, even if the IRQs were disabled
654 * elsewhere. */
655 synchronize_irq(MACEISA_PAR_CTXA_IRQ);
656 synchronize_irq(MACEISA_PAR_CTXB_IRQ);
657
658 /* Stop DMA transfer */
659 ctrl = readq(&mace->perif.ctrl.parport.cntlstat);
660 ctrl &= ~MACEPAR_CTLSTAT_ENABLE;
661 writeq(ctrl, &mace->perif.ctrl.parport.cntlstat);
662
663 /* Adjust residue (parport_ip32_dma.left) */
664 ctx_a = readq(&mace->perif.ctrl.parport.context_a);
665 ctx_b = readq(&mace->perif.ctrl.parport.context_b);
666 ctrl = readq(&mace->perif.ctrl.parport.cntlstat);
667 diag = readq(&mace->perif.ctrl.parport.diagnostic);
668 res[0] = (ctrl & MACEPAR_CTLSTAT_CTXA_VALID) ?
669 1 + ((ctx_a & MACEPAR_CONTEXT_DATALEN_MASK) >>
670 MACEPAR_CONTEXT_DATALEN_SHIFT) :
671 0;
672 res[1] = (ctrl & MACEPAR_CTLSTAT_CTXB_VALID) ?
673 1 + ((ctx_b & MACEPAR_CONTEXT_DATALEN_MASK) >>
674 MACEPAR_CONTEXT_DATALEN_SHIFT) :
675 0;
676 if (diag & MACEPAR_DIAG_DMACTIVE)
677 res[(diag & MACEPAR_DIAG_CTXINUSE) != 0] =
678 1 + ((diag & MACEPAR_DIAG_CTRMASK) >>
679 MACEPAR_DIAG_CTRSHIFT);
680 parport_ip32_dma.left += res[0] + res[1];
681
682 /* Reset DMA controller, and re-enable IRQs */
683 ctrl = MACEPAR_CTLSTAT_RESET;
684 writeq(ctrl, &mace->perif.ctrl.parport.cntlstat);
685 pr_debug(PPIP32 "IRQ on (stop)\n");
686 enable_irq(MACEISA_PAR_CTXA_IRQ);
687 enable_irq(MACEISA_PAR_CTXB_IRQ);
688 parport_ip32_dma.irq_on = 1;
689
690 dma_unmap_single(NULL, parport_ip32_dma.buf, parport_ip32_dma.len,
691 parport_ip32_dma.dir);
692}
693
694/**
695 * parport_ip32_dma_get_residue - get residue from last DMA transfer
696 *
697 * Returns the number of bytes remaining from last DMA transfer.
698 */
699static inline size_t parport_ip32_dma_get_residue(void)
700{
701 return parport_ip32_dma.left;
702}
703
704/**
705 * parport_ip32_dma_register - initialize DMA engine
706 *
707 * Returns zero for success.
708 */
709static int parport_ip32_dma_register(void)
710{
711 int err;
712
713 spin_lock_init(&parport_ip32_dma.lock);
714 parport_ip32_dma.irq_on = 1;
715
716 /* Reset DMA controller */
717 writeq(MACEPAR_CTLSTAT_RESET, &mace->perif.ctrl.parport.cntlstat);
718
719 /* Request IRQs */
720 err = request_irq(MACEISA_PAR_CTXA_IRQ, parport_ip32_dma_interrupt,
721 0, "parport_ip32", NULL);
722 if (err)
723 goto fail_a;
724 err = request_irq(MACEISA_PAR_CTXB_IRQ, parport_ip32_dma_interrupt,
725 0, "parport_ip32", NULL);
726 if (err)
727 goto fail_b;
728#if DEBUG_PARPORT_IP32
729 /* FIXME - what is this IRQ for? */
730 err = request_irq(MACEISA_PAR_MERR_IRQ, parport_ip32_merr_interrupt,
731 0, "parport_ip32", NULL);
732 if (err)
733 goto fail_merr;
734#endif
735 return 0;
736
737#if DEBUG_PARPORT_IP32
738fail_merr:
739 free_irq(MACEISA_PAR_CTXB_IRQ, NULL);
740#endif
741fail_b:
742 free_irq(MACEISA_PAR_CTXA_IRQ, NULL);
743fail_a:
744 return err;
745}
746
747/**
748 * parport_ip32_dma_unregister - release and free resources for DMA engine
749 */
750static void parport_ip32_dma_unregister(void)
751{
752#if DEBUG_PARPORT_IP32
753 free_irq(MACEISA_PAR_MERR_IRQ, NULL);
754#endif
755 free_irq(MACEISA_PAR_CTXB_IRQ, NULL);
756 free_irq(MACEISA_PAR_CTXA_IRQ, NULL);
757}
758
759/*--- Interrupt handlers and associates --------------------------------*/
760
761/**
762 * parport_ip32_wakeup - wakes up code waiting for an interrupt
763 * @p: pointer to &struct parport
764 */
765static inline void parport_ip32_wakeup(struct parport *p)
766{
767 struct parport_ip32_private * const priv = p->physport->private_data;
768 complete(&priv->irq_complete);
769}
770
771/**
772 * parport_ip32_interrupt - interrupt handler
773 * @irq: interrupt number
774 * @dev_id: pointer to &struct parport
775 * @regs: pointer to &struct pt_regs
776 *
777 * Caught interrupts are forwarded to the upper parport layer if IRQ_mode is
778 * %PARPORT_IP32_IRQ_FWD.
779 */
780static irqreturn_t parport_ip32_interrupt(int irq, void *dev_id,
781 struct pt_regs *regs)
782{
783 struct parport * const p = dev_id;
784 struct parport_ip32_private * const priv = p->physport->private_data;
785 enum parport_ip32_irq_mode irq_mode = priv->irq_mode;
786 switch (irq_mode) {
787 case PARPORT_IP32_IRQ_FWD:
788 parport_generic_irq(irq, p, regs);
789 break;
790 case PARPORT_IP32_IRQ_HERE:
791 parport_ip32_wakeup(p);
792 break;
793 }
794 return IRQ_HANDLED;
795}
796
797/*--- Some utility function to manipulate ECR register -----------------*/
798
799/**
800 * parport_ip32_read_econtrol - read contents of the ECR register
801 * @p: pointer to &struct parport
802 */
803static inline unsigned int parport_ip32_read_econtrol(struct parport *p)
804{
805 struct parport_ip32_private * const priv = p->physport->private_data;
806 return readb(priv->regs.ecr);
807}
808
809/**
810 * parport_ip32_write_econtrol - write new contents to the ECR register
811 * @p: pointer to &struct parport
812 * @c: new value to write
813 */
814static inline void parport_ip32_write_econtrol(struct parport *p,
815 unsigned int c)
816{
817 struct parport_ip32_private * const priv = p->physport->private_data;
818 writeb(c, priv->regs.ecr);
819}
820
821/**
822 * parport_ip32_frob_econtrol - change bits from the ECR register
823 * @p: pointer to &struct parport
824 * @mask: bit mask of bits to change
825 * @val: new value for changed bits
826 *
827 * Read from the ECR, mask out the bits in @mask, exclusive-or with the bits
828 * in @val, and write the result to the ECR.
829 */
830static inline void parport_ip32_frob_econtrol(struct parport *p,
831 unsigned int mask,
832 unsigned int val)
833{
834 unsigned int c;
835 c = (parport_ip32_read_econtrol(p) & ~mask) ^ val;
836 parport_ip32_write_econtrol(p, c);
837}
838
839/**
840 * parport_ip32_set_mode - change mode of ECP port
841 * @p: pointer to &struct parport
842 * @mode: new mode to write in ECR
843 *
844 * ECR is reset in a sane state (interrupts and DMA disabled), and placed in
845 * mode @mode. Go through PS2 mode if needed.
846 */
847static void parport_ip32_set_mode(struct parport *p, unsigned int mode)
848{
849 unsigned int omode;
850
851 mode &= ECR_MODE_MASK;
852 omode = parport_ip32_read_econtrol(p) & ECR_MODE_MASK;
853
854 if (!(mode == ECR_MODE_SPP || mode == ECR_MODE_PS2
855 || omode == ECR_MODE_SPP || omode == ECR_MODE_PS2)) {
856 /* We have to go through PS2 mode */
857 unsigned int ecr = ECR_MODE_PS2 | ECR_nERRINTR | ECR_SERVINTR;
858 parport_ip32_write_econtrol(p, ecr);
859 }
860 parport_ip32_write_econtrol(p, mode | ECR_nERRINTR | ECR_SERVINTR);
861}
862
863/*--- Basic functions needed for parport -------------------------------*/
864
865/**
866 * parport_ip32_read_data - return current contents of the DATA register
867 * @p: pointer to &struct parport
868 */
869static inline unsigned char parport_ip32_read_data(struct parport *p)
870{
871 struct parport_ip32_private * const priv = p->physport->private_data;
872 return readb(priv->regs.data);
873}
874
875/**
876 * parport_ip32_write_data - set new contents for the DATA register
877 * @p: pointer to &struct parport
878 * @d: new value to write
879 */
880static inline void parport_ip32_write_data(struct parport *p, unsigned char d)
881{
882 struct parport_ip32_private * const priv = p->physport->private_data;
883 writeb(d, priv->regs.data);
884}
885
886/**
887 * parport_ip32_read_status - return current contents of the DSR register
888 * @p: pointer to &struct parport
889 */
890static inline unsigned char parport_ip32_read_status(struct parport *p)
891{
892 struct parport_ip32_private * const priv = p->physport->private_data;
893 return readb(priv->regs.dsr);
894}
895
896/**
897 * __parport_ip32_read_control - return cached contents of the DCR register
898 * @p: pointer to &struct parport
899 */
900static inline unsigned int __parport_ip32_read_control(struct parport *p)
901{
902 struct parport_ip32_private * const priv = p->physport->private_data;
903 return priv->dcr_cache; /* use soft copy */
904}
905
906/**
907 * __parport_ip32_write_control - set new contents for the DCR register
908 * @p: pointer to &struct parport
909 * @c: new value to write
910 */
911static inline void __parport_ip32_write_control(struct parport *p,
912 unsigned int c)
913{
914 struct parport_ip32_private * const priv = p->physport->private_data;
915 CHECK_EXTRA_BITS(p, c, priv->dcr_writable);
916 c &= priv->dcr_writable; /* only writable bits */
917 writeb(c, priv->regs.dcr);
918 priv->dcr_cache = c; /* update soft copy */
919}
920
921/**
922 * __parport_ip32_frob_control - change bits from the DCR register
923 * @p: pointer to &struct parport
924 * @mask: bit mask of bits to change
925 * @val: new value for changed bits
926 *
927 * This is equivalent to read from the DCR, mask out the bits in @mask,
928 * exclusive-or with the bits in @val, and write the result to the DCR.
929 * Actually, the cached contents of the DCR is used.
930 */
931static inline void __parport_ip32_frob_control(struct parport *p,
932 unsigned int mask,
933 unsigned int val)
934{
935 unsigned int c;
936 c = (__parport_ip32_read_control(p) & ~mask) ^ val;
937 __parport_ip32_write_control(p, c);
938}
939
940/**
941 * parport_ip32_read_control - return cached contents of the DCR register
942 * @p: pointer to &struct parport
943 *
944 * The return value is masked so as to only return the value of %DCR_STROBE,
945 * %DCR_AUTOFD, %DCR_nINIT, and %DCR_SELECT.
946 */
947static inline unsigned char parport_ip32_read_control(struct parport *p)
948{
949 const unsigned int rm =
950 DCR_STROBE | DCR_AUTOFD | DCR_nINIT | DCR_SELECT;
951 return __parport_ip32_read_control(p) & rm;
952}
953
954/**
955 * parport_ip32_write_control - set new contents for the DCR register
956 * @p: pointer to &struct parport
957 * @c: new value to write
958 *
959 * The value is masked so as to only change the value of %DCR_STROBE,
960 * %DCR_AUTOFD, %DCR_nINIT, and %DCR_SELECT.
961 */
962static inline void parport_ip32_write_control(struct parport *p,
963 unsigned char c)
964{
965 const unsigned int wm =
966 DCR_STROBE | DCR_AUTOFD | DCR_nINIT | DCR_SELECT;
967 CHECK_EXTRA_BITS(p, c, wm);
968 __parport_ip32_frob_control(p, wm, c & wm);
969}
970
971/**
972 * parport_ip32_frob_control - change bits from the DCR register
973 * @p: pointer to &struct parport
974 * @mask: bit mask of bits to change
975 * @val: new value for changed bits
976 *
977 * This differs from __parport_ip32_frob_control() in that it only allows to
978 * change the value of %DCR_STROBE, %DCR_AUTOFD, %DCR_nINIT, and %DCR_SELECT.
979 */
980static inline unsigned char parport_ip32_frob_control(struct parport *p,
981 unsigned char mask,
982 unsigned char val)
983{
984 const unsigned int wm =
985 DCR_STROBE | DCR_AUTOFD | DCR_nINIT | DCR_SELECT;
986 CHECK_EXTRA_BITS(p, mask, wm);
987 CHECK_EXTRA_BITS(p, val, wm);
988 __parport_ip32_frob_control(p, mask & wm, val & wm);
989 return parport_ip32_read_control(p);
990}
991
992/**
993 * parport_ip32_disable_irq - disable interrupts on the rising edge of nACK
994 * @p: pointer to &struct parport
995 */
996static inline void parport_ip32_disable_irq(struct parport *p)
997{
998 __parport_ip32_frob_control(p, DCR_IRQ, 0);
999}
1000
1001/**
1002 * parport_ip32_enable_irq - enable interrupts on the rising edge of nACK
1003 * @p: pointer to &struct parport
1004 */
1005static inline void parport_ip32_enable_irq(struct parport *p)
1006{
1007 __parport_ip32_frob_control(p, DCR_IRQ, DCR_IRQ);
1008}
1009
1010/**
1011 * parport_ip32_data_forward - enable host-to-peripheral communications
1012 * @p: pointer to &struct parport
1013 *
1014 * Enable the data line drivers, for 8-bit host-to-peripheral communications.
1015 */
1016static inline void parport_ip32_data_forward(struct parport *p)
1017{
1018 __parport_ip32_frob_control(p, DCR_DIR, 0);
1019}
1020
1021/**
1022 * parport_ip32_data_reverse - enable peripheral-to-host communications
1023 * @p: pointer to &struct parport
1024 *
1025 * Place the data bus in a high impedance state, if @p->modes has the
1026 * PARPORT_MODE_TRISTATE bit set.
1027 */
1028static inline void parport_ip32_data_reverse(struct parport *p)
1029{
1030 __parport_ip32_frob_control(p, DCR_DIR, DCR_DIR);
1031}
1032
1033/**
1034 * parport_ip32_init_state - for core parport code
1035 * @dev: pointer to &struct pardevice
1036 * @s: pointer to &struct parport_state to initialize
1037 */
1038static void parport_ip32_init_state(struct pardevice *dev,
1039 struct parport_state *s)
1040{
1041 s->u.ip32.dcr = DCR_SELECT | DCR_nINIT;
1042 s->u.ip32.ecr = ECR_MODE_PS2 | ECR_nERRINTR | ECR_SERVINTR;
1043}
1044
1045/**
1046 * parport_ip32_save_state - for core parport code
1047 * @p: pointer to &struct parport
1048 * @s: pointer to &struct parport_state to save state to
1049 */
1050static void parport_ip32_save_state(struct parport *p,
1051 struct parport_state *s)
1052{
1053 s->u.ip32.dcr = __parport_ip32_read_control(p);
1054 s->u.ip32.ecr = parport_ip32_read_econtrol(p);
1055}
1056
1057/**
1058 * parport_ip32_restore_state - for core parport code
1059 * @p: pointer to &struct parport
1060 * @s: pointer to &struct parport_state to restore state from
1061 */
1062static void parport_ip32_restore_state(struct parport *p,
1063 struct parport_state *s)
1064{
1065 parport_ip32_set_mode(p, s->u.ip32.ecr & ECR_MODE_MASK);
1066 parport_ip32_write_econtrol(p, s->u.ip32.ecr);
1067 __parport_ip32_write_control(p, s->u.ip32.dcr);
1068}
1069
1070/*--- EPP mode functions -----------------------------------------------*/
1071
1072/**
1073 * parport_ip32_clear_epp_timeout - clear Timeout bit in EPP mode
1074 * @p: pointer to &struct parport
1075 *
1076 * Returns 1 if the Timeout bit is clear, and 0 otherwise.
1077 */
1078static unsigned int parport_ip32_clear_epp_timeout(struct parport *p)
1079{
1080 struct parport_ip32_private * const priv = p->physport->private_data;
1081 unsigned int cleared;
1082
1083 if (!(parport_ip32_read_status(p) & DSR_TIMEOUT))
1084 cleared = 1;
1085 else {
1086 unsigned int r;
1087 /* To clear timeout some chips require double read */
1088 parport_ip32_read_status(p);
1089 r = parport_ip32_read_status(p);
1090 /* Some reset by writing 1 */
1091 writeb(r | DSR_TIMEOUT, priv->regs.dsr);
1092 /* Others by writing 0 */
1093 writeb(r & ~DSR_TIMEOUT, priv->regs.dsr);
1094
1095 r = parport_ip32_read_status(p);
1096 cleared = !(r & DSR_TIMEOUT);
1097 }
1098
1099 pr_trace(p, "(): %s", cleared ? "cleared" : "failed");
1100 return cleared;
1101}
1102
1103/**
1104 * parport_ip32_epp_read - generic EPP read function
1105 * @eppreg: I/O register to read from
1106 * @p: pointer to &struct parport
1107 * @buf: buffer to store read data
1108 * @len: length of buffer @buf
1109 * @flags: may be PARPORT_EPP_FAST
1110 */
1111static size_t parport_ip32_epp_read(void __iomem *eppreg,
1112 struct parport *p, void *buf,
1113 size_t len, int flags)
1114{
1115 struct parport_ip32_private * const priv = p->physport->private_data;
1116 size_t got;
1117 parport_ip32_set_mode(p, ECR_MODE_EPP);
1118 parport_ip32_data_reverse(p);
1119 parport_ip32_write_control(p, DCR_nINIT);
1120 if ((flags & PARPORT_EPP_FAST) && (len > 1)) {
1121 readsb(eppreg, buf, len);
1122 if (readb(priv->regs.dsr) & DSR_TIMEOUT) {
1123 parport_ip32_clear_epp_timeout(p);
1124 return -EIO;
1125 }
1126 got = len;
1127 } else {
1128 u8 *bufp = buf;
1129 for (got = 0; got < len; got++) {
1130 *bufp++ = readb(eppreg);
1131 if (readb(priv->regs.dsr) & DSR_TIMEOUT) {
1132 parport_ip32_clear_epp_timeout(p);
1133 break;
1134 }
1135 }
1136 }
1137 parport_ip32_data_forward(p);
1138 parport_ip32_set_mode(p, ECR_MODE_PS2);
1139 return got;
1140}
1141
1142/**
1143 * parport_ip32_epp_write - generic EPP write function
1144 * @eppreg: I/O register to write to
1145 * @p: pointer to &struct parport
1146 * @buf: buffer of data to write
1147 * @len: length of buffer @buf
1148 * @flags: may be PARPORT_EPP_FAST
1149 */
1150static size_t parport_ip32_epp_write(void __iomem *eppreg,
1151 struct parport *p, const void *buf,
1152 size_t len, int flags)
1153{
1154 struct parport_ip32_private * const priv = p->physport->private_data;
1155 size_t written;
1156 parport_ip32_set_mode(p, ECR_MODE_EPP);
1157 parport_ip32_data_forward(p);
1158 parport_ip32_write_control(p, DCR_nINIT);
1159 if ((flags & PARPORT_EPP_FAST) && (len > 1)) {
1160 writesb(eppreg, buf, len);
1161 if (readb(priv->regs.dsr) & DSR_TIMEOUT) {
1162 parport_ip32_clear_epp_timeout(p);
1163 return -EIO;
1164 }
1165 written = len;
1166 } else {
1167 const u8 *bufp = buf;
1168 for (written = 0; written < len; written++) {
1169 writeb(*bufp++, eppreg);
1170 if (readb(priv->regs.dsr) & DSR_TIMEOUT) {
1171 parport_ip32_clear_epp_timeout(p);
1172 break;
1173 }
1174 }
1175 }
1176 parport_ip32_set_mode(p, ECR_MODE_PS2);
1177 return written;
1178}
1179
1180/**
1181 * parport_ip32_epp_read_data - read a block of data in EPP mode
1182 * @p: pointer to &struct parport
1183 * @buf: buffer to store read data
1184 * @len: length of buffer @buf
1185 * @flags: may be PARPORT_EPP_FAST
1186 */
1187static size_t parport_ip32_epp_read_data(struct parport *p, void *buf,
1188 size_t len, int flags)
1189{
1190 struct parport_ip32_private * const priv = p->physport->private_data;
1191 return parport_ip32_epp_read(priv->regs.eppData0, p, buf, len, flags);
1192}
1193
1194/**
1195 * parport_ip32_epp_write_data - write a block of data in EPP mode
1196 * @p: pointer to &struct parport
1197 * @buf: buffer of data to write
1198 * @len: length of buffer @buf
1199 * @flags: may be PARPORT_EPP_FAST
1200 */
1201static size_t parport_ip32_epp_write_data(struct parport *p, const void *buf,
1202 size_t len, int flags)
1203{
1204 struct parport_ip32_private * const priv = p->physport->private_data;
1205 return parport_ip32_epp_write(priv->regs.eppData0, p, buf, len, flags);
1206}
1207
1208/**
1209 * parport_ip32_epp_read_addr - read a block of addresses in EPP mode
1210 * @p: pointer to &struct parport
1211 * @buf: buffer to store read data
1212 * @len: length of buffer @buf
1213 * @flags: may be PARPORT_EPP_FAST
1214 */
1215static size_t parport_ip32_epp_read_addr(struct parport *p, void *buf,
1216 size_t len, int flags)
1217{
1218 struct parport_ip32_private * const priv = p->physport->private_data;
1219 return parport_ip32_epp_read(priv->regs.eppAddr, p, buf, len, flags);
1220}
1221
1222/**
1223 * parport_ip32_epp_write_addr - write a block of addresses in EPP mode
1224 * @p: pointer to &struct parport
1225 * @buf: buffer of data to write
1226 * @len: length of buffer @buf
1227 * @flags: may be PARPORT_EPP_FAST
1228 */
1229static size_t parport_ip32_epp_write_addr(struct parport *p, const void *buf,
1230 size_t len, int flags)
1231{
1232 struct parport_ip32_private * const priv = p->physport->private_data;
1233 return parport_ip32_epp_write(priv->regs.eppAddr, p, buf, len, flags);
1234}
1235
1236/*--- ECP mode functions (FIFO) ----------------------------------------*/
1237
1238/**
1239 * parport_ip32_fifo_wait_break - check if the waiting function should return
1240 * @p: pointer to &struct parport
1241 * @expire: timeout expiring date, in jiffies
1242 *
1243 * parport_ip32_fifo_wait_break() checks if the waiting function should return
1244 * immediately or not. The break conditions are:
1245 * - expired timeout;
1246 * - a pending signal;
1247 * - nFault asserted low.
1248 * This function also calls cond_resched().
1249 */
1250static unsigned int parport_ip32_fifo_wait_break(struct parport *p,
1251 unsigned long expire)
1252{
1253 cond_resched();
1254 if (time_after(jiffies, expire)) {
1255 pr_debug1(PPIP32 "%s: FIFO write timed out\n", p->name);
1256 return 1;
1257 }
1258 if (signal_pending(current)) {
1259 pr_debug1(PPIP32 "%s: Signal pending\n", p->name);
1260 return 1;
1261 }
1262 if (!(parport_ip32_read_status(p) & DSR_nFAULT)) {
1263 pr_debug1(PPIP32 "%s: nFault asserted low\n", p->name);
1264 return 1;
1265 }
1266 return 0;
1267}
1268
1269/**
1270 * parport_ip32_fwp_wait_polling - wait for FIFO to empty (polling)
1271 * @p: pointer to &struct parport
1272 *
1273 * Returns the number of bytes that can safely be written in the FIFO. A
1274 * return value of zero means that the calling function should terminate as
1275 * fast as possible.
1276 */
1277static unsigned int parport_ip32_fwp_wait_polling(struct parport *p)
1278{
1279 struct parport_ip32_private * const priv = p->physport->private_data;
1280 struct parport * const physport = p->physport;
1281 unsigned long expire;
1282 unsigned int count;
1283 unsigned int ecr;
1284
1285 expire = jiffies + physport->cad->timeout;
1286 count = 0;
1287 while (1) {
1288 if (parport_ip32_fifo_wait_break(p, expire))
1289 break;
1290
1291 /* Check FIFO state. We do nothing when the FIFO is nor full,
1292 * nor empty. It appears that the FIFO full bit is not always
1293 * reliable, the FIFO state is sometimes wrongly reported, and
1294 * the chip gets confused if we give it another byte. */
1295 ecr = parport_ip32_read_econtrol(p);
1296 if (ecr & ECR_F_EMPTY) {
1297 /* FIFO is empty, fill it up */
1298 count = priv->fifo_depth;
1299 break;
1300 }
1301
1302 /* Wait a moment... */
1303 udelay(FIFO_POLLING_INTERVAL);
1304 } /* while (1) */
1305
1306 return count;
1307}
1308
1309/**
1310 * parport_ip32_fwp_wait_interrupt - wait for FIFO to empty (interrupt-driven)
1311 * @p: pointer to &struct parport
1312 *
1313 * Returns the number of bytes that can safely be written in the FIFO. A
1314 * return value of zero means that the calling function should terminate as
1315 * fast as possible.
1316 */
1317static unsigned int parport_ip32_fwp_wait_interrupt(struct parport *p)
1318{
1319 static unsigned int lost_interrupt = 0;
1320 struct parport_ip32_private * const priv = p->physport->private_data;
1321 struct parport * const physport = p->physport;
1322 unsigned long nfault_timeout;
1323 unsigned long expire;
1324 unsigned int count;
1325 unsigned int ecr;
1326
1327 nfault_timeout = min((unsigned long)physport->cad->timeout,
1328 msecs_to_jiffies(FIFO_NFAULT_TIMEOUT));
1329 expire = jiffies + physport->cad->timeout;
1330 count = 0;
1331 while (1) {
1332 if (parport_ip32_fifo_wait_break(p, expire))
1333 break;
1334
1335 /* Initialize mutex used to take interrupts into account */
1336 INIT_COMPLETION(priv->irq_complete);
1337
1338 /* Enable serviceIntr */
1339 parport_ip32_frob_econtrol(p, ECR_SERVINTR, 0);
1340
1341 /* Enabling serviceIntr while the FIFO is empty does not
1342 * always generate an interrupt, so check for emptiness
1343 * now. */
1344 ecr = parport_ip32_read_econtrol(p);
1345 if (!(ecr & ECR_F_EMPTY)) {
1346 /* FIFO is not empty: wait for an interrupt or a
1347 * timeout to occur */
1348 wait_for_completion_interruptible_timeout(
1349 &priv->irq_complete, nfault_timeout);
1350 ecr = parport_ip32_read_econtrol(p);
1351 if ((ecr & ECR_F_EMPTY) && !(ecr & ECR_SERVINTR)
1352 && !lost_interrupt) {
1353 printk(KERN_WARNING PPIP32
1354 "%s: lost interrupt in %s\n",
1355 p->name, __func__);
1356 lost_interrupt = 1;
1357 }
1358 }
1359
1360 /* Disable serviceIntr */
1361 parport_ip32_frob_econtrol(p, ECR_SERVINTR, ECR_SERVINTR);
1362
1363 /* Check FIFO state */
1364 if (ecr & ECR_F_EMPTY) {
1365 /* FIFO is empty, fill it up */
1366 count = priv->fifo_depth;
1367 break;
1368 } else if (ecr & ECR_SERVINTR) {
1369 /* FIFO is not empty, but we know that can safely push
1370 * writeIntrThreshold bytes into it */
1371 count = priv->writeIntrThreshold;
1372 break;
1373 }
1374 /* FIFO is not empty, and we did not get any interrupt.
1375 * Either it's time to check for nFault, or a signal is
1376 * pending. This is verified in
1377 * parport_ip32_fifo_wait_break(), so we continue the loop. */
1378 } /* while (1) */
1379
1380 return count;
1381}
1382
1383/**
1384 * parport_ip32_fifo_write_block_pio - write a block of data (PIO mode)
1385 * @p: pointer to &struct parport
1386 * @buf: buffer of data to write
1387 * @len: length of buffer @buf
1388 *
1389 * Uses PIO to write the contents of the buffer @buf into the parallel port
1390 * FIFO. Returns the number of bytes that were actually written. It can work
1391 * with or without the help of interrupts. The parallel port must be
1392 * correctly initialized before calling parport_ip32_fifo_write_block_pio().
1393 */
1394static size_t parport_ip32_fifo_write_block_pio(struct parport *p,
1395 const void *buf, size_t len)
1396{
1397 struct parport_ip32_private * const priv = p->physport->private_data;
1398 const u8 *bufp = buf;
1399 size_t left = len;
1400
1401 priv->irq_mode = PARPORT_IP32_IRQ_HERE;
1402
1403 while (left > 0) {
1404 unsigned int count;
1405
1406 count = (p->irq == PARPORT_IRQ_NONE) ?
1407 parport_ip32_fwp_wait_polling(p) :
1408 parport_ip32_fwp_wait_interrupt(p);
1409 if (count == 0)
1410 break; /* Transmission should be stopped */
1411 if (count > left)
1412 count = left;
1413 if (count == 1) {
1414 writeb(*bufp, priv->regs.fifo);
1415 bufp++, left--;
1416 } else {
1417 writesb(priv->regs.fifo, bufp, count);
1418 bufp += count, left -= count;
1419 }
1420 }
1421
1422 priv->irq_mode = PARPORT_IP32_IRQ_FWD;
1423
1424 return len - left;
1425}
1426
1427/**
1428 * parport_ip32_fifo_write_block_dma - write a block of data (DMA mode)
1429 * @p: pointer to &struct parport
1430 * @buf: buffer of data to write
1431 * @len: length of buffer @buf
1432 *
1433 * Uses DMA to write the contents of the buffer @buf into the parallel port
1434 * FIFO. Returns the number of bytes that were actually written. The
1435 * parallel port must be correctly initialized before calling
1436 * parport_ip32_fifo_write_block_dma().
1437 */
1438static size_t parport_ip32_fifo_write_block_dma(struct parport *p,
1439 const void *buf, size_t len)
1440{
1441 struct parport_ip32_private * const priv = p->physport->private_data;
1442 struct parport * const physport = p->physport;
1443 unsigned long nfault_timeout;
1444 unsigned long expire;
1445 size_t written;
1446 unsigned int ecr;
1447
1448 priv->irq_mode = PARPORT_IP32_IRQ_HERE;
1449
1450 parport_ip32_dma_start(DMA_TO_DEVICE, (void *)buf, len);
1451 INIT_COMPLETION(priv->irq_complete);
1452 parport_ip32_frob_econtrol(p, ECR_DMAEN | ECR_SERVINTR, ECR_DMAEN);
1453
1454 nfault_timeout = min((unsigned long)physport->cad->timeout,
1455 msecs_to_jiffies(FIFO_NFAULT_TIMEOUT));
1456 expire = jiffies + physport->cad->timeout;
1457 while (1) {
1458 if (parport_ip32_fifo_wait_break(p, expire))
1459 break;
1460 wait_for_completion_interruptible_timeout(&priv->irq_complete,
1461 nfault_timeout);
1462 ecr = parport_ip32_read_econtrol(p);
1463 if (ecr & ECR_SERVINTR)
1464 break; /* DMA transfer just finished */
1465 }
1466 parport_ip32_dma_stop();
1467 written = len - parport_ip32_dma_get_residue();
1468
1469 priv->irq_mode = PARPORT_IP32_IRQ_FWD;
1470
1471 return written;
1472}
1473
1474/**
1475 * parport_ip32_fifo_write_block - write a block of data
1476 * @p: pointer to &struct parport
1477 * @buf: buffer of data to write
1478 * @len: length of buffer @buf
1479 *
1480 * Uses PIO or DMA to write the contents of the buffer @buf into the parallel
1481 * p FIFO. Returns the number of bytes that were actually written.
1482 */
1483static size_t parport_ip32_fifo_write_block(struct parport *p,
1484 const void *buf, size_t len)
1485{
1486 size_t written = 0;
1487 if (len)
1488 /* FIXME - Maybe some threshold value should be set for @len
1489 * under which we revert to PIO mode? */
1490 written = (p->modes & PARPORT_MODE_DMA) ?
1491 parport_ip32_fifo_write_block_dma(p, buf, len) :
1492 parport_ip32_fifo_write_block_pio(p, buf, len);
1493 return written;
1494}
1495
1496/**
1497 * parport_ip32_drain_fifo - wait for FIFO to empty
1498 * @p: pointer to &struct parport
1499 * @timeout: timeout, in jiffies
1500 *
1501 * This function waits for FIFO to empty. It returns 1 when FIFO is empty, or
1502 * 0 if the timeout @timeout is reached before, or if a signal is pending.
1503 */
1504static unsigned int parport_ip32_drain_fifo(struct parport *p,
1505 unsigned long timeout)
1506{
1507 unsigned long expire = jiffies + timeout;
1508 unsigned int polling_interval;
1509 unsigned int counter;
1510
1511 /* Busy wait for approx. 200us */
1512 for (counter = 0; counter < 40; counter++) {
1513 if (parport_ip32_read_econtrol(p) & ECR_F_EMPTY)
1514 break;
1515 if (time_after(jiffies, expire))
1516 break;
1517 if (signal_pending(current))
1518 break;
1519 udelay(5);
1520 }
1521 /* Poll slowly. Polling interval starts with 1 millisecond, and is
1522 * increased exponentially until 128. */
1523 polling_interval = 1; /* msecs */
1524 while (!(parport_ip32_read_econtrol(p) & ECR_F_EMPTY)) {
1525 if (time_after_eq(jiffies, expire))
1526 break;
1527 msleep_interruptible(polling_interval);
1528 if (signal_pending(current))
1529 break;
1530 if (polling_interval < 128)
1531 polling_interval *= 2;
1532 }
1533
1534 return !!(parport_ip32_read_econtrol(p) & ECR_F_EMPTY);
1535}
1536
1537/**
1538 * parport_ip32_get_fifo_residue - reset FIFO
1539 * @p: pointer to &struct parport
1540 * @mode: current operation mode (ECR_MODE_PPF or ECR_MODE_ECP)
1541 *
1542 * This function resets FIFO, and returns the number of bytes remaining in it.
1543 */
1544static unsigned int parport_ip32_get_fifo_residue(struct parport *p,
1545 unsigned int mode)
1546{
1547 struct parport_ip32_private * const priv = p->physport->private_data;
1548 unsigned int residue;
1549 unsigned int cnfga;
1550
1551 /* FIXME - We are missing one byte if the printer is off-line. I
1552 * don't know how to detect this. It looks that the full bit is not
1553 * always reliable. For the moment, the problem is avoided in most
1554 * cases by testing for BUSY in parport_ip32_compat_write_data().
1555 */
1556 if (parport_ip32_read_econtrol(p) & ECR_F_EMPTY)
1557 residue = 0;
1558 else {
1559 pr_debug1(PPIP32 "%s: FIFO is stuck\n", p->name);
1560
1561 /* Stop all transfers.
1562 *
1563 * Microsoft's document instructs to drive DCR_STROBE to 0,
1564 * but it doesn't work (at least in Compatibility mode, not
1565 * tested in ECP mode). Switching directly to Test mode (as
1566 * in parport_pc) is not an option: it does confuse the port,
1567 * ECP service interrupts are no more working after that. A
1568 * hard reset is then needed to revert to a sane state.
1569 *
1570 * Let's hope that the FIFO is really stuck and that the
1571 * peripheral doesn't wake up now.
1572 */
1573 parport_ip32_frob_control(p, DCR_STROBE, 0);
1574
1575 /* Fill up FIFO */
1576 for (residue = priv->fifo_depth; residue > 0; residue--) {
1577 if (parport_ip32_read_econtrol(p) & ECR_F_FULL)
1578 break;
1579 writeb(0x00, priv->regs.fifo);
1580 }
1581 }
1582 if (residue)
1583 pr_debug1(PPIP32 "%s: %d PWord%s left in FIFO\n",
1584 p->name, residue,
1585 (residue == 1) ? " was" : "s were");
1586
1587 /* Now reset the FIFO */
1588 parport_ip32_set_mode(p, ECR_MODE_PS2);
1589
1590 /* Host recovery for ECP mode */
1591 if (mode == ECR_MODE_ECP) {
1592 parport_ip32_data_reverse(p);
1593 parport_ip32_frob_control(p, DCR_nINIT, 0);
1594 if (parport_wait_peripheral(p, DSR_PERROR, 0))
1595 pr_debug1(PPIP32 "%s: PEerror timeout 1 in %s\n",
1596 p->name, __func__);
1597 parport_ip32_frob_control(p, DCR_STROBE, DCR_STROBE);
1598 parport_ip32_frob_control(p, DCR_nINIT, DCR_nINIT);
1599 if (parport_wait_peripheral(p, DSR_PERROR, DSR_PERROR))
1600 pr_debug1(PPIP32 "%s: PEerror timeout 2 in %s\n",
1601 p->name, __func__);
1602 }
1603
1604 /* Adjust residue if needed */
1605 parport_ip32_set_mode(p, ECR_MODE_CFG);
1606 cnfga = readb(priv->regs.cnfgA);
1607 if (!(cnfga & CNFGA_nBYTEINTRANS)) {
1608 pr_debug1(PPIP32 "%s: cnfgA contains 0x%02x\n",
1609 p->name, cnfga);
1610 pr_debug1(PPIP32 "%s: Accounting for extra byte\n",
1611 p->name);
1612 residue++;
1613 }
1614
1615 /* Don't care about partial PWords since we do not support
1616 * PWord != 1 byte. */
1617
1618 /* Back to forward PS2 mode. */
1619 parport_ip32_set_mode(p, ECR_MODE_PS2);
1620 parport_ip32_data_forward(p);
1621
1622 return residue;
1623}
1624
1625/**
1626 * parport_ip32_compat_write_data - write a block of data in SPP mode
1627 * @p: pointer to &struct parport
1628 * @buf: buffer of data to write
1629 * @len: length of buffer @buf
1630 * @flags: ignored
1631 */
1632static size_t parport_ip32_compat_write_data(struct parport *p,
1633 const void *buf, size_t len,
1634 int flags)
1635{
1636 static unsigned int ready_before = 1;
1637 struct parport_ip32_private * const priv = p->physport->private_data;
1638 struct parport * const physport = p->physport;
1639 size_t written = 0;
1640
1641 /* Special case: a timeout of zero means we cannot call schedule().
1642 * Also if O_NONBLOCK is set then use the default implementation. */
1643 if (physport->cad->timeout <= PARPORT_INACTIVITY_O_NONBLOCK)
1644 return parport_ieee1284_write_compat(p, buf, len, flags);
1645
1646 /* Reset FIFO, go in forward mode, and disable ackIntEn */
1647 parport_ip32_set_mode(p, ECR_MODE_PS2);
1648 parport_ip32_write_control(p, DCR_SELECT | DCR_nINIT);
1649 parport_ip32_data_forward(p);
1650 parport_ip32_disable_irq(p);
1651 parport_ip32_set_mode(p, ECR_MODE_PPF);
1652 physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
1653
1654 /* Wait for peripheral to become ready */
1655 if (parport_wait_peripheral(p, DSR_nBUSY | DSR_nFAULT,
1656 DSR_nBUSY | DSR_nFAULT)) {
1657 /* Avoid to flood the logs */
1658 if (ready_before)
1659 printk(KERN_INFO PPIP32 "%s: not ready in %s\n",
1660 p->name, __func__);
1661 ready_before = 0;
1662 goto stop;
1663 }
1664 ready_before = 1;
1665
1666 written = parport_ip32_fifo_write_block(p, buf, len);
1667
1668 /* Wait FIFO to empty. Timeout is proportional to FIFO_depth. */
1669 parport_ip32_drain_fifo(p, physport->cad->timeout * priv->fifo_depth);
1670
1671 /* Check for a potential residue */
1672 written -= parport_ip32_get_fifo_residue(p, ECR_MODE_PPF);
1673
1674 /* Then, wait for BUSY to get low. */
1675 if (parport_wait_peripheral(p, DSR_nBUSY, DSR_nBUSY))
1676 printk(KERN_DEBUG PPIP32 "%s: BUSY timeout in %s\n",
1677 p->name, __func__);
1678
1679stop:
1680 /* Reset FIFO */
1681 parport_ip32_set_mode(p, ECR_MODE_PS2);
1682 physport->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
1683
1684 return written;
1685}
1686
1687/*
1688 * FIXME - Insert here parport_ip32_ecp_read_data().
1689 */
1690
1691/**
1692 * parport_ip32_ecp_write_data - write a block of data in ECP mode
1693 * @p: pointer to &struct parport
1694 * @buf: buffer of data to write
1695 * @len: length of buffer @buf
1696 * @flags: ignored
1697 */
1698static size_t parport_ip32_ecp_write_data(struct parport *p,
1699 const void *buf, size_t len,
1700 int flags)
1701{
1702 static unsigned int ready_before = 1;
1703 struct parport_ip32_private * const priv = p->physport->private_data;
1704 struct parport * const physport = p->physport;
1705 size_t written = 0;
1706
1707 /* Special case: a timeout of zero means we cannot call schedule().
1708 * Also if O_NONBLOCK is set then use the default implementation. */
1709 if (physport->cad->timeout <= PARPORT_INACTIVITY_O_NONBLOCK)
1710 return parport_ieee1284_ecp_write_data(p, buf, len, flags);
1711
1712 /* Negotiate to forward mode if necessary. */
1713 if (physport->ieee1284.phase != IEEE1284_PH_FWD_IDLE) {
1714 /* Event 47: Set nInit high. */
1715 parport_ip32_frob_control(p, DCR_nINIT | DCR_AUTOFD,
1716 DCR_nINIT | DCR_AUTOFD);
1717
1718 /* Event 49: PError goes high. */
1719 if (parport_wait_peripheral(p, DSR_PERROR, DSR_PERROR)) {
1720 printk(KERN_DEBUG PPIP32 "%s: PError timeout in %s",
1721 p->name, __func__);
1722 physport->ieee1284.phase = IEEE1284_PH_ECP_DIR_UNKNOWN;
1723 return 0;
1724 }
1725 }
1726
1727 /* Reset FIFO, go in forward mode, and disable ackIntEn */
1728 parport_ip32_set_mode(p, ECR_MODE_PS2);
1729 parport_ip32_write_control(p, DCR_SELECT | DCR_nINIT);
1730 parport_ip32_data_forward(p);
1731 parport_ip32_disable_irq(p);
1732 parport_ip32_set_mode(p, ECR_MODE_ECP);
1733 physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
1734
1735 /* Wait for peripheral to become ready */
1736 if (parport_wait_peripheral(p, DSR_nBUSY | DSR_nFAULT,
1737 DSR_nBUSY | DSR_nFAULT)) {
1738 /* Avoid to flood the logs */
1739 if (ready_before)
1740 printk(KERN_INFO PPIP32 "%s: not ready in %s\n",
1741 p->name, __func__);
1742 ready_before = 0;
1743 goto stop;
1744 }
1745 ready_before = 1;
1746
1747 written = parport_ip32_fifo_write_block(p, buf, len);
1748
1749 /* Wait FIFO to empty. Timeout is proportional to FIFO_depth. */
1750 parport_ip32_drain_fifo(p, physport->cad->timeout * priv->fifo_depth);
1751
1752 /* Check for a potential residue */
1753 written -= parport_ip32_get_fifo_residue(p, ECR_MODE_ECP);
1754
1755 /* Then, wait for BUSY to get low. */
1756 if (parport_wait_peripheral(p, DSR_nBUSY, DSR_nBUSY))
1757 printk(KERN_DEBUG PPIP32 "%s: BUSY timeout in %s\n",
1758 p->name, __func__);
1759
1760stop:
1761 /* Reset FIFO */
1762 parport_ip32_set_mode(p, ECR_MODE_PS2);
1763 physport->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
1764
1765 return written;
1766}
1767
1768/*
1769 * FIXME - Insert here parport_ip32_ecp_write_addr().
1770 */
1771
1772/*--- Default parport operations ---------------------------------------*/
1773
1774static __initdata struct parport_operations parport_ip32_ops = {
1775 .write_data = parport_ip32_write_data,
1776 .read_data = parport_ip32_read_data,
1777
1778 .write_control = parport_ip32_write_control,
1779 .read_control = parport_ip32_read_control,
1780 .frob_control = parport_ip32_frob_control,
1781
1782 .read_status = parport_ip32_read_status,
1783
1784 .enable_irq = parport_ip32_enable_irq,
1785 .disable_irq = parport_ip32_disable_irq,
1786
1787 .data_forward = parport_ip32_data_forward,
1788 .data_reverse = parport_ip32_data_reverse,
1789
1790 .init_state = parport_ip32_init_state,
1791 .save_state = parport_ip32_save_state,
1792 .restore_state = parport_ip32_restore_state,
1793
1794 .epp_write_data = parport_ieee1284_epp_write_data,
1795 .epp_read_data = parport_ieee1284_epp_read_data,
1796 .epp_write_addr = parport_ieee1284_epp_write_addr,
1797 .epp_read_addr = parport_ieee1284_epp_read_addr,
1798
1799 .ecp_write_data = parport_ieee1284_ecp_write_data,
1800 .ecp_read_data = parport_ieee1284_ecp_read_data,
1801 .ecp_write_addr = parport_ieee1284_ecp_write_addr,
1802
1803 .compat_write_data = parport_ieee1284_write_compat,
1804 .nibble_read_data = parport_ieee1284_read_nibble,
1805 .byte_read_data = parport_ieee1284_read_byte,
1806
1807 .owner = THIS_MODULE,
1808};
1809
1810/*--- Device detection -------------------------------------------------*/
1811
1812/**
1813 * parport_ip32_ecp_supported - check for an ECP port
1814 * @p: pointer to the &parport structure
1815 *
1816 * Returns 1 if an ECP port is found, and 0 otherwise. This function actually
1817 * checks if an Extended Control Register seems to be present. On successful
1818 * return, the port is placed in SPP mode.
1819 */
1820static __init unsigned int parport_ip32_ecp_supported(struct parport *p)
1821{
1822 struct parport_ip32_private * const priv = p->physport->private_data;
1823 unsigned int ecr;
1824
1825 ecr = ECR_MODE_PS2 | ECR_nERRINTR | ECR_SERVINTR;
1826 writeb(ecr, priv->regs.ecr);
1827 if (readb(priv->regs.ecr) != (ecr | ECR_F_EMPTY))
1828 goto fail;
1829
1830 pr_probe(p, "Found working ECR register\n");
1831 parport_ip32_set_mode(p, ECR_MODE_SPP);
1832 parport_ip32_write_control(p, DCR_SELECT | DCR_nINIT);
1833 return 1;
1834
1835fail:
1836 pr_probe(p, "ECR register not found\n");
1837 return 0;
1838}
1839
1840/**
1841 * parport_ip32_fifo_supported - check for FIFO parameters
1842 * @p: pointer to the &parport structure
1843 *
1844 * Check for FIFO parameters of an Extended Capabilities Port. Returns 1 on
1845 * success, and 0 otherwise. Adjust FIFO parameters in the parport structure.
1846 * On return, the port is placed in SPP mode.
1847 */
1848static __init unsigned int parport_ip32_fifo_supported(struct parport *p)
1849{
1850 struct parport_ip32_private * const priv = p->physport->private_data;
1851 unsigned int configa, configb;
1852 unsigned int pword;
1853 unsigned int i;
1854
1855 /* Configuration mode */
1856 parport_ip32_set_mode(p, ECR_MODE_CFG);
1857 configa = readb(priv->regs.cnfgA);
1858 configb = readb(priv->regs.cnfgB);
1859
1860 /* Find out PWord size */
1861 switch (configa & CNFGA_ID_MASK) {
1862 case CNFGA_ID_8:
1863 pword = 1;
1864 break;
1865 case CNFGA_ID_16:
1866 pword = 2;
1867 break;
1868 case CNFGA_ID_32:
1869 pword = 4;
1870 break;
1871 default:
1872 pr_probe(p, "Unknown implementation ID: 0x%0x\n",
1873 (configa & CNFGA_ID_MASK) >> CNFGA_ID_SHIFT);
1874 goto fail;
1875 break;
1876 }
1877 if (pword != 1) {
1878 pr_probe(p, "Unsupported PWord size: %u\n", pword);
1879 goto fail;
1880 }
1881 priv->pword = pword;
1882 pr_probe(p, "PWord is %u bits\n", 8 * priv->pword);
1883
1884 /* Check for compression support */
1885 writeb(configb | CNFGB_COMPRESS, priv->regs.cnfgB);
1886 if (readb(priv->regs.cnfgB) & CNFGB_COMPRESS)
1887 pr_probe(p, "Hardware compression detected (unsupported)\n");
1888 writeb(configb & ~CNFGB_COMPRESS, priv->regs.cnfgB);
1889
1890 /* Reset FIFO and go in test mode (no interrupt, no DMA) */
1891 parport_ip32_set_mode(p, ECR_MODE_TST);
1892
1893 /* FIFO must be empty now */
1894 if (!(readb(priv->regs.ecr) & ECR_F_EMPTY)) {
1895 pr_probe(p, "FIFO not reset\n");
1896 goto fail;
1897 }
1898
1899 /* Find out FIFO depth. */
1900 priv->fifo_depth = 0;
1901 for (i = 0; i < 1024; i++) {
1902 if (readb(priv->regs.ecr) & ECR_F_FULL) {
1903 /* FIFO full */
1904 priv->fifo_depth = i;
1905 break;
1906 }
1907 writeb((u8)i, priv->regs.fifo);
1908 }
1909 if (i >= 1024) {
1910 pr_probe(p, "Can't fill FIFO\n");
1911 goto fail;
1912 }
1913 if (!priv->fifo_depth) {
1914 pr_probe(p, "Can't get FIFO depth\n");
1915 goto fail;
1916 }
1917 pr_probe(p, "FIFO is %u PWords deep\n", priv->fifo_depth);
1918
1919 /* Enable interrupts */
1920 parport_ip32_frob_econtrol(p, ECR_SERVINTR, 0);
1921
1922 /* Find out writeIntrThreshold: number of PWords we know we can write
1923 * if we get an interrupt. */
1924 priv->writeIntrThreshold = 0;
1925 for (i = 0; i < priv->fifo_depth; i++) {
1926 if (readb(priv->regs.fifo) != (u8)i) {
1927 pr_probe(p, "Invalid data in FIFO\n");
1928 goto fail;
1929 }
1930 if (!priv->writeIntrThreshold
1931 && readb(priv->regs.ecr) & ECR_SERVINTR)
1932 /* writeIntrThreshold reached */
1933 priv->writeIntrThreshold = i + 1;
1934 if (i + 1 < priv->fifo_depth
1935 && readb(priv->regs.ecr) & ECR_F_EMPTY) {
1936 /* FIFO empty before the last byte? */
1937 pr_probe(p, "Data lost in FIFO\n");
1938 goto fail;
1939 }
1940 }
1941 if (!priv->writeIntrThreshold) {
1942 pr_probe(p, "Can't get writeIntrThreshold\n");
1943 goto fail;
1944 }
1945 pr_probe(p, "writeIntrThreshold is %u\n", priv->writeIntrThreshold);
1946
1947 /* FIFO must be empty now */
1948 if (!(readb(priv->regs.ecr) & ECR_F_EMPTY)) {
1949 pr_probe(p, "Can't empty FIFO\n");
1950 goto fail;
1951 }
1952
1953 /* Reset FIFO */
1954 parport_ip32_set_mode(p, ECR_MODE_PS2);
1955 /* Set reverse direction (must be in PS2 mode) */
1956 parport_ip32_data_reverse(p);
1957 /* Test FIFO, no interrupt, no DMA */
1958 parport_ip32_set_mode(p, ECR_MODE_TST);
1959 /* Enable interrupts */
1960 parport_ip32_frob_econtrol(p, ECR_SERVINTR, 0);
1961
1962 /* Find out readIntrThreshold: number of PWords we can read if we get
1963 * an interrupt. */
1964 priv->readIntrThreshold = 0;
1965 for (i = 0; i < priv->fifo_depth; i++) {
1966 writeb(0xaa, priv->regs.fifo);
1967 if (readb(priv->regs.ecr) & ECR_SERVINTR) {
1968 /* readIntrThreshold reached */
1969 priv->readIntrThreshold = i + 1;
1970 break;
1971 }
1972 }
1973 if (!priv->readIntrThreshold) {
1974 pr_probe(p, "Can't get readIntrThreshold\n");
1975 goto fail;
1976 }
1977 pr_probe(p, "readIntrThreshold is %u\n", priv->readIntrThreshold);
1978
1979 /* Reset ECR */
1980 parport_ip32_set_mode(p, ECR_MODE_PS2);
1981 parport_ip32_data_forward(p);
1982 parport_ip32_set_mode(p, ECR_MODE_SPP);
1983 return 1;
1984
1985fail:
1986 priv->fifo_depth = 0;
1987 parport_ip32_set_mode(p, ECR_MODE_SPP);
1988 return 0;
1989}
1990
1991/*--- Initialization code ----------------------------------------------*/
1992
1993/**
1994 * parport_ip32_make_isa_registers - compute (ISA) register addresses
1995 * @regs: pointer to &struct parport_ip32_regs to fill
1996 * @base: base address of standard and EPP registers
1997 * @base_hi: base address of ECP registers
1998 * @regshift: how much to shift register offset by
1999 *
2000 * Compute register addresses, according to the ISA standard. The addresses
2001 * of the standard and EPP registers are computed from address @base. The
2002 * addresses of the ECP registers are computed from address @base_hi.
2003 */
2004static void __init
2005parport_ip32_make_isa_registers(struct parport_ip32_regs *regs,
2006 void __iomem *base, void __iomem *base_hi,
2007 unsigned int regshift)
2008{
2009#define r_base(offset) ((u8 __iomem *)base + ((offset) << regshift))
2010#define r_base_hi(offset) ((u8 __iomem *)base_hi + ((offset) << regshift))
2011 *regs = (struct parport_ip32_regs){
2012 .data = r_base(0),
2013 .dsr = r_base(1),
2014 .dcr = r_base(2),
2015 .eppAddr = r_base(3),
2016 .eppData0 = r_base(4),
2017 .eppData1 = r_base(5),
2018 .eppData2 = r_base(6),
2019 .eppData3 = r_base(7),
2020 .ecpAFifo = r_base(0),
2021 .fifo = r_base_hi(0),
2022 .cnfgA = r_base_hi(0),
2023 .cnfgB = r_base_hi(1),
2024 .ecr = r_base_hi(2)
2025 };
2026#undef r_base_hi
2027#undef r_base
2028}
2029
2030/**
2031 * parport_ip32_probe_port - probe and register IP32 built-in parallel port
2032 *
2033 * Returns the new allocated &parport structure. On error, an error code is
2034 * encoded in return value with the ERR_PTR function.
2035 */
2036static __init struct parport *parport_ip32_probe_port(void)
2037{
2038 struct parport_ip32_regs regs;
2039 struct parport_ip32_private *priv = NULL;
2040 struct parport_operations *ops = NULL;
2041 struct parport *p = NULL;
2042 int err;
2043
2044 parport_ip32_make_isa_registers(&regs, &mace->isa.parallel,
2045 &mace->isa.ecp1284, 8 /* regshift */);
2046
2047 ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL);
2048 priv = kmalloc(sizeof(struct parport_ip32_private), GFP_KERNEL);
2049 p = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, ops);
2050 if (ops == NULL || priv == NULL || p == NULL) {
2051 err = -ENOMEM;
2052 goto fail;
2053 }
2054 p->base = MACE_BASE + offsetof(struct sgi_mace, isa.parallel);
2055 p->base_hi = MACE_BASE + offsetof(struct sgi_mace, isa.ecp1284);
2056 p->private_data = priv;
2057
2058 *ops = parport_ip32_ops;
2059 *priv = (struct parport_ip32_private){
2060 .regs = regs,
2061 .dcr_writable = DCR_DIR | DCR_SELECT | DCR_nINIT |
2062 DCR_AUTOFD | DCR_STROBE,
2063 .irq_mode = PARPORT_IP32_IRQ_FWD,
2064 };
2065 init_completion(&priv->irq_complete);
2066
2067 /* Probe port. */
2068 if (!parport_ip32_ecp_supported(p)) {
2069 err = -ENODEV;
2070 goto fail;
2071 }
2072 parport_ip32_dump_state(p, "begin init", 0);
2073
2074 /* We found what looks like a working ECR register. Simply assume
2075 * that all modes are correctly supported. Enable basic modes. */
2076 p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT;
2077 p->modes |= PARPORT_MODE_TRISTATE;
2078
2079 if (!parport_ip32_fifo_supported(p)) {
2080 printk(KERN_WARNING PPIP32
2081 "%s: error: FIFO disabled\n", p->name);
2082 /* Disable hardware modes depending on a working FIFO. */
2083 features &= ~PARPORT_IP32_ENABLE_SPP;
2084 features &= ~PARPORT_IP32_ENABLE_ECP;
2085 /* DMA is not needed if FIFO is not supported. */
2086 features &= ~PARPORT_IP32_ENABLE_DMA;
2087 }
2088
2089 /* Request IRQ */
2090 if (features & PARPORT_IP32_ENABLE_IRQ) {
2091 int irq = MACEISA_PARALLEL_IRQ;
2092 if (request_irq(irq, parport_ip32_interrupt, 0, p->name, p)) {
2093 printk(KERN_WARNING PPIP32
2094 "%s: error: IRQ disabled\n", p->name);
2095 /* DMA cannot work without interrupts. */
2096 features &= ~PARPORT_IP32_ENABLE_DMA;
2097 } else {
2098 pr_probe(p, "Interrupt support enabled\n");
2099 p->irq = irq;
2100 priv->dcr_writable |= DCR_IRQ;
2101 }
2102 }
2103
2104 /* Allocate DMA resources */
2105 if (features & PARPORT_IP32_ENABLE_DMA) {
2106 if (parport_ip32_dma_register())
2107 printk(KERN_WARNING PPIP32
2108 "%s: error: DMA disabled\n", p->name);
2109 else {
2110 pr_probe(p, "DMA support enabled\n");
2111 p->dma = 0; /* arbitrary value != PARPORT_DMA_NONE */
2112 p->modes |= PARPORT_MODE_DMA;
2113 }
2114 }
2115
2116 if (features & PARPORT_IP32_ENABLE_SPP) {
2117 /* Enable compatibility FIFO mode */
2118 p->ops->compat_write_data = parport_ip32_compat_write_data;
2119 p->modes |= PARPORT_MODE_COMPAT;
2120 pr_probe(p, "Hardware support for SPP mode enabled\n");
2121 }
2122 if (features & PARPORT_IP32_ENABLE_EPP) {
2123 /* Set up access functions to use EPP hardware. */
2124 p->ops->epp_read_data = parport_ip32_epp_read_data;
2125 p->ops->epp_write_data = parport_ip32_epp_write_data;
2126 p->ops->epp_read_addr = parport_ip32_epp_read_addr;
2127 p->ops->epp_write_addr = parport_ip32_epp_write_addr;
2128 p->modes |= PARPORT_MODE_EPP;
2129 pr_probe(p, "Hardware support for EPP mode enabled\n");
2130 }
2131 if (features & PARPORT_IP32_ENABLE_ECP) {
2132 /* Enable ECP FIFO mode */
2133 p->ops->ecp_write_data = parport_ip32_ecp_write_data;
2134 /* FIXME - not implemented */
2135/* p->ops->ecp_read_data = parport_ip32_ecp_read_data; */
2136/* p->ops->ecp_write_addr = parport_ip32_ecp_write_addr; */
2137 p->modes |= PARPORT_MODE_ECP;
2138 pr_probe(p, "Hardware support for ECP mode enabled\n");
2139 }
2140
2141 /* Initialize the port with sensible values */
2142 parport_ip32_set_mode(p, ECR_MODE_PS2);
2143 parport_ip32_write_control(p, DCR_SELECT | DCR_nINIT);
2144 parport_ip32_data_forward(p);
2145 parport_ip32_disable_irq(p);
2146 parport_ip32_write_data(p, 0x00);
2147 parport_ip32_dump_state(p, "end init", 0);
2148
2149 /* Print out what we found */
2150 printk(KERN_INFO "%s: SGI IP32 at 0x%lx (0x%lx)",
2151 p->name, p->base, p->base_hi);
2152 if (p->irq != PARPORT_IRQ_NONE)
2153 printk(", irq %d", p->irq);
2154 printk(" [");
2155#define printmode(x) if (p->modes & PARPORT_MODE_##x) \
2156 printk("%s%s", f++ ? "," : "", #x)
2157 {
2158 unsigned int f = 0;
2159 printmode(PCSPP);
2160 printmode(TRISTATE);
2161 printmode(COMPAT);
2162 printmode(EPP);
2163 printmode(ECP);
2164 printmode(DMA);
2165 }
2166#undef printmode
2167 printk("]\n");
2168
2169 parport_announce_port(p);
2170 return p;
2171
2172fail:
2173 if (p)
2174 parport_put_port(p);
2175 kfree(priv);
2176 kfree(ops);
2177 return ERR_PTR(err);
2178}
2179
2180/**
2181 * parport_ip32_unregister_port - unregister a parallel port
2182 * @p: pointer to the &struct parport
2183 *
2184 * Unregisters a parallel port and free previously allocated resources
2185 * (memory, IRQ, ...).
2186 */
2187static __exit void parport_ip32_unregister_port(struct parport *p)
2188{
2189 struct parport_ip32_private * const priv = p->physport->private_data;
2190 struct parport_operations *ops = p->ops;
2191
2192 parport_remove_port(p);
2193 if (p->modes & PARPORT_MODE_DMA)
2194 parport_ip32_dma_unregister();
2195 if (p->irq != PARPORT_IRQ_NONE)
2196 free_irq(p->irq, p);
2197 parport_put_port(p);
2198 kfree(priv);
2199 kfree(ops);
2200}
2201
2202/**
2203 * parport_ip32_init - module initialization function
2204 */
2205static int __init parport_ip32_init(void)
2206{
2207 pr_info(PPIP32 "SGI IP32 built-in parallel port driver v0.6\n");
2208 pr_debug1(PPIP32 "Compiled on %s, %s\n", __DATE__, __TIME__);
2209 this_port = parport_ip32_probe_port();
2210 return IS_ERR(this_port) ? PTR_ERR(this_port) : 0;
2211}
2212
2213/**
2214 * parport_ip32_exit - module termination function
2215 */
2216static void __exit parport_ip32_exit(void)
2217{
2218 parport_ip32_unregister_port(this_port);
2219}
2220
2221/*--- Module stuff -----------------------------------------------------*/
2222
2223MODULE_AUTHOR("Arnaud Giersch <arnaud.giersch@free.fr>");
2224MODULE_DESCRIPTION("SGI IP32 built-in parallel port driver");
2225MODULE_LICENSE("GPL");
2226MODULE_VERSION("0.6"); /* update in parport_ip32_init() too */
2227
2228module_init(parport_ip32_init);
2229module_exit(parport_ip32_exit);
2230
2231module_param(verbose_probing, bool, S_IRUGO);
2232MODULE_PARM_DESC(verbose_probing, "Log chit-chat during initialization");
2233
2234module_param(features, uint, S_IRUGO);
2235MODULE_PARM_DESC(features,
2236 "Bit mask of features to enable"
2237 ", bit 0: IRQ support"
2238 ", bit 1: DMA support"
2239 ", bit 2: hardware SPP mode"
2240 ", bit 3: hardware EPP mode"
2241 ", bit 4: hardware ECP mode");
2242
2243/*--- Inform (X)Emacs about preferred coding style ---------------------*/
2244/*
2245 * Local Variables:
2246 * mode: c
2247 * c-file-style: "linux"
2248 * indent-tabs-mode: t
2249 * tab-width: 8
2250 * fill-column: 78
2251 * ispell-local-dictionary: "american"
2252 * End:
2253 */
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 76dd077e3184..166de3507780 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -329,9 +329,9 @@ static int __devinit parport_register (struct pci_dev *dev,
329 329
330 if (priv->num_par == ARRAY_SIZE (priv->port)) { 330 if (priv->num_par == ARRAY_SIZE (priv->port)) {
331 printk (KERN_WARNING 331 printk (KERN_WARNING
332 "parport_serial: %s: only %u parallel ports " 332 "parport_serial: %s: only %zu parallel ports "
333 "supported (%d reported)\n", pci_name (dev), 333 "supported (%d reported)\n", pci_name (dev),
334 ARRAY_SIZE (priv->port), card->numports); 334 ARRAY_SIZE(priv->port), card->numports);
335 break; 335 break;
336 } 336 }
337 337
diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
index b62aee8de3cb..ea83b70e0de2 100644
--- a/drivers/parport/probe.c
+++ b/drivers/parport/probe.c
@@ -199,7 +199,7 @@ static ssize_t parport_read_device_id (struct parport *port, char *buffer,
199 199
200 if (port->physport->ieee1284.phase != IEEE1284_PH_HBUSY_DAVAIL) { 200 if (port->physport->ieee1284.phase != IEEE1284_PH_HBUSY_DAVAIL) {
201 if (belen != len) { 201 if (belen != len) {
202 printk (KERN_DEBUG "%s: Device ID was %d bytes" 202 printk (KERN_DEBUG "%s: Device ID was %zd bytes"
203 " while device told it would be %d" 203 " while device told it would be %d"
204 " bytes\n", 204 " bytes\n",
205 port->name, len, belen); 205 port->name, len, belen);
@@ -214,7 +214,7 @@ static ssize_t parport_read_device_id (struct parport *port, char *buffer,
214 if (buffer[len-1] == ';') { 214 if (buffer[len-1] == ';') {
215 printk (KERN_DEBUG "%s: Device ID reading stopped" 215 printk (KERN_DEBUG "%s: Device ID reading stopped"
216 " before device told data not available. " 216 " before device told data not available. "
217 "Current idlen %d of %d, len bytes %02X %02X\n", 217 "Current idlen %u of %u, len bytes %02X %02X\n",
218 port->name, current_idlen, numidlens, 218 port->name, current_idlen, numidlens,
219 length[0], length[1]); 219 length[0], length[1]);
220 goto done; 220 goto done;
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig
index 2f1289eebb3c..222a1cc4aa28 100644
--- a/drivers/pci/hotplug/Kconfig
+++ b/drivers/pci/hotplug/Kconfig
@@ -11,8 +11,7 @@ config HOTPLUG_PCI
11 ---help--- 11 ---help---
12 Say Y here if you have a motherboard with a PCI Hotplug controller. 12 Say Y here if you have a motherboard with a PCI Hotplug controller.
13 This allows you to add and remove PCI cards while the machine is 13 This allows you to add and remove PCI cards while the machine is
14 powered up and running. The file system pcihpfs must be mounted 14 powered up and running.
15 in order to interact with any PCI Hotplug controllers.
16 15
17 To compile this driver as a module, choose M here: the 16 To compile this driver as a module, choose M here: the
18 module will be called pci_hotplug. 17 module will be called pci_hotplug.
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 7e7f913ba7b9..317457dd4014 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -302,7 +302,7 @@ static int ibm_get_table_from_acpi(char **bufp)
302 } 302 }
303 303
304 package = (union acpi_object *) buffer.pointer; 304 package = (union acpi_object *) buffer.pointer;
305 if(!(package) || 305 if (!(package) ||
306 (package->type != ACPI_TYPE_PACKAGE) || 306 (package->type != ACPI_TYPE_PACKAGE) ||
307 !(package->package.elements)) { 307 !(package->package.elements)) {
308 err("%s: Invalid APCI object\n", __FUNCTION__); 308 err("%s: Invalid APCI object\n", __FUNCTION__);
@@ -405,7 +405,7 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
405 } 405 }
406 info.hardware_id.value[sizeof(info.hardware_id.value) - 1] = '\0'; 406 info.hardware_id.value[sizeof(info.hardware_id.value) - 1] = '\0';
407 407
408 if(info.current_status && (info.valid & ACPI_VALID_HID) && 408 if (info.current_status && (info.valid & ACPI_VALID_HID) &&
409 (!strcmp(info.hardware_id.value, IBM_HARDWARE_ID1) || 409 (!strcmp(info.hardware_id.value, IBM_HARDWARE_ID1) ||
410 !strcmp(info.hardware_id.value, IBM_HARDWARE_ID2))) { 410 !strcmp(info.hardware_id.value, IBM_HARDWARE_ID2))) {
411 dbg("found hardware: %s, handle: %p\n", info.hardware_id.value, 411 dbg("found hardware: %s, handle: %p\n", info.hardware_id.value,
@@ -449,13 +449,11 @@ static int __init ibm_acpiphp_init(void)
449 } 449 }
450 450
451 ibm_note.device = device; 451 ibm_note.device = device;
452 status = acpi_install_notify_handler( 452 status = acpi_install_notify_handler(ibm_acpi_handle,
453 ibm_acpi_handle, 453 ACPI_DEVICE_NOTIFY, ibm_handle_events,
454 ACPI_DEVICE_NOTIFY,
455 ibm_handle_events,
456 &ibm_note); 454 &ibm_note);
457 if (ACPI_FAILURE(status)) { 455 if (ACPI_FAILURE(status)) {
458 err("%s: Failed to register notification handler\n", 456 err("%s: Failed to register notification handler\n",
459 __FUNCTION__); 457 __FUNCTION__);
460 retval = -EBUSY; 458 retval = -EBUSY;
461 goto init_cleanup; 459 goto init_cleanup;
@@ -482,14 +480,13 @@ static void __exit ibm_acpiphp_exit(void)
482 if (acpiphp_unregister_attention(&ibm_attention_info)) 480 if (acpiphp_unregister_attention(&ibm_attention_info))
483 err("%s: attention info deregistration failed", __FUNCTION__); 481 err("%s: attention info deregistration failed", __FUNCTION__);
484 482
485 status = acpi_remove_notify_handler( 483 status = acpi_remove_notify_handler(
486 ibm_acpi_handle, 484 ibm_acpi_handle,
487 ACPI_DEVICE_NOTIFY, 485 ACPI_DEVICE_NOTIFY,
488 ibm_handle_events); 486 ibm_handle_events);
489 if (ACPI_FAILURE(status)) 487 if (ACPI_FAILURE(status))
490 err("%s: Notification handler removal failed\n", 488 err("%s: Notification handler removal failed\n", __FUNCTION__);
491 __FUNCTION__); 489 /* remove the /sys entries */
492 // remove the /sys entries
493 if (sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr)) 490 if (sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr))
494 err("%s: removal of sysfs file apci_table failed\n", 491 err("%s: removal of sysfs file apci_table failed\n",
495 __FUNCTION__); 492 __FUNCTION__);
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index aabf1e70b528..dc59da675c08 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -235,12 +235,12 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
235{ 235{
236 int rc = 0; 236 int rc = 0;
237 struct slot *pslot; 237 struct slot *pslot;
238 u8 cmd; 238 u8 cmd = 0x00; /* avoid compiler warning */
239 239
240 debug("set_attention_status - Entry hotplug_slot[%lx] value[%x]\n", 240 debug("set_attention_status - Entry hotplug_slot[%lx] value[%x]\n",
241 (ulong) hotplug_slot, value); 241 (ulong) hotplug_slot, value);
242 ibmphp_lock_operations(); 242 ibmphp_lock_operations();
243 cmd = 0x00; // avoid compiler warning 243
244 244
245 if (hotplug_slot) { 245 if (hotplug_slot) {
246 switch (value) { 246 switch (value) {
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index 7d93dbaf628d..3eefe2cec72d 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -103,13 +103,13 @@ static struct slot *find_slot(struct device_node *dn)
103 struct list_head *tmp, *n; 103 struct list_head *tmp, *n;
104 struct slot *slot; 104 struct slot *slot;
105 105
106 list_for_each_safe(tmp, n, &rpaphp_slot_head) { 106 list_for_each_safe(tmp, n, &rpaphp_slot_head) {
107 slot = list_entry(tmp, struct slot, rpaphp_slot_list); 107 slot = list_entry(tmp, struct slot, rpaphp_slot_list);
108 if (slot->dn == dn) 108 if (slot->dn == dn)
109 return slot; 109 return slot;
110 } 110 }
111 111
112 return NULL; 112 return NULL;
113} 113}
114 114
115static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, 115static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent,
@@ -126,9 +126,9 @@ static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent,
126 return NULL; 126 return NULL;
127} 127}
128 128
129static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) 129static void dlpar_pci_add_bus(struct device_node *dn)
130{ 130{
131 struct pci_dn *pdn = dn->data; 131 struct pci_dn *pdn = PCI_DN(dn);
132 struct pci_controller *phb = pdn->phb; 132 struct pci_controller *phb = pdn->phb;
133 struct pci_dev *dev = NULL; 133 struct pci_dev *dev = NULL;
134 134
@@ -139,52 +139,52 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
139 if (!dev) { 139 if (!dev) {
140 printk(KERN_ERR "%s: failed to create pci dev for %s\n", 140 printk(KERN_ERR "%s: failed to create pci dev for %s\n",
141 __FUNCTION__, dn->full_name); 141 __FUNCTION__, dn->full_name);
142 return NULL; 142 return;
143 } 143 }
144 144
145 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || 145 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
146 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) 146 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
147 of_scan_pci_bridge(dn, dev); 147 of_scan_pci_bridge(dn, dev);
148 148
149 rpaphp_init_new_devs(dev->subordinate); 149 pcibios_fixup_new_pci_devices(dev->subordinate,0);
150 150
151 /* Claim new bus resources */ 151 /* Claim new bus resources */
152 pcibios_claim_one_bus(dev->bus); 152 pcibios_claim_one_bus(dev->bus);
153 153
154 /* ioremap() for child bus, which may or may not succeed */ 154 /* ioremap() for child bus, which may or may not succeed */
155 (void) remap_bus_range(dev->bus); 155 remap_bus_range(dev->subordinate);
156 156
157 /* Add new devices to global lists. Register in proc, sysfs. */ 157 /* Add new devices to global lists. Register in proc, sysfs. */
158 pci_bus_add_devices(phb->bus); 158 pci_bus_add_devices(phb->bus);
159
160 /* Confirm new bridge dev was created */
161 dev = dlpar_find_new_dev(phb->bus, dn);
162 if (dev) {
163 if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
164 printk(KERN_ERR "%s: unexpected header type %d\n",
165 __FUNCTION__, dev->hdr_type);
166 return NULL;
167 }
168 }
169
170 return dev;
171} 159}
172 160
173static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) 161static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn)
174{ 162{
175 struct pci_dev *dev; 163 struct pci_dev *dev;
164 struct pci_controller *phb;
176 165
177 if (rpaphp_find_pci_bus(dn)) 166 if (pcibios_find_pci_bus(dn))
178 return -EINVAL; 167 return -EINVAL;
179 168
180 /* Add pci bus */ 169 /* Add pci bus */
181 dev = dlpar_pci_add_bus(dn); 170 dlpar_pci_add_bus(dn);
171
172 /* Confirm new bridge dev was created */
173 phb = PCI_DN(dn)->phb;
174 dev = dlpar_find_new_dev(phb->bus, dn);
175
182 if (!dev) { 176 if (!dev) {
183 printk(KERN_ERR "%s: unable to add bus %s\n", __FUNCTION__, 177 printk(KERN_ERR "%s: unable to add bus %s\n", __FUNCTION__,
184 drc_name); 178 drc_name);
185 return -EIO; 179 return -EIO;
186 } 180 }
187 181
182 if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
183 printk(KERN_ERR "%s: unexpected header type %d, unable to add bus %s\n",
184 __FUNCTION__, dev->hdr_type, drc_name);
185 return -EIO;
186 }
187
188 /* Add hotplug slot */ 188 /* Add hotplug slot */
189 if (rpaphp_add_slot(dn)) { 189 if (rpaphp_add_slot(dn)) {
190 printk(KERN_ERR "%s: unable to add hotplug slot %s\n", 190 printk(KERN_ERR "%s: unable to add hotplug slot %s\n",
@@ -221,13 +221,13 @@ static int dlpar_remove_phb(char *drc_name, struct device_node *dn)
221 struct pci_dn *pdn; 221 struct pci_dn *pdn;
222 int rc = 0; 222 int rc = 0;
223 223
224 if (!rpaphp_find_pci_bus(dn)) 224 if (!pcibios_find_pci_bus(dn))
225 return -EINVAL; 225 return -EINVAL;
226 226
227 slot = find_slot(dn); 227 slot = find_slot(dn);
228 if (slot) { 228 if (slot) {
229 /* Remove hotplug slot */ 229 /* Remove hotplug slot */
230 if (rpaphp_remove_slot(slot)) { 230 if (rpaphp_deregister_slot(slot)) {
231 printk(KERN_ERR 231 printk(KERN_ERR
232 "%s: unable to remove hotplug slot %s\n", 232 "%s: unable to remove hotplug slot %s\n",
233 __FUNCTION__, drc_name); 233 __FUNCTION__, drc_name);
@@ -366,21 +366,25 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
366 struct pci_bus *bus; 366 struct pci_bus *bus;
367 struct slot *slot; 367 struct slot *slot;
368 368
369 bus = rpaphp_find_pci_bus(dn); 369 bus = pcibios_find_pci_bus(dn);
370 if (!bus) 370 if (!bus)
371 return -EINVAL; 371 return -EINVAL;
372 372
373 slot = find_slot(dn); 373 slot = find_slot(dn);
374 if (slot) { 374 if (slot) {
375 /* Remove hotplug slot */ 375 /* Remove hotplug slot */
376 if (rpaphp_remove_slot(slot)) { 376 if (rpaphp_deregister_slot(slot)) {
377 printk(KERN_ERR 377 printk(KERN_ERR
378 "%s: unable to remove hotplug slot %s\n", 378 "%s: unable to remove hotplug slot %s\n",
379 __FUNCTION__, drc_name); 379 __FUNCTION__, drc_name);
380 return -EIO; 380 return -EIO;
381 } 381 }
382 } else { 382 } else {
383 rpaphp_unconfig_pci_adapter(bus); 383 struct pci_dev *dev, *tmp;
384 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
385 eeh_remove_bus_device(dev);
386 pci_remove_bus_device(dev);
387 }
384 } 388 }
385 389
386 if (unmap_bus_range(bus)) { 390 if (unmap_bus_range(bus)) {
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 57ea71a7bda5..310b6186c0e5 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -88,16 +88,10 @@ extern int num_slots;
88/* function prototypes */ 88/* function prototypes */
89 89
90/* rpaphp_pci.c */ 90/* rpaphp_pci.c */
91extern struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn);
92extern int rpaphp_claim_resource(struct pci_dev *dev, int resource);
93extern int rpaphp_enable_pci_slot(struct slot *slot); 91extern int rpaphp_enable_pci_slot(struct slot *slot);
94extern int register_pci_slot(struct slot *slot); 92extern int rpaphp_register_pci_slot(struct slot *slot);
95extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value); 93extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value);
96extern void rpaphp_init_new_devs(struct pci_bus *bus); 94extern int rpaphp_get_sensor_state(struct slot *slot, int *state);
97extern void rpaphp_eeh_init_nodes(struct device_node *dn);
98
99extern int rpaphp_config_pci_adapter(struct pci_bus *bus);
100extern int rpaphp_unconfig_pci_adapter(struct pci_bus *bus);
101 95
102/* rpaphp_core.c */ 96/* rpaphp_core.c */
103extern int rpaphp_add_slot(struct device_node *dn); 97extern int rpaphp_add_slot(struct device_node *dn);
@@ -108,8 +102,8 @@ extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
108/* rpaphp_slot.c */ 102/* rpaphp_slot.c */
109extern void dealloc_slot_struct(struct slot *slot); 103extern void dealloc_slot_struct(struct slot *slot);
110extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain); 104extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain);
111extern int register_slot(struct slot *slot); 105extern int rpaphp_register_slot(struct slot *slot);
112extern int deregister_slot(struct slot *slot); 106extern int rpaphp_deregister_slot(struct slot *slot);
113extern int rpaphp_get_power_status(struct slot *slot, u8 * value); 107extern int rpaphp_get_power_status(struct slot *slot, u8 * value);
114extern int rpaphp_set_attention_status(struct slot *slot, u8 status); 108extern int rpaphp_set_attention_status(struct slot *slot, u8 status);
115 109
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index cf075c34b578..6e79f5675b0d 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -56,25 +56,6 @@ MODULE_LICENSE("GPL");
56 56
57module_param(debug, bool, 0644); 57module_param(debug, bool, 0644);
58 58
59static int enable_slot(struct hotplug_slot *slot);
60static int disable_slot(struct hotplug_slot *slot);
61static int set_attention_status(struct hotplug_slot *slot, u8 value);
62static int get_power_status(struct hotplug_slot *slot, u8 * value);
63static int get_attention_status(struct hotplug_slot *slot, u8 * value);
64static int get_adapter_status(struct hotplug_slot *slot, u8 * value);
65static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value);
66
67struct hotplug_slot_ops rpaphp_hotplug_slot_ops = {
68 .owner = THIS_MODULE,
69 .enable_slot = enable_slot,
70 .disable_slot = disable_slot,
71 .set_attention_status = set_attention_status,
72 .get_power_status = get_power_status,
73 .get_attention_status = get_attention_status,
74 .get_adapter_status = get_adapter_status,
75 .get_max_bus_speed = get_max_bus_speed,
76};
77
78static int rpaphp_get_attention_status(struct slot *slot) 59static int rpaphp_get_attention_status(struct slot *slot)
79{ 60{
80 return slot->hotplug_slot->info->attention_status; 61 return slot->hotplug_slot->info->attention_status;
@@ -196,11 +177,6 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
196 return 0; 177 return 0;
197} 178}
198 179
199int rpaphp_remove_slot(struct slot *slot)
200{
201 return deregister_slot(slot);
202}
203
204static int get_children_props(struct device_node *dn, int **drc_indexes, 180static int get_children_props(struct device_node *dn, int **drc_indexes,
205 int **drc_names, int **drc_types, int **drc_power_domains) 181 int **drc_names, int **drc_types, int **drc_power_domains)
206{ 182{
@@ -307,13 +283,15 @@ static int is_php_dn(struct device_node *dn, int **indexes, int **names,
307 return 0; 283 return 0;
308} 284}
309 285
310/**************************************************************** 286/**
287 * rpaphp_add_slot -- add hotplug or dlpar slot
288 *
311 * rpaphp not only registers PCI hotplug slots(HOTPLUG), 289 * rpaphp not only registers PCI hotplug slots(HOTPLUG),
312 * but also logical DR slots(EMBEDDED). 290 * but also logical DR slots(EMBEDDED).
313 * HOTPLUG slot: An adapter can be physically added/removed. 291 * HOTPLUG slot: An adapter can be physically added/removed.
314 * EMBEDDED slot: An adapter can be logically removed/added 292 * EMBEDDED slot: An adapter can be logically removed/added
315 * from/to a partition with the slot. 293 * from/to a partition with the slot.
316 ***************************************************************/ 294 */
317int rpaphp_add_slot(struct device_node *dn) 295int rpaphp_add_slot(struct device_node *dn)
318{ 296{
319 struct slot *slot; 297 struct slot *slot;
@@ -344,7 +322,7 @@ int rpaphp_add_slot(struct device_node *dn)
344 dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n", 322 dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n",
345 indexes[i + 1], name, type); 323 indexes[i + 1], name, type);
346 324
347 retval = register_pci_slot(slot); 325 retval = rpaphp_register_pci_slot(slot);
348 } 326 }
349 } 327 }
350exit: 328exit:
@@ -393,53 +371,85 @@ static void __exit rpaphp_exit(void)
393 cleanup_slots(); 371 cleanup_slots();
394} 372}
395 373
396static int enable_slot(struct hotplug_slot *hotplug_slot) 374static int __enable_slot(struct slot *slot)
397{ 375{
398 int retval = 0; 376 int state;
399 struct slot *slot = (struct slot *)hotplug_slot->private; 377 int retval;
400 378
401 if (slot->state == CONFIGURED) { 379 if (slot->state == CONFIGURED)
402 dbg("%s: %s is already enabled\n", __FUNCTION__, slot->name); 380 return 0;
403 goto exit; 381
382 retval = rpaphp_get_sensor_state(slot, &state);
383 if (retval)
384 return retval;
385
386 if (state == PRESENT) {
387 pcibios_add_pci_devices(slot->bus);
388 slot->state = CONFIGURED;
389 } else if (state == EMPTY) {
390 slot->state = EMPTY;
391 } else {
392 err("%s: slot[%s] is in invalid state\n", __FUNCTION__, slot->name);
393 slot->state = NOT_VALID;
394 return -EINVAL;
404 } 395 }
396 return 0;
397}
398
399static int enable_slot(struct hotplug_slot *hotplug_slot)
400{
401 int retval;
402 struct slot *slot = (struct slot *)hotplug_slot->private;
405 403
406 dbg("ENABLING SLOT %s\n", slot->name);
407 down(&rpaphp_sem); 404 down(&rpaphp_sem);
408 retval = rpaphp_enable_pci_slot(slot); 405 retval = __enable_slot(slot);
409 up(&rpaphp_sem); 406 up(&rpaphp_sem);
410exit: 407
411 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
412 return retval; 408 return retval;
413} 409}
414 410
415static int disable_slot(struct hotplug_slot *hotplug_slot) 411static int __disable_slot(struct slot *slot)
416{ 412{
417 int retval = -EINVAL; 413 struct pci_dev *dev, *tmp;
418 struct slot *slot = (struct slot *)hotplug_slot->private;
419 414
420 dbg("%s - Entry: slot[%s]\n", __FUNCTION__, slot->name); 415 if (slot->state == NOT_CONFIGURED)
416 return -EINVAL;
421 417
422 if (slot->state == NOT_CONFIGURED) { 418 list_for_each_entry_safe(dev, tmp, &slot->bus->devices, bus_list) {
423 dbg("%s: %s is already disabled\n", __FUNCTION__, slot->name); 419 eeh_remove_bus_device(dev);
424 goto exit; 420 pci_remove_bus_device(dev);
425 } 421 }
426 422
427 dbg("DISABLING SLOT %s\n", slot->name); 423 slot->state = NOT_CONFIGURED;
424 return 0;
425}
426
427static int disable_slot(struct hotplug_slot *hotplug_slot)
428{
429 struct slot *slot = (struct slot *)hotplug_slot->private;
430 int retval;
431
428 down(&rpaphp_sem); 432 down(&rpaphp_sem);
429 retval = rpaphp_unconfig_pci_adapter(slot->bus); 433 retval = __disable_slot (slot);
430 up(&rpaphp_sem); 434 up(&rpaphp_sem);
431 slot->state = NOT_CONFIGURED; 435
432 info("%s: devices in slot[%s] unconfigured.\n", __FUNCTION__,
433 slot->name);
434exit:
435 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
436 return retval; 436 return retval;
437} 437}
438 438
439struct hotplug_slot_ops rpaphp_hotplug_slot_ops = {
440 .owner = THIS_MODULE,
441 .enable_slot = enable_slot,
442 .disable_slot = disable_slot,
443 .set_attention_status = set_attention_status,
444 .get_power_status = get_power_status,
445 .get_attention_status = get_attention_status,
446 .get_adapter_status = get_adapter_status,
447 .get_max_bus_speed = get_max_bus_speed,
448};
449
439module_init(rpaphp_init); 450module_init(rpaphp_init);
440module_exit(rpaphp_exit); 451module_exit(rpaphp_exit);
441 452
442EXPORT_SYMBOL_GPL(rpaphp_add_slot); 453EXPORT_SYMBOL_GPL(rpaphp_add_slot);
443EXPORT_SYMBOL_GPL(rpaphp_remove_slot);
444EXPORT_SYMBOL_GPL(rpaphp_slot_head); 454EXPORT_SYMBOL_GPL(rpaphp_slot_head);
445EXPORT_SYMBOL_GPL(rpaphp_get_drc_props); 455EXPORT_SYMBOL_GPL(rpaphp_get_drc_props);
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 396b54b0c847..6f6cbede5135 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -32,37 +32,7 @@
32#include "../pci.h" /* for pci_add_new_bus */ 32#include "../pci.h" /* for pci_add_new_bus */
33#include "rpaphp.h" 33#include "rpaphp.h"
34 34
35static struct pci_bus *find_bus_among_children(struct pci_bus *bus, 35int rpaphp_get_sensor_state(struct slot *slot, int *state)
36 struct device_node *dn)
37{
38 struct pci_bus *child = NULL;
39 struct list_head *tmp;
40 struct device_node *busdn;
41
42 busdn = pci_bus_to_OF_node(bus);
43 if (busdn == dn)
44 return bus;
45
46 list_for_each(tmp, &bus->children) {
47 child = find_bus_among_children(pci_bus_b(tmp), dn);
48 if (child)
49 break;
50 }
51 return child;
52}
53
54struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn)
55{
56 struct pci_dn *pdn = dn->data;
57
58 if (!pdn || !pdn->phb || !pdn->phb->bus)
59 return NULL;
60
61 return find_bus_among_children(pdn->phb->bus, dn);
62}
63EXPORT_SYMBOL_GPL(rpaphp_find_pci_bus);
64
65static int rpaphp_get_sensor_state(struct slot *slot, int *state)
66{ 36{
67 int rc; 37 int rc;
68 int setlevel; 38 int setlevel;
@@ -120,7 +90,7 @@ int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value)
120 /* config/unconfig adapter */ 90 /* config/unconfig adapter */
121 *value = slot->state; 91 *value = slot->state;
122 } else { 92 } else {
123 bus = rpaphp_find_pci_bus(slot->dn); 93 bus = pcibios_find_pci_bus(slot->dn);
124 if (bus && !list_empty(&bus->devices)) 94 if (bus && !list_empty(&bus->devices))
125 *value = CONFIGURED; 95 *value = CONFIGURED;
126 else 96 else
@@ -131,140 +101,6 @@ exit:
131 return rc; 101 return rc;
132} 102}
133 103
134/* Must be called before pci_bus_add_devices */
135void rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus)
136{
137 struct pci_dev *dev;
138
139 list_for_each_entry(dev, &bus->devices, bus_list) {
140 /*
141 * Skip already-present devices (which are on the
142 * global device list.)
143 */
144 if (list_empty(&dev->global_list)) {
145 int i;
146
147 /* Need to setup IOMMU tables */
148 ppc_md.iommu_dev_setup(dev);
149
150 if(fix_bus)
151 pcibios_fixup_device_resources(dev, bus);
152 pci_read_irq_line(dev);
153 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
154 struct resource *r = &dev->resource[i];
155
156 if (r->parent || !r->start || !r->flags)
157 continue;
158 pci_claim_resource(dev, i);
159 }
160 }
161 }
162}
163
164static void rpaphp_eeh_add_bus_device(struct pci_bus *bus)
165{
166 struct pci_dev *dev;
167
168 list_for_each_entry(dev, &bus->devices, bus_list) {
169 eeh_add_device_late(dev);
170 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
171 struct pci_bus *subbus = dev->subordinate;
172 if (subbus)
173 rpaphp_eeh_add_bus_device (subbus);
174 }
175 }
176}
177
178static int rpaphp_pci_config_bridge(struct pci_dev *dev)
179{
180 u8 sec_busno;
181 struct pci_bus *child_bus;
182 struct pci_dev *child_dev;
183
184 dbg("Enter %s: BRIDGE dev=%s\n", __FUNCTION__, pci_name(dev));
185
186 /* get busno of downstream bus */
187 pci_read_config_byte(dev, PCI_SECONDARY_BUS, &sec_busno);
188
189 /* add to children of PCI bridge dev->bus */
190 child_bus = pci_add_new_bus(dev->bus, dev, sec_busno);
191 if (!child_bus) {
192 err("%s: could not add second bus\n", __FUNCTION__);
193 return -EIO;
194 }
195 sprintf(child_bus->name, "PCI Bus #%02x", child_bus->number);
196 /* do pci_scan_child_bus */
197 pci_scan_child_bus(child_bus);
198
199 list_for_each_entry(child_dev, &child_bus->devices, bus_list) {
200 eeh_add_device_late(child_dev);
201 }
202
203 /* fixup new pci devices without touching bus struct */
204 rpaphp_fixup_new_pci_devices(child_bus, 0);
205
206 /* Make the discovered devices available */
207 pci_bus_add_devices(child_bus);
208 return 0;
209}
210
211void rpaphp_init_new_devs(struct pci_bus *bus)
212{
213 rpaphp_fixup_new_pci_devices(bus, 0);
214 rpaphp_eeh_add_bus_device(bus);
215}
216EXPORT_SYMBOL_GPL(rpaphp_init_new_devs);
217
218/*****************************************************************************
219 rpaphp_pci_config_slot() will configure all devices under the
220 given slot->dn and return the the first pci_dev.
221 *****************************************************************************/
222static struct pci_dev *
223rpaphp_pci_config_slot(struct pci_bus *bus)
224{
225 struct device_node *dn = pci_bus_to_OF_node(bus);
226 struct pci_dev *dev = NULL;
227 int slotno;
228 int num;
229
230 dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name);
231 if (!dn || !dn->child)
232 return NULL;
233
234 if (_machine == PLATFORM_PSERIES_LPAR) {
235 of_scan_bus(dn, bus);
236 if (list_empty(&bus->devices)) {
237 err("%s: No new device found\n", __FUNCTION__);
238 return NULL;
239 }
240
241 rpaphp_init_new_devs(bus);
242 pci_bus_add_devices(bus);
243 dev = list_entry(&bus->devices, struct pci_dev, bus_list);
244 } else {
245 slotno = PCI_SLOT(PCI_DN(dn->child)->devfn);
246
247 /* pci_scan_slot should find all children */
248 num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0));
249 if (num) {
250 rpaphp_fixup_new_pci_devices(bus, 1);
251 pci_bus_add_devices(bus);
252 }
253 if (list_empty(&bus->devices)) {
254 err("%s: No new device found\n", __FUNCTION__);
255 return NULL;
256 }
257 list_for_each_entry(dev, &bus->devices, bus_list) {
258 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)
259 rpaphp_pci_config_bridge(dev);
260
261 rpaphp_eeh_add_bus_device(bus);
262 }
263 }
264
265 return dev;
266}
267
268static void print_slot_pci_funcs(struct pci_bus *bus) 104static void print_slot_pci_funcs(struct pci_bus *bus)
269{ 105{
270 struct device_node *dn; 106 struct device_node *dn;
@@ -280,60 +116,6 @@ static void print_slot_pci_funcs(struct pci_bus *bus)
280 return; 116 return;
281} 117}
282 118
283int rpaphp_config_pci_adapter(struct pci_bus *bus)
284{
285 struct device_node *dn = pci_bus_to_OF_node(bus);
286 struct pci_dev *dev;
287 int rc = -ENODEV;
288
289 dbg("Entry %s: slot[%s]\n", __FUNCTION__, dn->full_name);
290 if (!dn)
291 goto exit;
292
293 eeh_add_device_tree_early(dn);
294 dev = rpaphp_pci_config_slot(bus);
295 if (!dev) {
296 err("%s: can't find any devices.\n", __FUNCTION__);
297 goto exit;
298 }
299 print_slot_pci_funcs(bus);
300 rc = 0;
301exit:
302 dbg("Exit %s: rc=%d\n", __FUNCTION__, rc);
303 return rc;
304}
305EXPORT_SYMBOL_GPL(rpaphp_config_pci_adapter);
306
307static void rpaphp_eeh_remove_bus_device(struct pci_dev *dev)
308{
309 eeh_remove_device(dev);
310 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
311 struct pci_bus *bus = dev->subordinate;
312 struct list_head *ln;
313 if (!bus)
314 return;
315 for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
316 struct pci_dev *pdev = pci_dev_b(ln);
317 if (pdev)
318 rpaphp_eeh_remove_bus_device(pdev);
319 }
320
321 }
322 return;
323}
324
325int rpaphp_unconfig_pci_adapter(struct pci_bus *bus)
326{
327 struct pci_dev *dev, *tmp;
328
329 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
330 rpaphp_eeh_remove_bus_device(dev);
331 pci_remove_bus_device(dev);
332 }
333 return 0;
334}
335EXPORT_SYMBOL_GPL(rpaphp_unconfig_pci_adapter);
336
337static int setup_pci_hotplug_slot_info(struct slot *slot) 119static int setup_pci_hotplug_slot_info(struct slot *slot)
338{ 120{
339 struct hotplug_slot_info *hotplug_slot_info = slot->hotplug_slot->info; 121 struct hotplug_slot_info *hotplug_slot_info = slot->hotplug_slot->info;
@@ -370,7 +152,7 @@ static int setup_pci_slot(struct slot *slot)
370 struct pci_bus *bus; 152 struct pci_bus *bus;
371 153
372 BUG_ON(!dn); 154 BUG_ON(!dn);
373 bus = rpaphp_find_pci_bus(dn); 155 bus = pcibios_find_pci_bus(dn);
374 if (!bus) { 156 if (!bus) {
375 err("%s: no pci_bus for dn %s\n", __FUNCTION__, dn->full_name); 157 err("%s: no pci_bus for dn %s\n", __FUNCTION__, dn->full_name);
376 goto exit_rc; 158 goto exit_rc;
@@ -395,10 +177,7 @@ static int setup_pci_slot(struct slot *slot)
395 if (slot->hotplug_slot->info->adapter_status == NOT_CONFIGURED) { 177 if (slot->hotplug_slot->info->adapter_status == NOT_CONFIGURED) {
396 dbg("%s CONFIGURING pci adapter in slot[%s]\n", 178 dbg("%s CONFIGURING pci adapter in slot[%s]\n",
397 __FUNCTION__, slot->name); 179 __FUNCTION__, slot->name);
398 if (rpaphp_config_pci_adapter(slot->bus)) { 180 pcibios_add_pci_devices(slot->bus);
399 err("%s: CONFIG pci adapter failed\n", __FUNCTION__);
400 goto exit_rc;
401 }
402 181
403 } else if (slot->hotplug_slot->info->adapter_status != CONFIGURED) { 182 } else if (slot->hotplug_slot->info->adapter_status != CONFIGURED) {
404 err("%s: slot[%s]'s adapter_status is NOT_VALID.\n", 183 err("%s: slot[%s]'s adapter_status is NOT_VALID.\n",
@@ -420,7 +199,7 @@ exit_rc:
420 return -EINVAL; 199 return -EINVAL;
421} 200}
422 201
423int register_pci_slot(struct slot *slot) 202int rpaphp_register_pci_slot(struct slot *slot)
424{ 203{
425 int rc = -EINVAL; 204 int rc = -EINVAL;
426 205
@@ -428,42 +207,8 @@ int register_pci_slot(struct slot *slot)
428 goto exit_rc; 207 goto exit_rc;
429 if (setup_pci_slot(slot)) 208 if (setup_pci_slot(slot))
430 goto exit_rc; 209 goto exit_rc;
431 rc = register_slot(slot); 210 rc = rpaphp_register_slot(slot);
432exit_rc: 211exit_rc:
433 return rc; 212 return rc;
434} 213}
435 214
436int rpaphp_enable_pci_slot(struct slot *slot)
437{
438 int retval = 0, state;
439
440 retval = rpaphp_get_sensor_state(slot, &state);
441 if (retval)
442 goto exit;
443 dbg("%s: sensor state[%d]\n", __FUNCTION__, state);
444 /* if slot is not empty, enable the adapter */
445 if (state == PRESENT) {
446 dbg("%s : slot[%s] is occupied.\n", __FUNCTION__, slot->name);
447 retval = rpaphp_config_pci_adapter(slot->bus);
448 if (!retval) {
449 slot->state = CONFIGURED;
450 info("%s: devices in slot[%s] configured\n",
451 __FUNCTION__, slot->name);
452 } else {
453 slot->state = NOT_CONFIGURED;
454 dbg("%s: no pci_dev struct for adapter in slot[%s]\n",
455 __FUNCTION__, slot->name);
456 }
457 } else if (state == EMPTY) {
458 dbg("%s : slot[%s] is empty\n", __FUNCTION__, slot->name);
459 slot->state = EMPTY;
460 } else {
461 err("%s: slot[%s] is in invalid state\n", __FUNCTION__,
462 slot->name);
463 slot->state = NOT_VALID;
464 retval = -EINVAL;
465 }
466exit:
467 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
468 return retval;
469}
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index daa89ae57123..78943e064b59 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -35,16 +35,16 @@
35 35
36static ssize_t location_read_file (struct hotplug_slot *php_slot, char *buf) 36static ssize_t location_read_file (struct hotplug_slot *php_slot, char *buf)
37{ 37{
38 char *value; 38 char *value;
39 int retval = -ENOENT; 39 int retval = -ENOENT;
40 struct slot *slot = (struct slot *)php_slot->private; 40 struct slot *slot = (struct slot *)php_slot->private;
41 41
42 if (!slot) 42 if (!slot)
43 return retval; 43 return retval;
44 44
45 value = slot->location; 45 value = slot->location;
46 retval = sprintf (buf, "%s\n", value); 46 retval = sprintf (buf, "%s\n", value);
47 return retval; 47 return retval;
48} 48}
49 49
50static struct hotplug_slot_attribute hotplug_slot_attr_location = { 50static struct hotplug_slot_attribute hotplug_slot_attr_location = {
@@ -137,7 +137,7 @@ static int is_registered(struct slot *slot)
137 return 0; 137 return 0;
138} 138}
139 139
140int deregister_slot(struct slot *slot) 140int rpaphp_deregister_slot(struct slot *slot)
141{ 141{
142 int retval = 0; 142 int retval = 0;
143 struct hotplug_slot *php_slot = slot->hotplug_slot; 143 struct hotplug_slot *php_slot = slot->hotplug_slot;
@@ -159,8 +159,9 @@ int deregister_slot(struct slot *slot)
159 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); 159 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
160 return retval; 160 return retval;
161} 161}
162EXPORT_SYMBOL_GPL(rpaphp_deregister_slot);
162 163
163int register_slot(struct slot *slot) 164int rpaphp_register_slot(struct slot *slot)
164{ 165{
165 int retval; 166 int retval;
166 167
@@ -169,7 +170,7 @@ int register_slot(struct slot *slot)
169 slot->power_domain, slot->type); 170 slot->power_domain, slot->type);
170 /* should not try to register the same slot twice */ 171 /* should not try to register the same slot twice */
171 if (is_registered(slot)) { /* should't be here */ 172 if (is_registered(slot)) { /* should't be here */
172 err("register_slot: slot[%s] is already registered\n", slot->name); 173 err("rpaphp_register_slot: slot[%s] is already registered\n", slot->name);
173 rpaphp_release_slot(slot->hotplug_slot); 174 rpaphp_release_slot(slot->hotplug_slot);
174 return -EAGAIN; 175 return -EAGAIN;
175 } 176 }
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index ce0e9b6ce833..7d6f521d02ea 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -95,6 +95,7 @@ struct controller {
95 u8 function; 95 u8 function;
96 u8 slot_device_offset; 96 u8 slot_device_offset;
97 u8 add_support; 97 u8 add_support;
98 u32 pcix_misc2_reg; /* for amd pogo errata */
98 enum pci_bus_speed speed; 99 enum pci_bus_speed speed;
99 u32 first_slot; /* First physical slot number */ 100 u32 first_slot; /* First physical slot number */
100 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 101 u8 slot_bus; /* Bus where the slots handled by this controller sit */
@@ -113,6 +114,26 @@ struct hotplug_params {
113 114
114/* Define AMD SHPC ID */ 115/* Define AMD SHPC ID */
115#define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450 116#define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450
117#define PCI_DEVICE_ID_AMD_POGO_7458 0x7458
118
119/* AMD PCIX bridge registers */
120
121#define PCIX_MEM_BASE_LIMIT_OFFSET 0x1C
122#define PCIX_MISCII_OFFSET 0x48
123#define PCIX_MISC_BRIDGE_ERRORS_OFFSET 0x80
124
125/* AMD PCIX_MISCII masks and offsets */
126#define PERRNONFATALENABLE_MASK 0x00040000
127#define PERRFATALENABLE_MASK 0x00080000
128#define PERRFLOODENABLE_MASK 0x00100000
129#define SERRNONFATALENABLE_MASK 0x00200000
130#define SERRFATALENABLE_MASK 0x00400000
131
132/* AMD PCIX_MISC_BRIDGE_ERRORS masks and offsets */
133#define PERR_OBSERVED_MASK 0x00000001
134
135/* AMD PCIX_MEM_BASE_LIMIT masks */
136#define RSE_MASK 0x40000000
116 137
117#define INT_BUTTON_IGNORE 0 138#define INT_BUTTON_IGNORE 0
118#define INT_PRESENCE_ON 1 139#define INT_PRESENCE_ON 1
@@ -333,6 +354,79 @@ static inline int wait_for_ctrl_irq (struct controller *ctrl)
333 return retval; 354 return retval;
334} 355}
335 356
357static inline void amd_pogo_errata_save_misc_reg(struct slot *p_slot)
358{
359 u32 pcix_misc2_temp;
360
361 /* save MiscII register */
362 pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, &pcix_misc2_temp);
363
364 p_slot->ctrl->pcix_misc2_reg = pcix_misc2_temp;
365
366 /* clear SERR/PERR enable bits */
367 pcix_misc2_temp &= ~SERRFATALENABLE_MASK;
368 pcix_misc2_temp &= ~SERRNONFATALENABLE_MASK;
369 pcix_misc2_temp &= ~PERRFLOODENABLE_MASK;
370 pcix_misc2_temp &= ~PERRFATALENABLE_MASK;
371 pcix_misc2_temp &= ~PERRNONFATALENABLE_MASK;
372 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp);
373}
374
375static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot)
376{
377 u32 pcix_misc2_temp;
378 u32 pcix_bridge_errors_reg;
379 u32 pcix_mem_base_reg;
380 u8 perr_set;
381 u8 rse_set;
382
383 /* write-one-to-clear Bridge_Errors[ PERR_OBSERVED ] */
384 pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, &pcix_bridge_errors_reg);
385 perr_set = pcix_bridge_errors_reg & PERR_OBSERVED_MASK;
386 if (perr_set) {
387 dbg ("%s W1C: Bridge_Errors[ PERR_OBSERVED = %08X]\n",__FUNCTION__ , perr_set);
388
389 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, perr_set);
390 }
391
392 /* write-one-to-clear Memory_Base_Limit[ RSE ] */
393 pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, &pcix_mem_base_reg);
394 rse_set = pcix_mem_base_reg & RSE_MASK;
395 if (rse_set) {
396 dbg ("%s W1C: Memory_Base_Limit[ RSE ]\n",__FUNCTION__ );
397
398 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set);
399 }
400 /* restore MiscII register */
401 pci_read_config_dword( p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, &pcix_misc2_temp );
402
403 if (p_slot->ctrl->pcix_misc2_reg & SERRFATALENABLE_MASK)
404 pcix_misc2_temp |= SERRFATALENABLE_MASK;
405 else
406 pcix_misc2_temp &= ~SERRFATALENABLE_MASK;
407
408 if (p_slot->ctrl->pcix_misc2_reg & SERRNONFATALENABLE_MASK)
409 pcix_misc2_temp |= SERRNONFATALENABLE_MASK;
410 else
411 pcix_misc2_temp &= ~SERRNONFATALENABLE_MASK;
412
413 if (p_slot->ctrl->pcix_misc2_reg & PERRFLOODENABLE_MASK)
414 pcix_misc2_temp |= PERRFLOODENABLE_MASK;
415 else
416 pcix_misc2_temp &= ~PERRFLOODENABLE_MASK;
417
418 if (p_slot->ctrl->pcix_misc2_reg & PERRFATALENABLE_MASK)
419 pcix_misc2_temp |= PERRFATALENABLE_MASK;
420 else
421 pcix_misc2_temp &= ~PERRFATALENABLE_MASK;
422
423 if (p_slot->ctrl->pcix_misc2_reg & PERRNONFATALENABLE_MASK)
424 pcix_misc2_temp |= PERRNONFATALENABLE_MASK;
425 else
426 pcix_misc2_temp &= ~PERRNONFATALENABLE_MASK;
427 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp);
428}
429
336#define SLOT_NAME_SIZE 10 430#define SLOT_NAME_SIZE 10
337 431
338static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) 432static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 25ccb0e47593..643252d9bf3b 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -894,7 +894,17 @@ int shpchp_enable_slot (struct slot *p_slot)
894 dbg("%s: p_slot->pwr_save %x\n", __FUNCTION__, p_slot->pwr_save); 894 dbg("%s: p_slot->pwr_save %x\n", __FUNCTION__, p_slot->pwr_save);
895 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 895 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
896 896
897 rc = board_added(p_slot); 897 if(((p_slot->ctrl->pci_dev->vendor == PCI_VENDOR_ID_AMD) ||
898 (p_slot->ctrl->pci_dev->device == PCI_DEVICE_ID_AMD_POGO_7458))
899 && p_slot->ctrl->num_slots == 1) {
900 /* handle amd pogo errata; this must be done before enable */
901 amd_pogo_errata_save_misc_reg(p_slot);
902 rc = board_added(p_slot);
903 /* handle amd pogo errata; this must be done after enable */
904 amd_pogo_errata_restore_misc_reg(p_slot);
905 } else
906 rc = board_added(p_slot);
907
898 if (rc) { 908 if (rc) {
899 p_slot->hpc_ops->get_adapter_status(p_slot, 909 p_slot->hpc_ops->get_adapter_status(p_slot,
900 &(p_slot->presence_save)); 910 &(p_slot->presence_save));
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 202b7507a357..48723d6fa60f 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -137,6 +137,8 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask)
137 break; 137 break;
138 } 138 }
139} 139}
140#else
141#define set_msi_affinity NULL
140#endif /* CONFIG_SMP */ 142#endif /* CONFIG_SMP */
141 143
142static void mask_MSI_irq(unsigned int vector) 144static void mask_MSI_irq(unsigned int vector)
@@ -214,7 +216,7 @@ static struct hw_interrupt_type msix_irq_type = {
214 .disable = mask_MSI_irq, 216 .disable = mask_MSI_irq,
215 .ack = mask_MSI_irq, 217 .ack = mask_MSI_irq,
216 .end = end_msi_irq_w_maskbit, 218 .end = end_msi_irq_w_maskbit,
217 .set_affinity = set_msi_irq_affinity 219 .set_affinity = set_msi_affinity
218}; 220};
219 221
220/* 222/*
@@ -230,7 +232,7 @@ static struct hw_interrupt_type msi_irq_w_maskbit_type = {
230 .disable = mask_MSI_irq, 232 .disable = mask_MSI_irq,
231 .ack = mask_MSI_irq, 233 .ack = mask_MSI_irq,
232 .end = end_msi_irq_w_maskbit, 234 .end = end_msi_irq_w_maskbit,
233 .set_affinity = set_msi_irq_affinity 235 .set_affinity = set_msi_affinity
234}; 236};
235 237
236/* 238/*
@@ -246,7 +248,7 @@ static struct hw_interrupt_type msi_irq_wo_maskbit_type = {
246 .disable = do_nothing, 248 .disable = do_nothing,
247 .ack = do_nothing, 249 .ack = do_nothing,
248 .end = end_msi_irq_wo_maskbit, 250 .end = end_msi_irq_wo_maskbit,
249 .set_affinity = set_msi_irq_affinity 251 .set_affinity = set_msi_affinity
250}; 252};
251 253
252static void msi_data_init(struct msg_data *msi_data, 254static void msi_data_init(struct msg_data *msi_data,
@@ -416,7 +418,9 @@ static void attach_msi_entry(struct msi_desc *entry, int vector)
416 418
417static void irq_handler_init(int cap_id, int pos, int mask) 419static void irq_handler_init(int cap_id, int pos, int mask)
418{ 420{
419 spin_lock(&irq_desc[pos].lock); 421 unsigned long flags;
422
423 spin_lock_irqsave(&irq_desc[pos].lock, flags);
420 if (cap_id == PCI_CAP_ID_MSIX) 424 if (cap_id == PCI_CAP_ID_MSIX)
421 irq_desc[pos].handler = &msix_irq_type; 425 irq_desc[pos].handler = &msix_irq_type;
422 else { 426 else {
@@ -425,7 +429,7 @@ static void irq_handler_init(int cap_id, int pos, int mask)
425 else 429 else
426 irq_desc[pos].handler = &msi_irq_w_maskbit_type; 430 irq_desc[pos].handler = &msi_irq_w_maskbit_type;
427 } 431 }
428 spin_unlock(&irq_desc[pos].lock); 432 spin_unlock_irqrestore(&irq_desc[pos].lock, flags);
429} 433}
430 434
431static void enable_msi_mode(struct pci_dev *dev, int pos, int type) 435static void enable_msi_mode(struct pci_dev *dev, int pos, int type)
diff --git a/drivers/pci/msi.h b/drivers/pci/msi.h
index 402136a5c9e4..4ac52d441e47 100644
--- a/drivers/pci/msi.h
+++ b/drivers/pci/msi.h
@@ -22,12 +22,6 @@ extern int vector_irq[NR_VECTORS];
22extern void (*interrupt[NR_IRQS])(void); 22extern void (*interrupt[NR_IRQS])(void);
23extern int pci_vector_resources(int last, int nr_released); 23extern int pci_vector_resources(int last, int nr_released);
24 24
25#ifdef CONFIG_SMP
26#define set_msi_irq_affinity set_msi_affinity
27#else
28#define set_msi_irq_affinity NULL
29#endif
30
31/* 25/*
32 * MSI-X Address Register 26 * MSI-X Address Register
33 */ 27 */
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d2a633efa10a..d2d187916643 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -163,6 +163,7 @@ int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
163 return __pci_bus_find_cap(bus, devfn, hdr_type & 0x7f, cap); 163 return __pci_bus_find_cap(bus, devfn, hdr_type & 0x7f, cap);
164} 164}
165 165
166#if 0
166/** 167/**
167 * pci_find_ext_capability - Find an extended capability 168 * pci_find_ext_capability - Find an extended capability
168 * @dev: PCI device to query 169 * @dev: PCI device to query
@@ -210,6 +211,7 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap)
210 211
211 return 0; 212 return 0;
212} 213}
214#endif /* 0 */
213 215
214/** 216/**
215 * pci_find_parent_resource - return resource region of parent bus of given region 217 * pci_find_parent_resource - return resource region of parent bus of given region
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 50d6685dcbcc..ea9277b7f899 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -112,6 +112,7 @@ pci_claim_resource(struct pci_dev *dev, int resource)
112 112
113 return err; 113 return err;
114} 114}
115EXPORT_SYMBOL_GPL(pci_claim_resource);
115 116
116int pci_assign_resource(struct pci_dev *dev, int resno) 117int pci_assign_resource(struct pci_dev *dev, int resno)
117{ 118{
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 0ecbe4edbec1..aaa568a3806e 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -363,7 +363,7 @@ static int card_resume(struct pnp_dev *dev)
363 363
364int pnp_register_card_driver(struct pnp_card_driver * drv) 364int pnp_register_card_driver(struct pnp_card_driver * drv)
365{ 365{
366 int count = 0; 366 int count;
367 struct list_head *pos, *temp; 367 struct list_head *pos, *temp;
368 368
369 drv->link.name = drv->name; 369 drv->link.name = drv->name;
@@ -374,10 +374,15 @@ int pnp_register_card_driver(struct pnp_card_driver * drv)
374 drv->link.suspend = drv->suspend ? card_suspend : NULL; 374 drv->link.suspend = drv->suspend ? card_suspend : NULL;
375 drv->link.resume = drv->resume ? card_resume : NULL; 375 drv->link.resume = drv->resume ? card_resume : NULL;
376 376
377 count = pnp_register_driver(&drv->link);
378 if (count < 0)
379 return count;
380
377 spin_lock(&pnp_lock); 381 spin_lock(&pnp_lock);
378 list_add_tail(&drv->global_list, &pnp_card_drivers); 382 list_add_tail(&drv->global_list, &pnp_card_drivers);
379 spin_unlock(&pnp_lock); 383 spin_unlock(&pnp_lock);
380 pnp_register_driver(&drv->link); 384
385 count = 0;
381 386
382 list_for_each_safe(pos,temp,&pnp_cards){ 387 list_for_each_safe(pos,temp,&pnp_cards){
383 struct pnp_card *card = list_entry(pos, struct pnp_card, global_list); 388 struct pnp_card *card = list_entry(pos, struct pnp_card, global_list);
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 816479ad217b..f104577f73e0 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -27,12 +27,15 @@
27 27
28static int num = 0; 28static int num = 0;
29 29
30/* We need only to blacklist devices that have already an acpi driver that
31 * can't use pnp layer. We don't need to blacklist device that are directly
32 * used by the kernel (PCI root, ...), as it is harmless and there were
33 * already present in pnpbios. But there is an exception for devices that
34 * have irqs (PIC, Timer) because we call acpi_register_gsi.
35 * Finaly only devices that have a CRS method need to be in this list.
36 */
30static char __initdata excluded_id_list[] = 37static char __initdata excluded_id_list[] =
31 "PNP0C0A," /* Battery */
32 "PNP0C0C,PNP0C0E,PNP0C0D," /* Button */
33 "PNP0C09," /* EC */ 38 "PNP0C09," /* EC */
34 "PNP0C0B," /* Fan */
35 "PNP0A03," /* PCI root */
36 "PNP0C0F," /* Link device */ 39 "PNP0C0F," /* Link device */
37 "PNP0000," /* PIC */ 40 "PNP0000," /* PIC */
38 "PNP0100," /* Timer */ 41 "PNP0100," /* Timer */
@@ -131,7 +134,8 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
131 struct pnp_id *dev_id; 134 struct pnp_id *dev_id;
132 struct pnp_dev *dev; 135 struct pnp_dev *dev;
133 136
134 if (!ispnpidacpi(acpi_device_hid(device)) || 137 status = acpi_get_handle(device->handle, "_CRS", &temp);
138 if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) ||
135 is_exclusive_device(device)) 139 is_exclusive_device(device))
136 return 0; 140 return 0;
137 141
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 416d30debe6c..407b4eaddcbf 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr> 4 * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr>
5 * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com> 5 * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the 8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any 9 * Free Software Foundation; either version 2, or (at your option) any
@@ -32,17 +32,17 @@
32/* 32/*
33 * Allocated Resources 33 * Allocated Resources
34 */ 34 */
35static int irq_flags(int edge_level, int active_high_low) 35static int irq_flags(int triggering, int polarity)
36{ 36{
37 int flag; 37 int flag;
38 if (edge_level == ACPI_LEVEL_SENSITIVE) { 38 if (triggering == ACPI_LEVEL_SENSITIVE) {
39 if(active_high_low == ACPI_ACTIVE_LOW) 39 if(polarity == ACPI_ACTIVE_LOW)
40 flag = IORESOURCE_IRQ_LOWLEVEL; 40 flag = IORESOURCE_IRQ_LOWLEVEL;
41 else 41 else
42 flag = IORESOURCE_IRQ_HIGHLEVEL; 42 flag = IORESOURCE_IRQ_HIGHLEVEL;
43 } 43 }
44 else { 44 else {
45 if(active_high_low == ACPI_ACTIVE_LOW) 45 if(polarity == ACPI_ACTIVE_LOW)
46 flag = IORESOURCE_IRQ_LOWEDGE; 46 flag = IORESOURCE_IRQ_LOWEDGE;
47 else 47 else
48 flag = IORESOURCE_IRQ_HIGHEDGE; 48 flag = IORESOURCE_IRQ_HIGHEDGE;
@@ -50,31 +50,31 @@ static int irq_flags(int edge_level, int active_high_low)
50 return flag; 50 return flag;
51} 51}
52 52
53static void decode_irq_flags(int flag, int *edge_level, int *active_high_low) 53static void decode_irq_flags(int flag, int *triggering, int *polarity)
54{ 54{
55 switch (flag) { 55 switch (flag) {
56 case IORESOURCE_IRQ_LOWLEVEL: 56 case IORESOURCE_IRQ_LOWLEVEL:
57 *edge_level = ACPI_LEVEL_SENSITIVE; 57 *triggering = ACPI_LEVEL_SENSITIVE;
58 *active_high_low = ACPI_ACTIVE_LOW; 58 *polarity = ACPI_ACTIVE_LOW;
59 break; 59 break;
60 case IORESOURCE_IRQ_HIGHLEVEL: 60 case IORESOURCE_IRQ_HIGHLEVEL:
61 *edge_level = ACPI_LEVEL_SENSITIVE; 61 *triggering = ACPI_LEVEL_SENSITIVE;
62 *active_high_low = ACPI_ACTIVE_HIGH; 62 *polarity = ACPI_ACTIVE_HIGH;
63 break; 63 break;
64 case IORESOURCE_IRQ_LOWEDGE: 64 case IORESOURCE_IRQ_LOWEDGE:
65 *edge_level = ACPI_EDGE_SENSITIVE; 65 *triggering = ACPI_EDGE_SENSITIVE;
66 *active_high_low = ACPI_ACTIVE_LOW; 66 *polarity = ACPI_ACTIVE_LOW;
67 break; 67 break;
68 case IORESOURCE_IRQ_HIGHEDGE: 68 case IORESOURCE_IRQ_HIGHEDGE:
69 *edge_level = ACPI_EDGE_SENSITIVE; 69 *triggering = ACPI_EDGE_SENSITIVE;
70 *active_high_low = ACPI_ACTIVE_HIGH; 70 *polarity = ACPI_ACTIVE_HIGH;
71 break; 71 break;
72 } 72 }
73} 73}
74 74
75static void 75static void
76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi, 76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi,
77 int edge_level, int active_high_low) 77 int triggering, int polarity)
78{ 78{
79 int i = 0; 79 int i = 0;
80 int irq; 80 int irq;
@@ -89,7 +89,7 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi,
89 return; 89 return;
90 90
91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
92 irq = acpi_register_gsi(gsi, edge_level, active_high_low); 92 irq = acpi_register_gsi(gsi, triggering, polarity);
93 if (irq < 0) { 93 if (irq < 0) {
94 res->irq_resource[i].flags |= IORESOURCE_DISABLED; 94 res->irq_resource[i].flags |= IORESOURCE_DISABLED;
95 return; 95 return;
@@ -163,77 +163,96 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
163 struct pnp_resource_table * res_table = (struct pnp_resource_table *)data; 163 struct pnp_resource_table * res_table = (struct pnp_resource_table *)data;
164 int i; 164 int i;
165 165
166 switch (res->id) { 166 switch (res->type) {
167 case ACPI_RSTYPE_IRQ: 167 case ACPI_RESOURCE_TYPE_IRQ:
168 /* 168 /*
169 * Per spec, only one interrupt per descriptor is allowed in 169 * Per spec, only one interrupt per descriptor is allowed in
170 * _CRS, but some firmware violates this, so parse them all. 170 * _CRS, but some firmware violates this, so parse them all.
171 */ 171 */
172 for (i = 0; i < res->data.irq.number_of_interrupts; i++) { 172 for (i = 0; i < res->data.irq.interrupt_count; i++) {
173 pnpacpi_parse_allocated_irqresource(res_table, 173 pnpacpi_parse_allocated_irqresource(res_table,
174 res->data.irq.interrupts[i], 174 res->data.irq.interrupts[i],
175 res->data.irq.edge_level, 175 res->data.irq.triggering,
176 res->data.irq.active_high_low); 176 res->data.irq.polarity);
177 } 177 }
178 break; 178 break;
179 179
180 case ACPI_RSTYPE_EXT_IRQ: 180 case ACPI_RESOURCE_TYPE_DMA:
181 for (i = 0; i < res->data.extended_irq.number_of_interrupts; i++) { 181 if (res->data.dma.channel_count > 0)
182 pnpacpi_parse_allocated_irqresource(res_table, 182 pnpacpi_parse_allocated_dmaresource(res_table,
183 res->data.extended_irq.interrupts[i],
184 res->data.extended_irq.edge_level,
185 res->data.extended_irq.active_high_low);
186 }
187 break;
188 case ACPI_RSTYPE_DMA:
189 if (res->data.dma.number_of_channels > 0)
190 pnpacpi_parse_allocated_dmaresource(res_table,
191 res->data.dma.channels[0]); 183 res->data.dma.channels[0]);
192 break; 184 break;
193 case ACPI_RSTYPE_IO: 185
194 pnpacpi_parse_allocated_ioresource(res_table, 186 case ACPI_RESOURCE_TYPE_IO:
195 res->data.io.min_base_address, 187 pnpacpi_parse_allocated_ioresource(res_table,
196 res->data.io.range_length); 188 res->data.io.minimum,
189 res->data.io.address_length);
197 break; 190 break;
198 case ACPI_RSTYPE_FIXED_IO: 191
199 pnpacpi_parse_allocated_ioresource(res_table, 192 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
200 res->data.fixed_io.base_address, 193 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
201 res->data.fixed_io.range_length);
202 break; 194 break;
203 case ACPI_RSTYPE_MEM24: 195
204 pnpacpi_parse_allocated_memresource(res_table, 196 case ACPI_RESOURCE_TYPE_FIXED_IO:
205 res->data.memory24.min_base_address, 197 pnpacpi_parse_allocated_ioresource(res_table,
206 res->data.memory24.range_length); 198 res->data.fixed_io.address,
199 res->data.fixed_io.address_length);
200 break;
201
202 case ACPI_RESOURCE_TYPE_VENDOR:
207 break; 203 break;
208 case ACPI_RSTYPE_MEM32: 204
209 pnpacpi_parse_allocated_memresource(res_table, 205 case ACPI_RESOURCE_TYPE_END_TAG:
210 res->data.memory32.min_base_address, 206 break;
211 res->data.memory32.range_length); 207
208 case ACPI_RESOURCE_TYPE_MEMORY24:
209 pnpacpi_parse_allocated_memresource(res_table,
210 res->data.memory24.minimum,
211 res->data.memory24.address_length);
212 break; 212 break;
213 case ACPI_RSTYPE_FIXED_MEM32: 213 case ACPI_RESOURCE_TYPE_MEMORY32:
214 pnpacpi_parse_allocated_memresource(res_table, 214 pnpacpi_parse_allocated_memresource(res_table,
215 res->data.fixed_memory32.range_base_address, 215 res->data.memory32.minimum,
216 res->data.fixed_memory32.range_length); 216 res->data.memory32.address_length);
217 break; 217 break;
218 case ACPI_RSTYPE_ADDRESS16: 218 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
219 pnpacpi_parse_allocated_memresource(res_table, 219 pnpacpi_parse_allocated_memresource(res_table,
220 res->data.address16.min_address_range, 220 res->data.fixed_memory32.address,
221 res->data.fixed_memory32.address_length);
222 break;
223 case ACPI_RESOURCE_TYPE_ADDRESS16:
224 pnpacpi_parse_allocated_memresource(res_table,
225 res->data.address16.minimum,
221 res->data.address16.address_length); 226 res->data.address16.address_length);
222 break; 227 break;
223 case ACPI_RSTYPE_ADDRESS32: 228 case ACPI_RESOURCE_TYPE_ADDRESS32:
224 pnpacpi_parse_allocated_memresource(res_table, 229 pnpacpi_parse_allocated_memresource(res_table,
225 res->data.address32.min_address_range, 230 res->data.address32.minimum,
226 res->data.address32.address_length); 231 res->data.address32.address_length);
227 break; 232 break;
228 case ACPI_RSTYPE_ADDRESS64: 233 case ACPI_RESOURCE_TYPE_ADDRESS64:
229 pnpacpi_parse_allocated_memresource(res_table, 234 pnpacpi_parse_allocated_memresource(res_table,
230 res->data.address64.min_address_range, 235 res->data.address64.minimum,
231 res->data.address64.address_length); 236 res->data.address64.address_length);
232 break; 237 break;
233 case ACPI_RSTYPE_VENDOR: 238
239 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
240 break;
241
242 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
243 for (i = 0; i < res->data.extended_irq.interrupt_count; i++) {
244 pnpacpi_parse_allocated_irqresource(res_table,
245 res->data.extended_irq.interrupts[i],
246 res->data.extended_irq.triggering,
247 res->data.extended_irq.polarity);
248 }
249 break;
250
251 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
234 break; 252 break;
253
235 default: 254 default:
236 pnp_warn("PnPACPI: unknown resource type %d", res->id); 255 pnp_warn("PnPACPI: unknown resource type %d", res->type);
237 return AE_ERROR; 256 return AE_ERROR;
238 } 257 }
239 258
@@ -253,13 +272,13 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso
253 int i; 272 int i;
254 struct pnp_dma * dma; 273 struct pnp_dma * dma;
255 274
256 if (p->number_of_channels == 0) 275 if (p->channel_count == 0)
257 return; 276 return;
258 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); 277 dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL);
259 if (!dma) 278 if (!dma)
260 return; 279 return;
261 280
262 for(i = 0; i < p->number_of_channels; i++) 281 for(i = 0; i < p->channel_count; i++)
263 dma->map |= 1 << p->channels[i]; 282 dma->map |= 1 << p->channels[i];
264 dma->flags = 0; 283 dma->flags = 0;
265 if (p->bus_master) 284 if (p->bus_master)
@@ -309,37 +328,37 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option,
309 int i; 328 int i;
310 struct pnp_irq * irq; 329 struct pnp_irq * irq;
311 330
312 if (p->number_of_interrupts == 0) 331 if (p->interrupt_count == 0)
313 return; 332 return;
314 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 333 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
315 if (!irq) 334 if (!irq)
316 return; 335 return;
317 336
318 for(i = 0; i < p->number_of_interrupts; i++) 337 for(i = 0; i < p->interrupt_count; i++)
319 if (p->interrupts[i]) 338 if (p->interrupts[i])
320 __set_bit(p->interrupts[i], irq->map); 339 __set_bit(p->interrupts[i], irq->map);
321 irq->flags = irq_flags(p->edge_level, p->active_high_low); 340 irq->flags = irq_flags(p->triggering, p->polarity);
322 341
323 pnp_register_irq_resource(option, irq); 342 pnp_register_irq_resource(option, irq);
324 return; 343 return;
325} 344}
326 345
327static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, 346static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
328 struct acpi_resource_ext_irq *p) 347 struct acpi_resource_extended_irq *p)
329{ 348{
330 int i; 349 int i;
331 struct pnp_irq * irq; 350 struct pnp_irq * irq;
332 351
333 if (p->number_of_interrupts == 0) 352 if (p->interrupt_count == 0)
334 return; 353 return;
335 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 354 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
336 if (!irq) 355 if (!irq)
337 return; 356 return;
338 357
339 for(i = 0; i < p->number_of_interrupts; i++) 358 for(i = 0; i < p->interrupt_count; i++)
340 if (p->interrupts[i]) 359 if (p->interrupts[i])
341 __set_bit(p->interrupts[i], irq->map); 360 __set_bit(p->interrupts[i], irq->map);
342 irq->flags = irq_flags(p->edge_level, p->active_high_low); 361 irq->flags = irq_flags(p->triggering, p->polarity);
343 362
344 pnp_register_irq_resource(option, irq); 363 pnp_register_irq_resource(option, irq);
345 return; 364 return;
@@ -351,16 +370,16 @@ pnpacpi_parse_port_option(struct pnp_option *option,
351{ 370{
352 struct pnp_port * port; 371 struct pnp_port * port;
353 372
354 if (io->range_length == 0) 373 if (io->address_length == 0)
355 return; 374 return;
356 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 375 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
357 if (!port) 376 if (!port)
358 return; 377 return;
359 port->min = io->min_base_address; 378 port->min = io->minimum;
360 port->max = io->max_base_address; 379 port->max = io->maximum;
361 port->align = io->alignment; 380 port->align = io->alignment;
362 port->size = io->range_length; 381 port->size = io->address_length;
363 port->flags = ACPI_DECODE_16 == io->io_decode ? 382 port->flags = ACPI_DECODE_16 == io->io_decode ?
364 PNP_PORT_FLAG_16BITADDR : 0; 383 PNP_PORT_FLAG_16BITADDR : 0;
365 pnp_register_port_resource(option,port); 384 pnp_register_port_resource(option,port);
366 return; 385 return;
@@ -372,13 +391,13 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
372{ 391{
373 struct pnp_port * port; 392 struct pnp_port * port;
374 393
375 if (io->range_length == 0) 394 if (io->address_length == 0)
376 return; 395 return;
377 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 396 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
378 if (!port) 397 if (!port)
379 return; 398 return;
380 port->min = port->max = io->base_address; 399 port->min = port->max = io->address;
381 port->size = io->range_length; 400 port->size = io->address_length;
382 port->align = 0; 401 port->align = 0;
383 port->flags = PNP_PORT_FLAG_FIXED; 402 port->flags = PNP_PORT_FLAG_FIXED;
384 pnp_register_port_resource(option,port); 403 pnp_register_port_resource(option,port);
@@ -387,21 +406,21 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
387 406
388static void 407static void
389pnpacpi_parse_mem24_option(struct pnp_option *option, 408pnpacpi_parse_mem24_option(struct pnp_option *option,
390 struct acpi_resource_mem24 *p) 409 struct acpi_resource_memory24 *p)
391{ 410{
392 struct pnp_mem * mem; 411 struct pnp_mem * mem;
393 412
394 if (p->range_length == 0) 413 if (p->address_length == 0)
395 return; 414 return;
396 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 415 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
397 if (!mem) 416 if (!mem)
398 return; 417 return;
399 mem->min = p->min_base_address; 418 mem->min = p->minimum;
400 mem->max = p->max_base_address; 419 mem->max = p->maximum;
401 mem->align = p->alignment; 420 mem->align = p->alignment;
402 mem->size = p->range_length; 421 mem->size = p->address_length;
403 422
404 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 423 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
405 IORESOURCE_MEM_WRITEABLE : 0; 424 IORESOURCE_MEM_WRITEABLE : 0;
406 425
407 pnp_register_mem_resource(option,mem); 426 pnp_register_mem_resource(option,mem);
@@ -410,21 +429,21 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,
410 429
411static void 430static void
412pnpacpi_parse_mem32_option(struct pnp_option *option, 431pnpacpi_parse_mem32_option(struct pnp_option *option,
413 struct acpi_resource_mem32 *p) 432 struct acpi_resource_memory32 *p)
414{ 433{
415 struct pnp_mem * mem; 434 struct pnp_mem * mem;
416 435
417 if (p->range_length == 0) 436 if (p->address_length == 0)
418 return; 437 return;
419 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 438 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
420 if (!mem) 439 if (!mem)
421 return; 440 return;
422 mem->min = p->min_base_address; 441 mem->min = p->minimum;
423 mem->max = p->max_base_address; 442 mem->max = p->maximum;
424 mem->align = p->alignment; 443 mem->align = p->alignment;
425 mem->size = p->range_length; 444 mem->size = p->address_length;
426 445
427 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 446 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
428 IORESOURCE_MEM_WRITEABLE : 0; 447 IORESOURCE_MEM_WRITEABLE : 0;
429 448
430 pnp_register_mem_resource(option,mem); 449 pnp_register_mem_resource(option,mem);
@@ -433,33 +452,72 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,
433 452
434static void 453static void
435pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, 454pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
436 struct acpi_resource_fixed_mem32 *p) 455 struct acpi_resource_fixed_memory32 *p)
437{ 456{
438 struct pnp_mem * mem; 457 struct pnp_mem * mem;
439 458
440 if (p->range_length == 0) 459 if (p->address_length == 0)
441 return; 460 return;
442 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); 461 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
443 if (!mem) 462 if (!mem)
444 return; 463 return;
445 mem->min = mem->max = p->range_base_address; 464 mem->min = mem->max = p->address;
446 mem->size = p->range_length; 465 mem->size = p->address_length;
447 mem->align = 0; 466 mem->align = 0;
448 467
449 mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? 468 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
450 IORESOURCE_MEM_WRITEABLE : 0; 469 IORESOURCE_MEM_WRITEABLE : 0;
451 470
452 pnp_register_mem_resource(option,mem); 471 pnp_register_mem_resource(option,mem);
453 return; 472 return;
454} 473}
455 474
475static void
476pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
477{
478 struct acpi_resource_address64 addr, *p = &addr;
479 acpi_status status;
480 struct pnp_mem * mem;
481 struct pnp_port * port;
482
483 status = acpi_resource_to_address64(r, p);
484 if (!ACPI_SUCCESS(status)) {
485 pnp_warn("PnPACPI: failed to convert resource type %d", r->type);
486 return;
487 }
488
489 if (p->address_length == 0)
490 return;
491
492 if (p->resource_type == ACPI_MEMORY_RANGE) {
493 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
494 if (!mem)
495 return;
496 mem->min = mem->max = p->minimum;
497 mem->size = p->address_length;
498 mem->align = 0;
499 mem->flags = (p->info.mem.write_protect ==
500 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0;
501 pnp_register_mem_resource(option,mem);
502 } else if (p->resource_type == ACPI_IO_RANGE) {
503 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
504 if (!port)
505 return;
506 port->min = port->max = p->minimum;
507 port->size = p->address_length;
508 port->align = 0;
509 port->flags = PNP_PORT_FLAG_FIXED;
510 pnp_register_port_resource(option,port);
511 }
512}
513
456struct acpipnp_parse_option_s { 514struct acpipnp_parse_option_s {
457 struct pnp_option *option; 515 struct pnp_option *option;
458 struct pnp_option *option_independent; 516 struct pnp_option *option_independent;
459 struct pnp_dev *dev; 517 struct pnp_dev *dev;
460}; 518};
461 519
462static acpi_status pnpacpi_option_resource(struct acpi_resource *res, 520static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
463 void *data) 521 void *data)
464{ 522{
465 int priority = 0; 523 int priority = 0;
@@ -467,35 +525,16 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
467 struct pnp_dev *dev = parse_data->dev; 525 struct pnp_dev *dev = parse_data->dev;
468 struct pnp_option *option = parse_data->option; 526 struct pnp_option *option = parse_data->option;
469 527
470 switch (res->id) { 528 switch (res->type) {
471 case ACPI_RSTYPE_IRQ: 529 case ACPI_RESOURCE_TYPE_IRQ:
472 pnpacpi_parse_irq_option(option, &res->data.irq); 530 pnpacpi_parse_irq_option(option, &res->data.irq);
473 break; 531 break;
474 case ACPI_RSTYPE_EXT_IRQ: 532
475 pnpacpi_parse_ext_irq_option(option, 533 case ACPI_RESOURCE_TYPE_DMA:
476 &res->data.extended_irq);
477 break;
478 case ACPI_RSTYPE_DMA:
479 pnpacpi_parse_dma_option(option, &res->data.dma); 534 pnpacpi_parse_dma_option(option, &res->data.dma);
480 break; 535 break;
481 case ACPI_RSTYPE_IO: 536
482 pnpacpi_parse_port_option(option, &res->data.io); 537 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
483 break;
484 case ACPI_RSTYPE_FIXED_IO:
485 pnpacpi_parse_fixed_port_option(option,
486 &res->data.fixed_io);
487 break;
488 case ACPI_RSTYPE_MEM24:
489 pnpacpi_parse_mem24_option(option, &res->data.memory24);
490 break;
491 case ACPI_RSTYPE_MEM32:
492 pnpacpi_parse_mem32_option(option, &res->data.memory32);
493 break;
494 case ACPI_RSTYPE_FIXED_MEM32:
495 pnpacpi_parse_fixed_mem32_option(option,
496 &res->data.fixed_memory32);
497 break;
498 case ACPI_RSTYPE_START_DPF:
499 switch (res->data.start_dpf.compatibility_priority) { 538 switch (res->data.start_dpf.compatibility_priority) {
500 case ACPI_GOOD_CONFIGURATION: 539 case ACPI_GOOD_CONFIGURATION:
501 priority = PNP_RES_PRIORITY_PREFERRED; 540 priority = PNP_RES_PRIORITY_PREFERRED;
@@ -518,7 +557,8 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
518 return AE_ERROR; 557 return AE_ERROR;
519 parse_data->option = option; 558 parse_data->option = option;
520 break; 559 break;
521 case ACPI_RSTYPE_END_DPF: 560
561 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
522 /*only one EndDependentFn is allowed*/ 562 /*only one EndDependentFn is allowed*/
523 if (!parse_data->option_independent) { 563 if (!parse_data->option_independent) {
524 pnp_warn("PnPACPI: more than one EndDependentFn"); 564 pnp_warn("PnPACPI: more than one EndDependentFn");
@@ -527,15 +567,59 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
527 parse_data->option = parse_data->option_independent; 567 parse_data->option = parse_data->option_independent;
528 parse_data->option_independent = NULL; 568 parse_data->option_independent = NULL;
529 break; 569 break;
570
571 case ACPI_RESOURCE_TYPE_IO:
572 pnpacpi_parse_port_option(option, &res->data.io);
573 break;
574
575 case ACPI_RESOURCE_TYPE_FIXED_IO:
576 pnpacpi_parse_fixed_port_option(option,
577 &res->data.fixed_io);
578 break;
579
580 case ACPI_RESOURCE_TYPE_VENDOR:
581 case ACPI_RESOURCE_TYPE_END_TAG:
582 break;
583
584 case ACPI_RESOURCE_TYPE_MEMORY24:
585 pnpacpi_parse_mem24_option(option, &res->data.memory24);
586 break;
587
588 case ACPI_RESOURCE_TYPE_MEMORY32:
589 pnpacpi_parse_mem32_option(option, &res->data.memory32);
590 break;
591
592 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
593 pnpacpi_parse_fixed_mem32_option(option,
594 &res->data.fixed_memory32);
595 break;
596
597 case ACPI_RESOURCE_TYPE_ADDRESS16:
598 case ACPI_RESOURCE_TYPE_ADDRESS32:
599 case ACPI_RESOURCE_TYPE_ADDRESS64:
600 pnpacpi_parse_address_option(option, res);
601 break;
602
603 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
604 break;
605
606 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
607 pnpacpi_parse_ext_irq_option(option,
608 &res->data.extended_irq);
609 break;
610
611 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
612 break;
613
530 default: 614 default:
531 pnp_warn("PnPACPI: unknown resource type %d", res->id); 615 pnp_warn("PnPACPI: unknown resource type %d", res->type);
532 return AE_ERROR; 616 return AE_ERROR;
533 } 617 }
534 618
535 return AE_OK; 619 return AE_OK;
536} 620}
537 621
538acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, 622acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
539 struct pnp_dev *dev) 623 struct pnp_dev *dev)
540{ 624{
541 acpi_status status; 625 acpi_status status;
@@ -546,7 +630,7 @@ acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
546 return AE_ERROR; 630 return AE_ERROR;
547 parse_data.option_independent = parse_data.option; 631 parse_data.option_independent = parse_data.option;
548 parse_data.dev = dev; 632 parse_data.dev = dev;
549 status = acpi_walk_resources(handle, METHOD_NAME__PRS, 633 status = acpi_walk_resources(handle, METHOD_NAME__PRS,
550 pnpacpi_option_resource, &parse_data); 634 pnpacpi_option_resource, &parse_data);
551 635
552 return status; 636 return status;
@@ -559,21 +643,24 @@ static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
559 void *data) 643 void *data)
560{ 644{
561 int *res_cnt = (int *)data; 645 int *res_cnt = (int *)data;
562 switch (res->id) { 646 switch (res->type) {
563 case ACPI_RSTYPE_IRQ: 647 case ACPI_RESOURCE_TYPE_IRQ:
564 case ACPI_RSTYPE_EXT_IRQ: 648 case ACPI_RESOURCE_TYPE_DMA:
565 case ACPI_RSTYPE_DMA: 649 case ACPI_RESOURCE_TYPE_IO:
566 case ACPI_RSTYPE_IO: 650 case ACPI_RESOURCE_TYPE_FIXED_IO:
567 case ACPI_RSTYPE_FIXED_IO: 651 case ACPI_RESOURCE_TYPE_MEMORY24:
568 case ACPI_RSTYPE_MEM24: 652 case ACPI_RESOURCE_TYPE_MEMORY32:
569 case ACPI_RSTYPE_MEM32: 653 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
570 case ACPI_RSTYPE_FIXED_MEM32: 654 case ACPI_RESOURCE_TYPE_ADDRESS16:
571#if 0 655 case ACPI_RESOURCE_TYPE_ADDRESS32:
572 case ACPI_RSTYPE_ADDRESS16: 656 case ACPI_RESOURCE_TYPE_ADDRESS64:
573 case ACPI_RSTYPE_ADDRESS32: 657 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
574 case ACPI_RSTYPE_ADDRESS64:
575#endif
576 (*res_cnt) ++; 658 (*res_cnt) ++;
659 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
660 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
661 case ACPI_RESOURCE_TYPE_VENDOR:
662 case ACPI_RESOURCE_TYPE_END_TAG:
663 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
577 default: 664 default:
578 return AE_OK; 665 return AE_OK;
579 } 666 }
@@ -584,22 +671,25 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res,
584 void *data) 671 void *data)
585{ 672{
586 struct acpi_resource **resource = (struct acpi_resource **)data; 673 struct acpi_resource **resource = (struct acpi_resource **)data;
587 switch (res->id) { 674 switch (res->type) {
588 case ACPI_RSTYPE_IRQ: 675 case ACPI_RESOURCE_TYPE_IRQ:
589 case ACPI_RSTYPE_EXT_IRQ: 676 case ACPI_RESOURCE_TYPE_DMA:
590 case ACPI_RSTYPE_DMA: 677 case ACPI_RESOURCE_TYPE_IO:
591 case ACPI_RSTYPE_IO: 678 case ACPI_RESOURCE_TYPE_FIXED_IO:
592 case ACPI_RSTYPE_FIXED_IO: 679 case ACPI_RESOURCE_TYPE_MEMORY24:
593 case ACPI_RSTYPE_MEM24: 680 case ACPI_RESOURCE_TYPE_MEMORY32:
594 case ACPI_RSTYPE_MEM32: 681 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
595 case ACPI_RSTYPE_FIXED_MEM32: 682 case ACPI_RESOURCE_TYPE_ADDRESS16:
596#if 0 683 case ACPI_RESOURCE_TYPE_ADDRESS32:
597 case ACPI_RSTYPE_ADDRESS16: 684 case ACPI_RESOURCE_TYPE_ADDRESS64:
598 case ACPI_RSTYPE_ADDRESS32: 685 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
599 case ACPI_RSTYPE_ADDRESS64: 686 (*resource)->type = res->type;
600#endif
601 (*resource)->id = res->id;
602 (*resource)++; 687 (*resource)++;
688 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
689 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
690 case ACPI_RESOURCE_TYPE_VENDOR:
691 case ACPI_RESOURCE_TYPE_END_TAG:
692 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
603 default: 693 default:
604 return AE_OK; 694 return AE_OK;
605 } 695 }
@@ -607,14 +697,14 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res,
607 return AE_OK; 697 return AE_OK;
608} 698}
609 699
610int pnpacpi_build_resource_template(acpi_handle handle, 700int pnpacpi_build_resource_template(acpi_handle handle,
611 struct acpi_buffer *buffer) 701 struct acpi_buffer *buffer)
612{ 702{
613 struct acpi_resource *resource; 703 struct acpi_resource *resource;
614 int res_cnt = 0; 704 int res_cnt = 0;
615 acpi_status status; 705 acpi_status status;
616 706
617 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 707 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
618 pnpacpi_count_resources, &res_cnt); 708 pnpacpi_count_resources, &res_cnt);
619 if (ACPI_FAILURE(status)) { 709 if (ACPI_FAILURE(status)) {
620 pnp_err("Evaluate _CRS failed"); 710 pnp_err("Evaluate _CRS failed");
@@ -628,7 +718,7 @@ int pnpacpi_build_resource_template(acpi_handle handle,
628 return -ENOMEM; 718 return -ENOMEM;
629 pnp_dbg("Res cnt %d", res_cnt); 719 pnp_dbg("Res cnt %d", res_cnt);
630 resource = (struct acpi_resource *)buffer->pointer; 720 resource = (struct acpi_resource *)buffer->pointer;
631 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 721 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
632 pnpacpi_type_resources, &resource); 722 pnpacpi_type_resources, &resource);
633 if (ACPI_FAILURE(status)) { 723 if (ACPI_FAILURE(status)) {
634 kfree(buffer->pointer); 724 kfree(buffer->pointer);
@@ -636,54 +726,54 @@ int pnpacpi_build_resource_template(acpi_handle handle,
636 return -EINVAL; 726 return -EINVAL;
637 } 727 }
638 /* resource will pointer the end resource now */ 728 /* resource will pointer the end resource now */
639 resource->id = ACPI_RSTYPE_END_TAG; 729 resource->type = ACPI_RESOURCE_TYPE_END_TAG;
640 730
641 return 0; 731 return 0;
642} 732}
643 733
644static void pnpacpi_encode_irq(struct acpi_resource *resource, 734static void pnpacpi_encode_irq(struct acpi_resource *resource,
645 struct resource *p) 735 struct resource *p)
646{ 736{
647 int edge_level, active_high_low; 737 int triggering, polarity;
648 738
649 decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, 739 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering,
650 &active_high_low); 740 &polarity);
651 resource->id = ACPI_RSTYPE_IRQ; 741 resource->type = ACPI_RESOURCE_TYPE_IRQ;
652 resource->length = sizeof(struct acpi_resource); 742 resource->length = sizeof(struct acpi_resource);
653 resource->data.irq.edge_level = edge_level; 743 resource->data.irq.triggering = triggering;
654 resource->data.irq.active_high_low = active_high_low; 744 resource->data.irq.polarity = polarity;
655 if (edge_level == ACPI_EDGE_SENSITIVE) 745 if (triggering == ACPI_EDGE_SENSITIVE)
656 resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 746 resource->data.irq.sharable = ACPI_EXCLUSIVE;
657 else 747 else
658 resource->data.irq.shared_exclusive = ACPI_SHARED; 748 resource->data.irq.sharable = ACPI_SHARED;
659 resource->data.irq.number_of_interrupts = 1; 749 resource->data.irq.interrupt_count = 1;
660 resource->data.irq.interrupts[0] = p->start; 750 resource->data.irq.interrupts[0] = p->start;
661} 751}
662 752
663static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, 753static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
664 struct resource *p) 754 struct resource *p)
665{ 755{
666 int edge_level, active_high_low; 756 int triggering, polarity;
667 757
668 decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, 758 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering,
669 &active_high_low); 759 &polarity);
670 resource->id = ACPI_RSTYPE_EXT_IRQ; 760 resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
671 resource->length = sizeof(struct acpi_resource); 761 resource->length = sizeof(struct acpi_resource);
672 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER; 762 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER;
673 resource->data.extended_irq.edge_level = edge_level; 763 resource->data.extended_irq.triggering = triggering;
674 resource->data.extended_irq.active_high_low = active_high_low; 764 resource->data.extended_irq.polarity = polarity;
675 if (edge_level == ACPI_EDGE_SENSITIVE) 765 if (triggering == ACPI_EDGE_SENSITIVE)
676 resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE; 766 resource->data.irq.sharable = ACPI_EXCLUSIVE;
677 else 767 else
678 resource->data.irq.shared_exclusive = ACPI_SHARED; 768 resource->data.irq.sharable = ACPI_SHARED;
679 resource->data.extended_irq.number_of_interrupts = 1; 769 resource->data.extended_irq.interrupt_count = 1;
680 resource->data.extended_irq.interrupts[0] = p->start; 770 resource->data.extended_irq.interrupts[0] = p->start;
681} 771}
682 772
683static void pnpacpi_encode_dma(struct acpi_resource *resource, 773static void pnpacpi_encode_dma(struct acpi_resource *resource,
684 struct resource *p) 774 struct resource *p)
685{ 775{
686 resource->id = ACPI_RSTYPE_DMA; 776 resource->type = ACPI_RESOURCE_TYPE_DMA;
687 resource->length = sizeof(struct acpi_resource); 777 resource->length = sizeof(struct acpi_resource);
688 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ 778 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
689 if (p->flags & IORESOURCE_DMA_COMPATIBLE) 779 if (p->flags & IORESOURCE_DMA_COMPATIBLE)
@@ -701,75 +791,75 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource,
701 else if (p->flags & IORESOURCE_DMA_16BIT) 791 else if (p->flags & IORESOURCE_DMA_16BIT)
702 resource->data.dma.transfer = ACPI_TRANSFER_16; 792 resource->data.dma.transfer = ACPI_TRANSFER_16;
703 resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER; 793 resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER;
704 resource->data.dma.number_of_channels = 1; 794 resource->data.dma.channel_count = 1;
705 resource->data.dma.channels[0] = p->start; 795 resource->data.dma.channels[0] = p->start;
706} 796}
707 797
708static void pnpacpi_encode_io(struct acpi_resource *resource, 798static void pnpacpi_encode_io(struct acpi_resource *resource,
709 struct resource *p) 799 struct resource *p)
710{ 800{
711 resource->id = ACPI_RSTYPE_IO; 801 resource->type = ACPI_RESOURCE_TYPE_IO;
712 resource->length = sizeof(struct acpi_resource); 802 resource->length = sizeof(struct acpi_resource);
713 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ 803 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */
714 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? 804 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)?
715 ACPI_DECODE_16 : ACPI_DECODE_10; 805 ACPI_DECODE_16 : ACPI_DECODE_10;
716 resource->data.io.min_base_address = p->start; 806 resource->data.io.minimum = p->start;
717 resource->data.io.max_base_address = p->end; 807 resource->data.io.maximum = p->end;
718 resource->data.io.alignment = 0; /* Correct? */ 808 resource->data.io.alignment = 0; /* Correct? */
719 resource->data.io.range_length = p->end - p->start + 1; 809 resource->data.io.address_length = p->end - p->start + 1;
720} 810}
721 811
722static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, 812static void pnpacpi_encode_fixed_io(struct acpi_resource *resource,
723 struct resource *p) 813 struct resource *p)
724{ 814{
725 resource->id = ACPI_RSTYPE_FIXED_IO; 815 resource->type = ACPI_RESOURCE_TYPE_FIXED_IO;
726 resource->length = sizeof(struct acpi_resource); 816 resource->length = sizeof(struct acpi_resource);
727 resource->data.fixed_io.base_address = p->start; 817 resource->data.fixed_io.address = p->start;
728 resource->data.fixed_io.range_length = p->end - p->start + 1; 818 resource->data.fixed_io.address_length = p->end - p->start + 1;
729} 819}
730 820
731static void pnpacpi_encode_mem24(struct acpi_resource *resource, 821static void pnpacpi_encode_mem24(struct acpi_resource *resource,
732 struct resource *p) 822 struct resource *p)
733{ 823{
734 resource->id = ACPI_RSTYPE_MEM24; 824 resource->type = ACPI_RESOURCE_TYPE_MEMORY24;
735 resource->length = sizeof(struct acpi_resource); 825 resource->length = sizeof(struct acpi_resource);
736 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ 826 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */
737 resource->data.memory24.read_write_attribute = 827 resource->data.memory24.write_protect =
738 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 828 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
739 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 829 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
740 resource->data.memory24.min_base_address = p->start; 830 resource->data.memory24.minimum = p->start;
741 resource->data.memory24.max_base_address = p->end; 831 resource->data.memory24.maximum = p->end;
742 resource->data.memory24.alignment = 0; 832 resource->data.memory24.alignment = 0;
743 resource->data.memory24.range_length = p->end - p->start + 1; 833 resource->data.memory24.address_length = p->end - p->start + 1;
744} 834}
745 835
746static void pnpacpi_encode_mem32(struct acpi_resource *resource, 836static void pnpacpi_encode_mem32(struct acpi_resource *resource,
747 struct resource *p) 837 struct resource *p)
748{ 838{
749 resource->id = ACPI_RSTYPE_MEM32; 839 resource->type = ACPI_RESOURCE_TYPE_MEMORY32;
750 resource->length = sizeof(struct acpi_resource); 840 resource->length = sizeof(struct acpi_resource);
751 resource->data.memory32.read_write_attribute = 841 resource->data.memory32.write_protect =
752 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 842 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
753 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 843 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
754 resource->data.memory32.min_base_address = p->start; 844 resource->data.memory32.minimum = p->start;
755 resource->data.memory32.max_base_address = p->end; 845 resource->data.memory32.maximum = p->end;
756 resource->data.memory32.alignment = 0; 846 resource->data.memory32.alignment = 0;
757 resource->data.memory32.range_length = p->end - p->start + 1; 847 resource->data.memory32.address_length = p->end - p->start + 1;
758} 848}
759 849
760static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, 850static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource,
761 struct resource *p) 851 struct resource *p)
762{ 852{
763 resource->id = ACPI_RSTYPE_FIXED_MEM32; 853 resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32;
764 resource->length = sizeof(struct acpi_resource); 854 resource->length = sizeof(struct acpi_resource);
765 resource->data.fixed_memory32.read_write_attribute = 855 resource->data.fixed_memory32.write_protect =
766 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 856 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
767 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 857 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
768 resource->data.fixed_memory32.range_base_address = p->start; 858 resource->data.fixed_memory32.address = p->start;
769 resource->data.fixed_memory32.range_length = p->end - p->start + 1; 859 resource->data.fixed_memory32.address_length = p->end - p->start + 1;
770} 860}
771 861
772int pnpacpi_encode_resources(struct pnp_resource_table *res_table, 862int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
773 struct acpi_buffer *buffer) 863 struct acpi_buffer *buffer)
774{ 864{
775 int i = 0; 865 int i = 0;
@@ -780,58 +870,67 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
780 870
781 pnp_dbg("res cnt %d", res_cnt); 871 pnp_dbg("res cnt %d", res_cnt);
782 while (i < res_cnt) { 872 while (i < res_cnt) {
783 switch(resource->id) { 873 switch(resource->type) {
784 case ACPI_RSTYPE_IRQ: 874 case ACPI_RESOURCE_TYPE_IRQ:
785 pnp_dbg("Encode irq"); 875 pnp_dbg("Encode irq");
786 pnpacpi_encode_irq(resource, 876 pnpacpi_encode_irq(resource,
787 &res_table->irq_resource[irq]); 877 &res_table->irq_resource[irq]);
788 irq++; 878 irq++;
789 break; 879 break;
790 880
791 case ACPI_RSTYPE_EXT_IRQ: 881 case ACPI_RESOURCE_TYPE_DMA:
792 pnp_dbg("Encode ext irq");
793 pnpacpi_encode_ext_irq(resource,
794 &res_table->irq_resource[irq]);
795 irq++;
796 break;
797 case ACPI_RSTYPE_DMA:
798 pnp_dbg("Encode dma"); 882 pnp_dbg("Encode dma");
799 pnpacpi_encode_dma(resource, 883 pnpacpi_encode_dma(resource,
800 &res_table->dma_resource[dma]); 884 &res_table->dma_resource[dma]);
801 dma ++; 885 dma ++;
802 break; 886 break;
803 case ACPI_RSTYPE_IO: 887 case ACPI_RESOURCE_TYPE_IO:
804 pnp_dbg("Encode io"); 888 pnp_dbg("Encode io");
805 pnpacpi_encode_io(resource, 889 pnpacpi_encode_io(resource,
806 &res_table->port_resource[port]); 890 &res_table->port_resource[port]);
807 port ++; 891 port ++;
808 break; 892 break;
809 case ACPI_RSTYPE_FIXED_IO: 893 case ACPI_RESOURCE_TYPE_FIXED_IO:
810 pnp_dbg("Encode fixed io"); 894 pnp_dbg("Encode fixed io");
811 pnpacpi_encode_fixed_io(resource, 895 pnpacpi_encode_fixed_io(resource,
812 &res_table->port_resource[port]); 896 &res_table->port_resource[port]);
813 port ++; 897 port ++;
814 break; 898 break;
815 case ACPI_RSTYPE_MEM24: 899 case ACPI_RESOURCE_TYPE_MEMORY24:
816 pnp_dbg("Encode mem24"); 900 pnp_dbg("Encode mem24");
817 pnpacpi_encode_mem24(resource, 901 pnpacpi_encode_mem24(resource,
818 &res_table->mem_resource[mem]); 902 &res_table->mem_resource[mem]);
819 mem ++; 903 mem ++;
820 break; 904 break;
821 case ACPI_RSTYPE_MEM32: 905 case ACPI_RESOURCE_TYPE_MEMORY32:
822 pnp_dbg("Encode mem32"); 906 pnp_dbg("Encode mem32");
823 pnpacpi_encode_mem32(resource, 907 pnpacpi_encode_mem32(resource,
824 &res_table->mem_resource[mem]); 908 &res_table->mem_resource[mem]);
825 mem ++; 909 mem ++;
826 break; 910 break;
827 case ACPI_RSTYPE_FIXED_MEM32: 911 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
828 pnp_dbg("Encode fixed mem32"); 912 pnp_dbg("Encode fixed mem32");
829 pnpacpi_encode_fixed_mem32(resource, 913 pnpacpi_encode_fixed_mem32(resource,
830 &res_table->mem_resource[mem]); 914 &res_table->mem_resource[mem]);
831 mem ++; 915 mem ++;
832 break; 916 break;
917 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
918 pnp_dbg("Encode ext irq");
919 pnpacpi_encode_ext_irq(resource,
920 &res_table->irq_resource[irq]);
921 irq++;
922 break;
923 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
924 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
925 case ACPI_RESOURCE_TYPE_VENDOR:
926 case ACPI_RESOURCE_TYPE_END_TAG:
927 case ACPI_RESOURCE_TYPE_ADDRESS16:
928 case ACPI_RESOURCE_TYPE_ADDRESS32:
929 case ACPI_RESOURCE_TYPE_ADDRESS64:
930 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
931 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
833 default: /* other type */ 932 default: /* other type */
834 pnp_warn("unknown resource type %d", resource->id); 933 pnp_warn("unknown resource type %d", resource->type);
835 return -EINVAL; 934 return -EINVAL;
836 } 935 }
837 resource ++; 936 resource ++;
diff --git a/drivers/s390/Kconfig b/drivers/s390/Kconfig
index a86a650f3d6d..721787cc5a1c 100644
--- a/drivers/s390/Kconfig
+++ b/drivers/s390/Kconfig
@@ -51,6 +51,13 @@ config UNIX98_PTY_COUNT
51 When not in use, each additional set of 256 PTYs occupy 51 When not in use, each additional set of 256 PTYs occupy
52 approximately 8 KB of kernel memory on 32-bit architectures. 52 approximately 8 KB of kernel memory on 32-bit architectures.
53 53
54config HANGCHECK_TIMER
55 tristate "Hangcheck timer"
56 help
57 The hangcheck-timer module detects when the system has gone
58 out to lunch past a certain margin. It can reboot the system
59 or merely print a warning.
60
54source "drivers/char/watchdog/Kconfig" 61source "drivers/char/watchdog/Kconfig"
55 62
56comment "S/390 character device drivers" 63comment "S/390 character device drivers"
diff --git a/drivers/s390/block/Kconfig b/drivers/s390/block/Kconfig
index 6f50cc9323d9..6912399d0937 100644
--- a/drivers/s390/block/Kconfig
+++ b/drivers/s390/block/Kconfig
@@ -55,13 +55,21 @@ config DASD_DIAG
55 Disks under VM. If you are not running under VM or unsure what it is, 55 Disks under VM. If you are not running under VM or unsure what it is,
56 say "N". 56 say "N".
57 57
58config DASD_EER
59 tristate "Extended error reporting (EER)"
60 depends on DASD
61 help
62 This driver provides a character device interface to the
63 DASD extended error reporting. This is only needed if you want to
64 use applications written for the EER facility.
65
58config DASD_CMB 66config DASD_CMB
59 tristate "Compatibility interface for DASD channel measurement blocks" 67 tristate "Compatibility interface for DASD channel measurement blocks"
60 depends on DASD 68 depends on DASD
61 help 69 help
62 This driver provides an additional interface to the channel measurement 70 This driver provides an additional interface to the channel
63 facility, which is normally accessed though sysfs, with a set of 71 measurement facility, which is normally accessed though sysfs, with
64 ioctl functions specific to the dasd driver. 72 a set of ioctl functions specific to the dasd driver.
65 This is only needed if you want to use applications written for 73 This is only needed if you want to use applications written for
66 linux-2.4 dasd channel measurement facility interface. 74 linux-2.4 dasd channel measurement facility interface.
67 75
diff --git a/drivers/s390/block/Makefile b/drivers/s390/block/Makefile
index 58c6780134f7..0c0d871e8f51 100644
--- a/drivers/s390/block/Makefile
+++ b/drivers/s390/block/Makefile
@@ -5,6 +5,7 @@
5dasd_eckd_mod-objs := dasd_eckd.o dasd_3990_erp.o dasd_9343_erp.o 5dasd_eckd_mod-objs := dasd_eckd.o dasd_3990_erp.o dasd_9343_erp.o
6dasd_fba_mod-objs := dasd_fba.o dasd_3370_erp.o dasd_9336_erp.o 6dasd_fba_mod-objs := dasd_fba.o dasd_3370_erp.o dasd_9336_erp.o
7dasd_diag_mod-objs := dasd_diag.o 7dasd_diag_mod-objs := dasd_diag.o
8dasd_eer_mod-objs := dasd_eer.o
8dasd_mod-objs := dasd.o dasd_ioctl.o dasd_proc.o dasd_devmap.o \ 9dasd_mod-objs := dasd.o dasd_ioctl.o dasd_proc.o dasd_devmap.o \
9 dasd_genhd.o dasd_erp.o 10 dasd_genhd.o dasd_erp.o
10 11
@@ -13,5 +14,6 @@ obj-$(CONFIG_DASD_DIAG) += dasd_diag_mod.o
13obj-$(CONFIG_DASD_ECKD) += dasd_eckd_mod.o 14obj-$(CONFIG_DASD_ECKD) += dasd_eckd_mod.o
14obj-$(CONFIG_DASD_FBA) += dasd_fba_mod.o 15obj-$(CONFIG_DASD_FBA) += dasd_fba_mod.o
15obj-$(CONFIG_DASD_CMB) += dasd_cmb.o 16obj-$(CONFIG_DASD_CMB) += dasd_cmb.o
17obj-$(CONFIG_DASD_EER) += dasd_eer.o
16obj-$(CONFIG_BLK_DEV_XPRAM) += xpram.o 18obj-$(CONFIG_BLK_DEV_XPRAM) += xpram.o
17obj-$(CONFIG_DCSSBLK) += dcssblk.o 19obj-$(CONFIG_DCSSBLK) += dcssblk.o
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index ef4c687e7c01..08c88fcd8963 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -7,7 +7,6 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.172 $
11 */ 10 */
12 11
13#include <linux/config.h> 12#include <linux/config.h>
@@ -19,6 +18,7 @@
19#include <linux/slab.h> 18#include <linux/slab.h>
20#include <linux/buffer_head.h> 19#include <linux/buffer_head.h>
21#include <linux/hdreg.h> 20#include <linux/hdreg.h>
21#include <linux/notifier.h>
22 22
23#include <asm/ccwdev.h> 23#include <asm/ccwdev.h>
24#include <asm/ebcdic.h> 24#include <asm/ebcdic.h>
@@ -58,6 +58,7 @@ static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
58static void dasd_flush_ccw_queue(struct dasd_device *, int); 58static void dasd_flush_ccw_queue(struct dasd_device *, int);
59static void dasd_tasklet(struct dasd_device *); 59static void dasd_tasklet(struct dasd_device *);
60static void do_kick_device(void *data); 60static void do_kick_device(void *data);
61static void dasd_disable_eer(struct dasd_device *device);
61 62
62/* 63/*
63 * SECTION: Operations on the device structure. 64 * SECTION: Operations on the device structure.
@@ -152,6 +153,8 @@ dasd_state_new_to_known(struct dasd_device *device)
152static inline void 153static inline void
153dasd_state_known_to_new(struct dasd_device * device) 154dasd_state_known_to_new(struct dasd_device * device)
154{ 155{
156 /* disable extended error reporting for this device */
157 dasd_disable_eer(device);
155 /* Forget the discipline information. */ 158 /* Forget the discipline information. */
156 device->discipline = NULL; 159 device->discipline = NULL;
157 device->state = DASD_STATE_NEW; 160 device->state = DASD_STATE_NEW;
@@ -675,11 +678,8 @@ dasd_term_IO(struct dasd_ccw_req * cqr)
675 rc = ccw_device_clear(device->cdev, (long) cqr); 678 rc = ccw_device_clear(device->cdev, (long) cqr);
676 switch (rc) { 679 switch (rc) {
677 case 0: /* termination successful */ 680 case 0: /* termination successful */
678 if (cqr->retries > 0) { 681 cqr->retries--;
679 cqr->retries--; 682 cqr->status = DASD_CQR_CLEAR;
680 cqr->status = DASD_CQR_CLEAR;
681 } else
682 cqr->status = DASD_CQR_FAILED;
683 cqr->stopclk = get_clock(); 683 cqr->stopclk = get_clock();
684 DBF_DEV_EVENT(DBF_DEBUG, device, 684 DBF_DEV_EVENT(DBF_DEBUG, device,
685 "terminate cqr %p successful", 685 "terminate cqr %p successful",
@@ -871,6 +871,9 @@ dasd_handle_state_change_pending(struct dasd_device *device)
871 struct dasd_ccw_req *cqr; 871 struct dasd_ccw_req *cqr;
872 struct list_head *l, *n; 872 struct list_head *l, *n;
873 873
874 /* first of all call extended error reporting */
875 dasd_write_eer_trigger(DASD_EER_STATECHANGE, device, NULL);
876
874 device->stopped &= ~DASD_STOPPED_PENDING; 877 device->stopped &= ~DASD_STOPPED_PENDING;
875 878
876 /* restart all 'running' IO on queue */ 879 /* restart all 'running' IO on queue */
@@ -1090,6 +1093,19 @@ restart:
1090 } 1093 }
1091 goto restart; 1094 goto restart;
1092 } 1095 }
1096
1097 /* first of all call extended error reporting */
1098 if (device->eer && cqr->status == DASD_CQR_FAILED) {
1099 dasd_write_eer_trigger(DASD_EER_FATALERROR,
1100 device, cqr);
1101
1102 /* restart request */
1103 cqr->status = DASD_CQR_QUEUED;
1104 cqr->retries = 255;
1105 device->stopped |= DASD_STOPPED_QUIESCE;
1106 goto restart;
1107 }
1108
1093 /* Process finished ERP request. */ 1109 /* Process finished ERP request. */
1094 if (cqr->refers) { 1110 if (cqr->refers) {
1095 __dasd_process_erp(device, cqr); 1111 __dasd_process_erp(device, cqr);
@@ -1227,7 +1243,8 @@ __dasd_start_head(struct dasd_device * device)
1227 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list); 1243 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
1228 /* check FAILFAST */ 1244 /* check FAILFAST */
1229 if (device->stopped & ~DASD_STOPPED_PENDING && 1245 if (device->stopped & ~DASD_STOPPED_PENDING &&
1230 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags)) { 1246 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
1247 (!device->eer)) {
1231 cqr->status = DASD_CQR_FAILED; 1248 cqr->status = DASD_CQR_FAILED;
1232 dasd_schedule_bh(device); 1249 dasd_schedule_bh(device);
1233 } 1250 }
@@ -1308,7 +1325,7 @@ dasd_tasklet(struct dasd_device * device)
1308 /* Now call the callback function of requests with final status */ 1325 /* Now call the callback function of requests with final status */
1309 list_for_each_safe(l, n, &final_queue) { 1326 list_for_each_safe(l, n, &final_queue) {
1310 cqr = list_entry(l, struct dasd_ccw_req, list); 1327 cqr = list_entry(l, struct dasd_ccw_req, list);
1311 list_del(&cqr->list); 1328 list_del_init(&cqr->list);
1312 if (cqr->callback != NULL) 1329 if (cqr->callback != NULL)
1313 (cqr->callback)(cqr, cqr->callback_data); 1330 (cqr->callback)(cqr, cqr->callback_data);
1314 } 1331 }
@@ -1393,7 +1410,9 @@ _wait_for_wakeup(struct dasd_ccw_req *cqr)
1393 1410
1394 device = cqr->device; 1411 device = cqr->device;
1395 spin_lock_irq(get_ccwdev_lock(device->cdev)); 1412 spin_lock_irq(get_ccwdev_lock(device->cdev));
1396 rc = cqr->status == DASD_CQR_DONE || cqr->status == DASD_CQR_FAILED; 1413 rc = ((cqr->status == DASD_CQR_DONE ||
1414 cqr->status == DASD_CQR_FAILED) &&
1415 list_empty(&cqr->list));
1397 spin_unlock_irq(get_ccwdev_lock(device->cdev)); 1416 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1398 return rc; 1417 return rc;
1399} 1418}
@@ -1457,15 +1476,37 @@ dasd_sleep_on_interruptible(struct dasd_ccw_req * cqr)
1457 while (!finished) { 1476 while (!finished) {
1458 rc = wait_event_interruptible(wait_q, _wait_for_wakeup(cqr)); 1477 rc = wait_event_interruptible(wait_q, _wait_for_wakeup(cqr));
1459 if (rc != -ERESTARTSYS) { 1478 if (rc != -ERESTARTSYS) {
1460 /* Request status is either done or failed. */ 1479 /* Request is final (done or failed) */
1461 rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0; 1480 rc = (cqr->status == DASD_CQR_DONE) ? 0 : -EIO;
1462 break; 1481 break;
1463 } 1482 }
1464 spin_lock_irq(get_ccwdev_lock(device->cdev)); 1483 spin_lock_irq(get_ccwdev_lock(device->cdev));
1465 if (cqr->status == DASD_CQR_IN_IO && 1484 switch (cqr->status) {
1466 device->discipline->term_IO(cqr) == 0) { 1485 case DASD_CQR_IN_IO:
1467 list_del(&cqr->list); 1486 /* terminate runnig cqr */
1487 if (device->discipline->term_IO) {
1488 cqr->retries = -1;
1489 device->discipline->term_IO(cqr);
1490 /*nished =
1491 * wait (non-interruptible) for final status
1492 * because signal ist still pending
1493 */
1494 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1495 wait_event(wait_q, _wait_for_wakeup(cqr));
1496 spin_lock_irq(get_ccwdev_lock(device->cdev));
1497 rc = (cqr->status == DASD_CQR_DONE) ? 0 : -EIO;
1498 finished = 1;
1499 }
1500 break;
1501 case DASD_CQR_QUEUED:
1502 /* request */
1503 list_del_init(&cqr->list);
1504 rc = -EIO;
1468 finished = 1; 1505 finished = 1;
1506 break;
1507 default:
1508 /* cqr with 'non-interruptable' status - just wait */
1509 break;
1469 } 1510 }
1470 spin_unlock_irq(get_ccwdev_lock(device->cdev)); 1511 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1471 } 1512 }
@@ -1945,6 +1986,9 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
1945 switch (event) { 1986 switch (event) {
1946 case CIO_GONE: 1987 case CIO_GONE:
1947 case CIO_NO_PATH: 1988 case CIO_NO_PATH:
1989 /* first of all call extended error reporting */
1990 dasd_write_eer_trigger(DASD_EER_NOPATH, device, NULL);
1991
1948 if (device->state < DASD_STATE_BASIC) 1992 if (device->state < DASD_STATE_BASIC)
1949 break; 1993 break;
1950 /* Device is active. We want to keep it. */ 1994 /* Device is active. We want to keep it. */
@@ -2002,6 +2046,51 @@ dasd_generic_auto_online (struct ccw_driver *dasd_discipline_driver)
2002 put_driver(drv); 2046 put_driver(drv);
2003} 2047}
2004 2048
2049/*
2050 * notifications for extended error reports
2051 */
2052static struct notifier_block *dasd_eer_chain;
2053
2054int
2055dasd_register_eer_notifier(struct notifier_block *nb)
2056{
2057 return notifier_chain_register(&dasd_eer_chain, nb);
2058}
2059
2060int
2061dasd_unregister_eer_notifier(struct notifier_block *nb)
2062{
2063 return notifier_chain_unregister(&dasd_eer_chain, nb);
2064}
2065
2066/*
2067 * Notify the registered error reporting module of a problem
2068 */
2069void
2070dasd_write_eer_trigger(unsigned int id, struct dasd_device *device,
2071 struct dasd_ccw_req *cqr)
2072{
2073 if (device->eer) {
2074 struct dasd_eer_trigger temp;
2075 temp.id = id;
2076 temp.device = device;
2077 temp.cqr = cqr;
2078 notifier_call_chain(&dasd_eer_chain, DASD_EER_TRIGGER,
2079 (void *)&temp);
2080 }
2081}
2082
2083/*
2084 * Tell the registered error reporting module to disable error reporting for
2085 * a given device and to cleanup any private data structures on that device.
2086 */
2087static void
2088dasd_disable_eer(struct dasd_device *device)
2089{
2090 notifier_call_chain(&dasd_eer_chain, DASD_EER_DISABLE, (void *)device);
2091}
2092
2093
2005static int __init 2094static int __init
2006dasd_init(void) 2095dasd_init(void)
2007{ 2096{
@@ -2083,6 +2172,11 @@ EXPORT_SYMBOL_GPL(dasd_generic_set_online);
2083EXPORT_SYMBOL_GPL(dasd_generic_set_offline); 2172EXPORT_SYMBOL_GPL(dasd_generic_set_offline);
2084EXPORT_SYMBOL_GPL(dasd_generic_auto_online); 2173EXPORT_SYMBOL_GPL(dasd_generic_auto_online);
2085 2174
2175EXPORT_SYMBOL(dasd_register_eer_notifier);
2176EXPORT_SYMBOL(dasd_unregister_eer_notifier);
2177EXPORT_SYMBOL(dasd_write_eer_trigger);
2178
2179
2086/* 2180/*
2087 * Overrides for Emacs so that we follow Linus's tabbing style. 2181 * Overrides for Emacs so that we follow Linus's tabbing style.
2088 * Emacs will notice this stuff at the end of the file and automatically 2182 * Emacs will notice this stuff at the end of the file and automatically
diff --git a/drivers/s390/block/dasd_3370_erp.c b/drivers/s390/block/dasd_3370_erp.c
index 84565c8f584e..1d11c2a9525d 100644
--- a/drivers/s390/block/dasd_3370_erp.c
+++ b/drivers/s390/block/dasd_3370_erp.c
@@ -4,7 +4,6 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000
6 * 6 *
7 * $Revision: 1.9 $
8 */ 7 */
9 8
10#define PRINTK_HEADER "dasd_erp(3370)" 9#define PRINTK_HEADER "dasd_erp(3370)"
diff --git a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c
index c143ecb53d9d..c811380b9079 100644
--- a/drivers/s390/block/dasd_3990_erp.c
+++ b/drivers/s390/block/dasd_3990_erp.c
@@ -5,7 +5,6 @@
5 * Bugreports.to..: <Linux390@de.ibm.com> 5 * Bugreports.to..: <Linux390@de.ibm.com>
6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001 6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000, 2001
7 * 7 *
8 * $Revision: 1.36 $
9 */ 8 */
10 9
11#include <linux/timer.h> 10#include <linux/timer.h>
@@ -1109,6 +1108,9 @@ dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
1109 case 0x0B: 1108 case 0x0B:
1110 DEV_MESSAGE(KERN_WARNING, device, "%s", 1109 DEV_MESSAGE(KERN_WARNING, device, "%s",
1111 "FORMAT F - Volume is suspended duplex"); 1110 "FORMAT F - Volume is suspended duplex");
1111 /* call extended error reporting (EER) */
1112 dasd_write_eer_trigger(DASD_EER_PPRCSUSPEND, device,
1113 erp->refers);
1112 break; 1114 break;
1113 case 0x0C: 1115 case 0x0C:
1114 DEV_MESSAGE(KERN_WARNING, device, "%s", 1116 DEV_MESSAGE(KERN_WARNING, device, "%s",
diff --git a/drivers/s390/block/dasd_9336_erp.c b/drivers/s390/block/dasd_9336_erp.c
index 01e87170a3a2..dc861446d056 100644
--- a/drivers/s390/block/dasd_9336_erp.c
+++ b/drivers/s390/block/dasd_9336_erp.c
@@ -4,7 +4,6 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000
6 * 6 *
7 * $Revision: 1.8 $
8 */ 7 */
9 8
10#define PRINTK_HEADER "dasd_erp(9336)" 9#define PRINTK_HEADER "dasd_erp(9336)"
diff --git a/drivers/s390/block/dasd_9343_erp.c b/drivers/s390/block/dasd_9343_erp.c
index 2a23b74faf3f..4a5b79569aaa 100644
--- a/drivers/s390/block/dasd_9343_erp.c
+++ b/drivers/s390/block/dasd_9343_erp.c
@@ -4,7 +4,6 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000
6 * 6 *
7 * $Revision: 1.13 $
8 */ 7 */
9 8
10#define PRINTK_HEADER "dasd_erp(9343)" 9#define PRINTK_HEADER "dasd_erp(9343)"
diff --git a/drivers/s390/block/dasd_cmb.c b/drivers/s390/block/dasd_cmb.c
index 4f365bff275c..e88f73ee72ce 100644
--- a/drivers/s390/block/dasd_cmb.c
+++ b/drivers/s390/block/dasd_cmb.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/drivers/s390/block/dasd_cmb.c ($Revision: 1.9 $)
3 *
4 * Linux on zSeries Channel Measurement Facility support 2 * Linux on zSeries Channel Measurement Facility support
5 * (dasd device driver interface) 3 * (dasd device driver interface)
6 * 4 *
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index caee16a3dc62..1629b27c48ab 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -11,7 +11,6 @@
11 * functions may not be called from interrupt context. In particular 11 * functions may not be called from interrupt context. In particular
12 * dasd_get_device is a no-no from interrupt context. 12 * dasd_get_device is a no-no from interrupt context.
13 * 13 *
14 * $Revision: 1.43 $
15 */ 14 */
16 15
17#include <linux/config.h> 16#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index ba80fdea7ebf..3f9d704d2657 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -6,7 +6,6 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.53 $
10 */ 9 */
11 10
12#include <linux/config.h> 11#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_diag.h b/drivers/s390/block/dasd_diag.h
index a4f80bd735f1..38a4e55f8953 100644
--- a/drivers/s390/block/dasd_diag.h
+++ b/drivers/s390/block/dasd_diag.h
@@ -6,7 +6,6 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.9 $
10 */ 9 */
11 10
12#define MDSK_WRITE_REQ 0x01 11#define MDSK_WRITE_REQ 0x01
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 96eb48258580..822e2a265578 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -7,7 +7,6 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
9 * 9 *
10 * $Revision: 1.74 $
11 */ 10 */
12 11
13#include <linux/config.h> 12#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_eckd.h b/drivers/s390/block/dasd_eckd.h
index b6888c68b224..e15dd7978050 100644
--- a/drivers/s390/block/dasd_eckd.h
+++ b/drivers/s390/block/dasd_eckd.h
@@ -5,7 +5,6 @@
5 * Bugreports.to..: <Linux390@de.ibm.com> 5 * Bugreports.to..: <Linux390@de.ibm.com>
6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 6 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
7 * 7 *
8 * $Revision: 1.10 $
9 */ 8 */
10 9
11#ifndef DASD_ECKD_H 10#ifndef DASD_ECKD_H
@@ -30,6 +29,7 @@
30#define DASD_ECKD_CCW_PSF 0x27 29#define DASD_ECKD_CCW_PSF 0x27
31#define DASD_ECKD_CCW_RSSD 0x3e 30#define DASD_ECKD_CCW_RSSD 0x3e
32#define DASD_ECKD_CCW_LOCATE_RECORD 0x47 31#define DASD_ECKD_CCW_LOCATE_RECORD 0x47
32#define DASD_ECKD_CCW_SNSS 0x54
33#define DASD_ECKD_CCW_DEFINE_EXTENT 0x63 33#define DASD_ECKD_CCW_DEFINE_EXTENT 0x63
34#define DASD_ECKD_CCW_WRITE_MT 0x85 34#define DASD_ECKD_CCW_WRITE_MT 0x85
35#define DASD_ECKD_CCW_READ_MT 0x86 35#define DASD_ECKD_CCW_READ_MT 0x86
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
new file mode 100644
index 000000000000..f70cd7716b24
--- /dev/null
+++ b/drivers/s390/block/dasd_eer.c
@@ -0,0 +1,1090 @@
1/*
2 * character device driver for extended error reporting
3 *
4 *
5 * Copyright (C) 2005 IBM Corporation
6 * extended error reporting for DASD ECKD devices
7 * Author(s): Stefan Weinhuber <wein@de.ibm.com>
8 *
9 */
10
11#include <linux/init.h>
12#include <linux/fs.h>
13#include <linux/kernel.h>
14#include <linux/miscdevice.h>
15#include <linux/module.h>
16#include <linux/moduleparam.h>
17#include <linux/device.h>
18#include <linux/workqueue.h>
19#include <linux/poll.h>
20#include <linux/notifier.h>
21
22#include <asm/uaccess.h>
23#include <asm/semaphore.h>
24#include <asm/atomic.h>
25#include <asm/ebcdic.h>
26
27#include "dasd_int.h"
28#include "dasd_eckd.h"
29
30
31MODULE_LICENSE("GPL");
32
33MODULE_AUTHOR("Stefan Weinhuber <wein@de.ibm.com>");
34MODULE_DESCRIPTION("DASD extended error reporting module");
35
36
37#ifdef PRINTK_HEADER
38#undef PRINTK_HEADER
39#endif /* PRINTK_HEADER */
40#define PRINTK_HEADER "dasd(eer):"
41
42
43
44
45
46/*****************************************************************************/
47/* the internal buffer */
48/*****************************************************************************/
49
50/*
51 * The internal buffer is meant to store obaque blobs of data, so it doesn't
52 * know of higher level concepts like triggers.
53 * It consists of a number of pages that are used as a ringbuffer. Each data
54 * blob is stored in a simple record that consists of an integer, which
55 * contains the size of the following data, and the data bytes themselfes.
56 *
57 * To allow for multiple independent readers we create one internal buffer
58 * each time the device is opened and destroy the buffer when the file is
59 * closed again.
60 *
61 * One record can be written to a buffer by using the functions
62 * - dasd_eer_start_record (one time per record to write the size to the buffer
63 * and reserve the space for the data)
64 * - dasd_eer_write_buffer (one or more times per record to write the data)
65 * The data can be written in several steps but you will have to compute
66 * the total size up front for the invocation of dasd_eer_start_record.
67 * If the ringbuffer is full, dasd_eer_start_record will remove the required
68 * number of old records.
69 *
70 * A record is typically read in two steps, first read the integer that
71 * specifies the size of the following data, then read the data.
72 * Both can be done by
73 * - dasd_eer_read_buffer
74 *
75 * For all mentioned functions you need to get the bufferlock first and keep it
76 * until a complete record is written or read.
77 */
78
79
80/*
81 * Alle information necessary to keep track of an internal buffer is kept in
82 * a struct eerbuffer. The buffer specific to a file pointer is strored in
83 * the private_data field of that file. To be able to write data to all
84 * existing buffers, each buffer is also added to the bufferlist.
85 * If the user doesn't want to read a complete record in one go, we have to
86 * keep track of the rest of the record. residual stores the number of bytes
87 * that are still to deliver. If the rest of the record is invalidated between
88 * two reads then residual will be set to -1 so that the next read will fail.
89 * All entries in the eerbuffer structure are protected with the bufferlock.
90 * To avoid races between writing to a buffer on the one side and creating
91 * and destroying buffers on the other side, the bufferlock must also be used
92 * to protect the bufferlist.
93 */
94
95struct eerbuffer {
96 struct list_head list;
97 char **buffer;
98 int buffersize;
99 int buffer_page_count;
100 int head;
101 int tail;
102 int residual;
103};
104
105LIST_HEAD(bufferlist);
106
107static spinlock_t bufferlock = SPIN_LOCK_UNLOCKED;
108
109DECLARE_WAIT_QUEUE_HEAD(dasd_eer_read_wait_queue);
110
111/*
112 * How many free bytes are available on the buffer.
113 * needs to be called with bufferlock held
114 */
115static int
116dasd_eer_get_free_bytes(struct eerbuffer *eerb)
117{
118 if (eerb->head < eerb->tail) {
119 return eerb->tail - eerb->head - 1;
120 } else
121 return eerb->buffersize - eerb->head + eerb->tail -1;
122}
123
124/*
125 * How many bytes of buffer space are used.
126 * needs to be called with bufferlock held
127 */
128static int
129dasd_eer_get_filled_bytes(struct eerbuffer *eerb)
130{
131
132 if (eerb->head >= eerb->tail) {
133 return eerb->head - eerb->tail;
134 } else
135 return eerb->buffersize - eerb->tail + eerb->head;
136}
137
138/*
139 * The dasd_eer_write_buffer function just copies count bytes of data
140 * to the buffer. Make sure to call dasd_eer_start_record first, to
141 * make sure that enough free space is available.
142 * needs to be called with bufferlock held
143 */
144static void
145dasd_eer_write_buffer(struct eerbuffer *eerb, int count, char *data)
146{
147
148 unsigned long headindex,localhead;
149 unsigned long rest, len;
150 char *nextdata;
151
152 nextdata = data;
153 rest = count;
154 while (rest > 0) {
155 headindex = eerb->head / PAGE_SIZE;
156 localhead = eerb->head % PAGE_SIZE;
157 len = min(rest, (PAGE_SIZE - localhead));
158 memcpy(eerb->buffer[headindex]+localhead, nextdata, len);
159 nextdata += len;
160 rest -= len;
161 eerb->head += len;
162 if ( eerb->head == eerb->buffersize )
163 eerb->head = 0; /* wrap around */
164 if (eerb->head > eerb->buffersize) {
165 MESSAGE(KERN_ERR, "%s", "runaway buffer head.");
166 BUG();
167 }
168 }
169}
170
171/*
172 * needs to be called with bufferlock held
173 */
174static int
175dasd_eer_read_buffer(struct eerbuffer *eerb, int count, char *data)
176{
177
178 unsigned long tailindex,localtail;
179 unsigned long rest, len, finalcount;
180 char *nextdata;
181
182 finalcount = min(count, dasd_eer_get_filled_bytes(eerb));
183 nextdata = data;
184 rest = finalcount;
185 while (rest > 0) {
186 tailindex = eerb->tail / PAGE_SIZE;
187 localtail = eerb->tail % PAGE_SIZE;
188 len = min(rest, (PAGE_SIZE - localtail));
189 memcpy(nextdata, eerb->buffer[tailindex]+localtail, len);
190 nextdata += len;
191 rest -= len;
192 eerb->tail += len;
193 if ( eerb->tail == eerb->buffersize )
194 eerb->tail = 0; /* wrap around */
195 if (eerb->tail > eerb->buffersize) {
196 MESSAGE(KERN_ERR, "%s", "runaway buffer tail.");
197 BUG();
198 }
199 }
200 return finalcount;
201}
202
203/*
204 * Whenever you want to write a blob of data to the internal buffer you
205 * have to start by using this function first. It will write the number
206 * of bytes that will be written to the buffer. If necessary it will remove
207 * old records to make room for the new one.
208 * needs to be called with bufferlock held
209 */
210static int
211dasd_eer_start_record(struct eerbuffer *eerb, int count)
212{
213 int tailcount;
214 if (count + sizeof(count) > eerb->buffersize)
215 return -ENOMEM;
216 while (dasd_eer_get_free_bytes(eerb) < count + sizeof(count)) {
217 if (eerb->residual > 0) {
218 eerb->tail += eerb->residual;
219 if (eerb->tail >= eerb->buffersize)
220 eerb->tail -= eerb->buffersize;
221 eerb->residual = -1;
222 }
223 dasd_eer_read_buffer(eerb, sizeof(tailcount),
224 (char*)(&tailcount));
225 eerb->tail += tailcount;
226 if (eerb->tail >= eerb->buffersize)
227 eerb->tail -= eerb->buffersize;
228 }
229 dasd_eer_write_buffer(eerb, sizeof(count), (char*)(&count));
230
231 return 0;
232};
233
234/*
235 * release pages that are not used anymore
236 */
237static void
238dasd_eer_free_buffer_pages(char **buf, int no_pages)
239{
240 int i;
241
242 for (i = 0; i < no_pages; ++i) {
243 free_page((unsigned long)buf[i]);
244 }
245}
246
247/*
248 * allocate a new set of memory pages
249 */
250static int
251dasd_eer_allocate_buffer_pages(char **buf, int no_pages)
252{
253 int i;
254
255 for (i = 0; i < no_pages; ++i) {
256 buf[i] = (char *) get_zeroed_page(GFP_KERNEL);
257 if (!buf[i]) {
258 dasd_eer_free_buffer_pages(buf, i);
259 return -ENOMEM;
260 }
261 }
262 return 0;
263}
264
265/*
266 * empty the buffer by resetting head and tail
267 * In case there is a half read data blob in the buffer, we set residual
268 * to -1 to indicate that the remainder of the blob is lost.
269 */
270static void
271dasd_eer_purge_buffer(struct eerbuffer *eerb)
272{
273 unsigned long flags;
274
275 spin_lock_irqsave(&bufferlock, flags);
276 if (eerb->residual > 0)
277 eerb->residual = -1;
278 eerb->tail=0;
279 eerb->head=0;
280 spin_unlock_irqrestore(&bufferlock, flags);
281}
282
283/*
284 * set the size of the buffer, newsize is the new number of pages to be used
285 * we don't try to copy any data back an forth, so any resize will also purge
286 * the buffer
287 */
288static int
289dasd_eer_resize_buffer(struct eerbuffer *eerb, int newsize)
290{
291 int i, oldcount, reuse;
292 char **new;
293 char **old;
294 unsigned long flags;
295
296 if (newsize < 1)
297 return -EINVAL;
298 if (eerb->buffer_page_count == newsize) {
299 /* documented behaviour is that any successfull invocation
300 * will purge all records */
301 dasd_eer_purge_buffer(eerb);
302 return 0;
303 }
304 new = kmalloc(newsize*sizeof(char*), GFP_KERNEL);
305 if (!new)
306 return -ENOMEM;
307
308 reuse=min(eerb->buffer_page_count, newsize);
309 for (i = 0; i < reuse; ++i) {
310 new[i] = eerb->buffer[i];
311 }
312 if (eerb->buffer_page_count < newsize) {
313 if (dasd_eer_allocate_buffer_pages(
314 &new[eerb->buffer_page_count],
315 newsize - eerb->buffer_page_count)) {
316 kfree(new);
317 return -ENOMEM;
318 }
319 }
320
321 spin_lock_irqsave(&bufferlock, flags);
322 old = eerb->buffer;
323 eerb->buffer = new;
324 if (eerb->residual > 0)
325 eerb->residual = -1;
326 eerb->tail = 0;
327 eerb->head = 0;
328 oldcount = eerb->buffer_page_count;
329 eerb->buffer_page_count = newsize;
330 spin_unlock_irqrestore(&bufferlock, flags);
331
332 if (oldcount > newsize) {
333 for (i = newsize; i < oldcount; ++i) {
334 free_page((unsigned long)old[i]);
335 }
336 }
337 kfree(old);
338
339 return 0;
340}
341
342
343/*****************************************************************************/
344/* The extended error reporting functionality */
345/*****************************************************************************/
346
347/*
348 * When a DASD device driver wants to report an error, it calls the
349 * function dasd_eer_write_trigger (via a notifier mechanism) and gives the
350 * respective trigger ID as parameter.
351 * Currently there are four kinds of triggers:
352 *
353 * DASD_EER_FATALERROR: all kinds of unrecoverable I/O problems
354 * DASD_EER_PPRCSUSPEND: PPRC was suspended
355 * DASD_EER_NOPATH: There is no path to the device left.
356 * DASD_EER_STATECHANGE: The state of the device has changed.
357 *
358 * For the first three triggers all required information can be supplied by
359 * the caller. For these triggers a record is written by the function
360 * dasd_eer_write_standard_trigger.
361 *
362 * When dasd_eer_write_trigger is called to write a DASD_EER_STATECHANGE
363 * trigger, we have to gather the necessary sense data first. We cannot queue
364 * the necessary SNSS (sense subsystem status) request immediatly, since we
365 * are likely to run in a deadlock situation. Instead, we schedule a
366 * work_struct that calls the function dasd_eer_sense_subsystem_status to
367 * create and start an SNSS request asynchronously.
368 *
369 * To avoid memory allocations at runtime, the necessary memory is allocated
370 * when the extended error reporting is enabled for a device (by
371 * dasd_eer_probe). There is one private eer data structure for each eer
372 * enabled DASD device. It contains memory for the work_struct, one SNSS cqr
373 * and a flags field that is used to coordinate the use of the cqr. The call
374 * to write a state change trigger can come in at any time, so we have one flag
375 * CQR_IN_USE that protects the cqr itself. When this flag indicates that the
376 * cqr is currently in use, dasd_eer_sense_subsystem_status cannot start a
377 * second request but sets the SNSS_REQUESTED flag instead.
378 *
379 * When the request is finished, the callback function dasd_eer_SNSS_cb
380 * is called. This function will invoke the function
381 * dasd_eer_write_SNSS_trigger to finally write the trigger. It will also
382 * check the SNSS_REQUESTED flag and if it is set it will call
383 * dasd_eer_sense_subsystem_status again.
384 *
385 * To avoid race conditions during the handling of the lock, the flags must
386 * be protected by the snsslock.
387 */
388
389struct dasd_eer_private {
390 struct dasd_ccw_req *cqr;
391 unsigned long flags;
392 struct work_struct worker;
393};
394
395static void dasd_eer_destroy(struct dasd_device *device,
396 struct dasd_eer_private *eer);
397static int
398dasd_eer_write_trigger(struct dasd_eer_trigger *trigger);
399static void dasd_eer_sense_subsystem_status(void *data);
400static int dasd_eer_notify(struct notifier_block *self,
401 unsigned long action, void *data);
402
403struct workqueue_struct *dasd_eer_workqueue;
404
405#define SNSS_DATA_SIZE 44
406static spinlock_t snsslock = SPIN_LOCK_UNLOCKED;
407
408#define DASD_EER_BUSID_SIZE 10
409struct dasd_eer_header {
410 __u32 total_size;
411 __u32 trigger;
412 __u64 tv_sec;
413 __u64 tv_usec;
414 char busid[DASD_EER_BUSID_SIZE];
415} __attribute__ ((packed));
416
417static struct notifier_block dasd_eer_nb = {
418 .notifier_call = dasd_eer_notify,
419};
420
421/*
422 * flags for use with dasd_eer_private
423 */
424#define CQR_IN_USE 0
425#define SNSS_REQUESTED 1
426
427/*
428 * This function checks if extended error reporting is available for a given
429 * dasd_device. If yes, then it creates and returns a struct dasd_eer,
430 * otherwise it returns an -EPERM error pointer.
431 */
432struct dasd_eer_private *
433dasd_eer_probe(struct dasd_device *device)
434{
435 struct dasd_eer_private *private;
436
437 if (!(device && device->discipline
438 && !strcmp(device->discipline->name, "ECKD"))) {
439 return ERR_PTR(-EPERM);
440 }
441 /* allocate the private data structure */
442 private = (struct dasd_eer_private *)kmalloc(
443 sizeof(struct dasd_eer_private), GFP_KERNEL);
444 if (!private) {
445 return ERR_PTR(-ENOMEM);
446 }
447 INIT_WORK(&private->worker, dasd_eer_sense_subsystem_status,
448 (void *)device);
449 private->cqr = dasd_kmalloc_request("ECKD",
450 1 /* SNSS */ ,
451 SNSS_DATA_SIZE ,
452 device);
453 if (!private->cqr) {
454 kfree(private);
455 return ERR_PTR(-ENOMEM);
456 }
457 private->flags = 0;
458 return private;
459};
460
461/*
462 * If our private SNSS request is queued, remove it from the
463 * dasd ccw queue so we can free the requests memory.
464 */
465static void
466dasd_eer_dequeue_SNSS_request(struct dasd_device *device,
467 struct dasd_eer_private *eer)
468{
469 struct list_head *lst, *nxt;
470 struct dasd_ccw_req *cqr, *erpcqr;
471 dasd_erp_fn_t erp_fn;
472
473 spin_lock_irq(get_ccwdev_lock(device->cdev));
474 list_for_each_safe(lst, nxt, &device->ccw_queue) {
475 cqr = list_entry(lst, struct dasd_ccw_req, list);
476 /* we are looking for two kinds or requests */
477 /* first kind: our SNSS request: */
478 if (cqr == eer->cqr) {
479 if (cqr->status == DASD_CQR_IN_IO)
480 device->discipline->term_IO(cqr);
481 list_del(&cqr->list);
482 break;
483 }
484 /* second kind: ERP requests for our SNSS request */
485 if (cqr->refers) {
486 /* If this erp request chain ends in our cqr, then */
487 /* cal the erp_postaction to clean it up */
488 erpcqr = cqr;
489 while (erpcqr->refers) {
490 erpcqr = erpcqr->refers;
491 }
492 if (erpcqr == eer->cqr) {
493 erp_fn = device->discipline->erp_postaction(
494 cqr);
495 erp_fn(cqr);
496 }
497 continue;
498 }
499 }
500 spin_unlock_irq(get_ccwdev_lock(device->cdev));
501}
502
503/*
504 * This function dismantles a struct dasd_eer that was created by
505 * dasd_eer_probe. Since we want to free our private data structure,
506 * we must make sure that the memory is not in use anymore.
507 * We have to flush the work queue and remove a possible SNSS request
508 * from the dasd queue.
509 */
510static void
511dasd_eer_destroy(struct dasd_device *device, struct dasd_eer_private *eer)
512{
513 flush_workqueue(dasd_eer_workqueue);
514 dasd_eer_dequeue_SNSS_request(device, eer);
515 dasd_kfree_request(eer->cqr, device);
516 kfree(eer);
517};
518
519/*
520 * enable the extended error reporting for a particular device
521 */
522static int
523dasd_eer_enable_on_device(struct dasd_device *device)
524{
525 void *eer;
526 if (!device)
527 return -ENODEV;
528 if (device->eer)
529 return 0;
530 if (!try_module_get(THIS_MODULE)) {
531 return -EINVAL;
532 }
533 eer = (void *)dasd_eer_probe(device);
534 if (IS_ERR(eer)) {
535 module_put(THIS_MODULE);
536 return PTR_ERR(eer);
537 }
538 device->eer = eer;
539 return 0;
540}
541
542/*
543 * enable the extended error reporting for a particular device
544 */
545static int
546dasd_eer_disable_on_device(struct dasd_device *device)
547{
548 struct dasd_eer_private *eer = device->eer;
549
550 if (!device)
551 return -ENODEV;
552 if (!device->eer)
553 return 0;
554 device->eer = NULL;
555 dasd_eer_destroy(device,eer);
556 module_put(THIS_MODULE);
557
558 return 0;
559}
560
561/*
562 * Set extended error reporting (eer)
563 * Note: This will be registered as a DASD ioctl, to be called on DASD devices.
564 */
565static int
566dasd_ioctl_set_eer(struct block_device *bdev, int no, long args)
567{
568 struct dasd_device *device;
569 int intval;
570
571 if (!capable(CAP_SYS_ADMIN))
572 return -EACCES;
573 if (bdev != bdev->bd_contains)
574 /* Error-reporting is not allowed for partitions */
575 return -EINVAL;
576 if (get_user(intval, (int __user *) args))
577 return -EFAULT;
578 device = bdev->bd_disk->private_data;
579 if (device == NULL)
580 return -ENODEV;
581
582 intval = (intval != 0);
583 DEV_MESSAGE (KERN_DEBUG, device,
584 "set eer on device to %d", intval);
585 if (intval)
586 return dasd_eer_enable_on_device(device);
587 else
588 return dasd_eer_disable_on_device(device);
589}
590
591/*
592 * Get value of extended error reporting.
593 * Note: This will be registered as a DASD ioctl, to be called on DASD devices.
594 */
595static int
596dasd_ioctl_get_eer(struct block_device *bdev, int no, long args)
597{
598 struct dasd_device *device;
599
600 device = bdev->bd_disk->private_data;
601 if (device == NULL)
602 return -ENODEV;
603 return put_user((device->eer != NULL), (int __user *) args);
604}
605
606/*
607 * The following function can be used for those triggers that have
608 * all necessary data available when the function is called.
609 * If the parameter cqr is not NULL, the chain of requests will be searched
610 * for valid sense data, and all valid sense data sets will be added to
611 * the triggers data.
612 */
613static int
614dasd_eer_write_standard_trigger(int trigger, struct dasd_device *device,
615 struct dasd_ccw_req *cqr)
616{
617 struct dasd_ccw_req *temp_cqr;
618 int data_size;
619 struct timeval tv;
620 struct dasd_eer_header header;
621 unsigned long flags;
622 struct eerbuffer *eerb;
623
624 /* go through cqr chain and count the valid sense data sets */
625 temp_cqr = cqr;
626 data_size = 0;
627 while (temp_cqr) {
628 if (temp_cqr->irb.esw.esw0.erw.cons)
629 data_size += 32;
630 temp_cqr = temp_cqr->refers;
631 }
632
633 header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
634 header.trigger = trigger;
635 do_gettimeofday(&tv);
636 header.tv_sec = tv.tv_sec;
637 header.tv_usec = tv.tv_usec;
638 strncpy(header.busid, device->cdev->dev.bus_id, DASD_EER_BUSID_SIZE);
639
640 spin_lock_irqsave(&bufferlock, flags);
641 list_for_each_entry(eerb, &bufferlist, list) {
642 dasd_eer_start_record(eerb, header.total_size);
643 dasd_eer_write_buffer(eerb, sizeof(header), (char*)(&header));
644 temp_cqr = cqr;
645 while (temp_cqr) {
646 if (temp_cqr->irb.esw.esw0.erw.cons)
647 dasd_eer_write_buffer(eerb, 32, cqr->irb.ecw);
648 temp_cqr = temp_cqr->refers;
649 }
650 dasd_eer_write_buffer(eerb, 4,"EOR");
651 }
652 spin_unlock_irqrestore(&bufferlock, flags);
653
654 wake_up_interruptible(&dasd_eer_read_wait_queue);
655
656 return 0;
657}
658
659/*
660 * This function writes a DASD_EER_STATECHANGE trigger.
661 */
662static void
663dasd_eer_write_SNSS_trigger(struct dasd_device *device,
664 struct dasd_ccw_req *cqr)
665{
666 int data_size;
667 int snss_rc;
668 struct timeval tv;
669 struct dasd_eer_header header;
670 unsigned long flags;
671 struct eerbuffer *eerb;
672
673 snss_rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
674 if (snss_rc)
675 data_size = 0;
676 else
677 data_size = SNSS_DATA_SIZE;
678
679 header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
680 header.trigger = DASD_EER_STATECHANGE;
681 do_gettimeofday(&tv);
682 header.tv_sec = tv.tv_sec;
683 header.tv_usec = tv.tv_usec;
684 strncpy(header.busid, device->cdev->dev.bus_id, DASD_EER_BUSID_SIZE);
685
686 spin_lock_irqsave(&bufferlock, flags);
687 list_for_each_entry(eerb, &bufferlist, list) {
688 dasd_eer_start_record(eerb, header.total_size);
689 dasd_eer_write_buffer(eerb, sizeof(header),(char*)(&header));
690 if (!snss_rc)
691 dasd_eer_write_buffer(eerb, SNSS_DATA_SIZE, cqr->data);
692 dasd_eer_write_buffer(eerb, 4,"EOR");
693 }
694 spin_unlock_irqrestore(&bufferlock, flags);
695
696 wake_up_interruptible(&dasd_eer_read_wait_queue);
697}
698
699/*
700 * callback function for use with SNSS request
701 */
702static void
703dasd_eer_SNSS_cb(struct dasd_ccw_req *cqr, void *data)
704{
705 struct dasd_device *device;
706 struct dasd_eer_private *private;
707 unsigned long irqflags;
708
709 device = (struct dasd_device *)data;
710 private = (struct dasd_eer_private *)device->eer;
711 dasd_eer_write_SNSS_trigger(device, cqr);
712 spin_lock_irqsave(&snsslock, irqflags);
713 if(!test_and_clear_bit(SNSS_REQUESTED, &private->flags)) {
714 clear_bit(CQR_IN_USE, &private->flags);
715 spin_unlock_irqrestore(&snsslock, irqflags);
716 return;
717 };
718 clear_bit(CQR_IN_USE, &private->flags);
719 spin_unlock_irqrestore(&snsslock, irqflags);
720 dasd_eer_sense_subsystem_status(device);
721 return;
722}
723
724/*
725 * clean a used cqr before using it again
726 */
727static void
728dasd_eer_clean_SNSS_request(struct dasd_ccw_req *cqr)
729{
730 struct ccw1 *cpaddr = cqr->cpaddr;
731 void *data = cqr->data;
732
733 memset(cqr, 0, sizeof(struct dasd_ccw_req));
734 memset(cpaddr, 0, sizeof(struct ccw1));
735 memset(data, 0, SNSS_DATA_SIZE);
736 cqr->cpaddr = cpaddr;
737 cqr->data = data;
738 strncpy((char *) &cqr->magic, "ECKD", 4);
739 ASCEBC((char *) &cqr->magic, 4);
740 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
741}
742
743/*
744 * build and start an SNSS request
745 * This function is called from a work queue so we have to
746 * pass the dasd_device pointer as a void pointer.
747 */
748static void
749dasd_eer_sense_subsystem_status(void *data)
750{
751 struct dasd_device *device;
752 struct dasd_eer_private *private;
753 struct dasd_ccw_req *cqr;
754 struct ccw1 *ccw;
755 unsigned long irqflags;
756
757 device = (struct dasd_device *)data;
758 private = (struct dasd_eer_private *)device->eer;
759 if (!private) /* device not eer enabled any more */
760 return;
761 cqr = private->cqr;
762 spin_lock_irqsave(&snsslock, irqflags);
763 if(test_and_set_bit(CQR_IN_USE, &private->flags)) {
764 set_bit(SNSS_REQUESTED, &private->flags);
765 spin_unlock_irqrestore(&snsslock, irqflags);
766 return;
767 };
768 spin_unlock_irqrestore(&snsslock, irqflags);
769 dasd_eer_clean_SNSS_request(cqr);
770 cqr->device = device;
771 cqr->retries = 255;
772 cqr->expires = 10 * HZ;
773
774 ccw = cqr->cpaddr;
775 ccw->cmd_code = DASD_ECKD_CCW_SNSS;
776 ccw->count = SNSS_DATA_SIZE;
777 ccw->flags = 0;
778 ccw->cda = (__u32)(addr_t)cqr->data;
779
780 cqr->buildclk = get_clock();
781 cqr->status = DASD_CQR_FILLED;
782 cqr->callback = dasd_eer_SNSS_cb;
783 cqr->callback_data = (void *)device;
784 dasd_add_request_head(cqr);
785
786 return;
787}
788
789/*
790 * This function is called for all triggers. It calls the appropriate
791 * function that writes the actual trigger records.
792 */
793static int
794dasd_eer_write_trigger(struct dasd_eer_trigger *trigger)
795{
796 int rc;
797 struct dasd_eer_private *private = trigger->device->eer;
798
799 switch (trigger->id) {
800 case DASD_EER_FATALERROR:
801 case DASD_EER_PPRCSUSPEND:
802 rc = dasd_eer_write_standard_trigger(
803 trigger->id, trigger->device, trigger->cqr);
804 break;
805 case DASD_EER_NOPATH:
806 rc = dasd_eer_write_standard_trigger(
807 trigger->id, trigger->device, NULL);
808 break;
809 case DASD_EER_STATECHANGE:
810 if (queue_work(dasd_eer_workqueue, &private->worker)) {
811 rc=0;
812 } else {
813 /* If the work_struct was already queued, it can't
814 * be queued again. But this is OK since we don't
815 * need to have it queued twice.
816 */
817 rc = -EBUSY;
818 }
819 break;
820 default: /* unknown trigger, so we write it without any sense data */
821 rc = dasd_eer_write_standard_trigger(
822 trigger->id, trigger->device, NULL);
823 break;
824 }
825 return rc;
826}
827
828/*
829 * This function is registered with the dasd device driver and gets called
830 * for all dasd eer notifications.
831 */
832static int dasd_eer_notify(struct notifier_block *self,
833 unsigned long action, void *data)
834{
835 switch (action) {
836 case DASD_EER_DISABLE:
837 dasd_eer_disable_on_device((struct dasd_device *)data);
838 break;
839 case DASD_EER_TRIGGER:
840 dasd_eer_write_trigger((struct dasd_eer_trigger *)data);
841 break;
842 }
843 return NOTIFY_OK;
844}
845
846
847/*****************************************************************************/
848/* the device operations */
849/*****************************************************************************/
850
851/*
852 * On the one side we need a lock to access our internal buffer, on the
853 * other side a copy_to_user can sleep. So we need to copy the data we have
854 * to transfer in a readbuffer, which is protected by the readbuffer_mutex.
855 */
856static char readbuffer[PAGE_SIZE];
857DECLARE_MUTEX(readbuffer_mutex);
858
859
860static int
861dasd_eer_open(struct inode *inp, struct file *filp)
862{
863 struct eerbuffer *eerb;
864 unsigned long flags;
865
866 eerb = kmalloc(sizeof(struct eerbuffer), GFP_KERNEL);
867 eerb->head = 0;
868 eerb->tail = 0;
869 eerb->residual = 0;
870 eerb->buffer_page_count = 1;
871 eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE;
872 eerb->buffer = kmalloc(eerb->buffer_page_count*sizeof(char*),
873 GFP_KERNEL);
874 if (!eerb->buffer)
875 return -ENOMEM;
876 if (dasd_eer_allocate_buffer_pages(eerb->buffer,
877 eerb->buffer_page_count)) {
878 kfree(eerb->buffer);
879 return -ENOMEM;
880 }
881 filp->private_data = eerb;
882 spin_lock_irqsave(&bufferlock, flags);
883 list_add(&eerb->list, &bufferlist);
884 spin_unlock_irqrestore(&bufferlock, flags);
885
886 return nonseekable_open(inp,filp);
887}
888
889static int
890dasd_eer_close(struct inode *inp, struct file *filp)
891{
892 struct eerbuffer *eerb;
893 unsigned long flags;
894
895 eerb = (struct eerbuffer *)filp->private_data;
896 spin_lock_irqsave(&bufferlock, flags);
897 list_del(&eerb->list);
898 spin_unlock_irqrestore(&bufferlock, flags);
899 dasd_eer_free_buffer_pages(eerb->buffer, eerb->buffer_page_count);
900 kfree(eerb->buffer);
901 kfree(eerb);
902
903 return 0;
904}
905
906static long
907dasd_eer_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
908{
909 int intval;
910 struct eerbuffer *eerb;
911
912 eerb = (struct eerbuffer *)filp->private_data;
913 switch (cmd) {
914 case DASD_EER_PURGE:
915 dasd_eer_purge_buffer(eerb);
916 return 0;
917 case DASD_EER_SETBUFSIZE:
918 if (get_user(intval, (int __user *)arg))
919 return -EFAULT;
920 return dasd_eer_resize_buffer(eerb, intval);
921 default:
922 return -ENOIOCTLCMD;
923 }
924}
925
926static ssize_t
927dasd_eer_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
928{
929 int tc,rc;
930 int tailcount,effective_count;
931 unsigned long flags;
932 struct eerbuffer *eerb;
933
934 eerb = (struct eerbuffer *)filp->private_data;
935 if(down_interruptible(&readbuffer_mutex))
936 return -ERESTARTSYS;
937
938 spin_lock_irqsave(&bufferlock, flags);
939
940 if (eerb->residual < 0) { /* the remainder of this record */
941 /* has been deleted */
942 eerb->residual = 0;
943 spin_unlock_irqrestore(&bufferlock, flags);
944 up(&readbuffer_mutex);
945 return -EIO;
946 } else if (eerb->residual > 0) {
947 /* OK we still have a second half of a record to deliver */
948 effective_count = min(eerb->residual, (int)count);
949 eerb->residual -= effective_count;
950 } else {
951 tc = 0;
952 while (!tc) {
953 tc = dasd_eer_read_buffer(eerb,
954 sizeof(tailcount), (char*)(&tailcount));
955 if (!tc) {
956 /* no data available */
957 spin_unlock_irqrestore(&bufferlock, flags);
958 up(&readbuffer_mutex);
959 if (filp->f_flags & O_NONBLOCK)
960 return -EAGAIN;
961 rc = wait_event_interruptible(
962 dasd_eer_read_wait_queue,
963 eerb->head != eerb->tail);
964 if (rc) {
965 return rc;
966 }
967 if(down_interruptible(&readbuffer_mutex))
968 return -ERESTARTSYS;
969 spin_lock_irqsave(&bufferlock, flags);
970 }
971 }
972 WARN_ON(tc != sizeof(tailcount));
973 effective_count = min(tailcount,(int)count);
974 eerb->residual = tailcount - effective_count;
975 }
976
977 tc = dasd_eer_read_buffer(eerb, effective_count, readbuffer);
978 WARN_ON(tc != effective_count);
979
980 spin_unlock_irqrestore(&bufferlock, flags);
981
982 if (copy_to_user(buf, readbuffer, effective_count)) {
983 up(&readbuffer_mutex);
984 return -EFAULT;
985 }
986
987 up(&readbuffer_mutex);
988 return effective_count;
989}
990
991static unsigned int
992dasd_eer_poll (struct file *filp, poll_table *ptable)
993{
994 unsigned int mask;
995 unsigned long flags;
996 struct eerbuffer *eerb;
997
998 eerb = (struct eerbuffer *)filp->private_data;
999 poll_wait(filp, &dasd_eer_read_wait_queue, ptable);
1000 spin_lock_irqsave(&bufferlock, flags);
1001 if (eerb->head != eerb->tail)
1002 mask = POLLIN | POLLRDNORM ;
1003 else
1004 mask = 0;
1005 spin_unlock_irqrestore(&bufferlock, flags);
1006 return mask;
1007}
1008
1009static struct file_operations dasd_eer_fops = {
1010 .open = &dasd_eer_open,
1011 .release = &dasd_eer_close,
1012 .unlocked_ioctl = &dasd_eer_ioctl,
1013 .compat_ioctl = &dasd_eer_ioctl,
1014 .read = &dasd_eer_read,
1015 .poll = &dasd_eer_poll,
1016 .owner = THIS_MODULE,
1017};
1018
1019static struct miscdevice dasd_eer_dev = {
1020 .minor = MISC_DYNAMIC_MINOR,
1021 .name = "dasd_eer",
1022 .fops = &dasd_eer_fops,
1023};
1024
1025
1026/*****************************************************************************/
1027/* Init and exit */
1028/*****************************************************************************/
1029
1030static int
1031__init dasd_eer_init(void)
1032{
1033 int rc;
1034
1035 dasd_eer_workqueue = create_singlethread_workqueue("dasd_eer");
1036 if (!dasd_eer_workqueue) {
1037 MESSAGE(KERN_ERR , "%s", "dasd_eer_init could not "
1038 "create workqueue \n");
1039 rc = -ENOMEM;
1040 goto out;
1041 }
1042
1043 rc = dasd_register_eer_notifier(&dasd_eer_nb);
1044 if (rc) {
1045 MESSAGE(KERN_ERR, "%s", "dasd_eer_init could not "
1046 "register error reporting");
1047 goto queue;
1048 }
1049
1050 dasd_ioctl_no_register(THIS_MODULE, BIODASDEERSET, dasd_ioctl_set_eer);
1051 dasd_ioctl_no_register(THIS_MODULE, BIODASDEERGET, dasd_ioctl_get_eer);
1052
1053 /* we don't need our own character device,
1054 * so we just register as misc device */
1055 rc = misc_register(&dasd_eer_dev);
1056 if (rc) {
1057 MESSAGE(KERN_ERR, "%s", "dasd_eer_init could not "
1058 "register misc device");
1059 goto unregister;
1060 }
1061
1062 return 0;
1063
1064unregister:
1065 dasd_unregister_eer_notifier(&dasd_eer_nb);
1066 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERSET,
1067 dasd_ioctl_set_eer);
1068 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERGET,
1069 dasd_ioctl_get_eer);
1070queue:
1071 destroy_workqueue(dasd_eer_workqueue);
1072out:
1073 return rc;
1074
1075}
1076module_init(dasd_eer_init);
1077
1078static void
1079__exit dasd_eer_exit(void)
1080{
1081 dasd_unregister_eer_notifier(&dasd_eer_nb);
1082 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERSET,
1083 dasd_ioctl_set_eer);
1084 dasd_ioctl_no_unregister(THIS_MODULE, BIODASDEERGET,
1085 dasd_ioctl_get_eer);
1086 destroy_workqueue(dasd_eer_workqueue);
1087
1088 WARN_ON(misc_deregister(&dasd_eer_dev) != 0);
1089}
1090module_exit(dasd_eer_exit);
diff --git a/drivers/s390/block/dasd_erp.c b/drivers/s390/block/dasd_erp.c
index 7cb98d25f341..8fd71ab02ef0 100644
--- a/drivers/s390/block/dasd_erp.c
+++ b/drivers/s390/block/dasd_erp.c
@@ -7,7 +7,6 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.14 $
11 */ 10 */
12 11
13#include <linux/config.h> 12#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index 8ec75dc08e2c..91145698f8e9 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -4,7 +4,6 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
6 * 6 *
7 * $Revision: 1.41 $
8 */ 7 */
9 8
10#include <linux/config.h> 9#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_fba.h b/drivers/s390/block/dasd_fba.h
index 624f0402ee22..da1fa91fc01d 100644
--- a/drivers/s390/block/dasd_fba.h
+++ b/drivers/s390/block/dasd_fba.h
@@ -4,7 +4,6 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
6 * 6 *
7 * $Revision: 1.6 $
8 */ 7 */
9 8
10#ifndef DASD_FBA_H 9#ifndef DASD_FBA_H
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index a601c9a33541..65dc844b975c 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -9,7 +9,6 @@
9 * 9 *
10 * gendisk related functions for the dasd driver. 10 * gendisk related functions for the dasd driver.
11 * 11 *
12 * $Revision: 1.51 $
13 */ 12 */
14 13
15#include <linux/config.h> 14#include <linux/config.h>
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index e4b401500b01..d1b08fa13fd2 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -6,7 +6,6 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.68 $
10 */ 9 */
11 10
12#ifndef DASD_INT_H 11#ifndef DASD_INT_H
@@ -276,6 +275,34 @@ struct dasd_discipline {
276 275
277extern struct dasd_discipline *dasd_diag_discipline_pointer; 276extern struct dasd_discipline *dasd_diag_discipline_pointer;
278 277
278
279/*
280 * Notification numbers for extended error reporting notifications:
281 * The DASD_EER_DISABLE notification is sent before a dasd_device (and it's
282 * eer pointer) is freed. The error reporting module needs to do all necessary
283 * cleanup steps.
284 * The DASD_EER_TRIGGER notification sends the actual error reports (triggers).
285 */
286#define DASD_EER_DISABLE 0
287#define DASD_EER_TRIGGER 1
288
289/* Trigger IDs for extended error reporting DASD_EER_TRIGGER notification */
290#define DASD_EER_FATALERROR 1
291#define DASD_EER_NOPATH 2
292#define DASD_EER_STATECHANGE 3
293#define DASD_EER_PPRCSUSPEND 4
294
295/*
296 * The dasd_eer_trigger structure contains all data that we need to send
297 * along with an DASD_EER_TRIGGER notification.
298 */
299struct dasd_eer_trigger {
300 unsigned int id;
301 struct dasd_device *device;
302 struct dasd_ccw_req *cqr;
303};
304
305
279struct dasd_device { 306struct dasd_device {
280 /* Block device stuff. */ 307 /* Block device stuff. */
281 struct gendisk *gdp; 308 struct gendisk *gdp;
@@ -289,6 +316,9 @@ struct dasd_device {
289 unsigned long flags; /* per device flags */ 316 unsigned long flags; /* per device flags */
290 unsigned short features; /* copy of devmap-features (read-only!) */ 317 unsigned short features; /* copy of devmap-features (read-only!) */
291 318
319 /* extended error reporting stuff (eer) */
320 void *eer;
321
292 /* Device discipline stuff. */ 322 /* Device discipline stuff. */
293 struct dasd_discipline *discipline; 323 struct dasd_discipline *discipline;
294 char *private; 324 char *private;
@@ -489,6 +519,12 @@ int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *);
489int dasd_generic_set_offline (struct ccw_device *cdev); 519int dasd_generic_set_offline (struct ccw_device *cdev);
490int dasd_generic_notify(struct ccw_device *, int); 520int dasd_generic_notify(struct ccw_device *, int);
491void dasd_generic_auto_online (struct ccw_driver *); 521void dasd_generic_auto_online (struct ccw_driver *);
522int dasd_register_eer_notifier(struct notifier_block *);
523int dasd_unregister_eer_notifier(struct notifier_block *);
524void dasd_write_eer_trigger(unsigned int , struct dasd_device *,
525 struct dasd_ccw_req *);
526
527
492 528
493/* externals in dasd_devmap.c */ 529/* externals in dasd_devmap.c */
494extern int dasd_max_devindex; 530extern int dasd_max_devindex;
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index 9396fcacb8f8..fafeeae52675 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -7,8 +7,6 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.50 $
11 *
12 * i/o controls for the dasd driver. 10 * i/o controls for the dasd driver.
13 */ 11 */
14#include <linux/config.h> 12#include <linux/config.h>
@@ -423,8 +421,15 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
423 dasd_info->cu_model = cdev->id.cu_model; 421 dasd_info->cu_model = cdev->id.cu_model;
424 dasd_info->dev_type = cdev->id.dev_type; 422 dasd_info->dev_type = cdev->id.dev_type;
425 dasd_info->dev_model = cdev->id.dev_model; 423 dasd_info->dev_model = cdev->id.dev_model;
426 dasd_info->open_count = atomic_read(&device->open_count);
427 dasd_info->status = device->state; 424 dasd_info->status = device->state;
425 /*
426 * The open_count is increased for every opener, that includes
427 * the blkdev_get in dasd_scan_partitions.
428 * This must be hidden from user-space.
429 */
430 dasd_info->open_count = atomic_read(&device->open_count);
431 if (!device->bdev)
432 dasd_info->open_count++;
428 433
429 /* 434 /*
430 * check if device is really formatted 435 * check if device is really formatted
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index fff9020d4886..2d5da3c75ca7 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -9,7 +9,6 @@
9 * 9 *
10 * /proc interface for the dasd driver. 10 * /proc interface for the dasd driver.
11 * 11 *
12 * $Revision: 1.33 $
13 */ 12 */
14 13
15#include <linux/config.h> 14#include <linux/config.h>
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 1f060914cfa4..606f6ad285a0 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -21,6 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/console.h> 22#include <linux/console.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/err.h>
24 25
25#include <linux/slab.h> 26#include <linux/slab.h>
26#include <linux/bootmem.h> 27#include <linux/bootmem.h>
@@ -864,7 +865,7 @@ con3215_init(void)
864 } 865 }
865 866
866 cdev = ccw_device_probe_console(); 867 cdev = ccw_device_probe_console();
867 if (!cdev) 868 if (IS_ERR(cdev))
868 return -ENODEV; 869 return -ENODEV;
869 870
870 raw3215[0] = raw = (struct raw3215_info *) 871 raw3215[0] = raw = (struct raw3215_info *)
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
index c570a9f6ce9c..ef607a1de55a 100644
--- a/drivers/s390/char/con3270.c
+++ b/drivers/s390/char/con3270.c
@@ -15,6 +15,7 @@
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/err.h>
18 19
19#include <asm/ccwdev.h> 20#include <asm/ccwdev.h>
20#include <asm/cio.h> 21#include <asm/cio.h>
@@ -597,7 +598,7 @@ con3270_init(void)
597 } 598 }
598 599
599 cdev = ccw_device_probe_console(); 600 cdev = ccw_device_probe_console();
600 if (!cdev) 601 if (IS_ERR(cdev))
601 return -ENODEV; 602 return -ENODEV;
602 rp = raw3270_setup_console(cdev); 603 rp = raw3270_setup_console(cdev);
603 if (IS_ERR(rp)) 604 if (IS_ERR(rp))
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c
index 5bda2340a39d..a317a123daba 100644
--- a/drivers/s390/char/keyboard.c
+++ b/drivers/s390/char/keyboard.c
@@ -440,7 +440,11 @@ do_kdgkb_ioctl(struct kbd_data *kbd, struct kbsentry __user *u_kbs,
440 return -EPERM; 440 return -EPERM;
441 len = strnlen_user(u_kbs->kb_string, 441 len = strnlen_user(u_kbs->kb_string,
442 sizeof(u_kbs->kb_string) - 1); 442 sizeof(u_kbs->kb_string) - 1);
443 p = kmalloc(len, GFP_KERNEL); 443 if (!len)
444 return -EFAULT;
445 if (len > sizeof(u_kbs->kb_string) - 1)
446 return -EINVAL;
447 p = kmalloc(len + 1, GFP_KERNEL);
444 if (!p) 448 if (!p)
445 return -ENOMEM; 449 return -ENOMEM;
446 if (copy_from_user(p, u_kbs->kb_string, len)) { 450 if (copy_from_user(p, u_kbs->kb_string, len)) {
diff --git a/drivers/s390/char/tape_34xx.c b/drivers/s390/char/tape_34xx.c
index 20be88e91fa1..682039cac15b 100644
--- a/drivers/s390/char/tape_34xx.c
+++ b/drivers/s390/char/tape_34xx.c
@@ -1357,7 +1357,7 @@ tape_34xx_init (void)
1357 debug_set_level(TAPE_DBF_AREA, 6); 1357 debug_set_level(TAPE_DBF_AREA, 6);
1358#endif 1358#endif
1359 1359
1360 DBF_EVENT(3, "34xx init: $Revision: 1.23 $\n"); 1360 DBF_EVENT(3, "34xx init\n");
1361 /* Register driver for 3480/3490 tapes. */ 1361 /* Register driver for 3480/3490 tapes. */
1362 rc = ccw_driver_register(&tape_34xx_driver); 1362 rc = ccw_driver_register(&tape_34xx_driver);
1363 if (rc) 1363 if (rc)
@@ -1377,8 +1377,7 @@ tape_34xx_exit(void)
1377 1377
1378MODULE_DEVICE_TABLE(ccw, tape_34xx_ids); 1378MODULE_DEVICE_TABLE(ccw, tape_34xx_ids);
1379MODULE_AUTHOR("(C) 2001-2002 IBM Deutschland Entwicklung GmbH"); 1379MODULE_AUTHOR("(C) 2001-2002 IBM Deutschland Entwicklung GmbH");
1380MODULE_DESCRIPTION("Linux on zSeries channel attached 3480 tape " 1380MODULE_DESCRIPTION("Linux on zSeries channel attached 3480 tape device driver");
1381 "device driver ($Revision: 1.23 $)");
1382MODULE_LICENSE("GPL"); 1381MODULE_LICENSE("GPL");
1383 1382
1384module_init(tape_34xx_init); 1383module_init(tape_34xx_init);
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index fcaee447d6fe..b3569c82bb16 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * (C) Copyright IBM Corp. 2004 2 * (C) Copyright IBM Corp. 2004
3 * tape_class.c ($Revision: 1.8 $) 3 * tape_class.c
4 * 4 *
5 * Tape class device support 5 * Tape class device support
6 * 6 *
@@ -12,7 +12,7 @@
12MODULE_AUTHOR("Stefan Bader <shbader@de.ibm.com>"); 12MODULE_AUTHOR("Stefan Bader <shbader@de.ibm.com>");
13MODULE_DESCRIPTION( 13MODULE_DESCRIPTION(
14 "(C) Copyright IBM Corp. 2004 All Rights Reserved.\n" 14 "(C) Copyright IBM Corp. 2004 All Rights Reserved.\n"
15 "tape_class.c ($Revision: 1.8 $)" 15 "tape_class.c"
16); 16);
17MODULE_LICENSE("GPL"); 17MODULE_LICENSE("GPL");
18 18
diff --git a/drivers/s390/char/tape_class.h b/drivers/s390/char/tape_class.h
index 33133ad00ba2..3d0ca054cdee 100644
--- a/drivers/s390/char/tape_class.h
+++ b/drivers/s390/char/tape_class.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * (C) Copyright IBM Corp. 2004 All Rights Reserved. 2 * (C) Copyright IBM Corp. 2004 All Rights Reserved.
3 * tape_class.h ($Revision: 1.4 $) 3 * tape_class.h
4 * 4 *
5 * Tape class device support 5 * Tape class device support
6 * 6 *
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 8f486e1a8507..4ea438c749c9 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -1239,7 +1239,7 @@ tape_init (void)
1239#ifdef DBF_LIKE_HELL 1239#ifdef DBF_LIKE_HELL
1240 debug_set_level(TAPE_DBF_AREA, 6); 1240 debug_set_level(TAPE_DBF_AREA, 6);
1241#endif 1241#endif
1242 DBF_EVENT(3, "tape init: ($Revision: 1.54 $)\n"); 1242 DBF_EVENT(3, "tape init\n");
1243 tape_proc_init(); 1243 tape_proc_init();
1244 tapechar_init (); 1244 tapechar_init ();
1245 tapeblock_init (); 1245 tapeblock_init ();
@@ -1263,8 +1263,7 @@ tape_exit(void)
1263 1263
1264MODULE_AUTHOR("(C) 2001 IBM Deutschland Entwicklung GmbH by Carsten Otte and " 1264MODULE_AUTHOR("(C) 2001 IBM Deutschland Entwicklung GmbH by Carsten Otte and "
1265 "Michael Holzheu (cotte@de.ibm.com,holzheu@de.ibm.com)"); 1265 "Michael Holzheu (cotte@de.ibm.com,holzheu@de.ibm.com)");
1266MODULE_DESCRIPTION("Linux on zSeries channel attached " 1266MODULE_DESCRIPTION("Linux on zSeries channel attached tape device driver");
1267 "tape device driver ($Revision: 1.54 $)");
1268MODULE_LICENSE("GPL"); 1267MODULE_LICENSE("GPL");
1269 1268
1270module_init(tape_init); 1269module_init(tape_init);
diff --git a/drivers/s390/cio/airq.c b/drivers/s390/cio/airq.c
index cd2cc28e16a7..5287631fbfc8 100644
--- a/drivers/s390/cio/airq.c
+++ b/drivers/s390/cio/airq.c
@@ -2,8 +2,6 @@
2 * drivers/s390/cio/airq.c 2 * drivers/s390/cio/airq.c
3 * S/390 common I/O routines -- support for adapter interruptions 3 * S/390 common I/O routines -- support for adapter interruptions
4 * 4 *
5 * $Revision: 1.15 $
6 *
7 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
8 * IBM Corporation 6 * IBM Corporation
9 * Author(s): Ingo Adlung (adlung@de.ibm.com) 7 * Author(s): Ingo Adlung (adlung@de.ibm.com)
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index 72f27c151c09..cb8e2e672b68 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/blacklist.c 2 * drivers/s390/cio/blacklist.c
3 * S/390 common I/O routines -- blacklisting of specific devices 3 * S/390 common I/O routines -- blacklisting of specific devices
4 * $Revision: 1.42 $
5 * 4 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 6c077ad71edc..8013c8eb76fe 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/ccwgroup.c 2 * drivers/s390/cio/ccwgroup.c
3 * bus driver for ccwgroup 3 * bus driver for ccwgroup
4 * $Revision: 1.35 $
5 * 4 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 2cbb724791a8..92be75d99a56 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/chsc.c 2 * drivers/s390/cio/chsc.c
3 * S/390 common I/O routines -- channel subsystem call 3 * S/390 common I/O routines -- channel subsystem call
4 * $Revision: 1.128 $
5 * 4 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/cio/chsc.h b/drivers/s390/cio/chsc.h
index 44e4b4bb1c5a..3e75095f35d0 100644
--- a/drivers/s390/cio/chsc.h
+++ b/drivers/s390/cio/chsc.h
@@ -68,6 +68,6 @@ extern void *chsc_get_chp_desc(struct subchannel*, int);
68 68
69extern int chsc_enable_facility(int); 69extern int chsc_enable_facility(int);
70 70
71#define to_channelpath(dev) container_of(dev, struct channel_path, dev) 71#define to_channelpath(device) container_of(device, struct channel_path, dev)
72 72
73#endif 73#endif
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 6223b06d27d5..cbb86fa5f293 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/cio.c 2 * drivers/s390/cio/cio.c
3 * S/390 common I/O routines -- low level i/o calls 3 * S/390 common I/O routines -- low level i/o calls
4 * $Revision: 1.140 $
5 * 4 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 0b03714e696a..07ef3f640f4a 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/s390/cio/cmf.c ($Revision: 1.19 $) 2 * linux/drivers/s390/cio/cmf.c
3 * 3 *
4 * Linux on zSeries Channel Measurement Facility support 4 * Linux on zSeries Channel Measurement Facility support
5 * 5 *
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 516108779f60..1bbf231f8aaf 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/css.c 2 * drivers/s390/cio/css.c
3 * driver for channel subsystem 3 * driver for channel subsystem
4 * $Revision: 1.96 $
5 * 4 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index a67e7e60e330..062fb100d94c 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/device.c 2 * drivers/s390/cio/device.c
3 * bus driver for ccw devices 3 * bus driver for ccw devices
4 * $Revision: 1.140 $
5 * 4 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
@@ -255,7 +254,7 @@ modalias_show (struct device *dev, struct device_attribute *attr, char *buf)
255 struct ccw_device_id *id = &(cdev->id); 254 struct ccw_device_id *id = &(cdev->id);
256 int ret; 255 int ret;
257 256
258 ret = sprintf(buf, "ccw:t%04Xm%02x", 257 ret = sprintf(buf, "ccw:t%04Xm%02X",
259 id->cu_type, id->cu_model); 258 id->cu_type, id->cu_model);
260 if (id->dev_type != 0) 259 if (id->dev_type != 0)
261 ret += sprintf(buf + ret, "dt%04Xdm%02X\n", 260 ret += sprintf(buf + ret, "dt%04Xdm%02X\n",
@@ -1013,7 +1012,7 @@ ccw_device_probe_console(void)
1013 int ret; 1012 int ret;
1014 1013
1015 if (xchg(&console_cdev_in_use, 1) != 0) 1014 if (xchg(&console_cdev_in_use, 1) != 0)
1016 return NULL; 1015 return ERR_PTR(-EBUSY);
1017 sch = cio_probe_console(); 1016 sch = cio_probe_console();
1018 if (IS_ERR(sch)) { 1017 if (IS_ERR(sch)) {
1019 console_cdev_in_use = 0; 1018 console_cdev_in_use = 0;
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 8b0218949b62..3a50b1903287 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * drivers/s390/cio/device_ops.c 2 * drivers/s390/cio/device_ops.c
3 * 3 *
4 * $Revision: 1.61 $
5 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 4 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 5 * IBM Corporation
8 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 77be2c39bfe4..45ce032772f4 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -56,8 +56,6 @@
56#include "ioasm.h" 56#include "ioasm.h"
57#include "chsc.h" 57#include "chsc.h"
58 58
59#define VERSION_QDIO_C "$Revision: 1.117 $"
60
61/****************** MODULE PARAMETER VARIABLES ********************/ 59/****************** MODULE PARAMETER VARIABLES ********************/
62MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>"); 60MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
63MODULE_DESCRIPTION("QDIO base support version 2, " \ 61MODULE_DESCRIPTION("QDIO base support version 2, " \
@@ -66,8 +64,7 @@ MODULE_LICENSE("GPL");
66 64
67/******************** HERE WE GO ***********************************/ 65/******************** HERE WE GO ***********************************/
68 66
69static const char version[] = "QDIO base support version 2 (" 67static const char version[] = "QDIO base support version 2";
70 VERSION_QDIO_C "/" VERSION_QDIO_H "/" VERSION_CIO_QDIO_H ")";
71 68
72#ifdef QDIO_PERFORMANCE_STATS 69#ifdef QDIO_PERFORMANCE_STATS
73static int proc_perf_file_registration; 70static int proc_perf_file_registration;
diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
index fa385e761fe1..ceb3ab31ee08 100644
--- a/drivers/s390/cio/qdio.h
+++ b/drivers/s390/cio/qdio.h
@@ -5,8 +5,6 @@
5 5
6#include "schid.h" 6#include "schid.h"
7 7
8#define VERSION_CIO_QDIO_H "$Revision: 1.40 $"
9
10#ifdef CONFIG_QDIO_DEBUG 8#ifdef CONFIG_QDIO_DEBUG
11#define QDIO_VERBOSE_LEVEL 9 9#define QDIO_VERBOSE_LEVEL 9
12#else /* CONFIG_QDIO_DEBUG */ 10#else /* CONFIG_QDIO_DEBUG */
diff --git a/drivers/s390/crypto/z90common.h b/drivers/s390/crypto/z90common.h
index f87c785f2039..dbbcda3c846a 100644
--- a/drivers/s390/crypto/z90common.h
+++ b/drivers/s390/crypto/z90common.h
@@ -27,8 +27,6 @@
27#ifndef _Z90COMMON_H_ 27#ifndef _Z90COMMON_H_
28#define _Z90COMMON_H_ 28#define _Z90COMMON_H_
29 29
30#define VERSION_Z90COMMON_H "$Revision: 1.17 $"
31
32 30
33#define RESPBUFFSIZE 256 31#define RESPBUFFSIZE 256
34#define PCI_FUNC_KEY_DECRYPT 0x5044 32#define PCI_FUNC_KEY_DECRYPT 0x5044
diff --git a/drivers/s390/crypto/z90crypt.h b/drivers/s390/crypto/z90crypt.h
index 3a18443fdfa7..5e6b1f535f62 100644
--- a/drivers/s390/crypto/z90crypt.h
+++ b/drivers/s390/crypto/z90crypt.h
@@ -29,8 +29,6 @@
29 29
30#include <linux/ioctl.h> 30#include <linux/ioctl.h>
31 31
32#define VERSION_Z90CRYPT_H "$Revision: 1.2.2.4 $"
33
34#define z90crypt_VERSION 1 32#define z90crypt_VERSION 1
35#define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards 33#define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards
36#define z90crypt_VARIANT 3 // 3 = CEX2A support 34#define z90crypt_VARIANT 3 // 3 = CEX2A support
diff --git a/drivers/s390/crypto/z90hardware.c b/drivers/s390/crypto/z90hardware.c
index d7f7494a0cbe..4141919da805 100644
--- a/drivers/s390/crypto/z90hardware.c
+++ b/drivers/s390/crypto/z90hardware.c
@@ -32,12 +32,6 @@
32#include "z90crypt.h" 32#include "z90crypt.h"
33#include "z90common.h" 33#include "z90common.h"
34 34
35#define VERSION_Z90HARDWARE_C "$Revision: 1.34 $"
36
37char z90hardware_version[] __initdata =
38 "z90hardware.o (" VERSION_Z90HARDWARE_C "/"
39 VERSION_Z90COMMON_H "/" VERSION_Z90CRYPT_H ")";
40
41struct cca_token_hdr { 35struct cca_token_hdr {
42 unsigned char token_identifier; 36 unsigned char token_identifier;
43 unsigned char version; 37 unsigned char version;
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index 2f54d033d7cf..7d6f19030ef9 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -38,14 +38,6 @@
38#include "z90crypt.h" 38#include "z90crypt.h"
39#include "z90common.h" 39#include "z90common.h"
40 40
41#define VERSION_Z90MAIN_C "$Revision: 1.62 $"
42
43static char z90main_version[] __initdata =
44 "z90main.o (" VERSION_Z90MAIN_C "/"
45 VERSION_Z90COMMON_H "/" VERSION_Z90CRYPT_H ")";
46
47extern char z90hardware_version[];
48
49/** 41/**
50 * Defaults that may be modified. 42 * Defaults that may be modified.
51 */ 43 */
@@ -594,8 +586,6 @@ z90crypt_init_module(void)
594 PRINTKN("Version %d.%d.%d loaded, built on %s %s\n", 586 PRINTKN("Version %d.%d.%d loaded, built on %s %s\n",
595 z90crypt_VERSION, z90crypt_RELEASE, z90crypt_VARIANT, 587 z90crypt_VERSION, z90crypt_RELEASE, z90crypt_VARIANT,
596 __DATE__, __TIME__); 588 __DATE__, __TIME__);
597 PRINTKN("%s\n", z90main_version);
598 PRINTKN("%s\n", z90hardware_version);
599 PDEBUG("create_z90crypt (domain index %d) successful.\n", 589 PDEBUG("create_z90crypt (domain index %d) successful.\n",
600 domain); 590 domain);
601 } else 591 } else
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index e70af7f39946..a86436a7a606 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -2,8 +2,6 @@
2 * drivers/s390/net/claw.c 2 * drivers/s390/net/claw.c
3 * ESCON CLAW network driver 3 * ESCON CLAW network driver
4 * 4 *
5 * $Revision: 1.38 $ $Date: 2005/08/29 09:47:04 $
6 *
7 * Linux for zSeries version 5 * Linux for zSeries version
8 * Copyright (C) 2002,2005 IBM Corporation 6 * Copyright (C) 2002,2005 IBM Corporation
9 * Author(s) Original code written by: 7 * Author(s) Original code written by:
@@ -4391,14 +4389,7 @@ static int __init
4391claw_init(void) 4389claw_init(void)
4392{ 4390{
4393 int ret = 0; 4391 int ret = 0;
4394 printk(KERN_INFO "claw: starting driver " 4392 printk(KERN_INFO "claw: starting driver\n");
4395#ifdef MODULE
4396 "module "
4397#else
4398 "compiled into kernel "
4399#endif
4400 " $Revision: 1.38 $ $Date: 2005/08/29 09:47:04 $ \n");
4401
4402 4393
4403#ifdef FUNCTRACE 4394#ifdef FUNCTRACE
4404 printk(KERN_INFO "claw: %s() enter \n",__FUNCTION__); 4395 printk(KERN_INFO "claw: %s() enter \n",__FUNCTION__);
diff --git a/drivers/s390/net/claw.h b/drivers/s390/net/claw.h
index 3df71970f601..969be465309c 100644
--- a/drivers/s390/net/claw.h
+++ b/drivers/s390/net/claw.h
@@ -2,7 +2,7 @@
2* Define constants * 2* Define constants *
3* * 3* *
4********************************************************/ 4********************************************************/
5#define VERSION_CLAW_H "$Revision: 1.6 $" 5
6/*-----------------------------------------------------* 6/*-----------------------------------------------------*
7* CCW command codes for CLAW protocol * 7* CCW command codes for CLAW protocol *
8*------------------------------------------------------*/ 8*------------------------------------------------------*/
diff --git a/drivers/s390/net/ctcdbug.c b/drivers/s390/net/ctcdbug.c
index 0e2a8bb93032..e6e72deb36b5 100644
--- a/drivers/s390/net/ctcdbug.c
+++ b/drivers/s390/net/ctcdbug.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/ctcdbug.c ($Revision: 1.6 $) 3 * linux/drivers/s390/net/ctcdbug.c
4 * 4 *
5 * CTC / ESCON network driver - s390 dbf exploit. 5 * CTC / ESCON network driver - s390 dbf exploit.
6 * 6 *
@@ -9,8 +9,6 @@
9 * Author(s): Original Code written by 9 * Author(s): Original Code written by
10 * Peter Tiedemann (ptiedem@de.ibm.com) 10 * Peter Tiedemann (ptiedem@de.ibm.com)
11 * 11 *
12 * $Revision: 1.6 $ $Date: 2005/05/11 08:10:17 $
13 *
14 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option) 14 * the Free Software Foundation; either version 2, or (at your option)
@@ -80,4 +78,3 @@ ctc_register_dbf_views(void)
80 return 0; 78 return 0;
81} 79}
82 80
83
diff --git a/drivers/s390/net/ctcdbug.h b/drivers/s390/net/ctcdbug.h
index 7d6afa1627c3..413925ee23d1 100644
--- a/drivers/s390/net/ctcdbug.h
+++ b/drivers/s390/net/ctcdbug.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/ctcdbug.h ($Revision: 1.6 $) 3 * linux/drivers/s390/net/ctcdbug.h
4 * 4 *
5 * CTC / ESCON network driver - s390 dbf exploit. 5 * CTC / ESCON network driver - s390 dbf exploit.
6 * 6 *
@@ -9,8 +9,6 @@
9 * Author(s): Original Code written by 9 * Author(s): Original Code written by
10 * Peter Tiedemann (ptiedem@de.ibm.com) 10 * Peter Tiedemann (ptiedem@de.ibm.com)
11 * 11 *
12 * $Revision: 1.6 $ $Date: 2005/05/11 08:10:17 $
13 *
14 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option) 14 * the Free Software Foundation; either version 2, or (at your option)
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
index 1901feef07d9..af9f212314b3 100644
--- a/drivers/s390/net/ctcmain.c
+++ b/drivers/s390/net/ctcmain.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ctcmain.c,v 1.79 2006/01/11 11:32:18 cohuck Exp $
3 *
4 * CTC / ESCON network driver 2 * CTC / ESCON network driver
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
@@ -37,8 +35,6 @@
37 * along with this program; if not, write to the Free Software 35 * along with this program; if not, write to the Free Software
38 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 36 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
39 * 37 *
40 * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.79 $
41 *
42 */ 38 */
43#undef DEBUG 39#undef DEBUG
44#include <linux/module.h> 40#include <linux/module.h>
@@ -248,22 +244,11 @@ static void
248print_banner(void) 244print_banner(void)
249{ 245{
250 static int printed = 0; 246 static int printed = 0;
251 char vbuf[] = "$Revision: 1.79 $";
252 char *version = vbuf;
253 247
254 if (printed) 248 if (printed)
255 return; 249 return;
256 if ((version = strchr(version, ':'))) { 250
257 char *p = strchr(version + 1, '$'); 251 printk(KERN_INFO "CTC driver initialized\n");
258 if (p)
259 *p = '\0';
260 } else
261 version = " ??? ";
262 printk(KERN_INFO "CTC driver Version%s"
263#ifdef DEBUG
264 " (DEBUG-VERSION, " __DATE__ __TIME__ ")"
265#endif
266 " initialized\n", version);
267 printed = 1; 252 printed = 1;
268} 253}
269 254
diff --git a/drivers/s390/net/ctcmain.h b/drivers/s390/net/ctcmain.h
index ba3605f16335..d2e835c0c134 100644
--- a/drivers/s390/net/ctcmain.h
+++ b/drivers/s390/net/ctcmain.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ctcmain.h,v 1.4 2005/03/24 09:04:17 mschwide Exp $
3 *
4 * CTC / ESCON network driver 2 * CTC / ESCON network driver
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
@@ -29,8 +27,6 @@
29 * along with this program; if not, write to the Free Software 27 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 * 29 *
32 * RELEASE-TAG: CTC/ESCON network driver $Revision: 1.4 $
33 *
34 */ 30 */
35 31
36#ifndef _CTCMAIN_H_ 32#ifndef _CTCMAIN_H_
diff --git a/drivers/s390/net/ctctty.c b/drivers/s390/net/ctctty.c
index 93d1725eb79b..5cdcdbf92962 100644
--- a/drivers/s390/net/ctctty.c
+++ b/drivers/s390/net/ctctty.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ctctty.c,v 1.29 2005/04/05 08:50:44 mschwide Exp $
3 *
4 * CTC / ESCON network driver, tty interface. 2 * CTC / ESCON network driver, tty interface.
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
diff --git a/drivers/s390/net/ctctty.h b/drivers/s390/net/ctctty.h
index 84b2f8f23ab3..7254dc006311 100644
--- a/drivers/s390/net/ctctty.h
+++ b/drivers/s390/net/ctctty.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ctctty.h,v 1.4 2003/09/18 08:01:10 mschwide Exp $
3 *
4 * CTC / ESCON network driver, tty interface. 2 * CTC / ESCON network driver, tty interface.
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
diff --git a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c
index 2014fb7a4881..b12533104c1f 100644
--- a/drivers/s390/net/cu3088.c
+++ b/drivers/s390/net/cu3088.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: cu3088.c,v 1.38 2006/01/12 14:33:09 cohuck Exp $
3 *
4 * CTC / LCS ccw_device driver 2 * CTC / LCS ccw_device driver
5 * 3 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
diff --git a/drivers/s390/net/fsm.c b/drivers/s390/net/fsm.c
index 24029bd9c7d0..6caf5fa6a3b5 100644
--- a/drivers/s390/net/fsm.c
+++ b/drivers/s390/net/fsm.c
@@ -1,6 +1,4 @@
1/** 1/**
2 * $Id: fsm.c,v 1.6 2003/10/15 11:37:29 mschwide Exp $
3 *
4 * A generic FSM based on fsm used in isdn4linux 2 * A generic FSM based on fsm used in isdn4linux
5 * 3 *
6 */ 4 */
diff --git a/drivers/s390/net/fsm.h b/drivers/s390/net/fsm.h
index 5b98253be7aa..af679c10f1bd 100644
--- a/drivers/s390/net/fsm.h
+++ b/drivers/s390/net/fsm.h
@@ -1,5 +1,3 @@
1/* $Id: fsm.h,v 1.1.1.1 2002/03/13 19:33:09 mschwide Exp $
2 */
3#ifndef _FSM_H_ 1#ifndef _FSM_H_
4#define _FSM_H_ 2#define _FSM_H_
5 3
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
index ea8177392564..760e77ec5a11 100644
--- a/drivers/s390/net/iucv.c
+++ b/drivers/s390/net/iucv.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: iucv.c,v 1.47 2005/11/21 11:35:22 mschwide Exp $
3 *
4 * IUCV network driver 2 * IUCV network driver
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
@@ -29,8 +27,6 @@
29 * along with this program; if not, write to the Free Software 27 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 * 29 *
32 * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.47 $
33 *
34 */ 30 */
35 31
36/* #define DEBUG */ 32/* #define DEBUG */
@@ -355,17 +351,7 @@ do { \
355static void 351static void
356iucv_banner(void) 352iucv_banner(void)
357{ 353{
358 char vbuf[] = "$Revision: 1.47 $"; 354 printk(KERN_INFO "IUCV lowlevel driver initialized\n");
359 char *version = vbuf;
360
361 if ((version = strchr(version, ':'))) {
362 char *p = strchr(version + 1, '$');
363 if (p)
364 *p = '\0';
365 } else
366 version = " ??? ";
367 printk(KERN_INFO
368 "IUCV lowlevel driver Version%s initialized\n", version);
369} 355}
370 356
371/** 357/**
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index da8c515743e8..6229ba4995ad 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -11,8 +11,6 @@
11 * Frank Pavlic (fpavlic@de.ibm.com) and 11 * Frank Pavlic (fpavlic@de.ibm.com) and
12 * Martin Schwidefsky <schwidefsky@de.ibm.com> 12 * Martin Schwidefsky <schwidefsky@de.ibm.com>
13 * 13 *
14 * $Revision: 1.99 $ $Date: 2005/05/11 08:10:17 $
15 *
16 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by 15 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2, or (at your option) 16 * the Free Software Foundation; either version 2, or (at your option)
@@ -59,9 +57,8 @@
59/** 57/**
60 * initialization string for output 58 * initialization string for output
61 */ 59 */
62#define VERSION_LCS_C "$Revision: 1.99 $"
63 60
64static char version[] __initdata = "LCS driver ("VERSION_LCS_C "/" VERSION_LCS_H ")"; 61static char version[] __initdata = "LCS driver";
65static char debug_buffer[255]; 62static char debug_buffer[255];
66 63
67/** 64/**
diff --git a/drivers/s390/net/lcs.h b/drivers/s390/net/lcs.h
index a7f348ef1b08..08e60ad43916 100644
--- a/drivers/s390/net/lcs.h
+++ b/drivers/s390/net/lcs.h
@@ -6,8 +6,6 @@
6#include <linux/workqueue.h> 6#include <linux/workqueue.h>
7#include <asm/ccwdev.h> 7#include <asm/ccwdev.h>
8 8
9#define VERSION_LCS_H "$Revision: 1.19 $"
10
11#define LCS_DBF_TEXT(level, name, text) \ 9#define LCS_DBF_TEXT(level, name, text) \
12 do { \ 10 do { \
13 debug_text_event(lcs_dbf_##name, level, text); \ 11 debug_text_event(lcs_dbf_##name, level, text); \
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index ac4c4b83fe17..71d3853e8682 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: netiucv.c,v 1.69 2006/01/12 14:33:09 cohuck Exp $
3 *
4 * IUCV network driver 2 * IUCV network driver
5 * 3 *
6 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation 4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
@@ -31,8 +29,6 @@
31 * along with this program; if not, write to the Free Software 29 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 * 31 *
34 * RELEASE-TAG: IUCV network driver $Revision: 1.69 $
35 *
36 */ 32 */
37 33
38#undef DEBUG 34#undef DEBUG
@@ -2077,16 +2073,7 @@ DRIVER_ATTR(remove, 0200, NULL, remove_write);
2077static void 2073static void
2078netiucv_banner(void) 2074netiucv_banner(void)
2079{ 2075{
2080 char vbuf[] = "$Revision: 1.69 $"; 2076 PRINT_INFO("NETIUCV driver initialized\n");
2081 char *version = vbuf;
2082
2083 if ((version = strchr(version, ':'))) {
2084 char *p = strchr(version + 1, '$');
2085 if (p)
2086 *p = '\0';
2087 } else
2088 version = " ??? ";
2089 PRINT_INFO("NETIUCV driver Version%s initialized\n", version);
2090} 2077}
2091 2078
2092static void __exit 2079static void __exit
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h
index d238c7ed103b..9a064d4727ad 100644
--- a/drivers/s390/net/qeth.h
+++ b/drivers/s390/net/qeth.h
@@ -25,8 +25,6 @@
25 25
26#include "qeth_mpc.h" 26#include "qeth_mpc.h"
27 27
28#define VERSION_QETH_H "$Revision: 1.152 $"
29
30#ifdef CONFIG_QETH_IPV6 28#ifdef CONFIG_QETH_IPV6
31#define QETH_VERSION_IPV6 ":IPv6" 29#define QETH_VERSION_IPV6 ":IPv6"
32#else 30#else
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index f94f1f25eec6..b02313127780 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_eddp.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * 2 * linux/drivers/s390/net/qeth_eddp.c
3 * linux/drivers/s390/net/qeth_eddp.c ($Revision: 1.13 $)
4 * 3 *
5 * Enhanced Device Driver Packing (EDDP) support for the qeth driver. 4 * Enhanced Device Driver Packing (EDDP) support for the qeth driver.
6 * 5 *
@@ -8,8 +7,6 @@
8 * 7 *
9 * Author(s): Thomas Spatzier <tspat@de.ibm.com> 8 * Author(s): Thomas Spatzier <tspat@de.ibm.com>
10 * 9 *
11 * $Revision: 1.13 $ $Date: 2005/05/04 20:19:18 $
12 *
13 */ 10 */
14#include <linux/config.h> 11#include <linux/config.h>
15#include <linux/errno.h> 12#include <linux/errno.h>
diff --git a/drivers/s390/net/qeth_eddp.h b/drivers/s390/net/qeth_eddp.h
index e1b51860bc57..cae9ba265056 100644
--- a/drivers/s390/net/qeth_eddp.h
+++ b/drivers/s390/net/qeth_eddp.h
@@ -1,14 +1,12 @@
1/* 1/*
2 * linux/drivers/s390/net/qeth_eddp.c ($Revision: 1.5 $) 2 * linux/drivers/s390/net/qeth_eddp.h
3 * 3 *
4 * Header file for qeth enhanced device driver pakcing. 4 * Header file for qeth enhanced device driver packing.
5 * 5 *
6 * Copyright 2004 IBM Corporation 6 * Copyright 2004 IBM Corporation
7 * 7 *
8 * Author(s): Thomas Spatzier <tspat@de.ibm.com> 8 * Author(s): Thomas Spatzier <tspat@de.ibm.com>
9 * 9 *
10 * $Revision: 1.5 $ $Date: 2005/03/24 09:04:18 $
11 *
12 */ 10 */
13#ifndef __QETH_EDDP_H__ 11#ifndef __QETH_EDDP_H__
14#define __QETH_EDDP_H__ 12#define __QETH_EDDP_H__
diff --git a/drivers/s390/net/qeth_fs.h b/drivers/s390/net/qeth_fs.h
index c0b4c8d82c45..e422b41c656e 100644
--- a/drivers/s390/net/qeth_fs.h
+++ b/drivers/s390/net/qeth_fs.h
@@ -12,11 +12,6 @@
12#ifndef __QETH_FS_H__ 12#ifndef __QETH_FS_H__
13#define __QETH_FS_H__ 13#define __QETH_FS_H__
14 14
15#define VERSION_QETH_FS_H "$Revision: 1.10 $"
16
17extern const char *VERSION_QETH_PROC_C;
18extern const char *VERSION_QETH_SYS_C;
19
20#ifdef CONFIG_PROC_FS 15#ifdef CONFIG_PROC_FS
21extern int 16extern int
22qeth_create_procfs_entries(void); 17qeth_create_procfs_entries(void);
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 97f927c01a82..410abeada6c4 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * 2 * linux/drivers/s390/net/qeth_main.c
3 * linux/drivers/s390/net/qeth_main.c ($Revision: 1.251 $)
4 * 3 *
5 * Linux on zSeries OSA Express and HiperSockets support 4 * Linux on zSeries OSA Express and HiperSockets support
6 * 5 *
@@ -12,8 +11,6 @@
12 * Frank Pavlic (fpavlic@de.ibm.com) and 11 * Frank Pavlic (fpavlic@de.ibm.com) and
13 * Thomas Spatzier <tspat@de.ibm.com> 12 * Thomas Spatzier <tspat@de.ibm.com>
14 * 13 *
15 * $Revision: 1.251 $ $Date: 2005/05/04 20:19:18 $
16 *
17 * This program is free software; you can redistribute it and/or modify 14 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by 15 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2, or (at your option) 16 * the Free Software Foundation; either version 2, or (at your option)
@@ -73,7 +70,6 @@
73#include "qeth_eddp.h" 70#include "qeth_eddp.h"
74#include "qeth_tso.h" 71#include "qeth_tso.h"
75 72
76#define VERSION_QETH_C "$Revision: 1.251 $"
77static const char *version = "qeth S/390 OSA-Express driver"; 73static const char *version = "qeth S/390 OSA-Express driver";
78 74
79/** 75/**
@@ -8626,12 +8622,7 @@ qeth_init(void)
8626{ 8622{
8627 int rc=0; 8623 int rc=0;
8628 8624
8629 PRINT_INFO("loading %s (%s/%s/%s/%s/%s/%s/%s %s %s)\n", 8625 PRINT_INFO("loading %s\n", version);
8630 version, VERSION_QETH_C, VERSION_QETH_H,
8631 VERSION_QETH_MPC_H, VERSION_QETH_MPC_C,
8632 VERSION_QETH_FS_H, VERSION_QETH_PROC_C,
8633 VERSION_QETH_SYS_C, QETH_VERSION_IPV6,
8634 QETH_VERSION_VLAN);
8635 8626
8636 INIT_LIST_HEAD(&qeth_card_list.list); 8627 INIT_LIST_HEAD(&qeth_card_list.list);
8637 INIT_LIST_HEAD(&qeth_notify_list); 8628 INIT_LIST_HEAD(&qeth_notify_list);
diff --git a/drivers/s390/net/qeth_mpc.c b/drivers/s390/net/qeth_mpc.c
index 5f8754addc14..77c83209d70e 100644
--- a/drivers/s390/net/qeth_mpc.c
+++ b/drivers/s390/net/qeth_mpc.c
@@ -11,8 +11,6 @@
11#include <asm/cio.h> 11#include <asm/cio.h>
12#include "qeth_mpc.h" 12#include "qeth_mpc.h"
13 13
14const char *VERSION_QETH_MPC_C = "$Revision: 1.13 $";
15
16unsigned char IDX_ACTIVATE_READ[]={ 14unsigned char IDX_ACTIVATE_READ[]={
17 0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00, 15 0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00,
18 0x19,0x01,0x01,0x80, 0x00,0x00,0x00,0x00, 16 0x19,0x01,0x01,0x80, 0x00,0x00,0x00,0x00,
diff --git a/drivers/s390/net/qeth_mpc.h b/drivers/s390/net/qeth_mpc.h
index 864cec5f6c62..011c41041029 100644
--- a/drivers/s390/net/qeth_mpc.h
+++ b/drivers/s390/net/qeth_mpc.h
@@ -14,10 +14,6 @@
14 14
15#include <asm/qeth.h> 15#include <asm/qeth.h>
16 16
17#define VERSION_QETH_MPC_H "$Revision: 1.46 $"
18
19extern const char *VERSION_QETH_MPC_C;
20
21#define IPA_PDU_HEADER_SIZE 0x40 17#define IPA_PDU_HEADER_SIZE 0x40
22#define QETH_IPA_PDU_LEN_TOTAL(buffer) (buffer+0x0e) 18#define QETH_IPA_PDU_LEN_TOTAL(buffer) (buffer+0x0e)
23#define QETH_IPA_PDU_LEN_PDU1(buffer) (buffer+0x26) 19#define QETH_IPA_PDU_LEN_PDU1(buffer) (buffer+0x26)
diff --git a/drivers/s390/net/qeth_proc.c b/drivers/s390/net/qeth_proc.c
index 7bf35098831e..3c6339df879d 100644
--- a/drivers/s390/net/qeth_proc.c
+++ b/drivers/s390/net/qeth_proc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/qeth_fs.c ($Revision: 1.16 $) 3 * linux/drivers/s390/net/qeth_fs.c
4 * 4 *
5 * Linux on zSeries OSA Express and HiperSockets support 5 * Linux on zSeries OSA Express and HiperSockets support
6 * This file contains code related to procfs. 6 * This file contains code related to procfs.
@@ -21,8 +21,6 @@
21#include "qeth_mpc.h" 21#include "qeth_mpc.h"
22#include "qeth_fs.h" 22#include "qeth_fs.h"
23 23
24const char *VERSION_QETH_PROC_C = "$Revision: 1.16 $";
25
26/***** /proc/qeth *****/ 24/***** /proc/qeth *****/
27#define QETH_PROCFILE_NAME "qeth" 25#define QETH_PROCFILE_NAME "qeth"
28static struct proc_dir_entry *qeth_procfile; 26static struct proc_dir_entry *qeth_procfile;
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
index 0ea185f70f75..c1831f572585 100644
--- a/drivers/s390/net/qeth_sys.c
+++ b/drivers/s390/net/qeth_sys.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.60 $) 3 * linux/drivers/s390/net/qeth_sys.c
4 * 4 *
5 * Linux on zSeries OSA Express and HiperSockets support 5 * Linux on zSeries OSA Express and HiperSockets support
6 * This file contains code related to sysfs. 6 * This file contains code related to sysfs.
@@ -20,8 +20,6 @@
20#include "qeth_mpc.h" 20#include "qeth_mpc.h"
21#include "qeth_fs.h" 21#include "qeth_fs.h"
22 22
23const char *VERSION_QETH_SYS_C = "$Revision: 1.60 $";
24
25/*****************************************************************************/ 23/*****************************************************************************/
26/* */ 24/* */
27/* /sys-fs stuff UNDER DEVELOPMENT !!! */ 25/* /sys-fs stuff UNDER DEVELOPMENT !!! */
diff --git a/drivers/s390/net/qeth_tso.h b/drivers/s390/net/qeth_tso.h
index 3c50b6f24f51..1286ddea450b 100644
--- a/drivers/s390/net/qeth_tso.h
+++ b/drivers/s390/net/qeth_tso.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/s390/net/qeth_tso.h ($Revision: 1.8 $) 2 * linux/drivers/s390/net/qeth_tso.h
3 * 3 *
4 * Header file for qeth TCP Segmentation Offload support. 4 * Header file for qeth TCP Segmentation Offload support.
5 * 5 *
@@ -7,8 +7,6 @@
7 * 7 *
8 * Author(s): Frank Pavlic <fpavlic@de.ibm.com> 8 * Author(s): Frank Pavlic <fpavlic@de.ibm.com>
9 * 9 *
10 * $Revision: 1.8 $ $Date: 2005/05/04 20:19:18 $
11 *
12 */ 10 */
13#ifndef __QETH_TSO_H__ 11#ifndef __QETH_TSO_H__
14#define __QETH_TSO_H__ 12#define __QETH_TSO_H__
diff --git a/drivers/s390/s390_rdev.c b/drivers/s390/s390_rdev.c
index 206518c7d332..e3f647169827 100644
--- a/drivers/s390/s390_rdev.c
+++ b/drivers/s390/s390_rdev.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * drivers/s390/s390_rdev.c 2 * drivers/s390/s390_rdev.c
3 * s390 root device 3 * s390 root device
4 * $Revision: 1.4 $
5 * 4 *
6 * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH, 5 * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 6 * IBM Corporation
diff --git a/drivers/s390/s390mach.h b/drivers/s390/s390mach.h
index d9ea7ed2e46e..7abb42a09ae2 100644
--- a/drivers/s390/s390mach.h
+++ b/drivers/s390/s390mach.h
@@ -90,15 +90,16 @@ struct crw {
90 90
91static inline int stcrw(struct crw *pcrw ) 91static inline int stcrw(struct crw *pcrw )
92{ 92{
93 int ccode; 93 int ccode;
94 94
95 __asm__ __volatile__( 95 __asm__ __volatile__(
96 "STCRW 0(%1)\n\t" 96 "stcrw 0(%2)\n\t"
97 "IPM %0\n\t" 97 "ipm %0\n\t"
98 "SRL %0,28\n\t" 98 "srl %0,28\n\t"
99 : "=d" (ccode) : "a" (pcrw) 99 : "=d" (ccode), "=m" (*pcrw)
100 : "cc", "1" ); 100 : "a" (pcrw)
101 return ccode; 101 : "cc" );
102 return ccode;
102} 103}
103 104
104#endif /* __s390mach */ 105#endif /* __s390mach */
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 167fef39d8a7..95b92f317b6f 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -29,8 +29,6 @@
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 */ 30 */
31 31
32#define ZFCP_AUX_REVISION "$Revision: 1.145 $"
33
34#include "zfcp_ext.h" 32#include "zfcp_ext.h"
35 33
36/* accumulated log level (module parameter) */ 34/* accumulated log level (module parameter) */
diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c
index 0fc46381fc22..241136d0c6eb 100644
--- a/drivers/s390/scsi/zfcp_ccw.c
+++ b/drivers/s390/scsi/zfcp_ccw.c
@@ -27,8 +27,6 @@
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 28 */
29 29
30#define ZFCP_CCW_C_REVISION "$Revision: 1.58 $"
31
32#include "zfcp_ext.h" 30#include "zfcp_ext.h"
33 31
34#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 95599719f8ab..4d7d47cf2394 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -23,8 +23,6 @@
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25 25
26#define ZFCP_DBF_REVISION "$Revision$"
27
28#include <asm/debug.h> 26#include <asm/debug.h>
29#include <linux/ctype.h> 27#include <linux/ctype.h>
30#include "zfcp_ext.h" 28#include "zfcp_ext.h"
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 9bb511083a26..e260d19fa717 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -34,8 +34,6 @@
34#ifndef ZFCP_DEF_H 34#ifndef ZFCP_DEF_H
35#define ZFCP_DEF_H 35#define ZFCP_DEF_H
36 36
37#define ZFCP_DEF_REVISION "$Revision: 1.111 $"
38
39/*************************** INCLUDES *****************************************/ 37/*************************** INCLUDES *****************************************/
40 38
41#include <linux/init.h> 39#include <linux/init.h>
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index c065cb836c97..da947e662031 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -31,8 +31,6 @@
31 31
32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_ERP 32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_ERP
33 33
34#define ZFCP_ERP_REVISION "$Revision: 1.86 $"
35
36#include "zfcp_ext.h" 34#include "zfcp_ext.h"
37 35
38static int zfcp_erp_adisc(struct zfcp_port *); 36static int zfcp_erp_adisc(struct zfcp_port *);
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index c3782261cb5c..c1ba7cf1b496 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -32,8 +32,6 @@
32#ifndef ZFCP_EXT_H 32#ifndef ZFCP_EXT_H
33#define ZFCP_EXT_H 33#define ZFCP_EXT_H
34 34
35#define ZFCP_EXT_REVISION "$Revision: 1.62 $"
36
37#include "zfcp_def.h" 35#include "zfcp_def.h"
38 36
39extern struct zfcp_data zfcp_data; 37extern struct zfcp_data zfcp_data;
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index cbfab09899c8..9f0cb3d820c0 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -30,8 +30,6 @@
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 */ 31 */
32 32
33#define ZFCP_FSF_C_REVISION "$Revision: 1.92 $"
34
35#include "zfcp_ext.h" 33#include "zfcp_ext.h"
36 34
37static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *); 35static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *);
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index d719f66a29a4..1c3275163c91 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -29,8 +29,6 @@
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 */ 30 */
31 31
32#define ZFCP_QDIO_C_REVISION "$Revision: 1.20 $"
33
34#include "zfcp_ext.h" 32#include "zfcp_ext.h"
35 33
36static inline void zfcp_qdio_sbal_limit(struct zfcp_fsf_req *, int); 34static inline void zfcp_qdio_sbal_limit(struct zfcp_fsf_req *, int);
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 3c2cbcccbf54..e0803757c0fa 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -31,8 +31,6 @@
31 31
32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_SCSI 32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_SCSI
33 33
34#define ZFCP_SCSI_REVISION "$Revision: 1.74 $"
35
36#include "zfcp_ext.h" 34#include "zfcp_ext.h"
37 35
38static void zfcp_scsi_slave_destroy(struct scsi_device *sdp); 36static void zfcp_scsi_slave_destroy(struct scsi_device *sdp);
diff --git a/drivers/s390/scsi/zfcp_sysfs_adapter.c b/drivers/s390/scsi/zfcp_sysfs_adapter.c
index 9f262250043a..dfc07370f412 100644
--- a/drivers/s390/scsi/zfcp_sysfs_adapter.c
+++ b/drivers/s390/scsi/zfcp_sysfs_adapter.c
@@ -27,8 +27,6 @@
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 28 */
29 29
30#define ZFCP_SYSFS_ADAPTER_C_REVISION "$Revision: 1.38 $"
31
32#include "zfcp_ext.h" 30#include "zfcp_ext.h"
33 31
34#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
diff --git a/drivers/s390/scsi/zfcp_sysfs_driver.c b/drivers/s390/scsi/zfcp_sysfs_driver.c
index 77a5e2dcc0ff..6622d55e0a45 100644
--- a/drivers/s390/scsi/zfcp_sysfs_driver.c
+++ b/drivers/s390/scsi/zfcp_sysfs_driver.c
@@ -27,8 +27,6 @@
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 28 */
29 29
30#define ZFCP_SYSFS_DRIVER_C_REVISION "$Revision: 1.17 $"
31
32#include "zfcp_ext.h" 30#include "zfcp_ext.h"
33 31
34#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 32#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
diff --git a/drivers/s390/scsi/zfcp_sysfs_port.c b/drivers/s390/scsi/zfcp_sysfs_port.c
index 3924eb38805c..f401d42db21c 100644
--- a/drivers/s390/scsi/zfcp_sysfs_port.c
+++ b/drivers/s390/scsi/zfcp_sysfs_port.c
@@ -28,8 +28,6 @@
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 29 */
30 30
31#define ZFCP_SYSFS_PORT_C_REVISION "$Revision: 1.47 $"
32
33#include "zfcp_ext.h" 31#include "zfcp_ext.h"
34 32
35#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 33#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
diff --git a/drivers/s390/scsi/zfcp_sysfs_unit.c b/drivers/s390/scsi/zfcp_sysfs_unit.c
index 2f50815f65c7..ad5dfb889bee 100644
--- a/drivers/s390/scsi/zfcp_sysfs_unit.c
+++ b/drivers/s390/scsi/zfcp_sysfs_unit.c
@@ -28,8 +28,6 @@
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 29 */
30 30
31#define ZFCP_SYSFS_UNIT_C_REVISION "$Revision: 1.30 $"
32
33#include "zfcp_ext.h" 31#include "zfcp_ext.h"
34 32
35#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG 33#define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index 19bd346951dd..a800fb51168b 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -286,6 +286,10 @@ static const struct pci_device_id ahci_pci_tbl[] = {
286 board_ahci }, /* ICH8M */ 286 board_ahci }, /* ICH8M */
287 { PCI_VENDOR_ID_INTEL, 0x282a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 287 { PCI_VENDOR_ID_INTEL, 0x282a, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
288 board_ahci }, /* ICH8M */ 288 board_ahci }, /* ICH8M */
289 { 0x197b, 0x2360, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
290 board_ahci }, /* JMicron JMB360 */
291 { 0x197b, 0x2363, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
292 board_ahci }, /* JMicron JMB363 */
289 { } /* terminate list */ 293 { } /* terminate list */
290}; 294};
291 295
@@ -802,7 +806,6 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
802 struct pci_dev *pdev = to_pci_dev(probe_ent->dev); 806 struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
803 void __iomem *mmio = probe_ent->mmio_base; 807 void __iomem *mmio = probe_ent->mmio_base;
804 u32 tmp, cap_save; 808 u32 tmp, cap_save;
805 u16 tmp16;
806 unsigned int i, j, using_dac; 809 unsigned int i, j, using_dac;
807 int rc; 810 int rc;
808 void __iomem *port_mmio; 811 void __iomem *port_mmio;
@@ -836,9 +839,13 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
836 writel(0xf, mmio + HOST_PORTS_IMPL); 839 writel(0xf, mmio + HOST_PORTS_IMPL);
837 (void) readl(mmio + HOST_PORTS_IMPL); /* flush */ 840 (void) readl(mmio + HOST_PORTS_IMPL); /* flush */
838 841
839 pci_read_config_word(pdev, 0x92, &tmp16); 842 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
840 tmp16 |= 0xf; 843 u16 tmp16;
841 pci_write_config_word(pdev, 0x92, tmp16); 844
845 pci_read_config_word(pdev, 0x92, &tmp16);
846 tmp16 |= 0xf;
847 pci_write_config_word(pdev, 0x92, tmp16);
848 }
842 849
843 hpriv->cap = readl(mmio + HOST_CAP); 850 hpriv->cap = readl(mmio + HOST_CAP);
844 hpriv->port_map = readl(mmio + HOST_PORTS_IMPL); 851 hpriv->port_map = readl(mmio + HOST_PORTS_IMPL);
@@ -1082,6 +1089,10 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1082 if (have_msi) 1089 if (have_msi)
1083 hpriv->flags |= AHCI_FLAG_MSI; 1090 hpriv->flags |= AHCI_FLAG_MSI;
1084 1091
1092 /* JMicron-specific fixup: make sure we're in AHCI mode */
1093 if (pdev->vendor == 0x197b)
1094 pci_write_config_byte(pdev, 0x41, 0xa1);
1095
1085 /* initialize adapter */ 1096 /* initialize adapter */
1086 rc = ahci_host_init(probe_ent); 1097 rc = ahci_host_init(probe_ent);
1087 if (rc) 1098 if (rc)
diff --git a/drivers/scsi/aic7xxx/Kconfig.aic79xx b/drivers/scsi/aic7xxx/Kconfig.aic79xx
index 69ed77fcb71f..7955ebe8e1e8 100644
--- a/drivers/scsi/aic7xxx/Kconfig.aic79xx
+++ b/drivers/scsi/aic7xxx/Kconfig.aic79xx
@@ -37,13 +37,13 @@ config AIC79XX_CMDS_PER_DEVICE
37config AIC79XX_RESET_DELAY_MS 37config AIC79XX_RESET_DELAY_MS
38 int "Initial bus reset delay in milli-seconds" 38 int "Initial bus reset delay in milli-seconds"
39 depends on SCSI_AIC79XX 39 depends on SCSI_AIC79XX
40 default "15000" 40 default "5000"
41 ---help--- 41 ---help---
42 The number of milliseconds to delay after an initial bus reset. 42 The number of milliseconds to delay after an initial bus reset.
43 The bus settle delay following all error recovery actions is 43 The bus settle delay following all error recovery actions is
44 dictated by the SCSI layer and is not affected by this value. 44 dictated by the SCSI layer and is not affected by this value.
45 45
46 Default: 15000 (15 seconds) 46 Default: 5000 (5 seconds)
47 47
48config AIC79XX_BUILD_FIRMWARE 48config AIC79XX_BUILD_FIRMWARE
49 bool "Build Adapter Firmware with Kernel Build" 49 bool "Build Adapter Firmware with Kernel Build"
diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h
index 2cfdbef447db..1d11f7e77564 100644
--- a/drivers/scsi/aic7xxx/aic79xx.h
+++ b/drivers/scsi/aic7xxx/aic79xx.h
@@ -37,7 +37,7 @@
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES. 38 * POSSIBILITY OF SUCH DAMAGES.
39 * 39 *
40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.h#108 $ 40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.h#109 $
41 * 41 *
42 * $FreeBSD$ 42 * $FreeBSD$
43 */ 43 */
@@ -222,6 +222,7 @@ typedef enum {
222typedef enum { 222typedef enum {
223 AHD_FENONE = 0x00000, 223 AHD_FENONE = 0x00000,
224 AHD_WIDE = 0x00001,/* Wide Channel */ 224 AHD_WIDE = 0x00001,/* Wide Channel */
225 AHD_AIC79XXB_SLOWCRC = 0x00002,/* SLOWCRC bit should be set */
225 AHD_MULTI_FUNC = 0x00100,/* Multi-Function/Channel Device */ 226 AHD_MULTI_FUNC = 0x00100,/* Multi-Function/Channel Device */
226 AHD_TARGETMODE = 0x01000,/* Has tested target mode support */ 227 AHD_TARGETMODE = 0x01000,/* Has tested target mode support */
227 AHD_MULTIROLE = 0x02000,/* Space for two roles at a time */ 228 AHD_MULTIROLE = 0x02000,/* Space for two roles at a time */
diff --git a/drivers/scsi/aic7xxx/aic79xx.reg b/drivers/scsi/aic7xxx/aic79xx.reg
index 3a3204703b15..be14e2ecb8f7 100644
--- a/drivers/scsi/aic7xxx/aic79xx.reg
+++ b/drivers/scsi/aic7xxx/aic79xx.reg
@@ -1,7 +1,7 @@
1/* 1/*
2 * Aic79xx register and scratch ram definitions. 2 * Aic79xx register and scratch ram definitions.
3 * 3 *
4 * Copyright (c) 1994-2001 Justin T. Gibbs. 4 * Copyright (c) 1994-2001, 2004 Justin T. Gibbs.
5 * Copyright (c) 2000-2002 Adaptec Inc. 5 * Copyright (c) 2000-2002 Adaptec Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -39,7 +39,7 @@
39 * 39 *
40 * $FreeBSD$ 40 * $FreeBSD$
41 */ 41 */
42VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#76 $" 42VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#77 $"
43 43
44/* 44/*
45 * This file is processed by the aic7xxx_asm utility for use in assembling 45 * This file is processed by the aic7xxx_asm utility for use in assembling
@@ -3715,8 +3715,9 @@ scratch_ram {
3715 3715
3716 SEQ_FLAGS2 { 3716 SEQ_FLAGS2 {
3717 size 1 3717 size 1
3718 field TARGET_MSG_PENDING 0x02 3718 field PENDING_MK_MESSAGE 0x01
3719 field SELECTOUT_QFROZEN 0x04 3719 field TARGET_MSG_PENDING 0x02
3720 field SELECTOUT_QFROZEN 0x04
3720 } 3721 }
3721 3722
3722 ALLOCFIFO_SCBPTR { 3723 ALLOCFIFO_SCBPTR {
@@ -3777,6 +3778,26 @@ scratch_ram {
3777 CMDSIZE_TABLE { 3778 CMDSIZE_TABLE {
3778 size 8 3779 size 8
3779 } 3780 }
3781 /*
3782 * When an SCB with the MK_MESSAGE flag is
3783 * queued to the controller, it cannot enter
3784 * the waiting for selection list until the
3785 * selections for any previously queued
3786 * commands to that target complete. During
3787 * the wait, the MK_MESSAGE SCB is queued
3788 * here.
3789 */
3790 MK_MESSAGE_SCB {
3791 size 2
3792 }
3793 /*
3794 * Saved SCSIID of MK_MESSAGE_SCB to avoid
3795 * an extra SCBPTR operation when deciding
3796 * if the MK_MESSAGE_SCB can be run.
3797 */
3798 MK_MESSAGE_SCSIID {
3799 size 1
3800 }
3780} 3801}
3781 3802
3782/************************* Hardware SCB Definition ****************************/ 3803/************************* Hardware SCB Definition ****************************/
diff --git a/drivers/scsi/aic7xxx/aic79xx.seq b/drivers/scsi/aic7xxx/aic79xx.seq
index bef1f9d369b6..58bc17591b54 100644
--- a/drivers/scsi/aic7xxx/aic79xx.seq
+++ b/drivers/scsi/aic7xxx/aic79xx.seq
@@ -1,7 +1,7 @@
1/* 1/*
2 * Adaptec U320 device driver firmware for Linux and FreeBSD. 2 * Adaptec U320 device driver firmware for Linux and FreeBSD.
3 * 3 *
4 * Copyright (c) 1994-2001 Justin T. Gibbs. 4 * Copyright (c) 1994-2001, 2004 Justin T. Gibbs.
5 * Copyright (c) 2000-2002 Adaptec Inc. 5 * Copyright (c) 2000-2002 Adaptec Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -40,7 +40,7 @@
40 * $FreeBSD$ 40 * $FreeBSD$
41 */ 41 */
42 42
43VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#119 $" 43VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#120 $"
44PATCH_ARG_LIST = "struct ahd_softc *ahd" 44PATCH_ARG_LIST = "struct ahd_softc *ahd"
45PREFIX = "ahd_" 45PREFIX = "ahd_"
46 46
@@ -110,10 +110,8 @@ check_waiting_list:
110 * one last time. 110 * one last time.
111 */ 111 */
112 test SSTAT0, SELDO jnz select_out; 112 test SSTAT0, SELDO jnz select_out;
113END_CRITICAL;
114 call start_selection; 113 call start_selection;
115idle_loop_checkbus: 114idle_loop_checkbus:
116BEGIN_CRITICAL;
117 test SSTAT0, SELDO jnz select_out; 115 test SSTAT0, SELDO jnz select_out;
118END_CRITICAL; 116END_CRITICAL;
119 test SSTAT0, SELDI jnz select_in; 117 test SSTAT0, SELDI jnz select_in;
@@ -294,7 +292,6 @@ fetch_new_scb_inprog:
294 test CCSCBCTL, ARRDONE jz return; 292 test CCSCBCTL, ARRDONE jz return;
295fetch_new_scb_done: 293fetch_new_scb_done:
296 and CCSCBCTL, ~(CCARREN|CCSCBEN); 294 and CCSCBCTL, ~(CCARREN|CCSCBEN);
297 bmov REG0, SCBPTR, 2;
298 clr A; 295 clr A;
299 add CMDS_PENDING, 1; 296 add CMDS_PENDING, 1;
300 adc CMDS_PENDING[1], A; 297 adc CMDS_PENDING[1], A;
@@ -316,43 +313,117 @@ fetch_new_scb_done:
316 clr SCB_FIFO_USE_COUNT; 313 clr SCB_FIFO_USE_COUNT;
317 /* Update the next SCB address to download. */ 314 /* Update the next SCB address to download. */
318 bmov NEXT_QUEUED_SCB_ADDR, SCB_NEXT_SCB_BUSADDR, 4; 315 bmov NEXT_QUEUED_SCB_ADDR, SCB_NEXT_SCB_BUSADDR, 4;
316 /*
317 * NULL out the SCB links since these fields
318 * occupy the same location as SCB_NEXT_SCB_BUSADDR.
319 */
319 mvi SCB_NEXT[1], SCB_LIST_NULL; 320 mvi SCB_NEXT[1], SCB_LIST_NULL;
320 mvi SCB_NEXT2[1], SCB_LIST_NULL; 321 mvi SCB_NEXT2[1], SCB_LIST_NULL;
321 /* Increment our position in the QINFIFO. */ 322 /* Increment our position in the QINFIFO. */
322 mov NONE, SNSCB_QOFF; 323 mov NONE, SNSCB_QOFF;
324
323 /* 325 /*
324 * SCBs that want to send messages are always 326 * Save SCBID of this SCB in REG0 since
325 * queued independently. This ensures that they 327 * SCBPTR will be clobbered during target
326 * are at the head of the SCB list to select out 328 * list updates. We also record the SCB's
327 * to a target and we will see the MK_MESSAGE flag. 329 * flags so that we can refer to them even
330 * after SCBPTR has been changed.
331 */
332 bmov REG0, SCBPTR, 2;
333 mov A, SCB_CONTROL;
334
335 /*
336 * Find the tail SCB of the execution queue
337 * for this target.
328 */ 338 */
329 test SCB_CONTROL, MK_MESSAGE jnz first_new_target_scb;
330 shr SINDEX, 3, SCB_SCSIID; 339 shr SINDEX, 3, SCB_SCSIID;
331 and SINDEX, ~0x1; 340 and SINDEX, ~0x1;
332 mvi SINDEX[1], (WAITING_SCB_TAILS >> 8); 341 mvi SINDEX[1], (WAITING_SCB_TAILS >> 8);
333 bmov DINDEX, SINDEX, 2; 342 bmov DINDEX, SINDEX, 2;
334 bmov SCBPTR, SINDIR, 2; 343 bmov SCBPTR, SINDIR, 2;
344
345 /*
346 * Update the tail to point to the new SCB.
347 */
335 bmov DINDIR, REG0, 2; 348 bmov DINDIR, REG0, 2;
349
350 /*
351 * If the queue was empty, queue this SCB as
352 * the first for this target.
353 */
336 cmp SCBPTR[1], SCB_LIST_NULL je first_new_target_scb; 354 cmp SCBPTR[1], SCB_LIST_NULL je first_new_target_scb;
355
356 /*
357 * SCBs that want to send messages must always be
358 * at the head of their per-target queue so that
359 * ATN can be asserted even if the current
360 * negotiation agreement is packetized. If the
361 * target queue is empty, the SCB can be queued
362 * immediately. If the queue is not empty, we must
363 * wait for it to empty before entering this SCB
364 * into the waiting for selection queue. Otherwise
365 * our batching and round-robin selection scheme
366 * could allow commands to be queued out of order.
367 * To simplify the implementation, we stop pulling
368 * new commands from the host until the MK_MESSAGE
369 * SCB can be queued to the waiting for selection
370 * list.
371 */
372 test A, MK_MESSAGE jz batch_scb;
373
374 /*
375 * If the last SCB is also a MK_MESSAGE SCB, then
376 * order is preserved even if we batch.
377 */
378 test SCB_CONTROL, MK_MESSAGE jz batch_scb;
379
380 /*
381 * Defer this SCB and stop fetching new SCBs until
382 * it can be queued. Since the SCB_SCSIID of the
383 * tail SCB must be the same as that of the newly
384 * queued SCB, there is no need to restore the SCBID
385 * here.
386 */
387 or SEQ_FLAGS2, PENDING_MK_MESSAGE;
388 bmov MK_MESSAGE_SCB, REG0, 2;
389 mov MK_MESSAGE_SCSIID, SCB_SCSIID ret;
390
391batch_scb:
392 /*
393 * Otherwise just update the previous tail SCB to
394 * point to the new tail.
395 */
337 bmov SCB_NEXT, REG0, 2 ret; 396 bmov SCB_NEXT, REG0, 2 ret;
397
338first_new_target_scb: 398first_new_target_scb:
399 /*
400 * Append SCB to the tail of the waiting for
401 * selection list.
402 */
339 cmp WAITING_TID_HEAD[1], SCB_LIST_NULL je first_new_scb; 403 cmp WAITING_TID_HEAD[1], SCB_LIST_NULL je first_new_scb;
340 bmov SCBPTR, WAITING_TID_TAIL, 2; 404 bmov SCBPTR, WAITING_TID_TAIL, 2;
341 bmov SCB_NEXT2, REG0, 2; 405 bmov SCB_NEXT2, REG0, 2;
342 bmov WAITING_TID_TAIL, REG0, 2 ret; 406 bmov WAITING_TID_TAIL, REG0, 2 ret;
343first_new_scb: 407first_new_scb:
408 /*
409 * Whole list is empty, so the head of
410 * the list must be initialized too.
411 */
344 bmov WAITING_TID_HEAD, REG0, 2; 412 bmov WAITING_TID_HEAD, REG0, 2;
345 bmov WAITING_TID_TAIL, REG0, 2 ret; 413 bmov WAITING_TID_TAIL, REG0, 2 ret;
346END_CRITICAL; 414END_CRITICAL;
347 415
348scbdma_idle: 416scbdma_idle:
349 /* 417 /*
350 * Give precedence to downloading new SCBs to execute 418 * Don't bother downloading new SCBs to execute
351 * unless select-outs are currently frozen. 419 * if select-outs are currently frozen or we have
420 * a MK_MESSAGE SCB waiting to enter the queue.
352 */ 421 */
353 test SEQ_FLAGS2, SELECTOUT_QFROZEN jnz . + 2; 422 test SEQ_FLAGS2, SELECTOUT_QFROZEN|PENDING_MK_MESSAGE
423 jnz scbdma_no_new_scbs;
354BEGIN_CRITICAL; 424BEGIN_CRITICAL;
355 test QOFF_CTLSTA, NEW_SCB_AVAIL jnz fetch_new_scb; 425 test QOFF_CTLSTA, NEW_SCB_AVAIL jnz fetch_new_scb;
426scbdma_no_new_scbs:
356 cmp COMPLETE_DMA_SCB_HEAD[1], SCB_LIST_NULL jne dma_complete_scb; 427 cmp COMPLETE_DMA_SCB_HEAD[1], SCB_LIST_NULL jne dma_complete_scb;
357 cmp COMPLETE_SCB_HEAD[1], SCB_LIST_NULL je return; 428 cmp COMPLETE_SCB_HEAD[1], SCB_LIST_NULL je return;
358 /* FALLTHROUGH */ 429 /* FALLTHROUGH */
@@ -671,27 +742,41 @@ curscb_ww_done:
671 } 742 }
672 743
673 /* 744 /*
674 * Requeue any SCBs not sent, to the tail of the waiting Q. 745 * The whole list made it. Clear our tail pointer to indicate
746 * that the per-target selection queue is now empty.
675 */ 747 */
676 cmp SCB_NEXT[1], SCB_LIST_NULL je select_out_list_done; 748 cmp SCB_NEXT[1], SCB_LIST_NULL je select_out_clear_tail;
677 749
678 /* 750 /*
751 * Requeue any SCBs not sent, to the tail of the waiting Q.
679 * We know that neither the per-TID list nor the list of 752 * We know that neither the per-TID list nor the list of
680 * TIDs is empty. Use this knowledge to our advantage. 753 * TIDs is empty. Use this knowledge to our advantage and
754 * queue the remainder to the tail of the global execution
755 * queue.
681 */ 756 */
682 bmov REG0, SCB_NEXT, 2; 757 bmov REG0, SCB_NEXT, 2;
758select_out_queue_remainder:
683 bmov SCBPTR, WAITING_TID_TAIL, 2; 759 bmov SCBPTR, WAITING_TID_TAIL, 2;
684 bmov SCB_NEXT2, REG0, 2; 760 bmov SCB_NEXT2, REG0, 2;
685 bmov WAITING_TID_TAIL, REG0, 2; 761 bmov WAITING_TID_TAIL, REG0, 2;
686 jmp select_out_inc_tid_q; 762 jmp select_out_inc_tid_q;
687 763
688select_out_list_done: 764select_out_clear_tail:
765 /*
766 * Queue any pending MK_MESSAGE SCB for this target now
767 * that the queue is empty.
768 */
769 test SEQ_FLAGS2, PENDING_MK_MESSAGE jz select_out_no_mk_message_scb;
770 mov A, MK_MESSAGE_SCSIID;
771 cmp SCB_SCSIID, A jne select_out_no_mk_message_scb;
772 and SEQ_FLAGS2, ~PENDING_MK_MESSAGE;
773 bmov REG0, MK_MESSAGE_SCB, 2;
774 jmp select_out_queue_remainder;
775
776select_out_no_mk_message_scb:
689 /* 777 /*
690 * The whole list made it. Just clear our TID's tail pointer 778 * Clear this target's execution tail and increment the queue.
691 * unless we were queued independently due to our need to
692 * send a message.
693 */ 779 */
694 test SCB_CONTROL, MK_MESSAGE jnz select_out_inc_tid_q;
695 shr DINDEX, 3, SCB_SCSIID; 780 shr DINDEX, 3, SCB_SCSIID;
696 or DINDEX, 1; /* Want only the second byte */ 781 or DINDEX, 1; /* Want only the second byte */
697 mvi DINDEX[1], ((WAITING_SCB_TAILS) >> 8); 782 mvi DINDEX[1], ((WAITING_SCB_TAILS) >> 8);
@@ -703,8 +788,8 @@ select_out_inc_tid_q:
703 mvi WAITING_TID_TAIL[1], SCB_LIST_NULL; 788 mvi WAITING_TID_TAIL[1], SCB_LIST_NULL;
704 bmov SCBPTR, CURRSCB, 2; 789 bmov SCBPTR, CURRSCB, 2;
705 mvi CLRSINT0, CLRSELDO; 790 mvi CLRSINT0, CLRSELDO;
706 test LQOSTAT2, LQOPHACHGOUTPKT jnz unexpected_nonpkt_phase; 791 test LQOSTAT2, LQOPHACHGOUTPKT jnz unexpected_nonpkt_mode_cleared;
707 test LQOSTAT1, LQOPHACHGINPKT jnz unexpected_nonpkt_phase; 792 test LQOSTAT1, LQOPHACHGINPKT jnz unexpected_nonpkt_mode_cleared;
708 793
709 /* 794 /*
710 * If this is a packetized connection, return to our 795 * If this is a packetized connection, return to our
@@ -2127,6 +2212,18 @@ SET_DST_MODE M_DFF0;
2127 mvi DFFSXFRCTL, CLRCHN; 2212 mvi DFFSXFRCTL, CLRCHN;
2128unexpected_nonpkt_mode_cleared: 2213unexpected_nonpkt_mode_cleared:
2129 mvi CLRSINT2, CLRNONPACKREQ; 2214 mvi CLRSINT2, CLRNONPACKREQ;
2215 if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
2216 /*
2217 * Test to ensure that the bus has not
2218 * already gone free prior to clearing
2219 * any stale busfree status. This avoids
2220 * a window whereby a busfree just after
2221 * a selection could be missed.
2222 */
2223 test SCSISIGI, BSYI jz . + 2;
2224 mvi CLRSINT1,CLRBUSFREE;
2225 or SIMODE1, ENBUSFREE;
2226 }
2130 test SCSIPHASE, ~(MSG_IN_PHASE|MSG_OUT_PHASE) jnz illegal_phase; 2227 test SCSIPHASE, ~(MSG_IN_PHASE|MSG_OUT_PHASE) jnz illegal_phase;
2131 SET_SEQINTCODE(ENTERING_NONPACK) 2228 SET_SEQINTCODE(ENTERING_NONPACK)
2132 jmp ITloop; 2229 jmp ITloop;
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index db8f5ce99ee3..342f77966a5b 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -37,7 +37,7 @@
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES. 38 * POSSIBILITY OF SUCH DAMAGES.
39 * 39 *
40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#247 $ 40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#250 $
41 */ 41 */
42 42
43#ifdef __linux__ 43#ifdef __linux__
@@ -197,7 +197,8 @@ static int ahd_search_scb_list(struct ahd_softc *ahd, int target,
197 char channel, int lun, u_int tag, 197 char channel, int lun, u_int tag,
198 role_t role, uint32_t status, 198 role_t role, uint32_t status,
199 ahd_search_action action, 199 ahd_search_action action,
200 u_int *list_head, u_int tid); 200 u_int *list_head, u_int *list_tail,
201 u_int tid);
201static void ahd_stitch_tid_list(struct ahd_softc *ahd, 202static void ahd_stitch_tid_list(struct ahd_softc *ahd,
202 u_int tid_prev, u_int tid_cur, 203 u_int tid_prev, u_int tid_cur,
203 u_int tid_next); 204 u_int tid_next);
@@ -1660,7 +1661,8 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
1660 * so just clear the error. 1661 * so just clear the error.
1661 */ 1662 */
1662 ahd_outb(ahd, CLRLQIINT1, CLRLQICRCI_NLQ); 1663 ahd_outb(ahd, CLRLQIINT1, CLRLQICRCI_NLQ);
1663 } else if ((status & BUSFREE) != 0) { 1664 } else if ((status & BUSFREE) != 0
1665 || (lqistat1 & LQOBUSFREE) != 0) {
1664 u_int lqostat1; 1666 u_int lqostat1;
1665 int restart; 1667 int restart;
1666 int clear_fifo; 1668 int clear_fifo;
@@ -2025,10 +2027,6 @@ ahd_handle_pkt_busfree(struct ahd_softc *ahd, u_int busfreetime)
2025 u_int waiting_t; 2027 u_int waiting_t;
2026 u_int next; 2028 u_int next;
2027 2029
2028 if ((busfreetime & BUSFREE_LQO) == 0)
2029 printf("%s: Warning, BUSFREE time is 0x%x. "
2030 "Expected BUSFREE_LQO.\n",
2031 ahd_name(ahd), busfreetime);
2032 /* 2030 /*
2033 * The LQO manager detected an unexpected busfree 2031 * The LQO manager detected an unexpected busfree
2034 * either: 2032 * either:
@@ -2251,8 +2249,14 @@ ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
2251 struct ahd_tmode_tstate *tstate; 2249 struct ahd_tmode_tstate *tstate;
2252 2250
2253 /* 2251 /*
2254 * PPR Rejected. Try non-ppr negotiation 2252 * PPR Rejected.
2255 * and retry command. 2253 *
2254 * If the previous negotiation was packetized,
2255 * this could be because the device has been
2256 * reset without our knowledge. Force our
2257 * current negotiation to async and retry the
2258 * negotiation. Otherwise retry the command
2259 * with non-ppr negotiation.
2256 */ 2260 */
2257#ifdef AHD_DEBUG 2261#ifdef AHD_DEBUG
2258 if ((ahd_debug & AHD_SHOW_MESSAGES) != 0) 2262 if ((ahd_debug & AHD_SHOW_MESSAGES) != 0)
@@ -2261,11 +2265,34 @@ ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
2261 tinfo = ahd_fetch_transinfo(ahd, devinfo.channel, 2265 tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
2262 devinfo.our_scsiid, 2266 devinfo.our_scsiid,
2263 devinfo.target, &tstate); 2267 devinfo.target, &tstate);
2264 tinfo->curr.transport_version = 2; 2268 if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ)!=0) {
2265 tinfo->goal.transport_version = 2; 2269 ahd_set_width(ahd, &devinfo,
2266 tinfo->goal.ppr_options = 0; 2270 MSG_EXT_WDTR_BUS_8_BIT,
2267 ahd_qinfifo_requeue_tail(ahd, scb); 2271 AHD_TRANS_CUR,
2268 printerror = 0; 2272 /*paused*/TRUE);
2273 ahd_set_syncrate(ahd, &devinfo,
2274 /*period*/0, /*offset*/0,
2275 /*ppr_options*/0,
2276 AHD_TRANS_CUR,
2277 /*paused*/TRUE);
2278 /*
2279 * The expect PPR busfree handler below
2280 * will effect the retry and necessary
2281 * abort.
2282 */
2283 } else {
2284 tinfo->curr.transport_version = 2;
2285 tinfo->goal.transport_version = 2;
2286 tinfo->goal.ppr_options = 0;
2287 /*
2288 * Remove any SCBs in the waiting for selection
2289 * queue that may also be for this target so
2290 * that command ordering is preserved.
2291 */
2292 ahd_freeze_devq(ahd, scb);
2293 ahd_qinfifo_requeue_tail(ahd, scb);
2294 printerror = 0;
2295 }
2269 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, FALSE) 2296 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_WDTR, FALSE)
2270 && ppr_busfree == 0) { 2297 && ppr_busfree == 0) {
2271 /* 2298 /*
@@ -2280,6 +2307,12 @@ ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
2280 MSG_EXT_WDTR_BUS_8_BIT, 2307 MSG_EXT_WDTR_BUS_8_BIT,
2281 AHD_TRANS_CUR|AHD_TRANS_GOAL, 2308 AHD_TRANS_CUR|AHD_TRANS_GOAL,
2282 /*paused*/TRUE); 2309 /*paused*/TRUE);
2310 /*
2311 * Remove any SCBs in the waiting for selection
2312 * queue that may also be for this target so that
2313 * command ordering is preserved.
2314 */
2315 ahd_freeze_devq(ahd, scb);
2283 ahd_qinfifo_requeue_tail(ahd, scb); 2316 ahd_qinfifo_requeue_tail(ahd, scb);
2284 printerror = 0; 2317 printerror = 0;
2285 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, FALSE) 2318 } else if (ahd_sent_msg(ahd, AHDMSG_EXT, MSG_EXT_SDTR, FALSE)
@@ -2297,6 +2330,12 @@ ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
2297 /*ppr_options*/0, 2330 /*ppr_options*/0,
2298 AHD_TRANS_CUR|AHD_TRANS_GOAL, 2331 AHD_TRANS_CUR|AHD_TRANS_GOAL,
2299 /*paused*/TRUE); 2332 /*paused*/TRUE);
2333 /*
2334 * Remove any SCBs in the waiting for selection
2335 * queue that may also be for this target so that
2336 * command ordering is preserved.
2337 */
2338 ahd_freeze_devq(ahd, scb);
2300 ahd_qinfifo_requeue_tail(ahd, scb); 2339 ahd_qinfifo_requeue_tail(ahd, scb);
2301 printerror = 0; 2340 printerror = 0;
2302 } else if ((ahd->msg_flags & MSG_FLAG_EXPECT_IDE_BUSFREE) != 0 2341 } else if ((ahd->msg_flags & MSG_FLAG_EXPECT_IDE_BUSFREE) != 0
@@ -2369,14 +2408,14 @@ ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
2369 */ 2408 */
2370 printf("%s: ", ahd_name(ahd)); 2409 printf("%s: ", ahd_name(ahd));
2371 } 2410 }
2372 if (lastphase != P_BUSFREE)
2373 ahd_force_renegotiation(ahd, &devinfo);
2374 printf("Unexpected busfree %s, %d SCBs aborted, " 2411 printf("Unexpected busfree %s, %d SCBs aborted, "
2375 "PRGMCNT == 0x%x\n", 2412 "PRGMCNT == 0x%x\n",
2376 ahd_lookup_phase_entry(lastphase)->phasemsg, 2413 ahd_lookup_phase_entry(lastphase)->phasemsg,
2377 aborted, 2414 aborted,
2378 ahd_inw(ahd, PRGMCNT)); 2415 ahd_inw(ahd, PRGMCNT));
2379 ahd_dump_card_state(ahd); 2416 ahd_dump_card_state(ahd);
2417 if (lastphase != P_BUSFREE)
2418 ahd_force_renegotiation(ahd, &devinfo);
2380 } 2419 }
2381 /* Always restart the sequencer. */ 2420 /* Always restart the sequencer. */
2382 return (1); 2421 return (1);
@@ -3293,6 +3332,15 @@ ahd_update_neg_table(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
3293 con_opts |= WIDEXFER; 3332 con_opts |= WIDEXFER;
3294 3333
3295 /* 3334 /*
3335 * Slow down our CRC interval to be
3336 * compatible with packetized U320 devices
3337 * that can't handle a CRC at full speed
3338 */
3339 if (ahd->features & AHD_AIC79XXB_SLOWCRC) {
3340 con_opts |= ENSLOWCRC;
3341 }
3342
3343 /*
3296 * During packetized transfers, the target will 3344 * During packetized transfers, the target will
3297 * give us the oportunity to send command packets 3345 * give us the oportunity to send command packets
3298 * without us asserting attention. 3346 * without us asserting attention.
@@ -3315,7 +3363,6 @@ ahd_update_pending_scbs(struct ahd_softc *ahd)
3315{ 3363{
3316 struct scb *pending_scb; 3364 struct scb *pending_scb;
3317 int pending_scb_count; 3365 int pending_scb_count;
3318 u_int scb_tag;
3319 int paused; 3366 int paused;
3320 u_int saved_scbptr; 3367 u_int saved_scbptr;
3321 ahd_mode_state saved_modes; 3368 ahd_mode_state saved_modes;
@@ -3333,7 +3380,6 @@ ahd_update_pending_scbs(struct ahd_softc *ahd)
3333 pending_scb_count = 0; 3380 pending_scb_count = 0;
3334 LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) { 3381 LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
3335 struct ahd_devinfo devinfo; 3382 struct ahd_devinfo devinfo;
3336 struct hardware_scb *pending_hscb;
3337 struct ahd_initiator_tinfo *tinfo; 3383 struct ahd_initiator_tinfo *tinfo;
3338 struct ahd_tmode_tstate *tstate; 3384 struct ahd_tmode_tstate *tstate;
3339 3385
@@ -3341,11 +3387,10 @@ ahd_update_pending_scbs(struct ahd_softc *ahd)
3341 tinfo = ahd_fetch_transinfo(ahd, devinfo.channel, 3387 tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
3342 devinfo.our_scsiid, 3388 devinfo.our_scsiid,
3343 devinfo.target, &tstate); 3389 devinfo.target, &tstate);
3344 pending_hscb = pending_scb->hscb;
3345 if ((tstate->auto_negotiate & devinfo.target_mask) == 0 3390 if ((tstate->auto_negotiate & devinfo.target_mask) == 0
3346 && (pending_scb->flags & SCB_AUTO_NEGOTIATE) != 0) { 3391 && (pending_scb->flags & SCB_AUTO_NEGOTIATE) != 0) {
3347 pending_scb->flags &= ~SCB_AUTO_NEGOTIATE; 3392 pending_scb->flags &= ~SCB_AUTO_NEGOTIATE;
3348 pending_hscb->control &= ~MK_MESSAGE; 3393 pending_scb->hscb->control &= ~MK_MESSAGE;
3349 } 3394 }
3350 ahd_sync_scb(ahd, pending_scb, 3395 ahd_sync_scb(ahd, pending_scb,
3351 BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); 3396 BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
@@ -3377,18 +3422,15 @@ ahd_update_pending_scbs(struct ahd_softc *ahd)
3377 ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO); 3422 ahd_outb(ahd, SCSISEQ0, ahd_inb(ahd, SCSISEQ0) & ~ENSELO);
3378 saved_scbptr = ahd_get_scbptr(ahd); 3423 saved_scbptr = ahd_get_scbptr(ahd);
3379 /* Ensure that the hscbs down on the card match the new information */ 3424 /* Ensure that the hscbs down on the card match the new information */
3380 for (scb_tag = 0; scb_tag < ahd->scb_data.maxhscbs; scb_tag++) { 3425 LIST_FOREACH(pending_scb, &ahd->pending_scbs, pending_links) {
3381 struct hardware_scb *pending_hscb; 3426 u_int scb_tag;
3382 u_int control; 3427 u_int control;
3383 3428
3384 pending_scb = ahd_lookup_scb(ahd, scb_tag); 3429 scb_tag = SCB_GET_TAG(pending_scb);
3385 if (pending_scb == NULL)
3386 continue;
3387 ahd_set_scbptr(ahd, scb_tag); 3430 ahd_set_scbptr(ahd, scb_tag);
3388 pending_hscb = pending_scb->hscb;
3389 control = ahd_inb_scbram(ahd, SCB_CONTROL); 3431 control = ahd_inb_scbram(ahd, SCB_CONTROL);
3390 control &= ~MK_MESSAGE; 3432 control &= ~MK_MESSAGE;
3391 control |= pending_hscb->control & MK_MESSAGE; 3433 control |= pending_scb->hscb->control & MK_MESSAGE;
3392 ahd_outb(ahd, SCB_CONTROL, control); 3434 ahd_outb(ahd, SCB_CONTROL, control);
3393 } 3435 }
3394 ahd_set_scbptr(ahd, saved_scbptr); 3436 ahd_set_scbptr(ahd, saved_scbptr);
@@ -6500,13 +6542,14 @@ ahd_chip_init(struct ahd_softc *ahd)
6500 | ENLQIOVERI_LQ|ENLQIOVERI_NLQ); 6542 | ENLQIOVERI_LQ|ENLQIOVERI_NLQ);
6501 ahd_outb(ahd, LQOMODE0, ENLQOATNLQ|ENLQOATNPKT|ENLQOTCRC); 6543 ahd_outb(ahd, LQOMODE0, ENLQOATNLQ|ENLQOATNPKT|ENLQOTCRC);
6502 /* 6544 /*
6503 * An interrupt from LQOBUSFREE is made redundant by the 6545 * We choose to have the sequencer catch LQOPHCHGINPKT errors
6504 * BUSFREE interrupt. We choose to have the sequencer catch 6546 * manually for the command phase at the start of a packetized
6505 * LQOPHCHGINPKT errors manually for the command phase at the 6547 * selection case. ENLQOBUSFREE should be made redundant by
6506 * start of a packetized selection case. 6548 * the BUSFREE interrupt, but it seems that some LQOBUSFREE
6507 ahd_outb(ahd, LQOMODE1, ENLQOBUSFREE|ENLQOPHACHGINPKT); 6549 * events fail to assert the BUSFREE interrupt so we must
6550 * also enable LQOBUSFREE interrupts.
6508 */ 6551 */
6509 ahd_outb(ahd, LQOMODE1, 0); 6552 ahd_outb(ahd, LQOMODE1, ENLQOBUSFREE);
6510 6553
6511 /* 6554 /*
6512 * Setup sequencer interrupt handlers. 6555 * Setup sequencer interrupt handlers.
@@ -6617,6 +6660,8 @@ ahd_chip_init(struct ahd_softc *ahd)
6617 /* We don't have any waiting selections */ 6660 /* We don't have any waiting selections */
6618 ahd_outw(ahd, WAITING_TID_HEAD, SCB_LIST_NULL); 6661 ahd_outw(ahd, WAITING_TID_HEAD, SCB_LIST_NULL);
6619 ahd_outw(ahd, WAITING_TID_TAIL, SCB_LIST_NULL); 6662 ahd_outw(ahd, WAITING_TID_TAIL, SCB_LIST_NULL);
6663 ahd_outw(ahd, MK_MESSAGE_SCB, SCB_LIST_NULL);
6664 ahd_outw(ahd, MK_MESSAGE_SCSIID, 0xFF);
6620 for (i = 0; i < AHD_NUM_TARGETS; i++) 6665 for (i = 0; i < AHD_NUM_TARGETS; i++)
6621 ahd_outw(ahd, WAITING_SCB_TAILS + (2 * i), SCB_LIST_NULL); 6666 ahd_outw(ahd, WAITING_SCB_TAILS + (2 * i), SCB_LIST_NULL);
6622 6667
@@ -6704,6 +6749,18 @@ ahd_chip_init(struct ahd_softc *ahd)
6704 6749
6705 ahd_loadseq(ahd); 6750 ahd_loadseq(ahd);
6706 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 6751 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
6752
6753 if (ahd->features & AHD_AIC79XXB_SLOWCRC) {
6754 u_int negodat3 = ahd_inb(ahd, NEGCONOPTS);
6755
6756 negodat3 |= ENSLOWCRC;
6757 ahd_outb(ahd, NEGCONOPTS, negodat3);
6758 negodat3 = ahd_inb(ahd, NEGCONOPTS);
6759 if (!(negodat3 & ENSLOWCRC))
6760 printf("aic79xx: failed to set the SLOWCRC bit\n");
6761 else
6762 printf("aic79xx: SLOWCRC bit set\n");
6763 }
6707} 6764}
6708 6765
6709/* 6766/*
@@ -7260,12 +7317,28 @@ ahd_reset_cmds_pending(struct ahd_softc *ahd)
7260 ahd->flags &= ~AHD_UPDATE_PEND_CMDS; 7317 ahd->flags &= ~AHD_UPDATE_PEND_CMDS;
7261} 7318}
7262 7319
7320void
7321ahd_done_with_status(struct ahd_softc *ahd, struct scb *scb, uint32_t status)
7322{
7323 cam_status ostat;
7324 cam_status cstat;
7325
7326 ostat = ahd_get_transaction_status(scb);
7327 if (ostat == CAM_REQ_INPROG)
7328 ahd_set_transaction_status(scb, status);
7329 cstat = ahd_get_transaction_status(scb);
7330 if (cstat != CAM_REQ_CMP)
7331 ahd_freeze_scb(scb);
7332 ahd_done(ahd, scb);
7333}
7334
7263int 7335int
7264ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel, 7336ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
7265 int lun, u_int tag, role_t role, uint32_t status, 7337 int lun, u_int tag, role_t role, uint32_t status,
7266 ahd_search_action action) 7338 ahd_search_action action)
7267{ 7339{
7268 struct scb *scb; 7340 struct scb *scb;
7341 struct scb *mk_msg_scb;
7269 struct scb *prev_scb; 7342 struct scb *prev_scb;
7270 ahd_mode_state saved_modes; 7343 ahd_mode_state saved_modes;
7271 u_int qinstart; 7344 u_int qinstart;
@@ -7274,6 +7347,7 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
7274 u_int tid_next; 7347 u_int tid_next;
7275 u_int tid_prev; 7348 u_int tid_prev;
7276 u_int scbid; 7349 u_int scbid;
7350 u_int seq_flags2;
7277 u_int savedscbptr; 7351 u_int savedscbptr;
7278 uint32_t busaddr; 7352 uint32_t busaddr;
7279 int found; 7353 int found;
@@ -7329,23 +7403,10 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
7329 found++; 7403 found++;
7330 switch (action) { 7404 switch (action) {
7331 case SEARCH_COMPLETE: 7405 case SEARCH_COMPLETE:
7332 {
7333 cam_status ostat;
7334 cam_status cstat;
7335
7336 ostat = ahd_get_transaction_status(scb);
7337 if (ostat == CAM_REQ_INPROG)
7338 ahd_set_transaction_status(scb,
7339 status);
7340 cstat = ahd_get_transaction_status(scb);
7341 if (cstat != CAM_REQ_CMP)
7342 ahd_freeze_scb(scb);
7343 if ((scb->flags & SCB_ACTIVE) == 0) 7406 if ((scb->flags & SCB_ACTIVE) == 0)
7344 printf("Inactive SCB in qinfifo\n"); 7407 printf("Inactive SCB in qinfifo\n");
7345 ahd_done(ahd, scb); 7408 ahd_done_with_status(ahd, scb, status);
7346
7347 /* FALLTHROUGH */ 7409 /* FALLTHROUGH */
7348 }
7349 case SEARCH_REMOVE: 7410 case SEARCH_REMOVE:
7350 break; 7411 break;
7351 case SEARCH_PRINT: 7412 case SEARCH_PRINT:
@@ -7375,21 +7436,24 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
7375 * looking for matches. 7436 * looking for matches.
7376 */ 7437 */
7377 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI); 7438 ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
7439 seq_flags2 = ahd_inb(ahd, SEQ_FLAGS2);
7440 if ((seq_flags2 & PENDING_MK_MESSAGE) != 0) {
7441 scbid = ahd_inw(ahd, MK_MESSAGE_SCB);
7442 mk_msg_scb = ahd_lookup_scb(ahd, scbid);
7443 } else
7444 mk_msg_scb = NULL;
7378 savedscbptr = ahd_get_scbptr(ahd); 7445 savedscbptr = ahd_get_scbptr(ahd);
7379 tid_next = ahd_inw(ahd, WAITING_TID_HEAD); 7446 tid_next = ahd_inw(ahd, WAITING_TID_HEAD);
7380 tid_prev = SCB_LIST_NULL; 7447 tid_prev = SCB_LIST_NULL;
7381 targets = 0; 7448 targets = 0;
7382 for (scbid = tid_next; !SCBID_IS_NULL(scbid); scbid = tid_next) { 7449 for (scbid = tid_next; !SCBID_IS_NULL(scbid); scbid = tid_next) {
7383 u_int tid_head; 7450 u_int tid_head;
7451 u_int tid_tail;
7384 7452
7385 /*
7386 * We limit based on the number of SCBs since
7387 * MK_MESSAGE SCBs are not in the per-tid lists.
7388 */
7389 targets++; 7453 targets++;
7390 if (targets > AHD_SCB_MAX) { 7454 if (targets > AHD_NUM_TARGETS)
7391 panic("TID LIST LOOP"); 7455 panic("TID LIST LOOP");
7392 } 7456
7393 if (scbid >= ahd->scb_data.numscbs) { 7457 if (scbid >= ahd->scb_data.numscbs) {
7394 printf("%s: Waiting TID List inconsistency. " 7458 printf("%s: Waiting TID List inconsistency. "
7395 "SCB index == 0x%x, yet numscbs == 0x%x.", 7459 "SCB index == 0x%x, yet numscbs == 0x%x.",
@@ -7419,8 +7483,71 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
7419 tid_head = scbid; 7483 tid_head = scbid;
7420 found += ahd_search_scb_list(ahd, target, channel, 7484 found += ahd_search_scb_list(ahd, target, channel,
7421 lun, tag, role, status, 7485 lun, tag, role, status,
7422 action, &tid_head, 7486 action, &tid_head, &tid_tail,
7423 SCB_GET_TARGET(ahd, scb)); 7487 SCB_GET_TARGET(ahd, scb));
7488 /*
7489 * Check any MK_MESSAGE SCB that is still waiting to
7490 * enter this target's waiting for selection queue.
7491 */
7492 if (mk_msg_scb != NULL
7493 && ahd_match_scb(ahd, mk_msg_scb, target, channel,
7494 lun, tag, role)) {
7495
7496 /*
7497 * We found an scb that needs to be acted on.
7498 */
7499 found++;
7500 switch (action) {
7501 case SEARCH_COMPLETE:
7502 if ((mk_msg_scb->flags & SCB_ACTIVE) == 0)
7503 printf("Inactive SCB pending MK_MSG\n");
7504 ahd_done_with_status(ahd, mk_msg_scb, status);
7505 /* FALLTHROUGH */
7506 case SEARCH_REMOVE:
7507 {
7508 u_int tail_offset;
7509
7510 printf("Removing MK_MSG scb\n");
7511
7512 /*
7513 * Reset our tail to the tail of the
7514 * main per-target list.
7515 */
7516 tail_offset = WAITING_SCB_TAILS
7517 + (2 * SCB_GET_TARGET(ahd, mk_msg_scb));
7518 ahd_outw(ahd, tail_offset, tid_tail);
7519
7520 seq_flags2 &= ~PENDING_MK_MESSAGE;
7521 ahd_outb(ahd, SEQ_FLAGS2, seq_flags2);
7522 ahd_outw(ahd, CMDS_PENDING,
7523 ahd_inw(ahd, CMDS_PENDING)-1);
7524 mk_msg_scb = NULL;
7525 break;
7526 }
7527 case SEARCH_PRINT:
7528 printf(" 0x%x", SCB_GET_TAG(scb));
7529 /* FALLTHROUGH */
7530 case SEARCH_COUNT:
7531 break;
7532 }
7533 }
7534
7535 if (mk_msg_scb != NULL
7536 && SCBID_IS_NULL(tid_head)
7537 && ahd_match_scb(ahd, scb, target, channel, CAM_LUN_WILDCARD,
7538 SCB_LIST_NULL, ROLE_UNKNOWN)) {
7539
7540 /*
7541 * When removing the last SCB for a target
7542 * queue with a pending MK_MESSAGE scb, we
7543 * must queue the MK_MESSAGE scb.
7544 */
7545 printf("Queueing mk_msg_scb\n");
7546 tid_head = ahd_inw(ahd, MK_MESSAGE_SCB);
7547 seq_flags2 &= ~PENDING_MK_MESSAGE;
7548 ahd_outb(ahd, SEQ_FLAGS2, seq_flags2);
7549 mk_msg_scb = NULL;
7550 }
7424 if (tid_head != scbid) 7551 if (tid_head != scbid)
7425 ahd_stitch_tid_list(ahd, tid_prev, tid_head, tid_next); 7552 ahd_stitch_tid_list(ahd, tid_prev, tid_head, tid_next);
7426 if (!SCBID_IS_NULL(tid_head)) 7553 if (!SCBID_IS_NULL(tid_head))
@@ -7428,6 +7555,8 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
7428 if (action == SEARCH_PRINT) 7555 if (action == SEARCH_PRINT)
7429 printf(")\n"); 7556 printf(")\n");
7430 } 7557 }
7558
7559 /* Restore saved state. */
7431 ahd_set_scbptr(ahd, savedscbptr); 7560 ahd_set_scbptr(ahd, savedscbptr);
7432 ahd_restore_modes(ahd, saved_modes); 7561 ahd_restore_modes(ahd, saved_modes);
7433 return (found); 7562 return (found);
@@ -7436,7 +7565,8 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
7436static int 7565static int
7437ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel, 7566ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
7438 int lun, u_int tag, role_t role, uint32_t status, 7567 int lun, u_int tag, role_t role, uint32_t status,
7439 ahd_search_action action, u_int *list_head, u_int tid) 7568 ahd_search_action action, u_int *list_head,
7569 u_int *list_tail, u_int tid)
7440{ 7570{
7441 struct scb *scb; 7571 struct scb *scb;
7442 u_int scbid; 7572 u_int scbid;
@@ -7448,6 +7578,7 @@ ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
7448 found = 0; 7578 found = 0;
7449 prev = SCB_LIST_NULL; 7579 prev = SCB_LIST_NULL;
7450 next = *list_head; 7580 next = *list_head;
7581 *list_tail = SCB_LIST_NULL;
7451 for (scbid = next; !SCBID_IS_NULL(scbid); scbid = next) { 7582 for (scbid = next; !SCBID_IS_NULL(scbid); scbid = next) {
7452 if (scbid >= ahd->scb_data.numscbs) { 7583 if (scbid >= ahd->scb_data.numscbs) {
7453 printf("%s:SCB List inconsistency. " 7584 printf("%s:SCB List inconsistency. "
@@ -7463,6 +7594,7 @@ ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
7463 panic("Waiting List traversal\n"); 7594 panic("Waiting List traversal\n");
7464 } 7595 }
7465 ahd_set_scbptr(ahd, scbid); 7596 ahd_set_scbptr(ahd, scbid);
7597 *list_tail = scbid;
7466 next = ahd_inw_scbram(ahd, SCB_NEXT); 7598 next = ahd_inw_scbram(ahd, SCB_NEXT);
7467 if (ahd_match_scb(ahd, scb, target, channel, 7599 if (ahd_match_scb(ahd, scb, target, channel,
7468 lun, SCB_LIST_NULL, role) == 0) { 7600 lun, SCB_LIST_NULL, role) == 0) {
@@ -7472,24 +7604,14 @@ ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
7472 found++; 7604 found++;
7473 switch (action) { 7605 switch (action) {
7474 case SEARCH_COMPLETE: 7606 case SEARCH_COMPLETE:
7475 {
7476 cam_status ostat;
7477 cam_status cstat;
7478
7479 ostat = ahd_get_transaction_status(scb);
7480 if (ostat == CAM_REQ_INPROG)
7481 ahd_set_transaction_status(scb, status);
7482 cstat = ahd_get_transaction_status(scb);
7483 if (cstat != CAM_REQ_CMP)
7484 ahd_freeze_scb(scb);
7485 if ((scb->flags & SCB_ACTIVE) == 0) 7607 if ((scb->flags & SCB_ACTIVE) == 0)
7486 printf("Inactive SCB in Waiting List\n"); 7608 printf("Inactive SCB in Waiting List\n");
7487 ahd_done(ahd, scb); 7609 ahd_done_with_status(ahd, scb, status);
7488 /* FALLTHROUGH */ 7610 /* FALLTHROUGH */
7489 }
7490 case SEARCH_REMOVE: 7611 case SEARCH_REMOVE:
7491 ahd_rem_wscb(ahd, scbid, prev, next, tid); 7612 ahd_rem_wscb(ahd, scbid, prev, next, tid);
7492 if (prev == SCB_LIST_NULL) 7613 *list_tail = prev;
7614 if (SCBID_IS_NULL(prev))
7493 *list_head = next; 7615 *list_head = next;
7494 break; 7616 break;
7495 case SEARCH_PRINT: 7617 case SEARCH_PRINT:
@@ -7558,14 +7680,17 @@ ahd_rem_wscb(struct ahd_softc *ahd, u_int scbid,
7558 } 7680 }
7559 7681
7560 /* 7682 /*
7561 * SCBs that had MK_MESSAGE set in them will not 7683 * SCBs that have MK_MESSAGE set in them may
7562 * be queued to the per-target lists, so don't 7684 * cause the tail pointer to be updated without
7563 * blindly clear the tail pointer. 7685 * setting the next pointer of the previous tail.
7686 * Only clear the tail if the removed SCB was
7687 * the tail.
7564 */ 7688 */
7565 tail_offset = WAITING_SCB_TAILS + (2 * tid); 7689 tail_offset = WAITING_SCB_TAILS + (2 * tid);
7566 if (SCBID_IS_NULL(next) 7690 if (SCBID_IS_NULL(next)
7567 && ahd_inw(ahd, tail_offset) == scbid) 7691 && ahd_inw(ahd, tail_offset) == scbid)
7568 ahd_outw(ahd, tail_offset, prev); 7692 ahd_outw(ahd, tail_offset, prev);
7693
7569 ahd_add_scb_to_free_list(ahd, scbid); 7694 ahd_add_scb_to_free_list(ahd, scbid);
7570 return (next); 7695 return (next);
7571} 7696}
@@ -8148,11 +8273,6 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
8148 ahd_setup_data_scb(ahd, scb); 8273 ahd_setup_data_scb(ahd, scb);
8149 scb->flags |= SCB_SENSE; 8274 scb->flags |= SCB_SENSE;
8150 ahd_queue_scb(ahd, scb); 8275 ahd_queue_scb(ahd, scb);
8151 /*
8152 * Ensure we have enough time to actually
8153 * retrieve the sense.
8154 */
8155 ahd_scb_timer_reset(scb, 5 * 1000000);
8156 break; 8276 break;
8157 } 8277 }
8158 case SCSI_STATUS_OK: 8278 case SCSI_STATUS_OK:
@@ -8793,6 +8913,9 @@ ahd_dump_card_state(struct ahd_softc *ahd)
8793 * Mode independent registers. 8913 * Mode independent registers.
8794 */ 8914 */
8795 cur_col = 0; 8915 cur_col = 0;
8916 ahd_intstat_print(ahd_inb(ahd, INTSTAT), &cur_col, 50);
8917 ahd_seloid_print(ahd_inb(ahd, SELOID), &cur_col, 50);
8918 ahd_selid_print(ahd_inb(ahd, SELID), &cur_col, 50);
8796 ahd_hs_mailbox_print(ahd_inb(ahd, LOCAL_HS_MAILBOX), &cur_col, 50); 8919 ahd_hs_mailbox_print(ahd_inb(ahd, LOCAL_HS_MAILBOX), &cur_col, 50);
8797 ahd_intctl_print(ahd_inb(ahd, INTCTL), &cur_col, 50); 8920 ahd_intctl_print(ahd_inb(ahd, INTCTL), &cur_col, 50);
8798 ahd_seqintstat_print(ahd_inb(ahd, SEQINTSTAT), &cur_col, 50); 8921 ahd_seqintstat_print(ahd_inb(ahd, SEQINTSTAT), &cur_col, 50);
@@ -8808,6 +8931,12 @@ ahd_dump_card_state(struct ahd_softc *ahd)
8808 ahd_seqintctl_print(ahd_inb(ahd, SEQINTCTL), &cur_col, 50); 8931 ahd_seqintctl_print(ahd_inb(ahd, SEQINTCTL), &cur_col, 50);
8809 ahd_seq_flags_print(ahd_inb(ahd, SEQ_FLAGS), &cur_col, 50); 8932 ahd_seq_flags_print(ahd_inb(ahd, SEQ_FLAGS), &cur_col, 50);
8810 ahd_seq_flags2_print(ahd_inb(ahd, SEQ_FLAGS2), &cur_col, 50); 8933 ahd_seq_flags2_print(ahd_inb(ahd, SEQ_FLAGS2), &cur_col, 50);
8934 ahd_qfreeze_count_print(ahd_inw(ahd, QFREEZE_COUNT), &cur_col, 50);
8935 ahd_kernel_qfreeze_count_print(ahd_inw(ahd, KERNEL_QFREEZE_COUNT),
8936 &cur_col, 50);
8937 ahd_mk_message_scb_print(ahd_inw(ahd, MK_MESSAGE_SCB), &cur_col, 50);
8938 ahd_mk_message_scsiid_print(ahd_inb(ahd, MK_MESSAGE_SCSIID),
8939 &cur_col, 50);
8811 ahd_sstat0_print(ahd_inb(ahd, SSTAT0), &cur_col, 50); 8940 ahd_sstat0_print(ahd_inb(ahd, SSTAT0), &cur_col, 50);
8812 ahd_sstat1_print(ahd_inb(ahd, SSTAT1), &cur_col, 50); 8941 ahd_sstat1_print(ahd_inb(ahd, SSTAT1), &cur_col, 50);
8813 ahd_sstat2_print(ahd_inb(ahd, SSTAT2), &cur_col, 50); 8942 ahd_sstat2_print(ahd_inb(ahd, SSTAT2), &cur_col, 50);
@@ -8915,7 +9044,7 @@ ahd_dump_card_state(struct ahd_softc *ahd)
8915 9044
8916 ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i); 9045 ahd_set_modes(ahd, AHD_MODE_DFF0 + i, AHD_MODE_DFF0 + i);
8917 fifo_scbptr = ahd_get_scbptr(ahd); 9046 fifo_scbptr = ahd_get_scbptr(ahd);
8918 printf("\n%s: FIFO%d %s, LONGJMP == 0x%x, SCB 0x%x\n", 9047 printf("\n\n%s: FIFO%d %s, LONGJMP == 0x%x, SCB 0x%x\n",
8919 ahd_name(ahd), i, 9048 ahd_name(ahd), i,
8920 (dffstat & (FIFO0FREE << i)) ? "Free" : "Active", 9049 (dffstat & (FIFO0FREE << i)) ? "Free" : "Active",
8921 ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr); 9050 ahd_inw(ahd, LONGJMP_ADDR), fifo_scbptr);
@@ -8970,6 +9099,9 @@ ahd_dump_card_state(struct ahd_softc *ahd)
8970 printf("%s: OS_SPACE_CNT = 0x%x MAXCMDCNT = 0x%x\n", 9099 printf("%s: OS_SPACE_CNT = 0x%x MAXCMDCNT = 0x%x\n",
8971 ahd_name(ahd), ahd_inb(ahd, OS_SPACE_CNT), 9100 ahd_name(ahd), ahd_inb(ahd, OS_SPACE_CNT),
8972 ahd_inb(ahd, MAXCMDCNT)); 9101 ahd_inb(ahd, MAXCMDCNT));
9102 printf("%s: SAVED_SCSIID = 0x%x SAVED_LUN = 0x%x\n",
9103 ahd_name(ahd), ahd_inb(ahd, SAVED_SCSIID),
9104 ahd_inb(ahd, SAVED_LUN));
8973 ahd_simode0_print(ahd_inb(ahd, SIMODE0), &cur_col, 50); 9105 ahd_simode0_print(ahd_inb(ahd, SIMODE0), &cur_col, 50);
8974 printf("\n"); 9106 printf("\n");
8975 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN); 9107 ahd_set_modes(ahd, AHD_MODE_CCHAN, AHD_MODE_CCHAN);
diff --git a/drivers/scsi/aic7xxx/aic79xx_inline.h b/drivers/scsi/aic7xxx/aic79xx_inline.h
index 91c4f7f484b1..8ad3ce945b9e 100644
--- a/drivers/scsi/aic7xxx/aic79xx_inline.h
+++ b/drivers/scsi/aic7xxx/aic79xx_inline.h
@@ -37,7 +37,7 @@
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES. 38 * POSSIBILITY OF SUCH DAMAGES.
39 * 39 *
40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#58 $ 40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#59 $
41 * 41 *
42 * $FreeBSD$ 42 * $FreeBSD$
43 */ 43 */
@@ -804,9 +804,10 @@ ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb)
804 uint64_t host_dataptr; 804 uint64_t host_dataptr;
805 805
806 host_dataptr = ahd_le64toh(scb->hscb->dataptr); 806 host_dataptr = ahd_le64toh(scb->hscb->dataptr);
807 printf("%s: Queueing SCB 0x%x bus addr 0x%x - 0x%x%x/0x%x\n", 807 printf("%s: Queueing SCB %d:0x%x bus addr 0x%x - 0x%x%x/0x%x\n",
808 ahd_name(ahd), 808 ahd_name(ahd),
809 SCB_GET_TAG(scb), ahd_le32toh(scb->hscb->hscb_busaddr), 809 SCB_GET_TAG(scb), scb->hscb->scsiid,
810 ahd_le32toh(scb->hscb->hscb_busaddr),
810 (u_int)((host_dataptr >> 32) & 0xFFFFFFFF), 811 (u_int)((host_dataptr >> 32) & 0xFFFFFFFF),
811 (u_int)(host_dataptr & 0xFFFFFFFF), 812 (u_int)(host_dataptr & 0xFFFFFFFF),
812 ahd_le32toh(scb->hscb->datacnt)); 813 ahd_le32toh(scb->hscb->datacnt));
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 2567e29960bd..7254ea535a16 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -314,6 +314,21 @@ static uint32_t aic79xx_seltime;
314 */ 314 */
315uint32_t aic79xx_periodic_otag; 315uint32_t aic79xx_periodic_otag;
316 316
317/* Some storage boxes are using an LSI chip which has a bug making it
318 * impossible to use aic79xx Rev B chip in 320 speeds. The following
319 * storage boxes have been reported to be buggy:
320 * EonStor 3U 16-Bay: U16U-G3A3
321 * EonStor 2U 12-Bay: U12U-G3A3
322 * SentinelRAID: 2500F R5 / R6
323 * SentinelRAID: 2500F R1
324 * SentinelRAID: 2500F/1500F
325 * SentinelRAID: 150F
326 *
327 * To get around this LSI bug, you can set your board to 160 mode
328 * or you can enable the SLOWCRC bit.
329 */
330uint32_t aic79xx_slowcrc;
331
317/* 332/*
318 * Module information and settable options. 333 * Module information and settable options.
319 */ 334 */
@@ -343,6 +358,7 @@ MODULE_PARM_DESC(aic79xx,
343" amplitude:<int> Set the signal amplitude (0-7).\n" 358" amplitude:<int> Set the signal amplitude (0-7).\n"
344" seltime:<int> Selection Timeout:\n" 359" seltime:<int> Selection Timeout:\n"
345" (0/256ms,1/128ms,2/64ms,3/32ms)\n" 360" (0/256ms,1/128ms,2/64ms,3/32ms)\n"
361" slowcrc Turn on the SLOWCRC bit (Rev B only)\n"
346"\n" 362"\n"
347" Sample /etc/modprobe.conf line:\n" 363" Sample /etc/modprobe.conf line:\n"
348" Enable verbose logging\n" 364" Enable verbose logging\n"
@@ -1003,6 +1019,7 @@ aic79xx_setup(char *s)
1003 { "slewrate", NULL }, 1019 { "slewrate", NULL },
1004 { "precomp", NULL }, 1020 { "precomp", NULL },
1005 { "amplitude", NULL }, 1021 { "amplitude", NULL },
1022 { "slowcrc", &aic79xx_slowcrc },
1006 }; 1023 };
1007 1024
1008 end = strchr(s, '\0'); 1025 end = strchr(s, '\0');
@@ -1072,7 +1089,6 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa
1072 return (ENOMEM); 1089 return (ENOMEM);
1073 1090
1074 *((struct ahd_softc **)host->hostdata) = ahd; 1091 *((struct ahd_softc **)host->hostdata) = ahd;
1075 ahd_lock(ahd, &s);
1076 ahd->platform_data->host = host; 1092 ahd->platform_data->host = host;
1077 host->can_queue = AHD_MAX_QUEUE; 1093 host->can_queue = AHD_MAX_QUEUE;
1078 host->cmd_per_lun = 2; 1094 host->cmd_per_lun = 2;
@@ -1083,7 +1099,9 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa
1083 host->max_lun = AHD_NUM_LUNS; 1099 host->max_lun = AHD_NUM_LUNS;
1084 host->max_channel = 0; 1100 host->max_channel = 0;
1085 host->sg_tablesize = AHD_NSEG; 1101 host->sg_tablesize = AHD_NSEG;
1102 ahd_lock(ahd, &s);
1086 ahd_set_unit(ahd, ahd_linux_unit++); 1103 ahd_set_unit(ahd, ahd_linux_unit++);
1104 ahd_unlock(ahd, &s);
1087 sprintf(buf, "scsi%d", host->host_no); 1105 sprintf(buf, "scsi%d", host->host_no);
1088 new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT); 1106 new_name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
1089 if (new_name != NULL) { 1107 if (new_name != NULL) {
@@ -1093,7 +1111,6 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa
1093 host->unique_id = ahd->unit; 1111 host->unique_id = ahd->unit;
1094 ahd_linux_initialize_scsi_bus(ahd); 1112 ahd_linux_initialize_scsi_bus(ahd);
1095 ahd_intr_enable(ahd, TRUE); 1113 ahd_intr_enable(ahd, TRUE);
1096 ahd_unlock(ahd, &s);
1097 1114
1098 host->transportt = ahd_linux_transport_template; 1115 host->transportt = ahd_linux_transport_template;
1099 1116
@@ -1127,6 +1144,7 @@ ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd)
1127{ 1144{
1128 u_int target_id; 1145 u_int target_id;
1129 u_int numtarg; 1146 u_int numtarg;
1147 unsigned long s;
1130 1148
1131 target_id = 0; 1149 target_id = 0;
1132 numtarg = 0; 1150 numtarg = 0;
@@ -1139,6 +1157,8 @@ ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd)
1139 else 1157 else
1140 numtarg = (ahd->features & AHD_WIDE) ? 16 : 8; 1158 numtarg = (ahd->features & AHD_WIDE) ? 16 : 8;
1141 1159
1160 ahd_lock(ahd, &s);
1161
1142 /* 1162 /*
1143 * Force negotiation to async for all targets that 1163 * Force negotiation to async for all targets that
1144 * will not see an initial bus reset. 1164 * will not see an initial bus reset.
@@ -1155,16 +1175,12 @@ ahd_linux_initialize_scsi_bus(struct ahd_softc *ahd)
1155 ahd_update_neg_request(ahd, &devinfo, tstate, 1175 ahd_update_neg_request(ahd, &devinfo, tstate,
1156 tinfo, AHD_NEG_ALWAYS); 1176 tinfo, AHD_NEG_ALWAYS);
1157 } 1177 }
1178 ahd_unlock(ahd, &s);
1158 /* Give the bus some time to recover */ 1179 /* Give the bus some time to recover */
1159 if ((ahd->flags & AHD_RESET_BUS_A) != 0) { 1180 if ((ahd->flags & AHD_RESET_BUS_A) != 0) {
1160 ahd_freeze_simq(ahd); 1181 ahd_freeze_simq(ahd);
1161 init_timer(&ahd->platform_data->reset_timer); 1182 msleep(AIC79XX_RESET_DELAY);
1162 ahd->platform_data->reset_timer.data = (u_long)ahd; 1183 ahd_release_simq(ahd);
1163 ahd->platform_data->reset_timer.expires =
1164 jiffies + (AIC79XX_RESET_DELAY * HZ)/1000;
1165 ahd->platform_data->reset_timer.function =
1166 (ahd_linux_callback_t *)ahd_release_simq;
1167 add_timer(&ahd->platform_data->reset_timer);
1168 } 1184 }
1169} 1185}
1170 1186
@@ -2033,6 +2049,9 @@ ahd_linux_sem_timeout(u_long arg)
2033void 2049void
2034ahd_freeze_simq(struct ahd_softc *ahd) 2050ahd_freeze_simq(struct ahd_softc *ahd)
2035{ 2051{
2052 unsigned long s;
2053
2054 ahd_lock(ahd, &s);
2036 ahd->platform_data->qfrozen++; 2055 ahd->platform_data->qfrozen++;
2037 if (ahd->platform_data->qfrozen == 1) { 2056 if (ahd->platform_data->qfrozen == 1) {
2038 scsi_block_requests(ahd->platform_data->host); 2057 scsi_block_requests(ahd->platform_data->host);
@@ -2040,6 +2059,7 @@ ahd_freeze_simq(struct ahd_softc *ahd)
2040 CAM_LUN_WILDCARD, SCB_LIST_NULL, 2059 CAM_LUN_WILDCARD, SCB_LIST_NULL,
2041 ROLE_INITIATOR, CAM_REQUEUE_REQ); 2060 ROLE_INITIATOR, CAM_REQUEUE_REQ);
2042 } 2061 }
2062 ahd_unlock(ahd, &s);
2043} 2063}
2044 2064
2045void 2065void
@@ -2344,8 +2364,9 @@ done:
2344 ahd_name(ahd), dev->active); 2364 ahd_name(ahd), dev->active);
2345 retval = FAILED; 2365 retval = FAILED;
2346 } 2366 }
2347 } 2367 } else
2348 ahd_unlock(ahd, &flags); 2368 ahd_unlock(ahd, &flags);
2369
2349 return (retval); 2370 return (retval);
2350} 2371}
2351 2372
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index cb74fccc8100..9cb101345107 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -36,7 +36,7 @@
36 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGES. 37 * POSSIBILITY OF SUCH DAMAGES.
38 * 38 *
39 * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#137 $ 39 * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#166 $
40 * 40 *
41 */ 41 */
42#ifndef _AIC79XX_LINUX_H_ 42#ifndef _AIC79XX_LINUX_H_
@@ -228,7 +228,6 @@ typedef struct timer_list ahd_timer_t;
228typedef void ahd_linux_callback_t (u_long); 228typedef void ahd_linux_callback_t (u_long);
229static __inline void ahd_timer_reset(ahd_timer_t *timer, int usec, 229static __inline void ahd_timer_reset(ahd_timer_t *timer, int usec,
230 ahd_callback_t *func, void *arg); 230 ahd_callback_t *func, void *arg);
231static __inline void ahd_scb_timer_reset(struct scb *scb, u_int usec);
232 231
233static __inline void 232static __inline void
234ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg) 233ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg)
@@ -243,12 +242,6 @@ ahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg)
243 add_timer(timer); 242 add_timer(timer);
244} 243}
245 244
246static __inline void
247ahd_scb_timer_reset(struct scb *scb, u_int usec)
248{
249 mod_timer(&scb->io_ctx->eh_timeout, jiffies + (usec * HZ)/1000000);
250}
251
252/***************************** SMP support ************************************/ 245/***************************** SMP support ************************************/
253#include <linux/spinlock.h> 246#include <linux/spinlock.h>
254 247
@@ -389,7 +382,6 @@ struct ahd_platform_data {
389 382
390 spinlock_t spin_lock; 383 spinlock_t spin_lock;
391 u_int qfrozen; 384 u_int qfrozen;
392 struct timer_list reset_timer;
393 struct semaphore eh_sem; 385 struct semaphore eh_sem;
394 struct Scsi_Host *host; /* pointer to scsi host */ 386 struct Scsi_Host *host; /* pointer to scsi host */
395#define AHD_LINUX_NOIRQ ((uint32_t)~0) 387#define AHD_LINUX_NOIRQ ((uint32_t)~0)
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
index bf360ae021ab..ebbf7e4ff4cc 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
@@ -220,10 +220,10 @@ ahd_linux_pci_reserve_io_regions(struct ahd_softc *ahd, u_long *base,
220 *base2 = pci_resource_start(ahd->dev_softc, 3); 220 *base2 = pci_resource_start(ahd->dev_softc, 3);
221 if (*base == 0 || *base2 == 0) 221 if (*base == 0 || *base2 == 0)
222 return (ENOMEM); 222 return (ENOMEM);
223 if (request_region(*base, 256, "aic79xx") == 0) 223 if (!request_region(*base, 256, "aic79xx"))
224 return (ENOMEM); 224 return (ENOMEM);
225 if (request_region(*base2, 256, "aic79xx") == 0) { 225 if (!request_region(*base2, 256, "aic79xx")) {
226 release_region(*base2, 256); 226 release_region(*base, 256);
227 return (ENOMEM); 227 return (ENOMEM);
228 } 228 }
229 return (0); 229 return (0);
@@ -237,7 +237,7 @@ ahd_linux_pci_reserve_mem_region(struct ahd_softc *ahd,
237 u_long start; 237 u_long start;
238 u_long base_page; 238 u_long base_page;
239 u_long base_offset; 239 u_long base_offset;
240 int error; 240 int error = 0;
241 241
242 if (aic79xx_allow_memio == 0) 242 if (aic79xx_allow_memio == 0)
243 return (ENOMEM); 243 return (ENOMEM);
@@ -245,16 +245,15 @@ ahd_linux_pci_reserve_mem_region(struct ahd_softc *ahd,
245 if ((ahd->bugs & AHD_PCIX_MMAPIO_BUG) != 0) 245 if ((ahd->bugs & AHD_PCIX_MMAPIO_BUG) != 0)
246 return (ENOMEM); 246 return (ENOMEM);
247 247
248 error = 0;
249 start = pci_resource_start(ahd->dev_softc, 1); 248 start = pci_resource_start(ahd->dev_softc, 1);
250 base_page = start & PAGE_MASK; 249 base_page = start & PAGE_MASK;
251 base_offset = start - base_page; 250 base_offset = start - base_page;
252 if (start != 0) { 251 if (start != 0) {
253 *bus_addr = start; 252 *bus_addr = start;
254 if (request_mem_region(start, 0x1000, "aic79xx") == 0) 253 if (!request_mem_region(start, 0x1000, "aic79xx"))
255 error = ENOMEM; 254 error = ENOMEM;
256 if (error == 0) { 255 if (!error) {
257 *maddr = ioremap_nocache(base_page, base_offset + 256); 256 *maddr = ioremap_nocache(base_page, base_offset + 512);
258 if (*maddr == NULL) { 257 if (*maddr == NULL) {
259 error = ENOMEM; 258 error = ENOMEM;
260 release_mem_region(start, 0x1000); 259 release_mem_region(start, 0x1000);
@@ -344,7 +343,7 @@ ahd_pci_map_int(struct ahd_softc *ahd)
344 343
345 error = request_irq(ahd->dev_softc->irq, ahd_linux_isr, 344 error = request_irq(ahd->dev_softc->irq, ahd_linux_isr,
346 SA_SHIRQ, "aic79xx", ahd); 345 SA_SHIRQ, "aic79xx", ahd);
347 if (error == 0) 346 if (!error)
348 ahd->platform_data->irq = ahd->dev_softc->irq; 347 ahd->platform_data->irq = ahd->dev_softc->irq;
349 348
350 return (-error); 349 return (-error);
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
index 196a6344b037..757242e522c2 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
@@ -38,7 +38,7 @@
38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGES. 39 * POSSIBILITY OF SUCH DAMAGES.
40 * 40 *
41 * $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#89 $ 41 * $Id: //depot/aic7xxx/aic7xxx/aic79xx_pci.c#92 $
42 */ 42 */
43 43
44#ifdef __linux__ 44#ifdef __linux__
@@ -950,12 +950,19 @@ ahd_aic790X_setup(struct ahd_softc *ahd)
950 if ((ahd->flags & AHD_HP_BOARD) == 0) 950 if ((ahd->flags & AHD_HP_BOARD) == 0)
951 AHD_SET_SLEWRATE(ahd, AHD_SLEWRATE_DEF_REVA); 951 AHD_SET_SLEWRATE(ahd, AHD_SLEWRATE_DEF_REVA);
952 } else { 952 } else {
953 /* This is revision B and newer. */
954 extern uint32_t aic79xx_slowcrc;
953 u_int devconfig1; 955 u_int devconfig1;
954 956
955 ahd->features |= AHD_RTI|AHD_NEW_IOCELL_OPTS 957 ahd->features |= AHD_RTI|AHD_NEW_IOCELL_OPTS
956 | AHD_NEW_DFCNTRL_OPTS|AHD_FAST_CDB_DELIVERY; 958 | AHD_NEW_DFCNTRL_OPTS|AHD_FAST_CDB_DELIVERY
959 | AHD_BUSFREEREV_BUG;
957 ahd->bugs |= AHD_LQOOVERRUN_BUG|AHD_EARLY_REQ_BUG; 960 ahd->bugs |= AHD_LQOOVERRUN_BUG|AHD_EARLY_REQ_BUG;
958 961
962 /* If the user requested the the SLOWCRC bit to be set. */
963 if (aic79xx_slowcrc)
964 ahd->features |= AHD_AIC79XXB_SLOWCRC;
965
959 /* 966 /*
960 * Some issues have been resolved in the 7901B. 967 * Some issues have been resolved in the 7901B.
961 */ 968 */
diff --git a/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped b/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped
index 8763b158856b..2068e00d2c75 100644
--- a/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped
+++ b/drivers/scsi/aic7xxx/aic79xx_reg.h_shipped
@@ -2,8 +2,8 @@
2 * DO NOT EDIT - This file is automatically generated 2 * DO NOT EDIT - This file is automatically generated
3 * from the following source files: 3 * from the following source files:
4 * 4 *
5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#119 $ 5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#120 $
6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#76 $ 6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#77 $
7 */ 7 */
8typedef int (ahd_reg_print_t)(u_int, u_int *, u_int); 8typedef int (ahd_reg_print_t)(u_int, u_int *, u_int);
9typedef struct ahd_reg_parse_entry { 9typedef struct ahd_reg_parse_entry {
@@ -2204,6 +2204,20 @@ ahd_reg_print_t ahd_cmdsize_table_print;
2204#endif 2204#endif
2205 2205
2206#if AIC_DEBUG_REGISTERS 2206#if AIC_DEBUG_REGISTERS
2207ahd_reg_print_t ahd_mk_message_scb_print;
2208#else
2209#define ahd_mk_message_scb_print(regvalue, cur_col, wrap) \
2210 ahd_print_register(NULL, 0, "MK_MESSAGE_SCB", 0x160, regvalue, cur_col, wrap)
2211#endif
2212
2213#if AIC_DEBUG_REGISTERS
2214ahd_reg_print_t ahd_mk_message_scsiid_print;
2215#else
2216#define ahd_mk_message_scsiid_print(regvalue, cur_col, wrap) \
2217 ahd_print_register(NULL, 0, "MK_MESSAGE_SCSIID", 0x162, regvalue, cur_col, wrap)
2218#endif
2219
2220#if AIC_DEBUG_REGISTERS
2207ahd_reg_print_t ahd_scb_base_print; 2221ahd_reg_print_t ahd_scb_base_print;
2208#else 2222#else
2209#define ahd_scb_base_print(regvalue, cur_col, wrap) \ 2223#define ahd_scb_base_print(regvalue, cur_col, wrap) \
@@ -3638,6 +3652,7 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3638#define SEQ_FLAGS2 0x14d 3652#define SEQ_FLAGS2 0x14d
3639#define SELECTOUT_QFROZEN 0x04 3653#define SELECTOUT_QFROZEN 0x04
3640#define TARGET_MSG_PENDING 0x02 3654#define TARGET_MSG_PENDING 0x02
3655#define PENDING_MK_MESSAGE 0x01
3641 3656
3642#define ALLOCFIFO_SCBPTR 0x14e 3657#define ALLOCFIFO_SCBPTR 0x14e
3643 3658
@@ -3655,6 +3670,10 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3655 3670
3656#define CMDSIZE_TABLE 0x158 3671#define CMDSIZE_TABLE 0x158
3657 3672
3673#define MK_MESSAGE_SCB 0x160
3674
3675#define MK_MESSAGE_SCSIID 0x162
3676
3658#define SCB_BASE 0x180 3677#define SCB_BASE 0x180
3659 3678
3660#define SCB_RESIDUAL_DATACNT 0x180 3679#define SCB_RESIDUAL_DATACNT 0x180
@@ -3800,5 +3819,5 @@ ahd_reg_print_t ahd_scb_disconnected_lists_print;
3800 3819
3801 3820
3802/* Exported Labels */ 3821/* Exported Labels */
3803#define LABEL_seq_isr 0x285 3822#define LABEL_seq_isr 0x28f
3804#define LABEL_timer_isr 0x281 3823#define LABEL_timer_isr 0x28b
diff --git a/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped b/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped
index a4137c985376..db38a61a8cb4 100644
--- a/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped
+++ b/drivers/scsi/aic7xxx/aic79xx_reg_print.c_shipped
@@ -2,8 +2,8 @@
2 * DO NOT EDIT - This file is automatically generated 2 * DO NOT EDIT - This file is automatically generated
3 * from the following source files: 3 * from the following source files:
4 * 4 *
5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#118 $ 5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#120 $
6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#75 $ 6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#77 $
7 */ 7 */
8 8
9#include "aic79xx_osm.h" 9#include "aic79xx_osm.h"
@@ -3382,6 +3382,7 @@ ahd_initiator_tag_print(u_int regvalue, u_int *cur_col, u_int wrap)
3382} 3382}
3383 3383
3384static ahd_reg_parse_entry_t SEQ_FLAGS2_parse_table[] = { 3384static ahd_reg_parse_entry_t SEQ_FLAGS2_parse_table[] = {
3385 { "PENDING_MK_MESSAGE", 0x01, 0x01 },
3385 { "TARGET_MSG_PENDING", 0x02, 0x02 }, 3386 { "TARGET_MSG_PENDING", 0x02, 0x02 },
3386 { "SELECTOUT_QFROZEN", 0x04, 0x04 } 3387 { "SELECTOUT_QFROZEN", 0x04, 0x04 }
3387}; 3388};
@@ -3389,7 +3390,7 @@ static ahd_reg_parse_entry_t SEQ_FLAGS2_parse_table[] = {
3389int 3390int
3390ahd_seq_flags2_print(u_int regvalue, u_int *cur_col, u_int wrap) 3391ahd_seq_flags2_print(u_int regvalue, u_int *cur_col, u_int wrap)
3391{ 3392{
3392 return (ahd_print_register(SEQ_FLAGS2_parse_table, 2, "SEQ_FLAGS2", 3393 return (ahd_print_register(SEQ_FLAGS2_parse_table, 3, "SEQ_FLAGS2",
3393 0x14d, regvalue, cur_col, wrap)); 3394 0x14d, regvalue, cur_col, wrap));
3394} 3395}
3395 3396
@@ -3450,6 +3451,20 @@ ahd_cmdsize_table_print(u_int regvalue, u_int *cur_col, u_int wrap)
3450} 3451}
3451 3452
3452int 3453int
3454ahd_mk_message_scb_print(u_int regvalue, u_int *cur_col, u_int wrap)
3455{
3456 return (ahd_print_register(NULL, 0, "MK_MESSAGE_SCB",
3457 0x160, regvalue, cur_col, wrap));
3458}
3459
3460int
3461ahd_mk_message_scsiid_print(u_int regvalue, u_int *cur_col, u_int wrap)
3462{
3463 return (ahd_print_register(NULL, 0, "MK_MESSAGE_SCSIID",
3464 0x162, regvalue, cur_col, wrap));
3465}
3466
3467int
3453ahd_scb_base_print(u_int regvalue, u_int *cur_col, u_int wrap) 3468ahd_scb_base_print(u_int regvalue, u_int *cur_col, u_int wrap)
3454{ 3469{
3455 return (ahd_print_register(NULL, 0, "SCB_BASE", 3470 return (ahd_print_register(NULL, 0, "SCB_BASE",
diff --git a/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped b/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped
index b1e5365be230..11bed07e90b7 100644
--- a/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped
+++ b/drivers/scsi/aic7xxx/aic79xx_seq.h_shipped
@@ -2,17 +2,17 @@
2 * DO NOT EDIT - This file is automatically generated 2 * DO NOT EDIT - This file is automatically generated
3 * from the following source files: 3 * from the following source files:
4 * 4 *
5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#119 $ 5 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#120 $
6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#76 $ 6 * $Id: //depot/aic7xxx/aic7xxx/aic79xx.reg#77 $
7 */ 7 */
8static uint8_t seqprog[] = { 8static uint8_t seqprog[] = {
9 0xff, 0x02, 0x06, 0x78, 9 0xff, 0x02, 0x06, 0x78,
10 0x00, 0xea, 0x64, 0x59, 10 0x00, 0xea, 0x6e, 0x59,
11 0x01, 0xea, 0x04, 0x30, 11 0x01, 0xea, 0x04, 0x30,
12 0xff, 0x04, 0x0c, 0x78, 12 0xff, 0x04, 0x0c, 0x78,
13 0x19, 0xea, 0x64, 0x59, 13 0x19, 0xea, 0x6e, 0x59,
14 0x19, 0xea, 0x04, 0x00, 14 0x19, 0xea, 0x04, 0x00,
15 0x33, 0xea, 0x5e, 0x59, 15 0x33, 0xea, 0x68, 0x59,
16 0x33, 0xea, 0x00, 0x00, 16 0x33, 0xea, 0x00, 0x00,
17 0x60, 0x3a, 0x3a, 0x68, 17 0x60, 0x3a, 0x3a, 0x68,
18 0x04, 0x4d, 0x35, 0x78, 18 0x04, 0x4d, 0x35, 0x78,
@@ -33,15 +33,15 @@ static uint8_t seqprog[] = {
33 0xff, 0xea, 0x62, 0x02, 33 0xff, 0xea, 0x62, 0x02,
34 0x00, 0xe2, 0x3a, 0x40, 34 0x00, 0xe2, 0x3a, 0x40,
35 0xff, 0x21, 0x3b, 0x70, 35 0xff, 0x21, 0x3b, 0x70,
36 0x40, 0x4b, 0xaa, 0x69, 36 0x40, 0x4b, 0xb4, 0x69,
37 0x00, 0xe2, 0x68, 0x59, 37 0x00, 0xe2, 0x72, 0x59,
38 0x40, 0x4b, 0xaa, 0x69, 38 0x40, 0x4b, 0xb4, 0x69,
39 0x20, 0x4b, 0x96, 0x69, 39 0x20, 0x4b, 0xa0, 0x69,
40 0xfc, 0x42, 0x44, 0x78, 40 0xfc, 0x42, 0x44, 0x78,
41 0x10, 0x40, 0x44, 0x78, 41 0x10, 0x40, 0x44, 0x78,
42 0x00, 0xe2, 0xfc, 0x5d, 42 0x00, 0xe2, 0x10, 0x5e,
43 0x20, 0x4d, 0x48, 0x78, 43 0x20, 0x4d, 0x48, 0x78,
44 0x00, 0xe2, 0xfc, 0x5d, 44 0x00, 0xe2, 0x10, 0x5e,
45 0x30, 0x3f, 0xc0, 0x09, 45 0x30, 0x3f, 0xc0, 0x09,
46 0x30, 0xe0, 0x50, 0x60, 46 0x30, 0xe0, 0x50, 0x60,
47 0x7f, 0x4a, 0x94, 0x08, 47 0x7f, 0x4a, 0x94, 0x08,
@@ -51,7 +51,7 @@ static uint8_t seqprog[] = {
51 0x00, 0xe2, 0x76, 0x58, 51 0x00, 0xe2, 0x76, 0x58,
52 0x00, 0xe2, 0x86, 0x58, 52 0x00, 0xe2, 0x86, 0x58,
53 0x00, 0xe2, 0x06, 0x40, 53 0x00, 0xe2, 0x06, 0x40,
54 0x33, 0xea, 0x5e, 0x59, 54 0x33, 0xea, 0x68, 0x59,
55 0x33, 0xea, 0x00, 0x00, 55 0x33, 0xea, 0x00, 0x00,
56 0x01, 0x52, 0x84, 0x78, 56 0x01, 0x52, 0x84, 0x78,
57 0x02, 0x58, 0x50, 0x31, 57 0x02, 0x58, 0x50, 0x31,
@@ -59,26 +59,26 @@ static uint8_t seqprog[] = {
59 0xff, 0x97, 0x6f, 0x78, 59 0xff, 0x97, 0x6f, 0x78,
60 0x50, 0x4b, 0x6a, 0x68, 60 0x50, 0x4b, 0x6a, 0x68,
61 0xbf, 0x3a, 0x74, 0x08, 61 0xbf, 0x3a, 0x74, 0x08,
62 0x14, 0xea, 0x64, 0x59, 62 0x14, 0xea, 0x6e, 0x59,
63 0x14, 0xea, 0x04, 0x00, 63 0x14, 0xea, 0x04, 0x00,
64 0x08, 0x92, 0x25, 0x03, 64 0x08, 0x92, 0x25, 0x03,
65 0xff, 0x90, 0x5f, 0x68, 65 0xff, 0x90, 0x5f, 0x68,
66 0x00, 0xe2, 0x76, 0x5b, 66 0x00, 0xe2, 0x8a, 0x5b,
67 0x00, 0xe2, 0x5e, 0x40, 67 0x00, 0xe2, 0x5e, 0x40,
68 0x00, 0xea, 0x5e, 0x59, 68 0x00, 0xea, 0x68, 0x59,
69 0x01, 0xea, 0x00, 0x30, 69 0x01, 0xea, 0x00, 0x30,
70 0x80, 0xf9, 0x7e, 0x68, 70 0x80, 0xf9, 0x7e, 0x68,
71 0x00, 0xe2, 0x5c, 0x59, 71 0x00, 0xe2, 0x66, 0x59,
72 0x11, 0xea, 0x5e, 0x59, 72 0x11, 0xea, 0x68, 0x59,
73 0x11, 0xea, 0x00, 0x00, 73 0x11, 0xea, 0x00, 0x00,
74 0x80, 0xf9, 0x5c, 0x79, 74 0x80, 0xf9, 0x66, 0x79,
75 0xff, 0xea, 0xd4, 0x0d, 75 0xff, 0xea, 0xd4, 0x0d,
76 0x22, 0xea, 0x5e, 0x59, 76 0x22, 0xea, 0x68, 0x59,
77 0x22, 0xea, 0x00, 0x00, 77 0x22, 0xea, 0x00, 0x00,
78 0x10, 0x16, 0x90, 0x78, 78 0x10, 0x16, 0x90, 0x78,
79 0x10, 0x16, 0x2c, 0x00, 79 0x10, 0x16, 0x2c, 0x00,
80 0x01, 0x0b, 0xae, 0x32, 80 0x01, 0x0b, 0xae, 0x32,
81 0x18, 0xad, 0x12, 0x79, 81 0x18, 0xad, 0x1c, 0x79,
82 0x04, 0xad, 0xdc, 0x68, 82 0x04, 0xad, 0xdc, 0x68,
83 0x80, 0xad, 0x84, 0x78, 83 0x80, 0xad, 0x84, 0x78,
84 0x10, 0xad, 0xaa, 0x78, 84 0x10, 0xad, 0xaa, 0x78,
@@ -118,7 +118,6 @@ static uint8_t seqprog[] = {
118 0x80, 0x18, 0x30, 0x04, 118 0x80, 0x18, 0x30, 0x04,
119 0x40, 0xad, 0x84, 0x78, 119 0x40, 0xad, 0x84, 0x78,
120 0xe7, 0xad, 0x5a, 0x09, 120 0xe7, 0xad, 0x5a, 0x09,
121 0x02, 0xa8, 0x40, 0x31,
122 0xff, 0xea, 0xc0, 0x09, 121 0xff, 0xea, 0xc0, 0x09,
123 0x01, 0x54, 0xa9, 0x1a, 122 0x01, 0x54, 0xa9, 0x1a,
124 0x00, 0x55, 0xab, 0x22, 123 0x00, 0x55, 0xab, 0x22,
@@ -128,24 +127,30 @@ static uint8_t seqprog[] = {
128 0xff, 0xea, 0x5a, 0x03, 127 0xff, 0xea, 0x5a, 0x03,
129 0xff, 0xea, 0x5e, 0x03, 128 0xff, 0xea, 0x5e, 0x03,
130 0x01, 0x10, 0xd4, 0x31, 129 0x01, 0x10, 0xd4, 0x31,
131 0x10, 0x92, 0x07, 0x69, 130 0x02, 0xa8, 0x40, 0x31,
131 0x01, 0x92, 0xc1, 0x31,
132 0x3d, 0x93, 0xc5, 0x29, 132 0x3d, 0x93, 0xc5, 0x29,
133 0xfe, 0xe2, 0xc4, 0x09, 133 0xfe, 0xe2, 0xc4, 0x09,
134 0x01, 0xea, 0xc6, 0x01, 134 0x01, 0xea, 0xc6, 0x01,
135 0x02, 0xe2, 0xc8, 0x31, 135 0x02, 0xe2, 0xc8, 0x31,
136 0x02, 0xec, 0x50, 0x31, 136 0x02, 0xec, 0x50, 0x31,
137 0x02, 0xa0, 0xda, 0x31, 137 0x02, 0xa0, 0xda, 0x31,
138 0xff, 0xa9, 0x06, 0x71, 138 0xff, 0xa9, 0x10, 0x71,
139 0x10, 0xe0, 0x0e, 0x79,
140 0x10, 0x92, 0x0f, 0x79,
141 0x01, 0x4d, 0x9b, 0x02,
142 0x02, 0xa0, 0xc0, 0x32,
143 0x01, 0x93, 0xc5, 0x36,
139 0x02, 0xa0, 0x58, 0x37, 144 0x02, 0xa0, 0x58, 0x37,
140 0xff, 0x21, 0x0f, 0x71, 145 0xff, 0x21, 0x19, 0x71,
141 0x02, 0x22, 0x51, 0x31, 146 0x02, 0x22, 0x51, 0x31,
142 0x02, 0xa0, 0x5c, 0x33, 147 0x02, 0xa0, 0x5c, 0x33,
143 0x02, 0xa0, 0x44, 0x36, 148 0x02, 0xa0, 0x44, 0x36,
144 0x02, 0xa0, 0x40, 0x32, 149 0x02, 0xa0, 0x40, 0x32,
145 0x02, 0xa0, 0x44, 0x36, 150 0x02, 0xa0, 0x44, 0x36,
146 0x04, 0x4d, 0x17, 0x69, 151 0x05, 0x4d, 0x21, 0x69,
147 0x40, 0x16, 0x48, 0x69, 152 0x40, 0x16, 0x52, 0x69,
148 0xff, 0x2d, 0x4d, 0x61, 153 0xff, 0x2d, 0x57, 0x61,
149 0xff, 0x29, 0x85, 0x70, 154 0xff, 0x29, 0x85, 0x70,
150 0x02, 0x28, 0x55, 0x32, 155 0x02, 0x28, 0x55, 0x32,
151 0x01, 0xea, 0x5a, 0x01, 156 0x01, 0xea, 0x5a, 0x01,
@@ -159,22 +164,22 @@ static uint8_t seqprog[] = {
159 0x01, 0x56, 0xad, 0x1a, 164 0x01, 0x56, 0xad, 0x1a,
160 0xff, 0x54, 0xa9, 0x1a, 165 0xff, 0x54, 0xa9, 0x1a,
161 0xff, 0x55, 0xab, 0x22, 166 0xff, 0x55, 0xab, 0x22,
162 0xff, 0x8d, 0x41, 0x71, 167 0xff, 0x8d, 0x4b, 0x71,
163 0x80, 0xac, 0x40, 0x71, 168 0x80, 0xac, 0x4a, 0x71,
164 0x20, 0x16, 0x40, 0x69, 169 0x20, 0x16, 0x4a, 0x69,
165 0x00, 0xac, 0xc4, 0x19, 170 0x00, 0xac, 0xc4, 0x19,
166 0x07, 0xe2, 0x40, 0xf9, 171 0x07, 0xe2, 0x4a, 0xf9,
167 0x02, 0x8c, 0x51, 0x31, 172 0x02, 0x8c, 0x51, 0x31,
168 0x00, 0xe2, 0x24, 0x41, 173 0x00, 0xe2, 0x2e, 0x41,
169 0x01, 0xac, 0x08, 0x31, 174 0x01, 0xac, 0x08, 0x31,
170 0x09, 0xea, 0x5a, 0x01, 175 0x09, 0xea, 0x5a, 0x01,
171 0x02, 0x8c, 0x51, 0x32, 176 0x02, 0x8c, 0x51, 0x32,
172 0xff, 0xea, 0x1a, 0x07, 177 0xff, 0xea, 0x1a, 0x07,
173 0x04, 0x24, 0xf9, 0x30, 178 0x04, 0x24, 0xf9, 0x30,
174 0x1d, 0xea, 0x52, 0x41, 179 0x1d, 0xea, 0x5c, 0x41,
175 0x02, 0x2c, 0x51, 0x31, 180 0x02, 0x2c, 0x51, 0x31,
176 0x04, 0xa8, 0xf9, 0x30, 181 0x04, 0xa8, 0xf9, 0x30,
177 0x19, 0xea, 0x52, 0x41, 182 0x19, 0xea, 0x5c, 0x41,
178 0x06, 0xea, 0x08, 0x81, 183 0x06, 0xea, 0x08, 0x81,
179 0x01, 0xe2, 0x5a, 0x35, 184 0x01, 0xe2, 0x5a, 0x35,
180 0x02, 0xf2, 0xf0, 0x31, 185 0x02, 0xf2, 0xf0, 0x31,
@@ -190,27 +195,27 @@ static uint8_t seqprog[] = {
190 0x02, 0x20, 0xb9, 0x30, 195 0x02, 0x20, 0xb9, 0x30,
191 0x02, 0x20, 0x51, 0x31, 196 0x02, 0x20, 0x51, 0x31,
192 0x4c, 0x93, 0xd7, 0x28, 197 0x4c, 0x93, 0xd7, 0x28,
193 0x10, 0x92, 0x77, 0x79, 198 0x10, 0x92, 0x81, 0x79,
194 0x01, 0x6b, 0xc0, 0x30, 199 0x01, 0x6b, 0xc0, 0x30,
195 0x02, 0x64, 0xc8, 0x00, 200 0x02, 0x64, 0xc8, 0x00,
196 0x40, 0x3a, 0x74, 0x04, 201 0x40, 0x3a, 0x74, 0x04,
197 0x00, 0xe2, 0x76, 0x58, 202 0x00, 0xe2, 0x76, 0x58,
198 0x33, 0xea, 0x5e, 0x59, 203 0x33, 0xea, 0x68, 0x59,
199 0x33, 0xea, 0x00, 0x00, 204 0x33, 0xea, 0x00, 0x00,
200 0x30, 0x3f, 0xc0, 0x09, 205 0x30, 0x3f, 0xc0, 0x09,
201 0x30, 0xe0, 0x78, 0x61, 206 0x30, 0xe0, 0x82, 0x61,
202 0x20, 0x3f, 0x8e, 0x69, 207 0x20, 0x3f, 0x98, 0x69,
203 0x10, 0x3f, 0x78, 0x79, 208 0x10, 0x3f, 0x82, 0x79,
204 0x02, 0xea, 0x7e, 0x00, 209 0x02, 0xea, 0x7e, 0x00,
205 0x00, 0xea, 0x5e, 0x59, 210 0x00, 0xea, 0x68, 0x59,
206 0x01, 0xea, 0x00, 0x30, 211 0x01, 0xea, 0x00, 0x30,
207 0x02, 0x4e, 0x51, 0x35, 212 0x02, 0x4e, 0x51, 0x35,
208 0x01, 0xea, 0x7e, 0x00, 213 0x01, 0xea, 0x7e, 0x00,
209 0x11, 0xea, 0x5e, 0x59, 214 0x11, 0xea, 0x68, 0x59,
210 0x11, 0xea, 0x00, 0x00, 215 0x11, 0xea, 0x00, 0x00,
211 0x02, 0x4e, 0x51, 0x35, 216 0x02, 0x4e, 0x51, 0x35,
212 0xc0, 0x4a, 0x94, 0x00, 217 0xc0, 0x4a, 0x94, 0x00,
213 0x04, 0x41, 0x9c, 0x79, 218 0x04, 0x41, 0xa6, 0x79,
214 0x08, 0xea, 0x98, 0x00, 219 0x08, 0xea, 0x98, 0x00,
215 0x08, 0x57, 0xae, 0x00, 220 0x08, 0x57, 0xae, 0x00,
216 0x08, 0x3c, 0x78, 0x00, 221 0x08, 0x3c, 0x78, 0x00,
@@ -218,12 +223,12 @@ static uint8_t seqprog[] = {
218 0x0f, 0x67, 0xc0, 0x09, 223 0x0f, 0x67, 0xc0, 0x09,
219 0x00, 0x3a, 0x75, 0x02, 224 0x00, 0x3a, 0x75, 0x02,
220 0x20, 0xea, 0x96, 0x00, 225 0x20, 0xea, 0x96, 0x00,
221 0x00, 0xe2, 0x14, 0x42, 226 0x00, 0xe2, 0x28, 0x42,
222 0xc0, 0x4a, 0x94, 0x00, 227 0xc0, 0x4a, 0x94, 0x00,
223 0x40, 0x3a, 0xc8, 0x69, 228 0x40, 0x3a, 0xd2, 0x69,
224 0x02, 0x55, 0x06, 0x68, 229 0x02, 0x55, 0x06, 0x68,
225 0x02, 0x56, 0xc8, 0x69, 230 0x02, 0x56, 0xd2, 0x69,
226 0xff, 0x5b, 0xc8, 0x61, 231 0xff, 0x5b, 0xd2, 0x61,
227 0x02, 0x20, 0x51, 0x31, 232 0x02, 0x20, 0x51, 0x31,
228 0x80, 0xea, 0xb2, 0x01, 233 0x80, 0xea, 0xb2, 0x01,
229 0x44, 0xea, 0x00, 0x00, 234 0x44, 0xea, 0x00, 0x00,
@@ -231,40 +236,45 @@ static uint8_t seqprog[] = {
231 0x33, 0xea, 0x00, 0x00, 236 0x33, 0xea, 0x00, 0x00,
232 0xff, 0xea, 0xb2, 0x09, 237 0xff, 0xea, 0xb2, 0x09,
233 0xff, 0xe0, 0xc0, 0x19, 238 0xff, 0xe0, 0xc0, 0x19,
234 0xff, 0xe0, 0xca, 0x79, 239 0xff, 0xe0, 0xd4, 0x79,
235 0x02, 0xac, 0x51, 0x31, 240 0x02, 0xac, 0x51, 0x31,
236 0x00, 0xe2, 0xc0, 0x41, 241 0x00, 0xe2, 0xca, 0x41,
237 0x02, 0x5e, 0x50, 0x31, 242 0x02, 0x5e, 0x50, 0x31,
238 0x02, 0xa8, 0xb8, 0x30, 243 0x02, 0xa8, 0xb8, 0x30,
239 0x02, 0x5c, 0x50, 0x31, 244 0x02, 0x5c, 0x50, 0x31,
240 0xff, 0xad, 0xdb, 0x71, 245 0xff, 0xad, 0xe5, 0x71,
241 0x02, 0xac, 0x41, 0x31, 246 0x02, 0xac, 0x41, 0x31,
242 0x02, 0x22, 0x51, 0x31, 247 0x02, 0x22, 0x51, 0x31,
243 0x02, 0xa0, 0x5c, 0x33, 248 0x02, 0xa0, 0x5c, 0x33,
244 0x02, 0xa0, 0x44, 0x32, 249 0x02, 0xa0, 0x44, 0x32,
245 0x00, 0xe2, 0xe4, 0x41, 250 0x00, 0xe2, 0xf8, 0x41,
246 0x10, 0x92, 0xe5, 0x69, 251 0x01, 0x4d, 0xf1, 0x79,
252 0x01, 0x62, 0xc1, 0x31,
253 0x00, 0x93, 0xf1, 0x61,
254 0xfe, 0x4d, 0x9b, 0x0a,
255 0x02, 0x60, 0x41, 0x31,
256 0x00, 0xe2, 0xdc, 0x41,
247 0x3d, 0x93, 0xc9, 0x29, 257 0x3d, 0x93, 0xc9, 0x29,
248 0x01, 0xe4, 0xc8, 0x01, 258 0x01, 0xe4, 0xc8, 0x01,
249 0x01, 0xea, 0xca, 0x01, 259 0x01, 0xea, 0xca, 0x01,
250 0xff, 0xea, 0xda, 0x01, 260 0xff, 0xea, 0xda, 0x01,
251 0x02, 0x20, 0x51, 0x31, 261 0x02, 0x20, 0x51, 0x31,
252 0x02, 0xae, 0x41, 0x32, 262 0x02, 0xae, 0x41, 0x32,
253 0xff, 0x21, 0xed, 0x61, 263 0xff, 0x21, 0x01, 0x62,
254 0xff, 0xea, 0x46, 0x02, 264 0xff, 0xea, 0x46, 0x02,
255 0x02, 0x5c, 0x50, 0x31, 265 0x02, 0x5c, 0x50, 0x31,
256 0x40, 0xea, 0x96, 0x00, 266 0x40, 0xea, 0x96, 0x00,
257 0x02, 0x56, 0x04, 0x6e, 267 0x02, 0x56, 0x20, 0x6e,
258 0x01, 0x55, 0x04, 0x6e, 268 0x01, 0x55, 0x20, 0x6e,
259 0x10, 0x92, 0xf9, 0x79, 269 0x10, 0x92, 0x0d, 0x7a,
260 0x10, 0x40, 0x02, 0x6a, 270 0x10, 0x40, 0x16, 0x6a,
261 0x01, 0x56, 0x02, 0x7a, 271 0x01, 0x56, 0x16, 0x7a,
262 0xff, 0x97, 0x07, 0x78, 272 0xff, 0x97, 0x07, 0x78,
263 0x13, 0xea, 0x64, 0x59, 273 0x13, 0xea, 0x6e, 0x59,
264 0x13, 0xea, 0x04, 0x00, 274 0x13, 0xea, 0x04, 0x00,
265 0x00, 0xe2, 0x06, 0x40, 275 0x00, 0xe2, 0x06, 0x40,
266 0xbf, 0x3a, 0x74, 0x08, 276 0xbf, 0x3a, 0x74, 0x08,
267 0x04, 0x41, 0x08, 0x7a, 277 0x04, 0x41, 0x1c, 0x7a,
268 0x08, 0xea, 0x98, 0x00, 278 0x08, 0xea, 0x98, 0x00,
269 0x08, 0x57, 0xae, 0x00, 279 0x08, 0x57, 0xae, 0x00,
270 0x01, 0x93, 0x75, 0x32, 280 0x01, 0x93, 0x75, 0x32,
@@ -272,108 +282,108 @@ static uint8_t seqprog[] = {
272 0x40, 0xea, 0x72, 0x02, 282 0x40, 0xea, 0x72, 0x02,
273 0x08, 0x3c, 0x78, 0x00, 283 0x08, 0x3c, 0x78, 0x00,
274 0x80, 0xea, 0x6e, 0x02, 284 0x80, 0xea, 0x6e, 0x02,
275 0x00, 0xe2, 0xe2, 0x5b, 285 0x00, 0xe2, 0xf6, 0x5b,
276 0x01, 0x3c, 0xc1, 0x31, 286 0x01, 0x3c, 0xc1, 0x31,
277 0x9f, 0xe0, 0x84, 0x7c, 287 0x9f, 0xe0, 0x98, 0x7c,
278 0x80, 0xe0, 0x28, 0x72, 288 0x80, 0xe0, 0x3c, 0x72,
279 0xa0, 0xe0, 0x64, 0x72, 289 0xa0, 0xe0, 0x78, 0x72,
280 0xc0, 0xe0, 0x5a, 0x72, 290 0xc0, 0xe0, 0x6e, 0x72,
281 0xe0, 0xe0, 0x94, 0x72, 291 0xe0, 0xe0, 0xa8, 0x72,
282 0x01, 0xea, 0x64, 0x59, 292 0x01, 0xea, 0x6e, 0x59,
283 0x01, 0xea, 0x04, 0x00, 293 0x01, 0xea, 0x04, 0x00,
284 0x00, 0xe2, 0x14, 0x42, 294 0x00, 0xe2, 0x28, 0x42,
285 0x80, 0x39, 0x2f, 0x7a, 295 0x80, 0x39, 0x43, 0x7a,
286 0x03, 0xea, 0x64, 0x59, 296 0x03, 0xea, 0x6e, 0x59,
287 0x03, 0xea, 0x04, 0x00, 297 0x03, 0xea, 0x04, 0x00,
288 0xee, 0x00, 0x36, 0x6a, 298 0xee, 0x00, 0x4a, 0x6a,
289 0x05, 0xea, 0xb4, 0x00, 299 0x05, 0xea, 0xb4, 0x00,
290 0x33, 0xea, 0x5e, 0x59, 300 0x33, 0xea, 0x68, 0x59,
291 0x33, 0xea, 0x00, 0x00, 301 0x33, 0xea, 0x00, 0x00,
292 0x02, 0xa8, 0x9c, 0x32, 302 0x02, 0xa8, 0x9c, 0x32,
293 0x00, 0xe2, 0x7e, 0x59, 303 0x00, 0xe2, 0x88, 0x59,
294 0xef, 0x96, 0xd5, 0x19, 304 0xef, 0x96, 0xd5, 0x19,
295 0x00, 0xe2, 0x46, 0x52, 305 0x00, 0xe2, 0x5a, 0x52,
296 0x09, 0x80, 0xe1, 0x30, 306 0x09, 0x80, 0xe1, 0x30,
297 0x02, 0xea, 0x36, 0x00, 307 0x02, 0xea, 0x36, 0x00,
298 0xa8, 0xea, 0x32, 0x00, 308 0xa8, 0xea, 0x32, 0x00,
299 0x00, 0xe2, 0x4c, 0x42, 309 0x00, 0xe2, 0x60, 0x42,
300 0x01, 0x96, 0xd1, 0x30, 310 0x01, 0x96, 0xd1, 0x30,
301 0x10, 0x80, 0x89, 0x31, 311 0x10, 0x80, 0x89, 0x31,
302 0x20, 0xea, 0x32, 0x00, 312 0x20, 0xea, 0x32, 0x00,
303 0xbf, 0x39, 0x73, 0x0a, 313 0xbf, 0x39, 0x73, 0x0a,
304 0x10, 0x4c, 0x56, 0x6a, 314 0x10, 0x4c, 0x6a, 0x6a,
305 0x20, 0x19, 0x4e, 0x6a, 315 0x20, 0x19, 0x62, 0x6a,
306 0x20, 0x19, 0x52, 0x6a, 316 0x20, 0x19, 0x66, 0x6a,
307 0x02, 0x4d, 0x14, 0x6a, 317 0x02, 0x4d, 0x28, 0x6a,
308 0x40, 0x39, 0x73, 0x02, 318 0x40, 0x39, 0x73, 0x02,
309 0x00, 0xe2, 0x14, 0x42, 319 0x00, 0xe2, 0x28, 0x42,
310 0x80, 0x39, 0xd5, 0x6a, 320 0x80, 0x39, 0xe9, 0x6a,
311 0x01, 0x44, 0x10, 0x33, 321 0x01, 0x44, 0x10, 0x33,
312 0x08, 0x92, 0x25, 0x03, 322 0x08, 0x92, 0x25, 0x03,
313 0x00, 0xe2, 0x14, 0x42, 323 0x00, 0xe2, 0x28, 0x42,
314 0x10, 0xea, 0x80, 0x00, 324 0x10, 0xea, 0x80, 0x00,
315 0x01, 0x37, 0xc5, 0x31, 325 0x01, 0x37, 0xc5, 0x31,
316 0x80, 0xe2, 0x80, 0x62, 326 0x80, 0xe2, 0x94, 0x62,
317 0x10, 0x92, 0xa5, 0x6a, 327 0x10, 0x92, 0xb9, 0x6a,
318 0xc0, 0x94, 0xc5, 0x01, 328 0xc0, 0x94, 0xc5, 0x01,
319 0x40, 0x92, 0x71, 0x6a, 329 0x40, 0x92, 0x85, 0x6a,
320 0xbf, 0xe2, 0xc4, 0x09, 330 0xbf, 0xe2, 0xc4, 0x09,
321 0x20, 0x92, 0x85, 0x7a, 331 0x20, 0x92, 0x99, 0x7a,
322 0x01, 0xe2, 0x88, 0x30, 332 0x01, 0xe2, 0x88, 0x30,
323 0x00, 0xe2, 0xe2, 0x5b, 333 0x00, 0xe2, 0xf6, 0x5b,
324 0xa0, 0x3c, 0x8d, 0x62, 334 0xa0, 0x3c, 0xa1, 0x62,
325 0x23, 0x92, 0x89, 0x08, 335 0x23, 0x92, 0x89, 0x08,
326 0x00, 0xe2, 0xe2, 0x5b, 336 0x00, 0xe2, 0xf6, 0x5b,
327 0xa0, 0x3c, 0x8d, 0x62, 337 0xa0, 0x3c, 0xa1, 0x62,
328 0x00, 0xa8, 0x84, 0x42, 338 0x00, 0xa8, 0x98, 0x42,
329 0xff, 0xe2, 0x84, 0x62, 339 0xff, 0xe2, 0x98, 0x62,
330 0x00, 0xe2, 0xa4, 0x42, 340 0x00, 0xe2, 0xb8, 0x42,
331 0x40, 0xea, 0x98, 0x00, 341 0x40, 0xea, 0x98, 0x00,
332 0x01, 0xe2, 0x88, 0x30, 342 0x01, 0xe2, 0x88, 0x30,
333 0x00, 0xe2, 0xe2, 0x5b, 343 0x00, 0xe2, 0xf6, 0x5b,
334 0xa0, 0x3c, 0x63, 0x72, 344 0xa0, 0x3c, 0x77, 0x72,
335 0x40, 0xea, 0x98, 0x00, 345 0x40, 0xea, 0x98, 0x00,
336 0x01, 0x37, 0x95, 0x32, 346 0x01, 0x37, 0x95, 0x32,
337 0x08, 0xea, 0x6e, 0x02, 347 0x08, 0xea, 0x6e, 0x02,
338 0x00, 0xe2, 0x14, 0x42, 348 0x00, 0xe2, 0x28, 0x42,
339 0xe0, 0xea, 0xfe, 0x5b, 349 0xe0, 0xea, 0x12, 0x5c,
340 0x80, 0xe0, 0xe0, 0x6a, 350 0x80, 0xe0, 0xf4, 0x6a,
341 0x04, 0xe0, 0x92, 0x73, 351 0x04, 0xe0, 0xa6, 0x73,
342 0x02, 0xe0, 0xc4, 0x73, 352 0x02, 0xe0, 0xd8, 0x73,
343 0x00, 0xea, 0x3e, 0x73, 353 0x00, 0xea, 0x52, 0x73,
344 0x03, 0xe0, 0xd4, 0x73, 354 0x03, 0xe0, 0xe8, 0x73,
345 0x23, 0xe0, 0xb6, 0x72, 355 0x23, 0xe0, 0xca, 0x72,
346 0x08, 0xe0, 0xdc, 0x72, 356 0x08, 0xe0, 0xf0, 0x72,
347 0x00, 0xe2, 0xe2, 0x5b, 357 0x00, 0xe2, 0xf6, 0x5b,
348 0x07, 0xea, 0x64, 0x59, 358 0x07, 0xea, 0x6e, 0x59,
349 0x07, 0xea, 0x04, 0x00, 359 0x07, 0xea, 0x04, 0x00,
350 0x08, 0x48, 0x15, 0x72, 360 0x08, 0x48, 0x29, 0x72,
351 0x04, 0x48, 0xb3, 0x62, 361 0x04, 0x48, 0xc7, 0x62,
352 0x01, 0x49, 0x89, 0x30, 362 0x01, 0x49, 0x89, 0x30,
353 0x00, 0xe2, 0xa4, 0x42, 363 0x00, 0xe2, 0xb8, 0x42,
354 0x01, 0x44, 0xd4, 0x31, 364 0x01, 0x44, 0xd4, 0x31,
355 0x00, 0xe2, 0xa4, 0x42, 365 0x00, 0xe2, 0xb8, 0x42,
356 0x01, 0x00, 0x6c, 0x32, 366 0x01, 0x00, 0x6c, 0x32,
357 0x33, 0xea, 0x5e, 0x59, 367 0x33, 0xea, 0x68, 0x59,
358 0x33, 0xea, 0x00, 0x00, 368 0x33, 0xea, 0x00, 0x00,
359 0x4c, 0x3a, 0xc1, 0x28, 369 0x4c, 0x3a, 0xc1, 0x28,
360 0x01, 0x64, 0xc0, 0x31, 370 0x01, 0x64, 0xc0, 0x31,
361 0x00, 0x36, 0x5f, 0x59, 371 0x00, 0x36, 0x69, 0x59,
362 0x01, 0x36, 0x01, 0x30, 372 0x01, 0x36, 0x01, 0x30,
363 0x01, 0xe0, 0xda, 0x7a, 373 0x01, 0xe0, 0xee, 0x7a,
364 0xa0, 0xea, 0xf4, 0x5b, 374 0xa0, 0xea, 0x08, 0x5c,
365 0x01, 0xa0, 0xda, 0x62, 375 0x01, 0xa0, 0xee, 0x62,
366 0x01, 0x84, 0xcf, 0x7a, 376 0x01, 0x84, 0xe3, 0x7a,
367 0x01, 0x95, 0xdd, 0x6a, 377 0x01, 0x95, 0xf1, 0x6a,
368 0x05, 0xea, 0x64, 0x59, 378 0x05, 0xea, 0x6e, 0x59,
369 0x05, 0xea, 0x04, 0x00, 379 0x05, 0xea, 0x04, 0x00,
370 0x00, 0xe2, 0xdc, 0x42, 380 0x00, 0xe2, 0xf0, 0x42,
371 0x03, 0xea, 0x64, 0x59, 381 0x03, 0xea, 0x6e, 0x59,
372 0x03, 0xea, 0x04, 0x00, 382 0x03, 0xea, 0x04, 0x00,
373 0x00, 0xe2, 0xdc, 0x42, 383 0x00, 0xe2, 0xf0, 0x42,
374 0x07, 0xea, 0x06, 0x5c, 384 0x07, 0xea, 0x1a, 0x5c,
375 0x01, 0x44, 0xd4, 0x31, 385 0x01, 0x44, 0xd4, 0x31,
376 0x00, 0xe2, 0x14, 0x42, 386 0x00, 0xe2, 0x28, 0x42,
377 0x3f, 0xe0, 0x76, 0x0a, 387 0x3f, 0xe0, 0x76, 0x0a,
378 0xc0, 0x3a, 0xc1, 0x09, 388 0xc0, 0x3a, 0xc1, 0x09,
379 0x00, 0x3b, 0x51, 0x01, 389 0x00, 0x3b, 0x51, 0x01,
@@ -384,54 +394,54 @@ static uint8_t seqprog[] = {
384 0x01, 0xea, 0xc6, 0x01, 394 0x01, 0xea, 0xc6, 0x01,
385 0x02, 0xe2, 0xc8, 0x31, 395 0x02, 0xe2, 0xc8, 0x31,
386 0x02, 0xec, 0x40, 0x31, 396 0x02, 0xec, 0x40, 0x31,
387 0xff, 0xa1, 0xfc, 0x72, 397 0xff, 0xa1, 0x10, 0x73,
388 0x02, 0xe8, 0xda, 0x31, 398 0x02, 0xe8, 0xda, 0x31,
389 0x02, 0xa0, 0x50, 0x31, 399 0x02, 0xa0, 0x50, 0x31,
390 0x00, 0xe2, 0x1e, 0x43, 400 0x00, 0xe2, 0x32, 0x43,
391 0x80, 0x39, 0x73, 0x02, 401 0x80, 0x39, 0x73, 0x02,
392 0x01, 0x44, 0xd4, 0x31, 402 0x01, 0x44, 0xd4, 0x31,
393 0x00, 0xe2, 0xe2, 0x5b, 403 0x00, 0xe2, 0xf6, 0x5b,
394 0x01, 0x39, 0x73, 0x02, 404 0x01, 0x39, 0x73, 0x02,
395 0xe0, 0x3c, 0x39, 0x63, 405 0xe0, 0x3c, 0x4d, 0x63,
396 0x02, 0x39, 0x73, 0x02, 406 0x02, 0x39, 0x73, 0x02,
397 0x20, 0x46, 0x32, 0x63, 407 0x20, 0x46, 0x46, 0x63,
398 0xff, 0xea, 0x52, 0x09, 408 0xff, 0xea, 0x52, 0x09,
399 0xa8, 0xea, 0xf4, 0x5b, 409 0xa8, 0xea, 0x08, 0x5c,
400 0x04, 0x92, 0x19, 0x7b, 410 0x04, 0x92, 0x2d, 0x7b,
401 0x01, 0x3a, 0xc1, 0x31, 411 0x01, 0x3a, 0xc1, 0x31,
402 0x00, 0x93, 0x19, 0x63, 412 0x00, 0x93, 0x2d, 0x63,
403 0x01, 0x3b, 0xc1, 0x31, 413 0x01, 0x3b, 0xc1, 0x31,
404 0x00, 0x94, 0x23, 0x73, 414 0x00, 0x94, 0x37, 0x73,
405 0x01, 0xa9, 0x52, 0x11, 415 0x01, 0xa9, 0x52, 0x11,
406 0xff, 0xa9, 0x0e, 0x6b, 416 0xff, 0xa9, 0x22, 0x6b,
407 0x00, 0xe2, 0x32, 0x43, 417 0x00, 0xe2, 0x46, 0x43,
408 0x10, 0x39, 0x73, 0x02, 418 0x10, 0x39, 0x73, 0x02,
409 0x04, 0x92, 0x33, 0x7b, 419 0x04, 0x92, 0x47, 0x7b,
410 0xfb, 0x92, 0x25, 0x0b, 420 0xfb, 0x92, 0x25, 0x0b,
411 0xff, 0xea, 0x72, 0x0a, 421 0xff, 0xea, 0x72, 0x0a,
412 0x01, 0xa4, 0x2d, 0x6b, 422 0x01, 0xa4, 0x41, 0x6b,
413 0x02, 0xa8, 0x9c, 0x32, 423 0x02, 0xa8, 0x9c, 0x32,
414 0x00, 0xe2, 0x7e, 0x59, 424 0x00, 0xe2, 0x88, 0x59,
415 0x10, 0x92, 0xdd, 0x7a, 425 0x10, 0x92, 0xf1, 0x7a,
416 0xff, 0xea, 0x06, 0x5c, 426 0xff, 0xea, 0x1a, 0x5c,
417 0x00, 0xe2, 0xdc, 0x42, 427 0x00, 0xe2, 0xf0, 0x42,
418 0x04, 0xea, 0x64, 0x59, 428 0x04, 0xea, 0x6e, 0x59,
419 0x04, 0xea, 0x04, 0x00, 429 0x04, 0xea, 0x04, 0x00,
420 0x00, 0xe2, 0xdc, 0x42, 430 0x00, 0xe2, 0xf0, 0x42,
421 0x04, 0xea, 0x64, 0x59, 431 0x04, 0xea, 0x6e, 0x59,
422 0x04, 0xea, 0x04, 0x00, 432 0x04, 0xea, 0x04, 0x00,
423 0x00, 0xe2, 0x14, 0x42, 433 0x00, 0xe2, 0x28, 0x42,
424 0x08, 0x92, 0xd5, 0x7a, 434 0x08, 0x92, 0xe9, 0x7a,
425 0xc0, 0x39, 0x49, 0x7b, 435 0xc0, 0x39, 0x5d, 0x7b,
426 0x80, 0x39, 0xd5, 0x6a, 436 0x80, 0x39, 0xe9, 0x6a,
427 0xff, 0x88, 0x49, 0x6b, 437 0xff, 0x88, 0x5d, 0x6b,
428 0x40, 0x39, 0xd5, 0x6a, 438 0x40, 0x39, 0xe9, 0x6a,
429 0x10, 0x92, 0x4f, 0x7b, 439 0x10, 0x92, 0x63, 0x7b,
430 0x0a, 0xea, 0x64, 0x59, 440 0x0a, 0xea, 0x6e, 0x59,
431 0x0a, 0xea, 0x04, 0x00, 441 0x0a, 0xea, 0x04, 0x00,
432 0x00, 0xe2, 0x6e, 0x5b, 442 0x00, 0xe2, 0x82, 0x5b,
433 0x00, 0xe2, 0xae, 0x43, 443 0x00, 0xe2, 0xc2, 0x43,
434 0x50, 0x4b, 0x56, 0x6b, 444 0x50, 0x4b, 0x6a, 0x6b,
435 0xbf, 0x3a, 0x74, 0x08, 445 0xbf, 0x3a, 0x74, 0x08,
436 0x01, 0xe0, 0xf4, 0x31, 446 0x01, 0xe0, 0xf4, 0x31,
437 0xff, 0xea, 0xc0, 0x09, 447 0xff, 0xea, 0xc0, 0x09,
@@ -441,31 +451,31 @@ static uint8_t seqprog[] = {
441 0x01, 0xfa, 0xc0, 0x35, 451 0x01, 0xfa, 0xc0, 0x35,
442 0x02, 0xa8, 0x90, 0x32, 452 0x02, 0xa8, 0x90, 0x32,
443 0x02, 0xea, 0xb4, 0x00, 453 0x02, 0xea, 0xb4, 0x00,
444 0x33, 0xea, 0x5e, 0x59, 454 0x33, 0xea, 0x68, 0x59,
445 0x33, 0xea, 0x00, 0x00, 455 0x33, 0xea, 0x00, 0x00,
446 0x02, 0x48, 0x51, 0x31, 456 0x02, 0x48, 0x51, 0x31,
447 0xff, 0x90, 0x85, 0x68, 457 0xff, 0x90, 0x85, 0x68,
448 0xff, 0x88, 0x7b, 0x6b, 458 0xff, 0x88, 0x8f, 0x6b,
449 0x01, 0xa4, 0x77, 0x6b, 459 0x01, 0xa4, 0x8b, 0x6b,
450 0x02, 0xa4, 0x7f, 0x6b, 460 0x02, 0xa4, 0x93, 0x6b,
451 0x01, 0x84, 0x7f, 0x7b, 461 0x01, 0x84, 0x93, 0x7b,
452 0x02, 0x28, 0x19, 0x33, 462 0x02, 0x28, 0x19, 0x33,
453 0x02, 0xa8, 0x50, 0x36, 463 0x02, 0xa8, 0x50, 0x36,
454 0xff, 0x88, 0x7f, 0x73, 464 0xff, 0x88, 0x93, 0x73,
455 0x00, 0xe2, 0x52, 0x5b, 465 0x00, 0xe2, 0x66, 0x5b,
456 0x02, 0xa8, 0x20, 0x33, 466 0x02, 0xa8, 0x20, 0x33,
457 0x04, 0xa4, 0x49, 0x03, 467 0x04, 0xa4, 0x49, 0x03,
458 0xff, 0xea, 0x1a, 0x03, 468 0xff, 0xea, 0x1a, 0x03,
459 0xff, 0x2d, 0x8b, 0x63, 469 0xff, 0x2d, 0x9f, 0x63,
460 0x02, 0xa8, 0x58, 0x32, 470 0x02, 0xa8, 0x58, 0x32,
461 0x02, 0xa8, 0x5c, 0x36, 471 0x02, 0xa8, 0x5c, 0x36,
462 0x02, 0xa8, 0x40, 0x31, 472 0x02, 0xa8, 0x40, 0x31,
463 0x02, 0x2e, 0x51, 0x31, 473 0x02, 0x2e, 0x51, 0x31,
464 0x02, 0xa0, 0x18, 0x33, 474 0x02, 0xa0, 0x18, 0x33,
465 0x02, 0xa0, 0x5c, 0x36, 475 0x02, 0xa0, 0x5c, 0x36,
466 0xc0, 0x39, 0xd5, 0x6a, 476 0xc0, 0x39, 0xe9, 0x6a,
467 0x04, 0x92, 0x25, 0x03, 477 0x04, 0x92, 0x25, 0x03,
468 0x20, 0x92, 0xaf, 0x6b, 478 0x20, 0x92, 0xc3, 0x6b,
469 0x02, 0xa8, 0x40, 0x31, 479 0x02, 0xa8, 0x40, 0x31,
470 0xc0, 0x3a, 0xc1, 0x09, 480 0xc0, 0x3a, 0xc1, 0x09,
471 0x00, 0x3b, 0x51, 0x01, 481 0x00, 0x3b, 0x51, 0x01,
@@ -480,60 +490,60 @@ static uint8_t seqprog[] = {
480 0xf7, 0x57, 0xae, 0x08, 490 0xf7, 0x57, 0xae, 0x08,
481 0x08, 0xea, 0x98, 0x00, 491 0x08, 0xea, 0x98, 0x00,
482 0x01, 0x44, 0xd4, 0x31, 492 0x01, 0x44, 0xd4, 0x31,
483 0xee, 0x00, 0xb8, 0x6b, 493 0xee, 0x00, 0xcc, 0x6b,
484 0x02, 0xea, 0xb4, 0x00, 494 0x02, 0xea, 0xb4, 0x00,
485 0xc0, 0xea, 0x72, 0x02, 495 0xc0, 0xea, 0x72, 0x02,
486 0x09, 0x4c, 0xba, 0x7b, 496 0x09, 0x4c, 0xce, 0x7b,
487 0x01, 0xea, 0x78, 0x02, 497 0x01, 0xea, 0x78, 0x02,
488 0x08, 0x4c, 0x06, 0x68, 498 0x08, 0x4c, 0x06, 0x68,
489 0x0b, 0xea, 0x64, 0x59, 499 0x0b, 0xea, 0x6e, 0x59,
490 0x0b, 0xea, 0x04, 0x00, 500 0x0b, 0xea, 0x04, 0x00,
491 0x01, 0x44, 0xd4, 0x31, 501 0x01, 0x44, 0xd4, 0x31,
492 0x20, 0x39, 0x15, 0x7a, 502 0x20, 0x39, 0x29, 0x7a,
493 0x00, 0xe2, 0xcc, 0x5b, 503 0x00, 0xe2, 0xe0, 0x5b,
494 0x00, 0xe2, 0x14, 0x42, 504 0x00, 0xe2, 0x28, 0x42,
495 0x01, 0x84, 0xd1, 0x7b, 505 0x01, 0x84, 0xe5, 0x7b,
496 0x01, 0xa4, 0x49, 0x07, 506 0x01, 0xa4, 0x49, 0x07,
497 0x08, 0x60, 0x30, 0x33, 507 0x08, 0x60, 0x30, 0x33,
498 0x08, 0x80, 0x41, 0x37, 508 0x08, 0x80, 0x41, 0x37,
499 0xdf, 0x39, 0x73, 0x0a, 509 0xdf, 0x39, 0x73, 0x0a,
500 0xee, 0x00, 0xde, 0x6b, 510 0xee, 0x00, 0xf2, 0x6b,
501 0x05, 0xea, 0xb4, 0x00, 511 0x05, 0xea, 0xb4, 0x00,
502 0x33, 0xea, 0x5e, 0x59, 512 0x33, 0xea, 0x68, 0x59,
503 0x33, 0xea, 0x00, 0x00, 513 0x33, 0xea, 0x00, 0x00,
504 0x00, 0xe2, 0x7e, 0x59, 514 0x00, 0xe2, 0x88, 0x59,
505 0x00, 0xe2, 0xdc, 0x42, 515 0x00, 0xe2, 0xf0, 0x42,
506 0xff, 0x42, 0xee, 0x6b, 516 0xff, 0x42, 0x02, 0x6c,
507 0x01, 0x41, 0xe2, 0x6b, 517 0x01, 0x41, 0xf6, 0x6b,
508 0x02, 0x41, 0xe2, 0x7b, 518 0x02, 0x41, 0xf6, 0x7b,
509 0xff, 0x42, 0xee, 0x6b, 519 0xff, 0x42, 0x02, 0x6c,
510 0x01, 0x41, 0xe2, 0x6b, 520 0x01, 0x41, 0xf6, 0x6b,
511 0x02, 0x41, 0xe2, 0x7b, 521 0x02, 0x41, 0xf6, 0x7b,
512 0xff, 0x42, 0xee, 0x7b, 522 0xff, 0x42, 0x02, 0x7c,
513 0x04, 0x4c, 0xe2, 0x6b, 523 0x04, 0x4c, 0xf6, 0x6b,
514 0xe0, 0x41, 0x78, 0x0e, 524 0xe0, 0x41, 0x78, 0x0e,
515 0x01, 0x44, 0xd4, 0x31, 525 0x01, 0x44, 0xd4, 0x31,
516 0xff, 0x42, 0xf6, 0x7b, 526 0xff, 0x42, 0x0a, 0x7c,
517 0x04, 0x4c, 0xf6, 0x6b, 527 0x04, 0x4c, 0x0a, 0x6c,
518 0xe0, 0x41, 0x78, 0x0a, 528 0xe0, 0x41, 0x78, 0x0a,
519 0xe0, 0x3c, 0x15, 0x62, 529 0xe0, 0x3c, 0x29, 0x62,
520 0xff, 0xea, 0xca, 0x09, 530 0xff, 0xea, 0xca, 0x09,
521 0x01, 0xe2, 0xc8, 0x31, 531 0x01, 0xe2, 0xc8, 0x31,
522 0x01, 0x46, 0xda, 0x35, 532 0x01, 0x46, 0xda, 0x35,
523 0x01, 0x44, 0xd4, 0x35, 533 0x01, 0x44, 0xd4, 0x35,
524 0x10, 0xea, 0x80, 0x00, 534 0x10, 0xea, 0x80, 0x00,
525 0x01, 0xe2, 0x6e, 0x36, 535 0x01, 0xe2, 0x6e, 0x36,
526 0x04, 0xa6, 0x0e, 0x7c, 536 0x04, 0xa6, 0x22, 0x7c,
527 0xff, 0xea, 0x5a, 0x09, 537 0xff, 0xea, 0x5a, 0x09,
528 0xff, 0xea, 0x4c, 0x0d, 538 0xff, 0xea, 0x4c, 0x0d,
529 0x01, 0xa6, 0x3a, 0x6c, 539 0x01, 0xa6, 0x4e, 0x6c,
530 0x10, 0xad, 0x84, 0x78, 540 0x10, 0xad, 0x84, 0x78,
531 0x80, 0xad, 0x32, 0x6c, 541 0x80, 0xad, 0x46, 0x6c,
532 0x08, 0xad, 0x84, 0x68, 542 0x08, 0xad, 0x84, 0x68,
533 0x20, 0x19, 0x26, 0x7c, 543 0x20, 0x19, 0x3a, 0x7c,
534 0x80, 0xea, 0xb2, 0x01, 544 0x80, 0xea, 0xb2, 0x01,
535 0x11, 0x00, 0x00, 0x10, 545 0x11, 0x00, 0x00, 0x10,
536 0x02, 0xa6, 0x22, 0x7c, 546 0x02, 0xa6, 0x36, 0x7c,
537 0xff, 0xea, 0xb2, 0x0d, 547 0xff, 0xea, 0xb2, 0x0d,
538 0x11, 0x00, 0x00, 0x10, 548 0x11, 0x00, 0x00, 0x10,
539 0xff, 0xea, 0xb2, 0x09, 549 0xff, 0xea, 0xb2, 0x09,
@@ -561,7 +571,7 @@ static uint8_t seqprog[] = {
561 0x00, 0x86, 0x0d, 0x23, 571 0x00, 0x86, 0x0d, 0x23,
562 0x00, 0x87, 0x0f, 0x23, 572 0x00, 0x87, 0x0f, 0x23,
563 0x01, 0x84, 0xc5, 0x31, 573 0x01, 0x84, 0xc5, 0x31,
564 0x80, 0x83, 0x5d, 0x7c, 574 0x80, 0x83, 0x71, 0x7c,
565 0x02, 0xe2, 0xc4, 0x01, 575 0x02, 0xe2, 0xc4, 0x01,
566 0xff, 0xea, 0x4c, 0x09, 576 0xff, 0xea, 0x4c, 0x09,
567 0x01, 0xe2, 0x36, 0x30, 577 0x01, 0xe2, 0x36, 0x30,
@@ -572,75 +582,75 @@ static uint8_t seqprog[] = {
572 0xfe, 0xa6, 0x4c, 0x0d, 582 0xfe, 0xa6, 0x4c, 0x0d,
573 0x0b, 0x98, 0xe1, 0x30, 583 0x0b, 0x98, 0xe1, 0x30,
574 0xfd, 0xa4, 0x49, 0x09, 584 0xfd, 0xa4, 0x49, 0x09,
575 0x80, 0xa3, 0x71, 0x7c, 585 0x80, 0xa3, 0x85, 0x7c,
576 0x02, 0xa4, 0x48, 0x01, 586 0x02, 0xa4, 0x48, 0x01,
577 0x01, 0xa4, 0x36, 0x30, 587 0x01, 0xa4, 0x36, 0x30,
578 0xa8, 0xea, 0x32, 0x00, 588 0xa8, 0xea, 0x32, 0x00,
579 0xfd, 0xa4, 0x49, 0x0b, 589 0xfd, 0xa4, 0x49, 0x0b,
580 0x05, 0xa3, 0x07, 0x33, 590 0x05, 0xa3, 0x07, 0x33,
581 0x80, 0x83, 0x7d, 0x6c, 591 0x80, 0x83, 0x91, 0x6c,
582 0x02, 0xea, 0x4c, 0x05, 592 0x02, 0xea, 0x4c, 0x05,
583 0xff, 0xea, 0x4c, 0x0d, 593 0xff, 0xea, 0x4c, 0x0d,
584 0x00, 0xe2, 0x56, 0x59, 594 0x00, 0xe2, 0x60, 0x59,
585 0x02, 0xa6, 0x10, 0x6c, 595 0x02, 0xa6, 0x24, 0x6c,
586 0x80, 0xf9, 0xf2, 0x05, 596 0x80, 0xf9, 0xf2, 0x05,
587 0xc0, 0x39, 0x8b, 0x7c, 597 0xc0, 0x39, 0x9f, 0x7c,
588 0x03, 0xea, 0x64, 0x59, 598 0x03, 0xea, 0x6e, 0x59,
589 0x03, 0xea, 0x04, 0x00, 599 0x03, 0xea, 0x04, 0x00,
590 0x20, 0x39, 0xaf, 0x7c, 600 0x20, 0x39, 0xc3, 0x7c,
591 0x01, 0x84, 0x95, 0x6c, 601 0x01, 0x84, 0xa9, 0x6c,
592 0x06, 0xea, 0x64, 0x59, 602 0x06, 0xea, 0x6e, 0x59,
593 0x06, 0xea, 0x04, 0x00, 603 0x06, 0xea, 0x04, 0x00,
594 0x00, 0xe2, 0xb2, 0x44, 604 0x00, 0xe2, 0xc6, 0x44,
595 0x01, 0x00, 0x6c, 0x32, 605 0x01, 0x00, 0x6c, 0x32,
596 0xee, 0x00, 0x9e, 0x6c, 606 0xee, 0x00, 0xb2, 0x6c,
597 0x05, 0xea, 0xb4, 0x00, 607 0x05, 0xea, 0xb4, 0x00,
598 0x33, 0xea, 0x5e, 0x59, 608 0x33, 0xea, 0x68, 0x59,
599 0x33, 0xea, 0x00, 0x00, 609 0x33, 0xea, 0x00, 0x00,
600 0x80, 0x3d, 0x7a, 0x00, 610 0x80, 0x3d, 0x7a, 0x00,
601 0xfc, 0x42, 0xa0, 0x7c, 611 0xfc, 0x42, 0xb4, 0x7c,
602 0x7f, 0x3d, 0x7a, 0x08, 612 0x7f, 0x3d, 0x7a, 0x08,
603 0x00, 0x36, 0x5f, 0x59, 613 0x00, 0x36, 0x69, 0x59,
604 0x01, 0x36, 0x01, 0x30, 614 0x01, 0x36, 0x01, 0x30,
605 0x09, 0xea, 0x64, 0x59, 615 0x09, 0xea, 0x6e, 0x59,
606 0x09, 0xea, 0x04, 0x00, 616 0x09, 0xea, 0x04, 0x00,
607 0x00, 0xe2, 0x14, 0x42, 617 0x00, 0xe2, 0x28, 0x42,
608 0x01, 0xa4, 0x95, 0x6c, 618 0x01, 0xa4, 0xa9, 0x6c,
609 0x00, 0xe2, 0x68, 0x5c, 619 0x00, 0xe2, 0x7c, 0x5c,
610 0x20, 0x39, 0x73, 0x02, 620 0x20, 0x39, 0x73, 0x02,
611 0x01, 0x00, 0x6c, 0x32, 621 0x01, 0x00, 0x6c, 0x32,
612 0x02, 0xa6, 0xba, 0x7c, 622 0x02, 0xa6, 0xce, 0x7c,
613 0x00, 0xe2, 0x7e, 0x5c, 623 0x00, 0xe2, 0x92, 0x5c,
614 0x00, 0xe2, 0x76, 0x58, 624 0x00, 0xe2, 0x76, 0x58,
615 0x00, 0xe2, 0x86, 0x58, 625 0x00, 0xe2, 0x86, 0x58,
616 0x00, 0xe2, 0x5a, 0x58, 626 0x00, 0xe2, 0x5a, 0x58,
617 0x00, 0x36, 0x5f, 0x59, 627 0x00, 0x36, 0x69, 0x59,
618 0x01, 0x36, 0x01, 0x30, 628 0x01, 0x36, 0x01, 0x30,
619 0x20, 0x19, 0xba, 0x6c, 629 0x20, 0x19, 0xce, 0x6c,
620 0x00, 0xe2, 0xea, 0x5c, 630 0x00, 0xe2, 0xfe, 0x5c,
621 0x04, 0x19, 0xd4, 0x6c, 631 0x04, 0x19, 0xe8, 0x6c,
622 0x02, 0x19, 0x32, 0x00, 632 0x02, 0x19, 0x32, 0x00,
623 0x01, 0x84, 0xd5, 0x7c, 633 0x01, 0x84, 0xe9, 0x7c,
624 0x01, 0x1b, 0xce, 0x7c, 634 0x01, 0x1b, 0xe2, 0x7c,
625 0x01, 0x1a, 0xd4, 0x6c, 635 0x01, 0x1a, 0xe8, 0x6c,
626 0x00, 0xe2, 0x84, 0x44, 636 0x00, 0xe2, 0x98, 0x44,
627 0x80, 0x4b, 0xda, 0x6c, 637 0x80, 0x4b, 0xee, 0x6c,
628 0x01, 0x4c, 0xd6, 0x7c, 638 0x01, 0x4c, 0xea, 0x7c,
629 0x03, 0x42, 0x84, 0x6c, 639 0x03, 0x42, 0x98, 0x6c,
630 0x00, 0xe2, 0x0a, 0x5c, 640 0x00, 0xe2, 0x1e, 0x5c,
631 0x80, 0xf9, 0xf2, 0x01, 641 0x80, 0xf9, 0xf2, 0x01,
632 0x04, 0x39, 0x15, 0x7a, 642 0x04, 0x39, 0x29, 0x7a,
633 0x00, 0xe2, 0x14, 0x42, 643 0x00, 0xe2, 0x28, 0x42,
634 0x08, 0x5d, 0xf2, 0x6c, 644 0x08, 0x5d, 0x06, 0x6d,
635 0x00, 0xe2, 0x76, 0x58, 645 0x00, 0xe2, 0x76, 0x58,
636 0x00, 0x36, 0x5f, 0x59, 646 0x00, 0x36, 0x69, 0x59,
637 0x01, 0x36, 0x01, 0x30, 647 0x01, 0x36, 0x01, 0x30,
638 0x02, 0x1b, 0xe2, 0x7c, 648 0x02, 0x1b, 0xf6, 0x7c,
639 0x08, 0x5d, 0xf0, 0x7c, 649 0x08, 0x5d, 0x04, 0x7d,
640 0x03, 0x68, 0x00, 0x37, 650 0x03, 0x68, 0x00, 0x37,
641 0x01, 0x84, 0x09, 0x07, 651 0x01, 0x84, 0x09, 0x07,
642 0x80, 0x1b, 0xfc, 0x7c, 652 0x80, 0x1b, 0x10, 0x7d,
643 0x80, 0x84, 0xfd, 0x6c, 653 0x80, 0x84, 0x11, 0x6d,
644 0xff, 0x85, 0x0b, 0x1b, 654 0xff, 0x85, 0x0b, 0x1b,
645 0xff, 0x86, 0x0d, 0x23, 655 0xff, 0x86, 0x0d, 0x23,
646 0xff, 0x87, 0x0f, 0x23, 656 0xff, 0x87, 0x0f, 0x23,
@@ -652,161 +662,164 @@ static uint8_t seqprog[] = {
652 0xf9, 0xd9, 0xb2, 0x0d, 662 0xf9, 0xd9, 0xb2, 0x0d,
653 0x01, 0xd9, 0xb2, 0x05, 663 0x01, 0xd9, 0xb2, 0x05,
654 0x01, 0x52, 0x48, 0x31, 664 0x01, 0x52, 0x48, 0x31,
655 0x20, 0xa4, 0x26, 0x7d, 665 0x20, 0xa4, 0x3a, 0x7d,
656 0x20, 0x5b, 0x26, 0x7d, 666 0x20, 0x5b, 0x3a, 0x7d,
657 0x80, 0xf9, 0x34, 0x7d, 667 0x80, 0xf9, 0x48, 0x7d,
658 0x02, 0xea, 0xb4, 0x00, 668 0x02, 0xea, 0xb4, 0x00,
659 0x11, 0x00, 0x00, 0x10, 669 0x11, 0x00, 0x00, 0x10,
660 0x04, 0x19, 0x40, 0x7d, 670 0x04, 0x19, 0x54, 0x7d,
661 0xdf, 0x19, 0x32, 0x08, 671 0xdf, 0x19, 0x32, 0x08,
662 0x60, 0x5b, 0x40, 0x6d, 672 0x60, 0x5b, 0x54, 0x6d,
663 0x01, 0x4c, 0x1a, 0x7d, 673 0x01, 0x4c, 0x2e, 0x7d,
664 0x20, 0x19, 0x32, 0x00, 674 0x20, 0x19, 0x32, 0x00,
665 0x01, 0xd9, 0xb2, 0x05, 675 0x01, 0xd9, 0xb2, 0x05,
666 0x02, 0xea, 0xb4, 0x00, 676 0x02, 0xea, 0xb4, 0x00,
667 0x01, 0xd9, 0xb2, 0x05, 677 0x01, 0xd9, 0xb2, 0x05,
668 0x10, 0x5b, 0x38, 0x6d, 678 0x10, 0x5b, 0x4c, 0x6d,
669 0x08, 0x5b, 0x42, 0x6d, 679 0x08, 0x5b, 0x56, 0x6d,
670 0x20, 0x5b, 0x32, 0x6d, 680 0x20, 0x5b, 0x46, 0x6d,
671 0x02, 0x5b, 0x62, 0x6d, 681 0x02, 0x5b, 0x76, 0x6d,
672 0x0e, 0xea, 0x64, 0x59, 682 0x0e, 0xea, 0x6e, 0x59,
673 0x0e, 0xea, 0x04, 0x00, 683 0x0e, 0xea, 0x04, 0x00,
674 0x80, 0xf9, 0x22, 0x6d, 684 0x80, 0xf9, 0x36, 0x6d,
675 0xdf, 0x5c, 0xb8, 0x08, 685 0xdf, 0x5c, 0xb8, 0x08,
676 0x01, 0xd9, 0xb2, 0x05, 686 0x01, 0xd9, 0xb2, 0x05,
677 0x01, 0xa4, 0x1d, 0x6e, 687 0x01, 0xa4, 0x37, 0x6e,
678 0x00, 0xe2, 0x68, 0x5c, 688 0x00, 0xe2, 0x7c, 0x5c,
679 0x00, 0xe2, 0x6c, 0x5d, 689 0x00, 0xe2, 0x80, 0x5d,
680 0x01, 0x90, 0x21, 0x1b, 690 0x01, 0x90, 0x21, 0x1b,
681 0x01, 0xd9, 0xb2, 0x05, 691 0x01, 0xd9, 0xb2, 0x05,
682 0x00, 0xe2, 0x52, 0x5b, 692 0x00, 0xe2, 0x66, 0x5b,
683 0xf3, 0x96, 0xd5, 0x19, 693 0xf3, 0x96, 0xd5, 0x19,
684 0x00, 0xe2, 0x50, 0x55, 694 0x00, 0xe2, 0x64, 0x55,
685 0x80, 0x96, 0x51, 0x6d, 695 0x80, 0x96, 0x65, 0x6d,
686 0x0f, 0xea, 0x64, 0x59, 696 0x0f, 0xea, 0x6e, 0x59,
687 0x0f, 0xea, 0x04, 0x00, 697 0x0f, 0xea, 0x04, 0x00,
688 0x00, 0xe2, 0x58, 0x45, 698 0x00, 0xe2, 0x6c, 0x45,
689 0x04, 0x8c, 0xe1, 0x30, 699 0x04, 0x8c, 0xe1, 0x30,
690 0x01, 0xea, 0xf2, 0x00, 700 0x01, 0xea, 0xf2, 0x00,
691 0x02, 0xea, 0x36, 0x00, 701 0x02, 0xea, 0x36, 0x00,
692 0xa8, 0xea, 0x32, 0x00, 702 0xa8, 0xea, 0x32, 0x00,
693 0xff, 0x97, 0x5f, 0x7d, 703 0xff, 0x97, 0x73, 0x7d,
694 0x14, 0xea, 0x64, 0x59, 704 0x14, 0xea, 0x6e, 0x59,
695 0x14, 0xea, 0x04, 0x00, 705 0x14, 0xea, 0x04, 0x00,
696 0x00, 0xe2, 0xce, 0x5d, 706 0x00, 0xe2, 0xe2, 0x5d,
697 0x01, 0xd9, 0xb2, 0x05, 707 0x01, 0xd9, 0xb2, 0x05,
698 0x09, 0x80, 0xe1, 0x30, 708 0x09, 0x80, 0xe1, 0x30,
699 0x02, 0xea, 0x36, 0x00, 709 0x02, 0xea, 0x36, 0x00,
700 0xa8, 0xea, 0x32, 0x00, 710 0xa8, 0xea, 0x32, 0x00,
701 0x00, 0xe2, 0xc6, 0x5d, 711 0x00, 0xe2, 0xda, 0x5d,
702 0x01, 0xd9, 0xb2, 0x05, 712 0x01, 0xd9, 0xb2, 0x05,
703 0x02, 0xa6, 0x7c, 0x7d, 713 0x02, 0xa6, 0x90, 0x7d,
704 0x00, 0xe2, 0x56, 0x59, 714 0x00, 0xe2, 0x60, 0x59,
705 0x20, 0x5b, 0x8a, 0x6d, 715 0x20, 0x5b, 0x9e, 0x6d,
706 0xfc, 0x42, 0x76, 0x7d, 716 0xfc, 0x42, 0x8a, 0x7d,
707 0x10, 0x40, 0x78, 0x6d, 717 0x10, 0x40, 0x8c, 0x6d,
708 0x20, 0x4d, 0x7a, 0x7d, 718 0x20, 0x4d, 0x8e, 0x7d,
709 0x08, 0x5d, 0x8a, 0x6d, 719 0x08, 0x5d, 0x9e, 0x6d,
710 0x02, 0xa6, 0x10, 0x6c, 720 0x02, 0xa6, 0x24, 0x6c,
711 0x00, 0xe2, 0x56, 0x59, 721 0x00, 0xe2, 0x60, 0x59,
712 0x20, 0x5b, 0x8a, 0x6d, 722 0x20, 0x5b, 0x9e, 0x6d,
713 0x01, 0x1b, 0xaa, 0x6d, 723 0x01, 0x1b, 0xbe, 0x6d,
714 0xfc, 0x42, 0x86, 0x7d, 724 0xfc, 0x42, 0x9a, 0x7d,
715 0x10, 0x40, 0x88, 0x6d, 725 0x10, 0x40, 0x9c, 0x6d,
716 0x20, 0x4d, 0x84, 0x78, 726 0x20, 0x4d, 0x84, 0x78,
717 0x08, 0x5d, 0x84, 0x78, 727 0x08, 0x5d, 0x84, 0x78,
718 0x02, 0x19, 0x32, 0x00, 728 0x02, 0x19, 0x32, 0x00,
719 0x01, 0x5b, 0x40, 0x31, 729 0x01, 0x5b, 0x40, 0x31,
720 0x00, 0xe2, 0xea, 0x5c, 730 0x00, 0xe2, 0xfe, 0x5c,
721 0x00, 0xe2, 0xcc, 0x5b, 731 0x00, 0xe2, 0xe0, 0x5b,
722 0x20, 0xea, 0xb6, 0x00, 732 0x20, 0xea, 0xb6, 0x00,
723 0x00, 0xe2, 0x0a, 0x5c, 733 0x00, 0xe2, 0x1e, 0x5c,
724 0x20, 0x5c, 0xb8, 0x00, 734 0x20, 0x5c, 0xb8, 0x00,
725 0x04, 0x19, 0xa0, 0x6d, 735 0x04, 0x19, 0xb4, 0x6d,
726 0x01, 0x1a, 0xa0, 0x6d, 736 0x01, 0x1a, 0xb4, 0x6d,
727 0x00, 0xe2, 0x56, 0x59, 737 0x00, 0xe2, 0x60, 0x59,
728 0x01, 0x1a, 0x84, 0x78, 738 0x01, 0x1a, 0x84, 0x78,
729 0x80, 0xf9, 0xf2, 0x01, 739 0x80, 0xf9, 0xf2, 0x01,
730 0x20, 0xa0, 0x04, 0x7e, 740 0x20, 0xa0, 0x18, 0x7e,
731 0xff, 0x90, 0x21, 0x1b, 741 0xff, 0x90, 0x21, 0x1b,
732 0x08, 0x92, 0x63, 0x6b, 742 0x08, 0x92, 0x77, 0x6b,
733 0x02, 0xea, 0xb4, 0x04, 743 0x02, 0xea, 0xb4, 0x04,
734 0x01, 0xa4, 0x49, 0x03, 744 0x01, 0xa4, 0x49, 0x03,
735 0x40, 0x5b, 0xba, 0x6d, 745 0x40, 0x5b, 0xce, 0x6d,
736 0x00, 0xe2, 0x56, 0x59, 746 0x00, 0xe2, 0x60, 0x59,
737 0x40, 0x5b, 0xba, 0x6d, 747 0x40, 0x5b, 0xce, 0x6d,
738 0x04, 0x5d, 0x1e, 0x7e, 748 0x04, 0x5d, 0x38, 0x7e,
739 0x01, 0x1a, 0x1e, 0x7e, 749 0x01, 0x1a, 0x38, 0x7e,
740 0x20, 0x4d, 0x84, 0x78, 750 0x20, 0x4d, 0x84, 0x78,
741 0x40, 0x5b, 0x04, 0x7e, 751 0x40, 0x5b, 0x18, 0x7e,
742 0x04, 0x5d, 0x1e, 0x7e, 752 0x04, 0x5d, 0x38, 0x7e,
743 0x01, 0x1a, 0x1e, 0x7e, 753 0x01, 0x1a, 0x38, 0x7e,
744 0x80, 0xf9, 0xf2, 0x01, 754 0x80, 0xf9, 0xf2, 0x01,
745 0xff, 0x90, 0x21, 0x1b, 755 0xff, 0x90, 0x21, 0x1b,
746 0x08, 0x92, 0x63, 0x6b, 756 0x08, 0x92, 0x77, 0x6b,
747 0x02, 0xea, 0xb4, 0x04, 757 0x02, 0xea, 0xb4, 0x04,
748 0x00, 0xe2, 0x56, 0x59, 758 0x00, 0xe2, 0x60, 0x59,
749 0x01, 0x1b, 0x84, 0x78, 759 0x01, 0x1b, 0x84, 0x78,
750 0x80, 0xf9, 0xf2, 0x01, 760 0x80, 0xf9, 0xf2, 0x01,
751 0x02, 0xea, 0xb4, 0x04, 761 0x02, 0xea, 0xb4, 0x04,
752 0x00, 0xe2, 0x56, 0x59, 762 0x00, 0xe2, 0x60, 0x59,
753 0x01, 0x1b, 0xe2, 0x6d, 763 0x01, 0x1b, 0xf6, 0x6d,
754 0x40, 0x5b, 0xf0, 0x7d, 764 0x40, 0x5b, 0x04, 0x7e,
755 0x01, 0x1b, 0xe2, 0x6d, 765 0x01, 0x1b, 0xf6, 0x6d,
756 0x02, 0x19, 0x32, 0x00, 766 0x02, 0x19, 0x32, 0x00,
757 0x01, 0x1a, 0x84, 0x78, 767 0x01, 0x1a, 0x84, 0x78,
758 0x80, 0xf9, 0xf2, 0x01, 768 0x80, 0xf9, 0xf2, 0x01,
759 0xff, 0xea, 0x10, 0x03, 769 0xff, 0xea, 0x10, 0x03,
760 0x08, 0x92, 0x25, 0x03, 770 0x08, 0x92, 0x25, 0x03,
761 0x00, 0xe2, 0x62, 0x43, 771 0x00, 0xe2, 0x76, 0x43,
762 0x01, 0x1a, 0xec, 0x7d, 772 0x01, 0x1a, 0x00, 0x7e,
763 0x40, 0x5b, 0xe8, 0x7d, 773 0x40, 0x5b, 0xfc, 0x7d,
764 0x01, 0x1a, 0xd6, 0x6d, 774 0x01, 0x1a, 0xea, 0x6d,
765 0xfc, 0x42, 0x84, 0x78, 775 0xfc, 0x42, 0x84, 0x78,
766 0x01, 0x1a, 0xf0, 0x6d, 776 0x01, 0x1a, 0x04, 0x6e,
767 0x10, 0xea, 0x64, 0x59, 777 0x10, 0xea, 0x6e, 0x59,
768 0x10, 0xea, 0x04, 0x00, 778 0x10, 0xea, 0x04, 0x00,
769 0xfc, 0x42, 0x84, 0x78, 779 0xfc, 0x42, 0x84, 0x78,
770 0x10, 0x40, 0xf6, 0x6d, 780 0x10, 0x40, 0x0a, 0x6e,
771 0x20, 0x4d, 0x84, 0x78, 781 0x20, 0x4d, 0x84, 0x78,
772 0x40, 0x5b, 0xd6, 0x6d, 782 0x40, 0x5b, 0xea, 0x6d,
773 0x01, 0x1a, 0x84, 0x78, 783 0x01, 0x1a, 0x84, 0x78,
774 0x01, 0x90, 0x21, 0x1b, 784 0x01, 0x90, 0x21, 0x1b,
775 0x30, 0x3f, 0xc0, 0x09, 785 0x30, 0x3f, 0xc0, 0x09,
776 0x30, 0xe0, 0x84, 0x60, 786 0x30, 0xe0, 0x84, 0x60,
777 0x40, 0x4b, 0x84, 0x68, 787 0x40, 0x4b, 0x84, 0x68,
778 0xff, 0xea, 0x52, 0x01, 788 0xff, 0xea, 0x52, 0x01,
779 0xee, 0x00, 0x0c, 0x6e, 789 0xee, 0x00, 0x20, 0x6e,
780 0x80, 0xf9, 0xf2, 0x01, 790 0x80, 0xf9, 0xf2, 0x01,
781 0xff, 0x90, 0x21, 0x1b, 791 0xff, 0x90, 0x21, 0x1b,
782 0x02, 0xea, 0xb4, 0x00, 792 0x02, 0xea, 0xb4, 0x00,
783 0x20, 0xea, 0x9a, 0x00, 793 0x20, 0xea, 0x9a, 0x00,
784 0xf3, 0x42, 0x16, 0x6e, 794 0x04, 0x41, 0x26, 0x7e,
785 0x12, 0xea, 0x64, 0x59, 795 0x08, 0xea, 0x98, 0x00,
796 0x08, 0x57, 0xae, 0x00,
797 0xf3, 0x42, 0x30, 0x6e,
798 0x12, 0xea, 0x6e, 0x59,
786 0x12, 0xea, 0x04, 0x00, 799 0x12, 0xea, 0x04, 0x00,
787 0x00, 0xe2, 0x14, 0x42, 800 0x00, 0xe2, 0x28, 0x42,
788 0x0d, 0xea, 0x64, 0x59, 801 0x0d, 0xea, 0x6e, 0x59,
789 0x0d, 0xea, 0x04, 0x00, 802 0x0d, 0xea, 0x04, 0x00,
790 0x00, 0xe2, 0x14, 0x42, 803 0x00, 0xe2, 0x28, 0x42,
791 0x01, 0x90, 0x21, 0x1b, 804 0x01, 0x90, 0x21, 0x1b,
792 0x11, 0xea, 0x64, 0x59, 805 0x11, 0xea, 0x6e, 0x59,
793 0x11, 0xea, 0x04, 0x00, 806 0x11, 0xea, 0x04, 0x00,
794 0x00, 0xe2, 0x52, 0x5b, 807 0x00, 0xe2, 0x66, 0x5b,
795 0x08, 0x5a, 0xb4, 0x00, 808 0x08, 0x5a, 0xb4, 0x00,
796 0x00, 0xe2, 0x44, 0x5e, 809 0x00, 0xe2, 0x5e, 0x5e,
797 0xa8, 0xea, 0x32, 0x00, 810 0xa8, 0xea, 0x32, 0x00,
798 0x00, 0xe2, 0x56, 0x59, 811 0x00, 0xe2, 0x60, 0x59,
799 0x80, 0x1a, 0x32, 0x7e, 812 0x80, 0x1a, 0x4c, 0x7e,
800 0x00, 0xe2, 0x44, 0x5e, 813 0x00, 0xe2, 0x5e, 0x5e,
801 0x80, 0x19, 0x32, 0x00, 814 0x80, 0x19, 0x32, 0x00,
802 0x40, 0x5b, 0x38, 0x6e, 815 0x40, 0x5b, 0x52, 0x6e,
803 0x08, 0x5a, 0x38, 0x7e, 816 0x08, 0x5a, 0x52, 0x7e,
804 0x20, 0x4d, 0x84, 0x78, 817 0x20, 0x4d, 0x84, 0x78,
805 0x02, 0x84, 0x09, 0x03, 818 0x02, 0x84, 0x09, 0x03,
806 0x40, 0x5b, 0x04, 0x7e, 819 0x40, 0x5b, 0x18, 0x7e,
807 0xff, 0x90, 0x21, 0x1b, 820 0xff, 0x90, 0x21, 0x1b,
808 0x80, 0xf9, 0xf2, 0x01, 821 0x80, 0xf9, 0xf2, 0x01,
809 0x08, 0x92, 0x63, 0x6b, 822 0x08, 0x92, 0x77, 0x6b,
810 0x02, 0xea, 0xb4, 0x04, 823 0x02, 0xea, 0xb4, 0x04,
811 0x01, 0x40, 0xe1, 0x30, 824 0x01, 0x40, 0xe1, 0x30,
812 0x05, 0x41, 0xe3, 0x98, 825 0x05, 0x41, 0xe3, 0x98,
@@ -1039,138 +1052,138 @@ static struct patch {
1039 { ahd_patch0_func, 64, 1, 1 }, 1052 { ahd_patch0_func, 64, 1, 1 },
1040 { ahd_patch2_func, 67, 1, 2 }, 1053 { ahd_patch2_func, 67, 1, 2 },
1041 { ahd_patch0_func, 68, 1, 1 }, 1054 { ahd_patch0_func, 68, 1, 1 },
1042 { ahd_patch4_func, 116, 1, 1 }, 1055 { ahd_patch4_func, 115, 1, 1 },
1043 { ahd_patch2_func, 175, 3, 1 }, 1056 { ahd_patch2_func, 180, 3, 1 },
1044 { ahd_patch1_func, 178, 2, 1 }, 1057 { ahd_patch1_func, 183, 2, 1 },
1045 { ahd_patch5_func, 180, 1, 1 }, 1058 { ahd_patch5_func, 185, 1, 1 },
1046 { ahd_patch2_func, 189, 1, 2 }, 1059 { ahd_patch2_func, 194, 1, 2 },
1047 { ahd_patch0_func, 190, 1, 1 }, 1060 { ahd_patch0_func, 195, 1, 1 },
1048 { ahd_patch6_func, 191, 2, 2 }, 1061 { ahd_patch6_func, 196, 2, 2 },
1049 { ahd_patch0_func, 193, 6, 3 }, 1062 { ahd_patch0_func, 198, 6, 3 },
1050 { ahd_patch2_func, 196, 1, 2 }, 1063 { ahd_patch2_func, 201, 1, 2 },
1051 { ahd_patch0_func, 197, 1, 1 }, 1064 { ahd_patch0_func, 202, 1, 1 },
1052 { ahd_patch2_func, 200, 1, 2 }, 1065 { ahd_patch2_func, 205, 1, 2 },
1053 { ahd_patch0_func, 201, 1, 1 }, 1066 { ahd_patch0_func, 206, 1, 1 },
1054 { ahd_patch3_func, 203, 1, 1 }, 1067 { ahd_patch3_func, 208, 1, 1 },
1055 { ahd_patch7_func, 204, 3, 1 }, 1068 { ahd_patch7_func, 209, 3, 1 },
1056 { ahd_patch3_func, 213, 1, 1 }, 1069 { ahd_patch3_func, 218, 1, 1 },
1057 { ahd_patch5_func, 214, 16, 2 }, 1070 { ahd_patch5_func, 219, 16, 2 },
1058 { ahd_patch0_func, 230, 1, 1 }, 1071 { ahd_patch0_func, 235, 1, 1 },
1059 { ahd_patch8_func, 250, 2, 1 }, 1072 { ahd_patch8_func, 260, 2, 1 },
1060 { ahd_patch1_func, 254, 1, 2 }, 1073 { ahd_patch1_func, 264, 1, 2 },
1061 { ahd_patch0_func, 255, 1, 1 }, 1074 { ahd_patch0_func, 265, 1, 1 },
1062 { ahd_patch7_func, 258, 3, 1 }, 1075 { ahd_patch7_func, 268, 3, 1 },
1063 { ahd_patch1_func, 273, 1, 2 }, 1076 { ahd_patch1_func, 283, 1, 2 },
1064 { ahd_patch0_func, 274, 1, 1 }, 1077 { ahd_patch0_func, 284, 1, 1 },
1065 { ahd_patch1_func, 277, 1, 2 }, 1078 { ahd_patch1_func, 287, 1, 2 },
1066 { ahd_patch0_func, 278, 1, 1 }, 1079 { ahd_patch0_func, 288, 1, 1 },
1067 { ahd_patch2_func, 281, 1, 2 }, 1080 { ahd_patch2_func, 291, 1, 2 },
1068 { ahd_patch0_func, 282, 1, 1 }, 1081 { ahd_patch0_func, 292, 1, 1 },
1069 { ahd_patch9_func, 295, 2, 2 }, 1082 { ahd_patch9_func, 305, 2, 2 },
1070 { ahd_patch0_func, 297, 1, 1 }, 1083 { ahd_patch0_func, 307, 1, 1 },
1071 { ahd_patch1_func, 339, 1, 2 }, 1084 { ahd_patch1_func, 349, 1, 2 },
1072 { ahd_patch0_func, 340, 1, 1 }, 1085 { ahd_patch0_func, 350, 1, 1 },
1073 { ahd_patch2_func, 348, 1, 2 }, 1086 { ahd_patch2_func, 358, 1, 2 },
1074 { ahd_patch0_func, 349, 1, 1 }, 1087 { ahd_patch0_func, 359, 1, 1 },
1075 { ahd_patch2_func, 352, 1, 2 }, 1088 { ahd_patch2_func, 362, 1, 2 },
1076 { ahd_patch0_func, 353, 1, 1 },
1077 { ahd_patch1_func, 359, 1, 2 },
1078 { ahd_patch0_func, 360, 1, 1 },
1079 { ahd_patch1_func, 362, 1, 2 },
1080 { ahd_patch0_func, 363, 1, 1 }, 1089 { ahd_patch0_func, 363, 1, 1 },
1081 { ahd_patch10_func, 382, 1, 1 }, 1090 { ahd_patch1_func, 369, 1, 2 },
1082 { ahd_patch10_func, 385, 1, 1 }, 1091 { ahd_patch0_func, 370, 1, 1 },
1083 { ahd_patch10_func, 387, 1, 1 }, 1092 { ahd_patch1_func, 372, 1, 2 },
1084 { ahd_patch10_func, 399, 1, 1 }, 1093 { ahd_patch0_func, 373, 1, 1 },
1085 { ahd_patch1_func, 409, 1, 2 }, 1094 { ahd_patch10_func, 392, 1, 1 },
1086 { ahd_patch0_func, 410, 1, 1 }, 1095 { ahd_patch10_func, 395, 1, 1 },
1087 { ahd_patch1_func, 412, 1, 2 }, 1096 { ahd_patch10_func, 397, 1, 1 },
1088 { ahd_patch0_func, 413, 1, 1 }, 1097 { ahd_patch10_func, 409, 1, 1 },
1089 { ahd_patch1_func, 421, 1, 2 }, 1098 { ahd_patch1_func, 419, 1, 2 },
1090 { ahd_patch0_func, 422, 1, 1 }, 1099 { ahd_patch0_func, 420, 1, 1 },
1091 { ahd_patch2_func, 435, 1, 2 }, 1100 { ahd_patch1_func, 422, 1, 2 },
1092 { ahd_patch0_func, 436, 1, 1 }, 1101 { ahd_patch0_func, 423, 1, 1 },
1093 { ahd_patch11_func, 472, 1, 1 }, 1102 { ahd_patch1_func, 431, 1, 2 },
1094 { ahd_patch1_func, 480, 1, 2 }, 1103 { ahd_patch0_func, 432, 1, 1 },
1095 { ahd_patch0_func, 481, 1, 1 }, 1104 { ahd_patch2_func, 445, 1, 2 },
1096 { ahd_patch2_func, 493, 1, 2 }, 1105 { ahd_patch0_func, 446, 1, 1 },
1097 { ahd_patch0_func, 494, 1, 1 }, 1106 { ahd_patch11_func, 482, 1, 1 },
1098 { ahd_patch12_func, 497, 6, 2 }, 1107 { ahd_patch1_func, 490, 1, 2 },
1099 { ahd_patch0_func, 503, 1, 1 }, 1108 { ahd_patch0_func, 491, 1, 1 },
1100 { ahd_patch13_func, 524, 7, 1 }, 1109 { ahd_patch2_func, 503, 1, 2 },
1101 { ahd_patch14_func, 533, 1, 1 }, 1110 { ahd_patch0_func, 504, 1, 1 },
1102 { ahd_patch15_func, 542, 1, 1 }, 1111 { ahd_patch12_func, 507, 6, 2 },
1103 { ahd_patch16_func, 543, 1, 2 }, 1112 { ahd_patch0_func, 513, 1, 1 },
1104 { ahd_patch0_func, 544, 1, 1 }, 1113 { ahd_patch13_func, 534, 7, 1 },
1105 { ahd_patch17_func, 547, 1, 1 }, 1114 { ahd_patch14_func, 543, 1, 1 },
1106 { ahd_patch16_func, 548, 1, 1 }, 1115 { ahd_patch15_func, 552, 1, 1 },
1107 { ahd_patch18_func, 559, 1, 2 }, 1116 { ahd_patch16_func, 553, 1, 2 },
1108 { ahd_patch0_func, 560, 1, 1 }, 1117 { ahd_patch0_func, 554, 1, 1 },
1109 { ahd_patch1_func, 579, 1, 2 }, 1118 { ahd_patch17_func, 557, 1, 1 },
1110 { ahd_patch0_func, 580, 1, 1 }, 1119 { ahd_patch16_func, 558, 1, 1 },
1111 { ahd_patch1_func, 583, 1, 2 }, 1120 { ahd_patch18_func, 569, 1, 2 },
1112 { ahd_patch0_func, 584, 1, 1 }, 1121 { ahd_patch0_func, 570, 1, 1 },
1113 { ahd_patch2_func, 589, 1, 2 }, 1122 { ahd_patch1_func, 589, 1, 2 },
1114 { ahd_patch0_func, 590, 1, 1 }, 1123 { ahd_patch0_func, 590, 1, 1 },
1115 { ahd_patch2_func, 594, 1, 2 }, 1124 { ahd_patch1_func, 593, 1, 2 },
1116 { ahd_patch0_func, 595, 1, 1 }, 1125 { ahd_patch0_func, 594, 1, 1 },
1117 { ahd_patch1_func, 596, 1, 2 }, 1126 { ahd_patch2_func, 599, 1, 2 },
1118 { ahd_patch0_func, 597, 1, 1 }, 1127 { ahd_patch0_func, 600, 1, 1 },
1119 { ahd_patch2_func, 608, 1, 2 }, 1128 { ahd_patch2_func, 604, 1, 2 },
1120 { ahd_patch0_func, 609, 1, 1 }, 1129 { ahd_patch0_func, 605, 1, 1 },
1121 { ahd_patch19_func, 613, 1, 1 }, 1130 { ahd_patch1_func, 606, 1, 2 },
1122 { ahd_patch20_func, 618, 1, 1 }, 1131 { ahd_patch0_func, 607, 1, 1 },
1123 { ahd_patch21_func, 619, 2, 1 }, 1132 { ahd_patch2_func, 618, 1, 2 },
1124 { ahd_patch20_func, 623, 1, 2 }, 1133 { ahd_patch0_func, 619, 1, 1 },
1125 { ahd_patch0_func, 624, 1, 1 }, 1134 { ahd_patch19_func, 623, 1, 1 },
1126 { ahd_patch2_func, 627, 1, 2 }, 1135 { ahd_patch20_func, 628, 1, 1 },
1127 { ahd_patch0_func, 628, 1, 1 }, 1136 { ahd_patch21_func, 629, 2, 1 },
1128 { ahd_patch2_func, 643, 1, 2 }, 1137 { ahd_patch20_func, 633, 1, 2 },
1129 { ahd_patch0_func, 644, 1, 1 }, 1138 { ahd_patch0_func, 634, 1, 1 },
1130 { ahd_patch13_func, 645, 14, 1 }, 1139 { ahd_patch2_func, 637, 1, 2 },
1131 { ahd_patch1_func, 663, 1, 2 }, 1140 { ahd_patch0_func, 638, 1, 1 },
1132 { ahd_patch0_func, 664, 1, 1 }, 1141 { ahd_patch2_func, 653, 1, 2 },
1133 { ahd_patch13_func, 665, 1, 1 }, 1142 { ahd_patch0_func, 654, 1, 1 },
1134 { ahd_patch1_func, 677, 1, 2 }, 1143 { ahd_patch13_func, 655, 14, 1 },
1135 { ahd_patch0_func, 678, 1, 1 }, 1144 { ahd_patch1_func, 673, 1, 2 },
1136 { ahd_patch1_func, 685, 1, 2 }, 1145 { ahd_patch0_func, 674, 1, 1 },
1137 { ahd_patch0_func, 686, 1, 1 }, 1146 { ahd_patch13_func, 675, 1, 1 },
1138 { ahd_patch19_func, 709, 1, 1 }, 1147 { ahd_patch1_func, 687, 1, 2 },
1139 { ahd_patch19_func, 747, 1, 1 }, 1148 { ahd_patch0_func, 688, 1, 1 },
1140 { ahd_patch1_func, 758, 1, 2 }, 1149 { ahd_patch1_func, 695, 1, 2 },
1141 { ahd_patch0_func, 759, 1, 1 }, 1150 { ahd_patch0_func, 696, 1, 1 },
1142 { ahd_patch1_func, 776, 1, 2 }, 1151 { ahd_patch19_func, 719, 1, 1 },
1143 { ahd_patch0_func, 777, 1, 1 }, 1152 { ahd_patch19_func, 757, 1, 1 },
1144 { ahd_patch1_func, 779, 1, 2 }, 1153 { ahd_patch1_func, 768, 1, 2 },
1145 { ahd_patch0_func, 780, 1, 1 }, 1154 { ahd_patch0_func, 769, 1, 1 },
1146 { ahd_patch1_func, 783, 1, 2 }, 1155 { ahd_patch7_func, 785, 3, 1 },
1147 { ahd_patch0_func, 784, 1, 1 }, 1156 { ahd_patch1_func, 789, 1, 2 },
1148 { ahd_patch22_func, 786, 1, 2 }, 1157 { ahd_patch0_func, 790, 1, 1 },
1149 { ahd_patch0_func, 787, 2, 1 }, 1158 { ahd_patch1_func, 792, 1, 2 },
1150 { ahd_patch23_func, 790, 4, 2 }, 1159 { ahd_patch0_func, 793, 1, 1 },
1151 { ahd_patch0_func, 794, 1, 1 }, 1160 { ahd_patch1_func, 796, 1, 2 },
1152 { ahd_patch23_func, 802, 11, 1 } 1161 { ahd_patch0_func, 797, 1, 1 },
1162 { ahd_patch22_func, 799, 1, 2 },
1163 { ahd_patch0_func, 800, 2, 1 },
1164 { ahd_patch23_func, 803, 4, 2 },
1165 { ahd_patch0_func, 807, 1, 1 },
1166 { ahd_patch23_func, 815, 11, 1 }
1153}; 1167};
1154 1168
1155static struct cs { 1169static struct cs {
1156 uint16_t begin; 1170 uint16_t begin;
1157 uint16_t end; 1171 uint16_t end;
1158} critical_sections[] = { 1172} critical_sections[] = {
1159 { 17, 28 }, 1173 { 17, 30 },
1160 { 29, 30 },
1161 { 47, 58 }, 1174 { 47, 58 },
1162 { 61, 63 }, 1175 { 61, 63 },
1163 { 65, 66 }, 1176 { 65, 66 },
1164 { 72, 92 }, 1177 { 72, 92 },
1165 { 110, 137 }, 1178 { 110, 142 },
1166 { 138, 175 }, 1179 { 143, 180 },
1167 { 180, 188 }, 1180 { 185, 193 },
1168 { 213, 264 }, 1181 { 218, 274 },
1169 { 425, 433 }, 1182 { 435, 443 },
1170 { 443, 445 }, 1183 { 453, 455 },
1171 { 448, 457 }, 1184 { 458, 467 },
1172 { 709, 739 }, 1185 { 719, 749 },
1173 { 749, 753 } 1186 { 759, 763 }
1174}; 1187};
1175 1188
1176static const int num_critical_sections = sizeof(critical_sections) 1189static const int num_critical_sections = sizeof(critical_sections)
diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm.c b/drivers/scsi/aic7xxx/aicasm/aicasm.c
index f936b691232f..924102720b14 100644
--- a/drivers/scsi/aic7xxx/aicasm/aicasm.c
+++ b/drivers/scsi/aic7xxx/aicasm/aicasm.c
@@ -37,7 +37,7 @@
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES. 38 * POSSIBILITY OF SUCH DAMAGES.
39 * 39 *
40 * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#22 $ 40 * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm.c#23 $
41 * 41 *
42 * $FreeBSD$ 42 * $FreeBSD$
43 */ 43 */
@@ -609,10 +609,10 @@ output_listing(char *ifilename)
609 609
610 while (line < cur_instr->srcline) { 610 while (line < cur_instr->srcline) {
611 fgets(buf, sizeof(buf), ifile); 611 fgets(buf, sizeof(buf), ifile);
612 fprintf(listfile, "\t\t%s", buf); 612 fprintf(listfile, " \t%s", buf);
613 line++; 613 line++;
614 } 614 }
615 fprintf(listfile, "%03x %02x%02x%02x%02x", instrptr, 615 fprintf(listfile, "%04x %02x%02x%02x%02x", instrptr,
616#ifdef __LITTLE_ENDIAN 616#ifdef __LITTLE_ENDIAN
617 cur_instr->format.bytes[0], 617 cur_instr->format.bytes[0],
618 cur_instr->format.bytes[1], 618 cur_instr->format.bytes[1],
@@ -624,14 +624,23 @@ output_listing(char *ifilename)
624 cur_instr->format.bytes[1], 624 cur_instr->format.bytes[1],
625 cur_instr->format.bytes[0]); 625 cur_instr->format.bytes[0]);
626#endif 626#endif
627 fgets(buf, sizeof(buf), ifile); 627 /*
628 fprintf(listfile, "\t%s", buf); 628 * Macro expansions can cause several instructions
629 line++; 629 * to be output for a single source line. Only
630 * advance the line once in these cases.
631 */
632 if (line == cur_instr->srcline) {
633 fgets(buf, sizeof(buf), ifile);
634 fprintf(listfile, "\t%s", buf);
635 line++;
636 } else {
637 fprintf(listfile, "\n");
638 }
630 instrptr++; 639 instrptr++;
631 } 640 }
632 /* Dump the remainder of the file */ 641 /* Dump the remainder of the file */
633 while(fgets(buf, sizeof(buf), ifile) != NULL) 642 while(fgets(buf, sizeof(buf), ifile) != NULL)
634 fprintf(listfile, "\t\t%s", buf); 643 fprintf(listfile, " %s", buf);
635 644
636 fclose(ifile); 645 fclose(ifile);
637} 646}
diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y b/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y
index 67e046d96625..c328596def3c 100644
--- a/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y
+++ b/drivers/scsi/aic7xxx/aicasm/aicasm_gram.y
@@ -38,7 +38,7 @@
38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGES. 39 * POSSIBILITY OF SUCH DAMAGES.
40 * 40 *
41 * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#29 $ 41 * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_gram.y#30 $
42 * 42 *
43 * $FreeBSD$ 43 * $FreeBSD$
44 */ 44 */
@@ -157,6 +157,8 @@ static int is_download_const(expression_t *immed);
157 157
158%token T_END_CS 158%token T_END_CS
159 159
160%token T_PAD_PAGE
161
160%token T_FIELD 162%token T_FIELD
161 163
162%token T_ENUM 164%token T_ENUM
@@ -189,6 +191,10 @@ static int is_download_const(expression_t *immed);
189 191
190%token <value> T_OR 192%token <value> T_OR
191 193
194/* 16 bit extensions */
195%token <value> T_OR16 T_AND16 T_XOR16 T_ADD16
196%token <value> T_ADC16 T_MVI16 T_TEST16 T_CMP16 T_CMPXCHG
197
192%token T_RET 198%token T_RET
193 199
194%token T_NOP 200%token T_NOP
@@ -207,7 +213,7 @@ static int is_download_const(expression_t *immed);
207 213
208%type <expression> expression immediate immediate_or_a 214%type <expression> expression immediate immediate_or_a
209 215
210%type <value> export ret f1_opcode f2_opcode jmp_jc_jnc_call jz_jnz je_jne 216%type <value> export ret f1_opcode f2_opcode f4_opcode jmp_jc_jnc_call jz_jnz je_jne
211 217
212%type <value> mode_value mode_list macro_arglist 218%type <value> mode_value mode_list macro_arglist
213 219
@@ -1304,6 +1310,15 @@ f2_opcode:
1304| T_ROR { $$ = AIC_OP_ROR; } 1310| T_ROR { $$ = AIC_OP_ROR; }
1305; 1311;
1306 1312
1313f4_opcode:
1314 T_OR16 { $$ = AIC_OP_OR16; }
1315| T_AND16 { $$ = AIC_OP_AND16; }
1316| T_XOR16 { $$ = AIC_OP_XOR16; }
1317| T_ADD16 { $$ = AIC_OP_ADD16; }
1318| T_ADC16 { $$ = AIC_OP_ADC16; }
1319| T_MVI16 { $$ = AIC_OP_MVI16; }
1320;
1321
1307code: 1322code:
1308 f2_opcode destination ',' expression opt_source ret ';' 1323 f2_opcode destination ',' expression opt_source ret ';'
1309 { 1324 {
diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h b/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h
index e64f802bbaaa..9df9e2ce3538 100644
--- a/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h
+++ b/drivers/scsi/aic7xxx/aicasm/aicasm_insformat.h
@@ -37,13 +37,14 @@
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES. 38 * POSSIBILITY OF SUCH DAMAGES.
39 * 39 *
40 * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#11 $ 40 * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_insformat.h#12 $
41 * 41 *
42 * $FreeBSD$ 42 * $FreeBSD$
43 */ 43 */
44 44
45#include <asm/byteorder.h> 45#include <asm/byteorder.h>
46 46
47/* 8bit ALU logic operations */
47struct ins_format1 { 48struct ins_format1 {
48#ifdef __LITTLE_ENDIAN 49#ifdef __LITTLE_ENDIAN
49 uint32_t immediate : 8, 50 uint32_t immediate : 8,
@@ -62,6 +63,7 @@ struct ins_format1 {
62#endif 63#endif
63}; 64};
64 65
66/* 8bit ALU shift/rotate operations */
65struct ins_format2 { 67struct ins_format2 {
66#ifdef __LITTLE_ENDIAN 68#ifdef __LITTLE_ENDIAN
67 uint32_t shift_control : 8, 69 uint32_t shift_control : 8,
@@ -80,6 +82,7 @@ struct ins_format2 {
80#endif 82#endif
81}; 83};
82 84
85/* 8bit branch control operations */
83struct ins_format3 { 86struct ins_format3 {
84#ifdef __LITTLE_ENDIAN 87#ifdef __LITTLE_ENDIAN
85 uint32_t immediate : 8, 88 uint32_t immediate : 8,
@@ -96,10 +99,68 @@ struct ins_format3 {
96#endif 99#endif
97}; 100};
98 101
102/* 16bit ALU logic operations */
103struct ins_format4 {
104#ifdef __LITTLE_ENDIAN
105 uint32_t opcode_ext : 8,
106 source : 9,
107 destination : 9,
108 ret : 1,
109 opcode : 4,
110 parity : 1;
111#else
112 uint32_t parity : 1,
113 opcode : 4,
114 ret : 1,
115 destination : 9,
116 source : 9,
117 opcode_ext : 8;
118#endif
119};
120
121/* 16bit branch control operations */
122struct ins_format5 {
123#ifdef __LITTLE_ENDIAN
124 uint32_t opcode_ext : 8,
125 source : 9,
126 address : 10,
127 opcode : 4,
128 parity : 1;
129#else
130 uint32_t parity : 1,
131 opcode : 4,
132 address : 10,
133 source : 9,
134 opcode_ext : 8;
135#endif
136};
137
138/* Far branch operations */
139struct ins_format6 {
140#ifdef __LITTLE_ENDIAN
141 uint32_t page : 3,
142 opcode_ext : 5,
143 source : 9,
144 address : 10,
145 opcode : 4,
146 parity : 1;
147#else
148 uint32_t parity : 1,
149 opcode : 4,
150 address : 10,
151 source : 9,
152 opcode_ext : 5,
153 page : 3;
154#endif
155};
156
99union ins_formats { 157union ins_formats {
100 struct ins_format1 format1; 158 struct ins_format1 format1;
101 struct ins_format2 format2; 159 struct ins_format2 format2;
102 struct ins_format3 format3; 160 struct ins_format3 format3;
161 struct ins_format4 format4;
162 struct ins_format5 format5;
163 struct ins_format6 format6;
103 uint8_t bytes[4]; 164 uint8_t bytes[4];
104 uint32_t integer; 165 uint32_t integer;
105}; 166};
@@ -118,6 +179,8 @@ struct instruction {
118#define AIC_OP_ROL 0x5 179#define AIC_OP_ROL 0x5
119#define AIC_OP_BMOV 0x6 180#define AIC_OP_BMOV 0x6
120 181
182#define AIC_OP_MVI16 0x7
183
121#define AIC_OP_JMP 0x8 184#define AIC_OP_JMP 0x8
122#define AIC_OP_JC 0x9 185#define AIC_OP_JC 0x9
123#define AIC_OP_JNC 0xa 186#define AIC_OP_JNC 0xa
@@ -131,3 +194,26 @@ struct instruction {
131#define AIC_OP_SHL 0x10 194#define AIC_OP_SHL 0x10
132#define AIC_OP_SHR 0x20 195#define AIC_OP_SHR 0x20
133#define AIC_OP_ROR 0x30 196#define AIC_OP_ROR 0x30
197
198/* 16bit Ops. Low byte main opcode. High byte extended opcode. */
199#define AIC_OP_OR16 0x8005
200#define AIC_OP_AND16 0x8105
201#define AIC_OP_XOR16 0x8205
202#define AIC_OP_ADD16 0x8305
203#define AIC_OP_ADC16 0x8405
204#define AIC_OP_JNE16 0x8805
205#define AIC_OP_JNZ16 0x8905
206#define AIC_OP_JE16 0x8C05
207#define AIC_OP_JZ16 0x8B05
208#define AIC_OP_JMP16 0x9005
209#define AIC_OP_JC16 0x9105
210#define AIC_OP_JNC16 0x9205
211#define AIC_OP_CALL16 0x9305
212#define AIC_OP_CALL16 0x9305
213
214/* Page extension is low three bits of second opcode byte. */
215#define AIC_OP_JMPF 0xA005
216#define AIC_OP_CALLF 0xB005
217#define AIC_OP_JCF 0xC005
218#define AIC_OP_JNCF 0xD005
219#define AIC_OP_CMPXCHG 0xE005
diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l b/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l
index 45c0b233d0bc..7c3983f868a9 100644
--- a/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l
+++ b/drivers/scsi/aic7xxx/aicasm/aicasm_scan.l
@@ -38,7 +38,7 @@
38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGES. 39 * POSSIBILITY OF SUCH DAMAGES.
40 * 40 *
41 * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#19 $ 41 * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_scan.l#20 $
42 * 42 *
43 * $FreeBSD$ 43 * $FreeBSD$
44 */ 44 */
@@ -132,7 +132,7 @@ if[ \t]*\( {
132 *string_buf_ptr++ = *yptr++; 132 *string_buf_ptr++ = *yptr++;
133 } 133 }
134 } 134 }
135 135else { return T_ELSE; }
136VERSION { return T_VERSION; } 136VERSION { return T_VERSION; }
137PREFIX { return T_PREFIX; } 137PREFIX { return T_PREFIX; }
138PATCH_ARG_LIST { return T_PATCH_ARG_LIST; } 138PATCH_ARG_LIST { return T_PATCH_ARG_LIST; }
@@ -173,10 +173,6 @@ RW|RO|WO {
173 yylval.value = WO; 173 yylval.value = WO;
174 return T_MODE; 174 return T_MODE;
175 } 175 }
176BEGIN_CRITICAL { return T_BEGIN_CS; }
177END_CRITICAL { return T_END_CS; }
178SET_SRC_MODE { return T_SET_SRC_MODE; }
179SET_DST_MODE { return T_SET_DST_MODE; }
180field { return T_FIELD; } 176field { return T_FIELD; }
181enum { return T_ENUM; } 177enum { return T_ENUM; }
182mask { return T_MASK; } 178mask { return T_MASK; }
@@ -192,6 +188,13 @@ none { return T_NONE; }
192sindex { return T_SINDEX; } 188sindex { return T_SINDEX; }
193A { return T_A; } 189A { return T_A; }
194 190
191 /* Instruction Formatting */
192PAD_PAGE { return T_PAD_PAGE; }
193BEGIN_CRITICAL { return T_BEGIN_CS; }
194END_CRITICAL { return T_END_CS; }
195SET_SRC_MODE { return T_SET_SRC_MODE; }
196SET_DST_MODE { return T_SET_DST_MODE; }
197
195 /* Opcodes */ 198 /* Opcodes */
196shl { return T_SHL; } 199shl { return T_SHL; }
197shr { return T_SHR; } 200shr { return T_SHR; }
@@ -223,7 +226,17 @@ and { return T_AND; }
223or { return T_OR; } 226or { return T_OR; }
224ret { return T_RET; } 227ret { return T_RET; }
225nop { return T_NOP; } 228nop { return T_NOP; }
226else { return T_ELSE; } 229
230 /* ARP2 16bit extensions */
231or16 { return T_OR16; }
232and16 { return T_AND16; }
233xor16 { return T_XOR16; }
234add16 { return T_ADD16; }
235adc16 { return T_ADC16; }
236mvi16 { return T_MVI16; }
237test16 { return T_TEST16; }
238cmp16 { return T_CMP16; }
239cmpxchg { return T_CMPXCHG; }
227 240
228 /* Allowed Symbols */ 241 /* Allowed Symbols */
229\<\< { return T_EXPR_LSHIFT; } 242\<\< { return T_EXPR_LSHIFT; }
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index c8a32cf47d73..cbf825263f3b 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -246,6 +246,7 @@ struct ScsiReqBlk {
246 * total_xfer_length in xferred. These values are restored in 246 * total_xfer_length in xferred. These values are restored in
247 * pci_unmap_srb_sense. This is the only place xferred is used. 247 * pci_unmap_srb_sense. This is the only place xferred is used.
248 */ 248 */
249 unsigned char *virt_addr_req; /* Saved virtual address of the request buffer */
249 u32 xferred; /* Saved copy of total_xfer_length */ 250 u32 xferred; /* Saved copy of total_xfer_length */
250 251
251 u16 state; 252 u16 state;
@@ -2017,7 +2018,7 @@ static void sg_update_list(struct ScsiReqBlk *srb, u32 left)
2017 sg_verify_length(srb); 2018 sg_verify_length(srb);
2018 2019
2019 /* we need the corresponding virtual address */ 2020 /* we need the corresponding virtual address */
2020 if (!segment) { 2021 if (!segment || (srb->flag & AUTO_REQSENSE)) {
2021 srb->virt_addr += xferred; 2022 srb->virt_addr += xferred;
2022 return; 2023 return;
2023 } 2024 }
@@ -3318,6 +3319,7 @@ static void pci_unmap_srb_sense(struct AdapterCtlBlk *acb,
3318 srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].address; 3319 srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].address;
3319 srb->segment_x[0].length = 3320 srb->segment_x[0].length =
3320 srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].length; 3321 srb->segment_x[DC395x_MAX_SG_LISTENTRY - 1].length;
3322 srb->virt_addr = srb->virt_addr_req;
3321} 3323}
3322 3324
3323 3325
@@ -3711,6 +3713,8 @@ static void request_sense(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
3711 srb->xferred = srb->total_xfer_length; 3713 srb->xferred = srb->total_xfer_length;
3712 /* srb->segment_x : a one entry of S/G list table */ 3714 /* srb->segment_x : a one entry of S/G list table */
3713 srb->total_xfer_length = sizeof(cmd->sense_buffer); 3715 srb->total_xfer_length = sizeof(cmd->sense_buffer);
3716 srb->virt_addr_req = srb->virt_addr;
3717 srb->virt_addr = cmd->sense_buffer;
3714 srb->segment_x[0].length = sizeof(cmd->sense_buffer); 3718 srb->segment_x[0].length = sizeof(cmd->sense_buffer);
3715 /* Map sense buffer */ 3719 /* Map sense buffer */
3716 srb->segment_x[0].address = 3720 srb->segment_x[0].address =
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 822b9fa706f3..eaefeddb2b4a 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -87,7 +87,7 @@ static int max_channel = 3;
87static int init_timeout = 5; 87static int init_timeout = 5;
88static int max_requests = 50; 88static int max_requests = 50;
89 89
90#define IBMVSCSI_VERSION "1.5.7" 90#define IBMVSCSI_VERSION "1.5.8"
91 91
92MODULE_DESCRIPTION("IBM Virtual SCSI"); 92MODULE_DESCRIPTION("IBM Virtual SCSI");
93MODULE_AUTHOR("Dave Boutcher"); 93MODULE_AUTHOR("Dave Boutcher");
@@ -534,7 +534,6 @@ static int map_data_for_srp_cmd(struct scsi_cmnd *cmd,
534static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, 534static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
535 struct ibmvscsi_host_data *hostdata) 535 struct ibmvscsi_host_data *hostdata)
536{ 536{
537 struct scsi_cmnd *cmnd;
538 u64 *crq_as_u64 = (u64 *) &evt_struct->crq; 537 u64 *crq_as_u64 = (u64 *) &evt_struct->crq;
539 int rc; 538 int rc;
540 539
@@ -544,19 +543,8 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
544 * can handle more requests (can_queue) when we actually can't 543 * can handle more requests (can_queue) when we actually can't
545 */ 544 */
546 if ((evt_struct->crq.format == VIOSRP_SRP_FORMAT) && 545 if ((evt_struct->crq.format == VIOSRP_SRP_FORMAT) &&
547 (atomic_dec_if_positive(&hostdata->request_limit) < 0)) { 546 (atomic_dec_if_positive(&hostdata->request_limit) < 0))
548 /* See if the adapter is disabled */ 547 goto send_error;
549 if (atomic_read(&hostdata->request_limit) < 0)
550 goto send_error;
551
552 printk(KERN_WARNING
553 "ibmvscsi: Warning, request_limit exceeded\n");
554 unmap_cmd_data(&evt_struct->iu.srp.cmd,
555 evt_struct,
556 hostdata->dev);
557 free_event_struct(&hostdata->pool, evt_struct);
558 return SCSI_MLQUEUE_HOST_BUSY;
559 }
560 548
561 /* Copy the IU into the transfer area */ 549 /* Copy the IU into the transfer area */
562 *evt_struct->xfer_iu = evt_struct->iu; 550 *evt_struct->xfer_iu = evt_struct->iu;
@@ -572,7 +560,7 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
572 ibmvscsi_send_crq(hostdata, crq_as_u64[0], crq_as_u64[1])) != 0) { 560 ibmvscsi_send_crq(hostdata, crq_as_u64[0], crq_as_u64[1])) != 0) {
573 list_del(&evt_struct->list); 561 list_del(&evt_struct->list);
574 562
575 printk(KERN_ERR "ibmvscsi: failed to send event struct rc %d\n", 563 printk(KERN_ERR "ibmvscsi: send error %d\n",
576 rc); 564 rc);
577 goto send_error; 565 goto send_error;
578 } 566 }
@@ -582,14 +570,8 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
582 send_error: 570 send_error:
583 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev); 571 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev);
584 572
585 if ((cmnd = evt_struct->cmnd) != NULL) {
586 cmnd->result = DID_ERROR << 16;
587 evt_struct->cmnd_done(cmnd);
588 } else if (evt_struct->done)
589 evt_struct->done(evt_struct);
590
591 free_event_struct(&hostdata->pool, evt_struct); 573 free_event_struct(&hostdata->pool, evt_struct);
592 return 0; 574 return SCSI_MLQUEUE_HOST_BUSY;
593} 575}
594 576
595/** 577/**
@@ -802,7 +784,8 @@ static void login_rsp(struct srp_event_struct *evt_struct)
802 case SRP_LOGIN_RSP_TYPE: /* it worked! */ 784 case SRP_LOGIN_RSP_TYPE: /* it worked! */
803 break; 785 break;
804 case SRP_LOGIN_REJ_TYPE: /* refused! */ 786 case SRP_LOGIN_REJ_TYPE: /* refused! */
805 printk(KERN_INFO "ibmvscsi: SRP_LOGIN_REQ rejected\n"); 787 printk(KERN_INFO "ibmvscsi: SRP_LOGIN_REJ reason %u\n",
788 evt_struct->xfer_iu->srp.login_rej.reason);
806 /* Login failed. */ 789 /* Login failed. */
807 atomic_set(&hostdata->request_limit, -1); 790 atomic_set(&hostdata->request_limit, -1);
808 return; 791 return;
@@ -834,6 +817,9 @@ static void login_rsp(struct srp_event_struct *evt_struct)
834 return; 817 return;
835 } 818 }
836 819
820 /* If we had any pending I/Os, kick them */
821 scsi_unblock_requests(hostdata->host);
822
837 send_mad_adapter_info(hostdata); 823 send_mad_adapter_info(hostdata);
838 return; 824 return;
839} 825}
@@ -862,6 +848,7 @@ static int send_srp_login(struct ibmvscsi_host_data *hostdata)
862 init_timeout * HZ); 848 init_timeout * HZ);
863 849
864 login = &evt_struct->iu.srp.login_req; 850 login = &evt_struct->iu.srp.login_req;
851 memset(login, 0x00, sizeof(struct srp_login_req));
865 login->type = SRP_LOGIN_REQ_TYPE; 852 login->type = SRP_LOGIN_REQ_TYPE;
866 login->max_requested_initiator_to_target_iulen = sizeof(union srp_iu); 853 login->max_requested_initiator_to_target_iulen = sizeof(union srp_iu);
867 login->required_buffer_formats = 0x0006; 854 login->required_buffer_formats = 0x0006;
@@ -1122,7 +1109,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
1122 * purge_requests: Our virtual adapter just shut down. purge any sent requests 1109 * purge_requests: Our virtual adapter just shut down. purge any sent requests
1123 * @hostdata: the adapter 1110 * @hostdata: the adapter
1124 */ 1111 */
1125static void purge_requests(struct ibmvscsi_host_data *hostdata) 1112static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code)
1126{ 1113{
1127 struct srp_event_struct *tmp_evt, *pos; 1114 struct srp_event_struct *tmp_evt, *pos;
1128 unsigned long flags; 1115 unsigned long flags;
@@ -1131,7 +1118,7 @@ static void purge_requests(struct ibmvscsi_host_data *hostdata)
1131 list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) { 1118 list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) {
1132 list_del(&tmp_evt->list); 1119 list_del(&tmp_evt->list);
1133 if (tmp_evt->cmnd) { 1120 if (tmp_evt->cmnd) {
1134 tmp_evt->cmnd->result = (DID_ERROR << 16); 1121 tmp_evt->cmnd->result = (error_code << 16);
1135 unmap_cmd_data(&tmp_evt->iu.srp.cmd, 1122 unmap_cmd_data(&tmp_evt->iu.srp.cmd,
1136 tmp_evt, 1123 tmp_evt,
1137 tmp_evt->hostdata->dev); 1124 tmp_evt->hostdata->dev);
@@ -1186,12 +1173,30 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
1186 printk(KERN_ERR "ibmvscsi: unknown crq message type\n"); 1173 printk(KERN_ERR "ibmvscsi: unknown crq message type\n");
1187 } 1174 }
1188 return; 1175 return;
1189 case 0xFF: /* Hypervisor telling us the connection is closed */ 1176 case 0xFF: /* Hypervisor telling us the connection is closed */
1190 printk(KERN_INFO "ibmvscsi: Virtual adapter failed!\n"); 1177 scsi_block_requests(hostdata->host);
1178 if (crq->format == 0x06) {
1179 /* We need to re-setup the interpartition connection */
1180 printk(KERN_INFO
1181 "ibmvscsi: Re-enabling adapter!\n");
1182 purge_requests(hostdata, DID_REQUEUE);
1183 if (ibmvscsi_reenable_crq_queue(&hostdata->queue,
1184 hostdata) == 0)
1185 if (ibmvscsi_send_crq(hostdata,
1186 0xC001000000000000LL, 0))
1187 printk(KERN_ERR
1188 "ibmvscsi: transmit error after"
1189 " enable\n");
1190 } else {
1191 printk(KERN_INFO
1192 "ibmvscsi: Virtual adapter failed rc %d!\n",
1193 crq->format);
1191 1194
1192 atomic_set(&hostdata->request_limit, -1); 1195 atomic_set(&hostdata->request_limit, -1);
1193 purge_requests(hostdata); 1196 purge_requests(hostdata, DID_ERROR);
1194 ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata); 1197 ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata);
1198 }
1199 scsi_unblock_requests(hostdata->host);
1195 return; 1200 return;
1196 case 0x80: /* real payload */ 1201 case 0x80: /* real payload */
1197 break; 1202 break;
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.h b/drivers/scsi/ibmvscsi/ibmvscsi.h
index 5b0edd1f1921..4550d71e4744 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.h
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.h
@@ -103,6 +103,9 @@ void ibmvscsi_release_crq_queue(struct crq_queue *queue,
103int ibmvscsi_reset_crq_queue(struct crq_queue *queue, 103int ibmvscsi_reset_crq_queue(struct crq_queue *queue,
104 struct ibmvscsi_host_data *hostdata); 104 struct ibmvscsi_host_data *hostdata);
105 105
106int ibmvscsi_reenable_crq_queue(struct crq_queue *queue,
107 struct ibmvscsi_host_data *hostdata);
108
106void ibmvscsi_handle_crq(struct viosrp_crq *crq, 109void ibmvscsi_handle_crq(struct viosrp_crq *crq,
107 struct ibmvscsi_host_data *hostdata); 110 struct ibmvscsi_host_data *hostdata);
108int ibmvscsi_send_crq(struct ibmvscsi_host_data *hostdata, 111int ibmvscsi_send_crq(struct ibmvscsi_host_data *hostdata,
diff --git a/drivers/scsi/ibmvscsi/iseries_vscsi.c b/drivers/scsi/ibmvscsi/iseries_vscsi.c
index ce15d9e39621..7eed0b098171 100644
--- a/drivers/scsi/ibmvscsi/iseries_vscsi.c
+++ b/drivers/scsi/ibmvscsi/iseries_vscsi.c
@@ -124,6 +124,19 @@ int ibmvscsi_reset_crq_queue(struct crq_queue *queue,
124} 124}
125 125
126/** 126/**
127 * reenable_crq_queue: - reenables a crq after a failure
128 * @queue: crq_queue to initialize and register
129 * @hostdata: ibmvscsi_host_data of host
130 *
131 * no-op for iSeries
132 */
133int ibmvscsi_reenable_crq_queue(struct crq_queue *queue,
134 struct ibmvscsi_host_data *hostdata)
135{
136 return 0;
137}
138
139/**
127 * ibmvscsi_send_crq: - Send a CRQ 140 * ibmvscsi_send_crq: - Send a CRQ
128 * @hostdata: the adapter 141 * @hostdata: the adapter
129 * @word1: the first 64 bits of the data 142 * @word1: the first 64 bits of the data
diff --git a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c
index 75db2f5c545e..f47dd87c05e7 100644
--- a/drivers/scsi/ibmvscsi/rpa_vscsi.c
+++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c
@@ -281,6 +281,28 @@ int ibmvscsi_init_crq_queue(struct crq_queue *queue,
281} 281}
282 282
283/** 283/**
284 * reenable_crq_queue: - reenables a crq after
285 * @queue: crq_queue to initialize and register
286 * @hostdata: ibmvscsi_host_data of host
287 *
288 */
289int ibmvscsi_reenable_crq_queue(struct crq_queue *queue,
290 struct ibmvscsi_host_data *hostdata)
291{
292 int rc;
293 struct vio_dev *vdev = to_vio_dev(hostdata->dev);
294
295 /* Re-enable the CRQ */
296 do {
297 rc = plpar_hcall_norets(H_ENABLE_CRQ, vdev->unit_address);
298 } while ((rc == H_InProgress) || (rc == H_Busy) || (H_isLongBusy(rc)));
299
300 if (rc)
301 printk(KERN_ERR "ibmvscsi: Error %d enabling adapter\n", rc);
302 return rc;
303}
304
305/**
284 * reset_crq_queue: - resets a crq after a failure 306 * reset_crq_queue: - resets a crq after a failure
285 * @queue: crq_queue to initialize and register 307 * @queue: crq_queue to initialize and register
286 * @hostdata: ibmvscsi_host_data of host 308 * @hostdata: ibmvscsi_host_data of host
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 3c688ef54660..0cf0e4c7ac0c 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -751,9 +751,8 @@ static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi)
751 idescsi_add_settings(drive); 751 idescsi_add_settings(drive);
752} 752}
753 753
754static int ide_scsi_remove(struct device *dev) 754static void ide_scsi_remove(ide_drive_t *drive)
755{ 755{
756 ide_drive_t *drive = to_ide_device(dev);
757 struct Scsi_Host *scsihost = drive->driver_data; 756 struct Scsi_Host *scsihost = drive->driver_data;
758 struct ide_scsi_obj *scsi = scsihost_to_idescsi(scsihost); 757 struct ide_scsi_obj *scsi = scsihost_to_idescsi(scsihost);
759 struct gendisk *g = scsi->disk; 758 struct gendisk *g = scsi->disk;
@@ -768,11 +767,9 @@ static int ide_scsi_remove(struct device *dev)
768 767
769 scsi_remove_host(scsihost); 768 scsi_remove_host(scsihost);
770 ide_scsi_put(scsi); 769 ide_scsi_put(scsi);
771
772 return 0;
773} 770}
774 771
775static int ide_scsi_probe(struct device *); 772static int ide_scsi_probe(ide_drive_t *);
776 773
777#ifdef CONFIG_PROC_FS 774#ifdef CONFIG_PROC_FS
778static ide_proc_entry_t idescsi_proc[] = { 775static ide_proc_entry_t idescsi_proc[] = {
@@ -788,9 +785,9 @@ static ide_driver_t idescsi_driver = {
788 .owner = THIS_MODULE, 785 .owner = THIS_MODULE,
789 .name = "ide-scsi", 786 .name = "ide-scsi",
790 .bus = &ide_bus_type, 787 .bus = &ide_bus_type,
791 .probe = ide_scsi_probe,
792 .remove = ide_scsi_remove,
793 }, 788 },
789 .probe = ide_scsi_probe,
790 .remove = ide_scsi_remove,
794 .version = IDESCSI_VERSION, 791 .version = IDESCSI_VERSION,
795 .media = ide_scsi, 792 .media = ide_scsi,
796 .supports_dsc_overlap = 0, 793 .supports_dsc_overlap = 0,
@@ -1119,9 +1116,8 @@ static struct scsi_host_template idescsi_template = {
1119 .proc_name = "ide-scsi", 1116 .proc_name = "ide-scsi",
1120}; 1117};
1121 1118
1122static int ide_scsi_probe(struct device *dev) 1119static int ide_scsi_probe(ide_drive_t *drive)
1123{ 1120{
1124 ide_drive_t *drive = to_ide_device(dev);
1125 idescsi_scsi_t *idescsi; 1121 idescsi_scsi_t *idescsi;
1126 struct Scsi_Host *host; 1122 struct Scsi_Host *host;
1127 struct gendisk *g; 1123 struct gendisk *g;
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index e5e1ca44e1ee..86c546164da9 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -3499,6 +3499,7 @@ ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp)
3499 int device_error; 3499 int device_error;
3500 uint32_t transfer_len; 3500 uint32_t transfer_len;
3501 IPS_DCDB_TABLE_TAPE *tapeDCDB; 3501 IPS_DCDB_TABLE_TAPE *tapeDCDB;
3502 IPS_SCSI_INQ_DATA inquiryData;
3502 3503
3503 METHOD_TRACE("ips_map_status", 1); 3504 METHOD_TRACE("ips_map_status", 1);
3504 3505
@@ -3557,13 +3558,13 @@ ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp)
3557 errcode = DID_OK; 3558 errcode = DID_OK;
3558 3559
3559 /* Restrict access to physical DASD */ 3560 /* Restrict access to physical DASD */
3560 if ((scb->scsi_cmd->cmnd[0] == INQUIRY) && 3561 if (scb->scsi_cmd->cmnd[0] == INQUIRY) {
3561 ((((char *) scb->scsi_cmd-> 3562 ips_scmd_buf_read(scb->scsi_cmd,
3562 buffer)[0] & 0x1f) == TYPE_DISK)) { 3563 &inquiryData, sizeof (inquiryData));
3563 /* underflow -- no error */ 3564 if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK) {
3564 /* restrict access to physical DASD */ 3565 errcode = DID_TIME_OUT;
3565 errcode = DID_TIME_OUT; 3566 break;
3566 break; 3567 }
3567 } 3568 }
3568 } else 3569 } else
3569 errcode = DID_ERROR; 3570 errcode = DID_ERROR;
@@ -4135,6 +4136,7 @@ ips_chkstatus(ips_ha_t * ha, IPS_STATUS * pstatus)
4135 uint8_t basic_status; 4136 uint8_t basic_status;
4136 uint8_t ext_status; 4137 uint8_t ext_status;
4137 int errcode; 4138 int errcode;
4139 IPS_SCSI_INQ_DATA inquiryData;
4138 4140
4139 METHOD_TRACE("ips_chkstatus", 1); 4141 METHOD_TRACE("ips_chkstatus", 1);
4140 4142
@@ -4255,11 +4257,11 @@ ips_chkstatus(ips_ha_t * ha, IPS_STATUS * pstatus)
4255 scb->scsi_cmd->result = errcode << 16; 4257 scb->scsi_cmd->result = errcode << 16;
4256 } else { /* bus == 0 */ 4258 } else { /* bus == 0 */
4257 /* restrict access to physical drives */ 4259 /* restrict access to physical drives */
4258 if ((scb->scsi_cmd->cmnd[0] == INQUIRY) && 4260 if (scb->scsi_cmd->cmnd[0] == INQUIRY) {
4259 ((((char *) scb->scsi_cmd->buffer)[0] & 0x1f) == 4261 ips_scmd_buf_read(scb->scsi_cmd,
4260 TYPE_DISK)) { 4262 &inquiryData, sizeof (inquiryData));
4261 4263 if ((inquiryData.DeviceType & 0x1f) == TYPE_DISK)
4262 scb->scsi_cmd->result = DID_TIME_OUT << 16; 4264 scb->scsi_cmd->result = DID_TIME_OUT << 16;
4263 } 4265 }
4264 } /* else */ 4266 } /* else */
4265 } else { /* recovered error / success */ 4267 } else { /* recovered error / success */
@@ -5012,7 +5014,7 @@ ips_init_copperhead(ips_ha_t * ha)
5012 break; 5014 break;
5013 5015
5014 /* Delay for 1 Second */ 5016 /* Delay for 1 Second */
5015 MDELAY(IPS_ONE_SEC); 5017 msleep(IPS_ONE_SEC);
5016 } 5018 }
5017 5019
5018 if (j >= 45) 5020 if (j >= 45)
@@ -5038,7 +5040,7 @@ ips_init_copperhead(ips_ha_t * ha)
5038 break; 5040 break;
5039 5041
5040 /* Delay for 1 Second */ 5042 /* Delay for 1 Second */
5041 MDELAY(IPS_ONE_SEC); 5043 msleep(IPS_ONE_SEC);
5042 } 5044 }
5043 5045
5044 if (j >= 240) 5046 if (j >= 240)
@@ -5056,7 +5058,7 @@ ips_init_copperhead(ips_ha_t * ha)
5056 break; 5058 break;
5057 5059
5058 /* Delay for 1 Second */ 5060 /* Delay for 1 Second */
5059 MDELAY(IPS_ONE_SEC); 5061 msleep(IPS_ONE_SEC);
5060 } 5062 }
5061 5063
5062 if (i >= 240) 5064 if (i >= 240)
@@ -5106,7 +5108,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
5106 break; 5108 break;
5107 5109
5108 /* Delay for 1 Second */ 5110 /* Delay for 1 Second */
5109 MDELAY(IPS_ONE_SEC); 5111 msleep(IPS_ONE_SEC);
5110 } 5112 }
5111 5113
5112 if (j >= 45) 5114 if (j >= 45)
@@ -5132,7 +5134,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
5132 break; 5134 break;
5133 5135
5134 /* Delay for 1 Second */ 5136 /* Delay for 1 Second */
5135 MDELAY(IPS_ONE_SEC); 5137 msleep(IPS_ONE_SEC);
5136 } 5138 }
5137 5139
5138 if (j >= 240) 5140 if (j >= 240)
@@ -5150,7 +5152,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
5150 break; 5152 break;
5151 5153
5152 /* Delay for 1 Second */ 5154 /* Delay for 1 Second */
5153 MDELAY(IPS_ONE_SEC); 5155 msleep(IPS_ONE_SEC);
5154 } 5156 }
5155 5157
5156 if (i >= 240) 5158 if (i >= 240)
@@ -5202,7 +5204,7 @@ ips_init_morpheus(ips_ha_t * ha)
5202 break; 5204 break;
5203 5205
5204 /* Delay for 1 Second */ 5206 /* Delay for 1 Second */
5205 MDELAY(IPS_ONE_SEC); 5207 msleep(IPS_ONE_SEC);
5206 } 5208 }
5207 5209
5208 if (i >= 45) { 5210 if (i >= 45) {
@@ -5228,7 +5230,7 @@ ips_init_morpheus(ips_ha_t * ha)
5228 if (Post != 0x4F00) 5230 if (Post != 0x4F00)
5229 break; 5231 break;
5230 /* Delay for 1 Second */ 5232 /* Delay for 1 Second */
5231 MDELAY(IPS_ONE_SEC); 5233 msleep(IPS_ONE_SEC);
5232 } 5234 }
5233 5235
5234 if (i >= 120) { 5236 if (i >= 120) {
@@ -5258,7 +5260,7 @@ ips_init_morpheus(ips_ha_t * ha)
5258 break; 5260 break;
5259 5261
5260 /* Delay for 1 Second */ 5262 /* Delay for 1 Second */
5261 MDELAY(IPS_ONE_SEC); 5263 msleep(IPS_ONE_SEC);
5262 } 5264 }
5263 5265
5264 if (i >= 240) { 5266 if (i >= 240) {
@@ -5318,12 +5320,12 @@ ips_reset_copperhead(ips_ha_t * ha)
5318 outb(IPS_BIT_RST, ha->io_addr + IPS_REG_SCPR); 5320 outb(IPS_BIT_RST, ha->io_addr + IPS_REG_SCPR);
5319 5321
5320 /* Delay for 1 Second */ 5322 /* Delay for 1 Second */
5321 MDELAY(IPS_ONE_SEC); 5323 msleep(IPS_ONE_SEC);
5322 5324
5323 outb(0, ha->io_addr + IPS_REG_SCPR); 5325 outb(0, ha->io_addr + IPS_REG_SCPR);
5324 5326
5325 /* Delay for 1 Second */ 5327 /* Delay for 1 Second */
5326 MDELAY(IPS_ONE_SEC); 5328 msleep(IPS_ONE_SEC);
5327 5329
5328 if ((*ha->func.init) (ha)) 5330 if ((*ha->func.init) (ha))
5329 break; 5331 break;
@@ -5363,12 +5365,12 @@ ips_reset_copperhead_memio(ips_ha_t * ha)
5363 writeb(IPS_BIT_RST, ha->mem_ptr + IPS_REG_SCPR); 5365 writeb(IPS_BIT_RST, ha->mem_ptr + IPS_REG_SCPR);
5364 5366
5365 /* Delay for 1 Second */ 5367 /* Delay for 1 Second */
5366 MDELAY(IPS_ONE_SEC); 5368 msleep(IPS_ONE_SEC);
5367 5369
5368 writeb(0, ha->mem_ptr + IPS_REG_SCPR); 5370 writeb(0, ha->mem_ptr + IPS_REG_SCPR);
5369 5371
5370 /* Delay for 1 Second */ 5372 /* Delay for 1 Second */
5371 MDELAY(IPS_ONE_SEC); 5373 msleep(IPS_ONE_SEC);
5372 5374
5373 if ((*ha->func.init) (ha)) 5375 if ((*ha->func.init) (ha))
5374 break; 5376 break;
@@ -5409,7 +5411,7 @@ ips_reset_morpheus(ips_ha_t * ha)
5409 writel(0x80000000, ha->mem_ptr + IPS_REG_I960_IDR); 5411 writel(0x80000000, ha->mem_ptr + IPS_REG_I960_IDR);
5410 5412
5411 /* Delay for 5 Seconds */ 5413 /* Delay for 5 Seconds */
5412 MDELAY(5 * IPS_ONE_SEC); 5414 msleep(5 * IPS_ONE_SEC);
5413 5415
5414 /* Do a PCI config read to wait for adapter */ 5416 /* Do a PCI config read to wait for adapter */
5415 pci_read_config_byte(ha->pcidev, 4, &junk); 5417 pci_read_config_byte(ha->pcidev, 4, &junk);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index cfbceb504718..07b1e7cc61df 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -1700,6 +1700,31 @@ static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last)
1700 return sizeof(def_rw_recovery_mpage); 1700 return sizeof(def_rw_recovery_mpage);
1701} 1701}
1702 1702
1703/*
1704 * We can turn this into a real blacklist if it's needed, for now just
1705 * blacklist any Maxtor BANC1G10 revision firmware
1706 */
1707static int ata_dev_supports_fua(u16 *id)
1708{
1709 unsigned char model[41], fw[9];
1710
1711 if (!ata_id_has_fua(id))
1712 return 0;
1713
1714 model[40] = '\0';
1715 fw[8] = '\0';
1716
1717 ata_dev_id_string(id, model, ATA_ID_PROD_OFS, sizeof(model) - 1);
1718 ata_dev_id_string(id, fw, ATA_ID_FW_REV_OFS, sizeof(fw) - 1);
1719
1720 if (strncmp(model, "Maxtor", 6))
1721 return 1;
1722 if (strncmp(fw, "BANC1G10", 8))
1723 return 1;
1724
1725 return 0; /* blacklisted */
1726}
1727
1703/** 1728/**
1704 * ata_scsiop_mode_sense - Simulate MODE SENSE 6, 10 commands 1729 * ata_scsiop_mode_sense - Simulate MODE SENSE 6, 10 commands
1705 * @args: device IDENTIFY data / SCSI command of interest. 1730 * @args: device IDENTIFY data / SCSI command of interest.
@@ -1797,7 +1822,7 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1797 return 0; 1822 return 0;
1798 1823
1799 dpofua = 0; 1824 dpofua = 0;
1800 if (ata_id_has_fua(args->id) && dev->flags & ATA_DFLAG_LBA48 && 1825 if (ata_dev_supports_fua(args->id) && dev->flags & ATA_DFLAG_LBA48 &&
1801 (!(dev->flags & ATA_DFLAG_PIO) || dev->multi_count)) 1826 (!(dev->flags & ATA_DFLAG_PIO) || dev->multi_count))
1802 dpofua = 1 << 4; 1827 dpofua = 1 << 4;
1803 1828
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index 511ed52a5807..a487f414960e 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -10,7 +10,7 @@
10 * 2 of the License, or (at your option) any later version. 10 * 2 of the License, or (at your option) any later version.
11 * 11 *
12 * FILE : megaraid_sas.c 12 * FILE : megaraid_sas.c
13 * Version : v00.00.02.00-rc4 13 * Version : v00.00.02.02
14 * 14 *
15 * Authors: 15 * Authors:
16 * Sreenivas Bagalkote <Sreenivas.Bagalkote@lsil.com> 16 * Sreenivas Bagalkote <Sreenivas.Bagalkote@lsil.com>
@@ -55,13 +55,13 @@ static struct pci_device_id megasas_pci_table[] = {
55 55
56 { 56 {
57 PCI_VENDOR_ID_LSI_LOGIC, 57 PCI_VENDOR_ID_LSI_LOGIC,
58 PCI_DEVICE_ID_LSI_SAS1064R, 58 PCI_DEVICE_ID_LSI_SAS1064R, // xscale IOP
59 PCI_ANY_ID, 59 PCI_ANY_ID,
60 PCI_ANY_ID, 60 PCI_ANY_ID,
61 }, 61 },
62 { 62 {
63 PCI_VENDOR_ID_DELL, 63 PCI_VENDOR_ID_DELL,
64 PCI_DEVICE_ID_DELL_PERC5, 64 PCI_DEVICE_ID_DELL_PERC5, // xscale IOP
65 PCI_ANY_ID, 65 PCI_ANY_ID,
66 PCI_ANY_ID, 66 PCI_ANY_ID,
67 }, 67 },
@@ -119,12 +119,18 @@ megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
119 spin_unlock_irqrestore(&instance->cmd_pool_lock, flags); 119 spin_unlock_irqrestore(&instance->cmd_pool_lock, flags);
120} 120}
121 121
122
123/**
124* The following functions are defined for xscale
125* (deviceid : 1064R, PERC5) controllers
126*/
127
122/** 128/**
123 * megasas_enable_intr - Enables interrupts 129 * megasas_enable_intr_xscale - Enables interrupts
124 * @regs: MFI register set 130 * @regs: MFI register set
125 */ 131 */
126static inline void 132static inline void
127megasas_enable_intr(struct megasas_register_set __iomem * regs) 133megasas_enable_intr_xscale(struct megasas_register_set __iomem * regs)
128{ 134{
129 writel(1, &(regs)->outbound_intr_mask); 135 writel(1, &(regs)->outbound_intr_mask);
130 136
@@ -133,13 +139,73 @@ megasas_enable_intr(struct megasas_register_set __iomem * regs)
133} 139}
134 140
135/** 141/**
142 * megasas_read_fw_status_reg_xscale - returns the current FW status value
143 * @regs: MFI register set
144 */
145static u32
146megasas_read_fw_status_reg_xscale(struct megasas_register_set __iomem * regs)
147{
148 return readl(&(regs)->outbound_msg_0);
149}
150/**
151 * megasas_clear_interrupt_xscale - Check & clear interrupt
152 * @regs: MFI register set
153 */
154static int
155megasas_clear_intr_xscale(struct megasas_register_set __iomem * regs)
156{
157 u32 status;
158 /*
159 * Check if it is our interrupt
160 */
161 status = readl(&regs->outbound_intr_status);
162
163 if (!(status & MFI_OB_INTR_STATUS_MASK)) {
164 return 1;
165 }
166
167 /*
168 * Clear the interrupt by writing back the same value
169 */
170 writel(status, &regs->outbound_intr_status);
171
172 return 0;
173}
174
175/**
176 * megasas_fire_cmd_xscale - Sends command to the FW
177 * @frame_phys_addr : Physical address of cmd
178 * @frame_count : Number of frames for the command
179 * @regs : MFI register set
180 */
181static inline void
182megasas_fire_cmd_xscale(dma_addr_t frame_phys_addr,u32 frame_count, struct megasas_register_set __iomem *regs)
183{
184 writel((frame_phys_addr >> 3)|(frame_count),
185 &(regs)->inbound_queue_port);
186}
187
188static struct megasas_instance_template megasas_instance_template_xscale = {
189
190 .fire_cmd = megasas_fire_cmd_xscale,
191 .enable_intr = megasas_enable_intr_xscale,
192 .clear_intr = megasas_clear_intr_xscale,
193 .read_fw_status_reg = megasas_read_fw_status_reg_xscale,
194};
195
196/**
197* This is the end of set of functions & definitions specific
198* to xscale (deviceid : 1064R, PERC5) controllers
199*/
200
201/**
136 * megasas_disable_intr - Disables interrupts 202 * megasas_disable_intr - Disables interrupts
137 * @regs: MFI register set 203 * @regs: MFI register set
138 */ 204 */
139static inline void 205static inline void
140megasas_disable_intr(struct megasas_register_set __iomem * regs) 206megasas_disable_intr(struct megasas_register_set __iomem * regs)
141{ 207{
142 u32 mask = readl(&regs->outbound_intr_mask) & (~0x00000001); 208 u32 mask = 0x1f;
143 writel(mask, &regs->outbound_intr_mask); 209 writel(mask, &regs->outbound_intr_mask);
144 210
145 /* Dummy readl to force pci flush */ 211 /* Dummy readl to force pci flush */
@@ -167,8 +233,7 @@ megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd)
167 /* 233 /*
168 * Issue the frame using inbound queue port 234 * Issue the frame using inbound queue port
169 */ 235 */
170 writel(cmd->frame_phys_addr >> 3, 236 instance->instancet->fire_cmd(cmd->frame_phys_addr ,0,instance->reg_set);
171 &instance->reg_set->inbound_queue_port);
172 237
173 /* 238 /*
174 * Wait for cmd_status to change 239 * Wait for cmd_status to change
@@ -198,8 +263,7 @@ megasas_issue_blocked_cmd(struct megasas_instance *instance,
198{ 263{
199 cmd->cmd_status = ENODATA; 264 cmd->cmd_status = ENODATA;
200 265
201 writel(cmd->frame_phys_addr >> 3, 266 instance->instancet->fire_cmd(cmd->frame_phys_addr ,0,instance->reg_set);
202 &instance->reg_set->inbound_queue_port);
203 267
204 wait_event(instance->int_cmd_wait_q, (cmd->cmd_status != ENODATA)); 268 wait_event(instance->int_cmd_wait_q, (cmd->cmd_status != ENODATA));
205 269
@@ -242,8 +306,7 @@ megasas_issue_blocked_abort_cmd(struct megasas_instance *instance,
242 cmd->sync_cmd = 1; 306 cmd->sync_cmd = 1;
243 cmd->cmd_status = 0xFF; 307 cmd->cmd_status = 0xFF;
244 308
245 writel(cmd->frame_phys_addr >> 3, 309 instance->instancet->fire_cmd(cmd->frame_phys_addr ,0,instance->reg_set);
246 &instance->reg_set->inbound_queue_port);
247 310
248 /* 311 /*
249 * Wait for this cmd to complete 312 * Wait for this cmd to complete
@@ -558,112 +621,29 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp,
558} 621}
559 622
560/** 623/**
561 * megasas_build_cmd - Prepares a command packet 624 * megasas_is_ldio - Checks if the cmd is for logical drive
562 * @instance: Adapter soft state 625 * @scmd: SCSI command
563 * @scp: SCSI command 626 *
564 * @frame_count: [OUT] Number of frames used to prepare this command 627 * Called by megasas_queue_command to find out if the command to be queued
628 * is a logical drive command
565 */ 629 */
566static struct megasas_cmd *megasas_build_cmd(struct megasas_instance 630static inline int megasas_is_ldio(struct scsi_cmnd *cmd)
567 *instance,
568 struct scsi_cmnd *scp,
569 int *frame_count)
570{ 631{
571 u32 logical_cmd; 632 if (!MEGASAS_IS_LOGICAL(cmd))
572 struct megasas_cmd *cmd; 633 return 0;
573 634 switch (cmd->cmnd[0]) {
574 /* 635 case READ_10:
575 * Find out if this is logical or physical drive command. 636 case WRITE_10:
576 */ 637 case READ_12:
577 logical_cmd = MEGASAS_IS_LOGICAL(scp); 638 case WRITE_12:
578 639 case READ_6:
579 /* 640 case WRITE_6:
580 * Logical drive command 641 case READ_16:
581 */ 642 case WRITE_16:
582 if (logical_cmd) { 643 return 1;
583 644 default:
584 if (scp->device->id >= MEGASAS_MAX_LD) { 645 return 0;
585 scp->result = DID_BAD_TARGET << 16;
586 return NULL;
587 }
588
589 switch (scp->cmnd[0]) {
590
591 case READ_10:
592 case WRITE_10:
593 case READ_12:
594 case WRITE_12:
595 case READ_6:
596 case WRITE_6:
597 case READ_16:
598 case WRITE_16:
599 /*
600 * Fail for LUN > 0
601 */
602 if (scp->device->lun) {
603 scp->result = DID_BAD_TARGET << 16;
604 return NULL;
605 }
606
607 cmd = megasas_get_cmd(instance);
608
609 if (!cmd) {
610 scp->result = DID_IMM_RETRY << 16;
611 return NULL;
612 }
613
614 *frame_count = megasas_build_ldio(instance, scp, cmd);
615
616 if (!(*frame_count)) {
617 megasas_return_cmd(instance, cmd);
618 return NULL;
619 }
620
621 return cmd;
622
623 default:
624 /*
625 * Fail for LUN > 0
626 */
627 if (scp->device->lun) {
628 scp->result = DID_BAD_TARGET << 16;
629 return NULL;
630 }
631
632 cmd = megasas_get_cmd(instance);
633
634 if (!cmd) {
635 scp->result = DID_IMM_RETRY << 16;
636 return NULL;
637 }
638
639 *frame_count = megasas_build_dcdb(instance, scp, cmd);
640
641 if (!(*frame_count)) {
642 megasas_return_cmd(instance, cmd);
643 return NULL;
644 }
645
646 return cmd;
647 }
648 } else {
649 cmd = megasas_get_cmd(instance);
650
651 if (!cmd) {
652 scp->result = DID_IMM_RETRY << 16;
653 return NULL;
654 }
655
656 *frame_count = megasas_build_dcdb(instance, scp, cmd);
657
658 if (!(*frame_count)) {
659 megasas_return_cmd(instance, cmd);
660 return NULL;
661 }
662
663 return cmd;
664 } 646 }
665
666 return NULL;
667} 647}
668 648
669/** 649/**
@@ -684,13 +664,27 @@ megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
684 scmd->scsi_done = done; 664 scmd->scsi_done = done;
685 scmd->result = 0; 665 scmd->result = 0;
686 666
687 cmd = megasas_build_cmd(instance, scmd, &frame_count); 667 if (MEGASAS_IS_LOGICAL(scmd) &&
688 668 (scmd->device->id >= MEGASAS_MAX_LD || scmd->device->lun)) {
689 if (!cmd) { 669 scmd->result = DID_BAD_TARGET << 16;
690 done(scmd); 670 goto out_done;
691 return 0;
692 } 671 }
693 672
673 cmd = megasas_get_cmd(instance);
674 if (!cmd)
675 return SCSI_MLQUEUE_HOST_BUSY;
676
677 /*
678 * Logical drive command
679 */
680 if (megasas_is_ldio(scmd))
681 frame_count = megasas_build_ldio(instance, scmd, cmd);
682 else
683 frame_count = megasas_build_dcdb(instance, scmd, cmd);
684
685 if (!frame_count)
686 goto out_return_cmd;
687
694 cmd->scmd = scmd; 688 cmd->scmd = scmd;
695 scmd->SCp.ptr = (char *)cmd; 689 scmd->SCp.ptr = (char *)cmd;
696 scmd->SCp.sent_command = jiffies; 690 scmd->SCp.sent_command = jiffies;
@@ -702,10 +696,15 @@ megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
702 instance->fw_outstanding++; 696 instance->fw_outstanding++;
703 spin_unlock_irqrestore(&instance->instance_lock, flags); 697 spin_unlock_irqrestore(&instance->instance_lock, flags);
704 698
705 writel(((cmd->frame_phys_addr >> 3) | (cmd->frame_count - 1)), 699 instance->instancet->fire_cmd(cmd->frame_phys_addr ,cmd->frame_count-1,instance->reg_set);
706 &instance->reg_set->inbound_queue_port);
707 700
708 return 0; 701 return 0;
702
703 out_return_cmd:
704 megasas_return_cmd(instance, cmd);
705 out_done:
706 done(scmd);
707 return 0;
709} 708}
710 709
711/** 710/**
@@ -1108,7 +1107,6 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
1108static int 1107static int
1109megasas_deplete_reply_queue(struct megasas_instance *instance, u8 alt_status) 1108megasas_deplete_reply_queue(struct megasas_instance *instance, u8 alt_status)
1110{ 1109{
1111 u32 status;
1112 u32 producer; 1110 u32 producer;
1113 u32 consumer; 1111 u32 consumer;
1114 u32 context; 1112 u32 context;
@@ -1116,17 +1114,10 @@ megasas_deplete_reply_queue(struct megasas_instance *instance, u8 alt_status)
1116 1114
1117 /* 1115 /*
1118 * Check if it is our interrupt 1116 * Check if it is our interrupt
1117 * Clear the interrupt
1119 */ 1118 */
1120 status = readl(&instance->reg_set->outbound_intr_status); 1119 if(instance->instancet->clear_intr(instance->reg_set))
1121
1122 if (!(status & MFI_OB_INTR_STATUS_MASK)) {
1123 return IRQ_NONE; 1120 return IRQ_NONE;
1124 }
1125
1126 /*
1127 * Clear the interrupt by writing back the same value
1128 */
1129 writel(status, &instance->reg_set->outbound_intr_status);
1130 1121
1131 producer = *instance->producer; 1122 producer = *instance->producer;
1132 consumer = *instance->consumer; 1123 consumer = *instance->consumer;
@@ -1160,7 +1151,7 @@ static irqreturn_t megasas_isr(int irq, void *devp, struct pt_regs *regs)
1160 1151
1161/** 1152/**
1162 * megasas_transition_to_ready - Move the FW to READY state 1153 * megasas_transition_to_ready - Move the FW to READY state
1163 * @reg_set: MFI register set 1154 * @instance: Adapter soft state
1164 * 1155 *
1165 * During the initialization, FW passes can potentially be in any one of 1156 * During the initialization, FW passes can potentially be in any one of
1166 * several possible states. If the FW in operational, waiting-for-handshake 1157 * several possible states. If the FW in operational, waiting-for-handshake
@@ -1168,14 +1159,14 @@ static irqreturn_t megasas_isr(int irq, void *devp, struct pt_regs *regs)
1168 * has to wait for the ready state. 1159 * has to wait for the ready state.
1169 */ 1160 */
1170static int 1161static int
1171megasas_transition_to_ready(struct megasas_register_set __iomem * reg_set) 1162megasas_transition_to_ready(struct megasas_instance* instance)
1172{ 1163{
1173 int i; 1164 int i;
1174 u8 max_wait; 1165 u8 max_wait;
1175 u32 fw_state; 1166 u32 fw_state;
1176 u32 cur_state; 1167 u32 cur_state;
1177 1168
1178 fw_state = readl(&reg_set->outbound_msg_0) & MFI_STATE_MASK; 1169 fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK;
1179 1170
1180 while (fw_state != MFI_STATE_READY) { 1171 while (fw_state != MFI_STATE_READY) {
1181 1172
@@ -1193,7 +1184,7 @@ megasas_transition_to_ready(struct megasas_register_set __iomem * reg_set)
1193 * Set the CLR bit in inbound doorbell 1184 * Set the CLR bit in inbound doorbell
1194 */ 1185 */
1195 writel(MFI_INIT_CLEAR_HANDSHAKE, 1186 writel(MFI_INIT_CLEAR_HANDSHAKE,
1196 &reg_set->inbound_doorbell); 1187 &instance->reg_set->inbound_doorbell);
1197 1188
1198 max_wait = 2; 1189 max_wait = 2;
1199 cur_state = MFI_STATE_WAIT_HANDSHAKE; 1190 cur_state = MFI_STATE_WAIT_HANDSHAKE;
@@ -1203,8 +1194,8 @@ megasas_transition_to_ready(struct megasas_register_set __iomem * reg_set)
1203 /* 1194 /*
1204 * Bring it to READY state; assuming max wait 2 secs 1195 * Bring it to READY state; assuming max wait 2 secs
1205 */ 1196 */
1206 megasas_disable_intr(reg_set); 1197 megasas_disable_intr(instance->reg_set);
1207 writel(MFI_INIT_READY, &reg_set->inbound_doorbell); 1198 writel(MFI_INIT_READY, &instance->reg_set->inbound_doorbell);
1208 1199
1209 max_wait = 10; 1200 max_wait = 10;
1210 cur_state = MFI_STATE_OPERATIONAL; 1201 cur_state = MFI_STATE_OPERATIONAL;
@@ -1253,8 +1244,8 @@ megasas_transition_to_ready(struct megasas_register_set __iomem * reg_set)
1253 * The cur_state should not last for more than max_wait secs 1244 * The cur_state should not last for more than max_wait secs
1254 */ 1245 */
1255 for (i = 0; i < (max_wait * 1000); i++) { 1246 for (i = 0; i < (max_wait * 1000); i++) {
1256 fw_state = MFI_STATE_MASK & 1247 fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) &
1257 readl(&reg_set->outbound_msg_0); 1248 MFI_STATE_MASK ;
1258 1249
1259 if (fw_state == cur_state) { 1250 if (fw_state == cur_state) {
1260 msleep(1); 1251 msleep(1);
@@ -1616,18 +1607,20 @@ static int megasas_init_mfi(struct megasas_instance *instance)
1616 1607
1617 reg_set = instance->reg_set; 1608 reg_set = instance->reg_set;
1618 1609
1610 instance->instancet = &megasas_instance_template_xscale;
1611
1619 /* 1612 /*
1620 * We expect the FW state to be READY 1613 * We expect the FW state to be READY
1621 */ 1614 */
1622 if (megasas_transition_to_ready(instance->reg_set)) 1615 if (megasas_transition_to_ready(instance))
1623 goto fail_ready_state; 1616 goto fail_ready_state;
1624 1617
1625 /* 1618 /*
1626 * Get various operational parameters from status register 1619 * Get various operational parameters from status register
1627 */ 1620 */
1628 instance->max_fw_cmds = readl(&reg_set->outbound_msg_0) & 0x00FFFF; 1621 instance->max_fw_cmds = instance->instancet->read_fw_status_reg(reg_set) & 0x00FFFF;
1629 instance->max_num_sge = (readl(&reg_set->outbound_msg_0) & 0xFF0000) >> 1622 instance->max_num_sge = (instance->instancet->read_fw_status_reg(reg_set) & 0xFF0000) >>
1630 0x10; 1623 0x10;
1631 /* 1624 /*
1632 * Create a pool of commands 1625 * Create a pool of commands
1633 */ 1626 */
@@ -1936,8 +1929,7 @@ megasas_register_aen(struct megasas_instance *instance, u32 seq_num,
1936 /* 1929 /*
1937 * Issue the aen registration frame 1930 * Issue the aen registration frame
1938 */ 1931 */
1939 writel(cmd->frame_phys_addr >> 3, 1932 instance->instancet->fire_cmd(cmd->frame_phys_addr ,0,instance->reg_set);
1940 &instance->reg_set->inbound_queue_port);
1941 1933
1942 return 0; 1934 return 0;
1943} 1935}
@@ -2126,7 +2118,7 @@ megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2126 goto fail_irq; 2118 goto fail_irq;
2127 } 2119 }
2128 2120
2129 megasas_enable_intr(instance->reg_set); 2121 instance->instancet->enable_intr(instance->reg_set);
2130 2122
2131 /* 2123 /*
2132 * Store instance in PCI softstate 2124 * Store instance in PCI softstate
@@ -2681,9 +2673,8 @@ megasas_mgmt_compat_ioctl(struct file *file, unsigned int cmd,
2681 unsigned long arg) 2673 unsigned long arg)
2682{ 2674{
2683 switch (cmd) { 2675 switch (cmd) {
2684 case MEGASAS_IOC_FIRMWARE:{ 2676 case MEGASAS_IOC_FIRMWARE32:
2685 return megasas_mgmt_compat_ioctl_fw(file, arg); 2677 return megasas_mgmt_compat_ioctl_fw(file, arg);
2686 }
2687 case MEGASAS_IOC_GET_AEN: 2678 case MEGASAS_IOC_GET_AEN:
2688 return megasas_mgmt_ioctl_aen(file, arg); 2679 return megasas_mgmt_ioctl_aen(file, arg);
2689 } 2680 }
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index eaec9d531424..d6d166c0663f 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -18,10 +18,9 @@
18/** 18/**
19 * MegaRAID SAS Driver meta data 19 * MegaRAID SAS Driver meta data
20 */ 20 */
21#define MEGASAS_VERSION "00.00.02.00-rc4" 21#define MEGASAS_VERSION "00.00.02.02"
22#define MEGASAS_RELDATE "Sep 16, 2005" 22#define MEGASAS_RELDATE "Jan 23, 2006"
23#define MEGASAS_EXT_VERSION "Fri Sep 16 12:37:08 EDT 2005" 23#define MEGASAS_EXT_VERSION "Mon Jan 23 14:09:01 PST 2006"
24
25/* 24/*
26 * ===================================== 25 * =====================================
27 * MegaRAID SAS MFI firmware definitions 26 * MegaRAID SAS MFI firmware definitions
@@ -1013,6 +1012,16 @@ struct megasas_evt_detail {
1013 1012
1014} __attribute__ ((packed)); 1013} __attribute__ ((packed));
1015 1014
1015 struct megasas_instance_template {
1016 void (*fire_cmd)(dma_addr_t ,u32 ,struct megasas_register_set __iomem *);
1017
1018 void (*enable_intr)(struct megasas_register_set __iomem *) ;
1019
1020 int (*clear_intr)(struct megasas_register_set __iomem *);
1021
1022 u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
1023 };
1024
1016struct megasas_instance { 1025struct megasas_instance {
1017 1026
1018 u32 *producer; 1027 u32 *producer;
@@ -1056,6 +1065,8 @@ struct megasas_instance {
1056 u32 fw_outstanding; 1065 u32 fw_outstanding;
1057 u32 hw_crit_error; 1066 u32 hw_crit_error;
1058 spinlock_t instance_lock; 1067 spinlock_t instance_lock;
1068
1069 struct megasas_instance_template *instancet;
1059}; 1070};
1060 1071
1061#define MEGASAS_IS_LOGICAL(scp) \ 1072#define MEGASAS_IS_LOGICAL(scp) \
@@ -1125,11 +1136,10 @@ struct compat_megasas_iocpacket {
1125 struct compat_iovec sgl[MAX_IOCTL_SGE]; 1136 struct compat_iovec sgl[MAX_IOCTL_SGE];
1126} __attribute__ ((packed)); 1137} __attribute__ ((packed));
1127 1138
1128#define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct compat_megasas_iocpacket)
1129#else
1130#define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
1131#endif 1139#endif
1132 1140
1141#define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
1142#define MEGASAS_IOC_FIRMWARE32 _IOWR('M', 1, struct compat_megasas_iocpacket)
1133#define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen) 1143#define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen)
1134 1144
1135struct megasas_mgmt_info { 1145struct megasas_mgmt_info {
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 0878f95b5449..e0230249fa0f 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -17,9 +17,11 @@
17* General Public License for more details. 17* General Public License for more details.
18* 18*
19******************************************************************************/ 19******************************************************************************/
20#define QLA1280_VERSION "3.25" 20#define QLA1280_VERSION "3.26"
21/***************************************************************************** 21/*****************************************************************************
22 Revision History: 22 Revision History:
23 Rev 3.26, January 16, 2006 Jes Sorensen
24 - Ditch all < 2.6 support
23 Rev 3.25.1, February 10, 2005 Christoph Hellwig 25 Rev 3.25.1, February 10, 2005 Christoph Hellwig
24 - use pci_map_single to map non-S/G requests 26 - use pci_map_single to map non-S/G requests
25 - remove qla1280_proc_info 27 - remove qla1280_proc_info
@@ -356,25 +358,18 @@
356#include <asm/types.h> 358#include <asm/types.h>
357#include <asm/system.h> 359#include <asm/system.h>
358 360
359#if LINUX_VERSION_CODE >= 0x020545
360#include <scsi/scsi.h> 361#include <scsi/scsi.h>
361#include <scsi/scsi_cmnd.h> 362#include <scsi/scsi_cmnd.h>
362#include <scsi/scsi_device.h> 363#include <scsi/scsi_device.h>
363#include <scsi/scsi_host.h> 364#include <scsi/scsi_host.h>
364#include <scsi/scsi_tcq.h> 365#include <scsi/scsi_tcq.h>
365#else
366#include <linux/blk.h>
367#include "scsi.h"
368#include <scsi/scsi_host.h>
369#include "sd.h"
370#endif
371 366
372#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) 367#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2)
373#include <asm/sn/io.h> 368#include <asm/sn/io.h>
374#endif 369#endif
375 370
376#if LINUX_VERSION_CODE < 0x020407 371#if LINUX_VERSION_CODE < 0x020600
377#error "Kernels older than 2.4.7 are no longer supported" 372#error "Kernels older than 2.6.0 are no longer supported"
378#endif 373#endif
379 374
380 375
@@ -441,52 +436,6 @@
441 436
442#define NVRAM_DELAY() udelay(500) /* 2 microseconds */ 437#define NVRAM_DELAY() udelay(500) /* 2 microseconds */
443 438
444#if LINUX_VERSION_CODE < 0x020500
445#define HOST_LOCK &io_request_lock
446#define irqreturn_t void
447#define IRQ_RETVAL(foo)
448#define MSG_ORDERED_TAG 1
449
450#define DMA_BIDIRECTIONAL SCSI_DATA_UNKNOWN
451#define DMA_TO_DEVICE SCSI_DATA_WRITE
452#define DMA_FROM_DEVICE SCSI_DATA_READ
453#define DMA_NONE SCSI_DATA_NONE
454
455#ifndef HAVE_SECTOR_T
456typedef unsigned int sector_t;
457#endif
458
459static inline void
460scsi_adjust_queue_depth(struct scsi_device *device, int tag, int depth)
461{
462 if (tag) {
463 device->tagged_queue = tag;
464 device->current_tag = 0;
465 }
466 device->queue_depth = depth;
467}
468static inline struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *t, size_t s)
469{
470 return scsi_register(t, s);
471}
472static inline void scsi_host_put(struct Scsi_Host *h)
473{
474 scsi_unregister(h);
475}
476#else
477#define HOST_LOCK ha->host->host_lock
478#endif
479#if LINUX_VERSION_CODE < 0x020600
480#define DEV_SIMPLE_TAGS(device) device->tagged_queue
481/*
482 * Hack around that qla1280_remove_one is called from
483 * qla1280_release in 2.4
484 */
485#undef __devexit
486#define __devexit
487#else
488#define DEV_SIMPLE_TAGS(device) device->simple_tags
489#endif
490#if defined(__ia64__) && !defined(ia64_platform_is) 439#if defined(__ia64__) && !defined(ia64_platform_is)
491#define ia64_platform_is(foo) (!strcmp(x, platform_name)) 440#define ia64_platform_is(foo) (!strcmp(x, platform_name))
492#endif 441#endif
@@ -506,9 +455,6 @@ static void qla1280_remove_one(struct pci_dev *);
506 * QLogic Driver Support Function Prototypes. 455 * QLogic Driver Support Function Prototypes.
507 */ 456 */
508static void qla1280_done(struct scsi_qla_host *); 457static void qla1280_done(struct scsi_qla_host *);
509#if LINUX_VERSION_CODE < 0x020545
510static void qla1280_get_target_options(struct scsi_cmnd *, struct scsi_qla_host *);
511#endif
512static int qla1280_get_token(char *); 458static int qla1280_get_token(char *);
513static int qla1280_setup(char *s) __init; 459static int qla1280_setup(char *s) __init;
514 460
@@ -610,11 +556,7 @@ __setup("qla1280=", qla1280_setup);
610#define CMD_SNSLEN(Cmnd) sizeof(Cmnd->sense_buffer) 556#define CMD_SNSLEN(Cmnd) sizeof(Cmnd->sense_buffer)
611#define CMD_RESULT(Cmnd) Cmnd->result 557#define CMD_RESULT(Cmnd) Cmnd->result
612#define CMD_HANDLE(Cmnd) Cmnd->host_scribble 558#define CMD_HANDLE(Cmnd) Cmnd->host_scribble
613#if LINUX_VERSION_CODE < 0x020545
614#define CMD_REQUEST(Cmnd) Cmnd->request.cmd
615#else
616#define CMD_REQUEST(Cmnd) Cmnd->request->cmd 559#define CMD_REQUEST(Cmnd) Cmnd->request->cmd
617#endif
618 560
619#define CMD_HOST(Cmnd) Cmnd->device->host 561#define CMD_HOST(Cmnd) Cmnd->device->host
620#define SCSI_BUS_32(Cmnd) Cmnd->device->channel 562#define SCSI_BUS_32(Cmnd) Cmnd->device->channel
@@ -1064,10 +1006,10 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action)
1064 add_timer(&timer); 1006 add_timer(&timer);
1065 1007
1066 /* wait for the action to complete (or the timer to expire) */ 1008 /* wait for the action to complete (or the timer to expire) */
1067 spin_unlock_irq(HOST_LOCK); 1009 spin_unlock_irq(ha->host->host_lock);
1068 wait_for_completion(&wait); 1010 wait_for_completion(&wait);
1069 del_timer_sync(&timer); 1011 del_timer_sync(&timer);
1070 spin_lock_irq(HOST_LOCK); 1012 spin_lock_irq(ha->host->host_lock);
1071 sp->wait = NULL; 1013 sp->wait = NULL;
1072 1014
1073 /* the only action we might get a fail for is abort */ 1015 /* the only action we might get a fail for is abort */
@@ -1173,96 +1115,6 @@ qla1280_biosparam(struct scsi_device *sdev, struct block_device *bdev,
1173 return 0; 1115 return 0;
1174} 1116}
1175 1117
1176#if LINUX_VERSION_CODE < 0x020600
1177static int
1178qla1280_detect(struct scsi_host_template *template)
1179{
1180 struct pci_device_id *id = &qla1280_pci_tbl[0];
1181 struct pci_dev *pdev = NULL;
1182 int num_hosts = 0;
1183
1184 if (sizeof(struct srb) > sizeof(Scsi_Pointer)) {
1185 printk(KERN_WARNING
1186 "qla1280: struct srb too big, aborting\n");
1187 return 0;
1188 }
1189
1190 if ((DMA_BIDIRECTIONAL != PCI_DMA_BIDIRECTIONAL) ||
1191 (DMA_TO_DEVICE != PCI_DMA_TODEVICE) ||
1192 (DMA_FROM_DEVICE != PCI_DMA_FROMDEVICE) ||
1193 (DMA_NONE != PCI_DMA_NONE)) {
1194 printk(KERN_WARNING
1195 "qla1280: dma direction bits don't match\n");
1196 return 0;
1197 }
1198
1199#ifdef MODULE
1200 /*
1201 * If we are called as a module, the qla1280 pointer may not be null
1202 * and it would point to our bootup string, just like on the lilo
1203 * command line. IF not NULL, then process this config string with
1204 * qla1280_setup
1205 *
1206 * Boot time Options
1207 * To add options at boot time add a line to your lilo.conf file like:
1208 * append="qla1280=verbose,max_tags:{{255,255,255,255},{255,255,255,255}}"
1209 * which will result in the first four devices on the first two
1210 * controllers being set to a tagged queue depth of 32.
1211 */
1212 if (qla1280)
1213 qla1280_setup(qla1280);
1214#endif
1215
1216 /* First Initialize QLA12160 on PCI Bus 1 Dev 2 */
1217 while ((pdev = pci_find_device(id->vendor, id->device, pdev))) {
1218 if (pdev->bus->number == 1 && PCI_SLOT(pdev->devfn) == 2) {
1219 if (!qla1280_probe_one(pdev, id))
1220 num_hosts++;
1221 }
1222 }
1223
1224 pdev = NULL;
1225 /* Try and find each different type of adapter we support */
1226 for (id = &qla1280_pci_tbl[0]; id->device; id++) {
1227 while ((pdev = pci_find_device(id->vendor, id->device, pdev))) {
1228 /*
1229 * skip QLA12160 already initialized on
1230 * PCI Bus 1 Dev 2 since we already initialized
1231 * and presented it
1232 */
1233 if (id->device == PCI_DEVICE_ID_QLOGIC_ISP12160 &&
1234 pdev->bus->number == 1 &&
1235 PCI_SLOT(pdev->devfn) == 2)
1236 continue;
1237
1238 if (!qla1280_probe_one(pdev, id))
1239 num_hosts++;
1240 }
1241 }
1242
1243 return num_hosts;
1244}
1245
1246/*
1247 * This looks a bit ugly as we could just pass down host to
1248 * qla1280_remove_one, but I want to keep qla1280_release purely a wrapper
1249 * around pci_driver::remove as used from 2.6 onwards.
1250 */
1251static int
1252qla1280_release(struct Scsi_Host *host)
1253{
1254 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
1255
1256 qla1280_remove_one(ha->pdev);
1257 return 0;
1258}
1259
1260static int
1261qla1280_biosparam_old(Disk * disk, kdev_t dev, int geom[])
1262{
1263 return qla1280_biosparam(disk->device, NULL, disk->capacity, geom);
1264}
1265#endif
1266 1118
1267/* disable risc and host interrupts */ 1119/* disable risc and host interrupts */
1268static inline void 1120static inline void
@@ -1295,7 +1147,7 @@ qla1280_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
1295 ENTER_INTR ("qla1280_intr_handler"); 1147 ENTER_INTR ("qla1280_intr_handler");
1296 ha = (struct scsi_qla_host *)dev_id; 1148 ha = (struct scsi_qla_host *)dev_id;
1297 1149
1298 spin_lock(HOST_LOCK); 1150 spin_lock(ha->host->host_lock);
1299 1151
1300 ha->isr_count++; 1152 ha->isr_count++;
1301 reg = ha->iobase; 1153 reg = ha->iobase;
@@ -1311,7 +1163,7 @@ qla1280_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
1311 if (!list_empty(&ha->done_q)) 1163 if (!list_empty(&ha->done_q))
1312 qla1280_done(ha); 1164 qla1280_done(ha);
1313 1165
1314 spin_unlock(HOST_LOCK); 1166 spin_unlock(ha->host->host_lock);
1315 1167
1316 qla1280_enable_intrs(ha); 1168 qla1280_enable_intrs(ha);
1317 1169
@@ -1411,11 +1263,9 @@ qla1280_slave_configure(struct scsi_device *device)
1411 scsi_adjust_queue_depth(device, 0, default_depth); 1263 scsi_adjust_queue_depth(device, 0, default_depth);
1412 } 1264 }
1413 1265
1414#if LINUX_VERSION_CODE > 0x020500
1415 nv->bus[bus].target[target].parameter.enable_sync = device->sdtr; 1266 nv->bus[bus].target[target].parameter.enable_sync = device->sdtr;
1416 nv->bus[bus].target[target].parameter.enable_wide = device->wdtr; 1267 nv->bus[bus].target[target].parameter.enable_wide = device->wdtr;
1417 nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = device->ppr; 1268 nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = device->ppr;
1418#endif
1419 1269
1420 if (driver_setup.no_sync || 1270 if (driver_setup.no_sync ||
1421 (driver_setup.sync_mask && 1271 (driver_setup.sync_mask &&
@@ -1432,38 +1282,14 @@ qla1280_slave_configure(struct scsi_device *device)
1432 nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0; 1282 nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0;
1433 } 1283 }
1434 1284
1435 spin_lock_irqsave(HOST_LOCK, flags); 1285 spin_lock_irqsave(ha->host->host_lock, flags);
1436 if (nv->bus[bus].target[target].parameter.enable_sync) 1286 if (nv->bus[bus].target[target].parameter.enable_sync)
1437 status = qla1280_set_target_parameters(ha, bus, target); 1287 status = qla1280_set_target_parameters(ha, bus, target);
1438 qla1280_get_target_parameters(ha, device); 1288 qla1280_get_target_parameters(ha, device);
1439 spin_unlock_irqrestore(HOST_LOCK, flags); 1289 spin_unlock_irqrestore(ha->host->host_lock, flags);
1440 return status; 1290 return status;
1441} 1291}
1442 1292
1443#if LINUX_VERSION_CODE < 0x020545
1444/**************************************************************************
1445 * qla1280_select_queue_depth
1446 *
1447 * Sets the queue depth for each SCSI device hanging off the input
1448 * host adapter. We use a queue depth of 2 for devices that do not
1449 * support tagged queueing.
1450 **************************************************************************/
1451static void
1452qla1280_select_queue_depth(struct Scsi_Host *host, struct scsi_device *sdev_q)
1453{
1454 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
1455 struct scsi_device *sdev;
1456
1457 ENTER("qla1280_select_queue_depth");
1458 for (sdev = sdev_q; sdev; sdev = sdev->next)
1459 if (sdev->host == host)
1460 qla1280_slave_configure(sdev);
1461
1462 if (sdev_q)
1463 qla1280_check_for_dead_scsi_bus(ha, sdev_q->channel);
1464 LEAVE("qla1280_select_queue_depth");
1465}
1466#endif
1467 1293
1468/* 1294/*
1469 * qla1280_done 1295 * qla1280_done
@@ -1523,10 +1349,6 @@ qla1280_done(struct scsi_qla_host *ha)
1523 CMD_HANDLE(sp->cmd) = (unsigned char *)INVALID_HANDLE; 1349 CMD_HANDLE(sp->cmd) = (unsigned char *)INVALID_HANDLE;
1524 ha->actthreads--; 1350 ha->actthreads--;
1525 1351
1526#if LINUX_VERSION_CODE < 0x020500
1527 if (cmd->cmnd[0] == INQUIRY)
1528 qla1280_get_target_options(cmd, ha);
1529#endif
1530 (*(cmd)->scsi_done)(cmd); 1352 (*(cmd)->scsi_done)(cmd);
1531 1353
1532 if(sp->wait != NULL) 1354 if(sp->wait != NULL)
@@ -1655,9 +1477,7 @@ qla1280_initialize_adapter(struct scsi_qla_host *ha)
1655 struct device_reg __iomem *reg; 1477 struct device_reg __iomem *reg;
1656 int status; 1478 int status;
1657 int bus; 1479 int bus;
1658#if LINUX_VERSION_CODE > 0x020500
1659 unsigned long flags; 1480 unsigned long flags;
1660#endif
1661 1481
1662 ENTER("qla1280_initialize_adapter"); 1482 ENTER("qla1280_initialize_adapter");
1663 1483
@@ -1695,15 +1515,12 @@ qla1280_initialize_adapter(struct scsi_qla_host *ha)
1695 "NVRAM\n"); 1515 "NVRAM\n");
1696 } 1516 }
1697 1517
1698#if LINUX_VERSION_CODE >= 0x020500
1699 /* 1518 /*
1700 * It's necessary to grab the spin here as qla1280_mailbox_command 1519 * It's necessary to grab the spin here as qla1280_mailbox_command
1701 * needs to be able to drop the lock unconditionally to wait 1520 * needs to be able to drop the lock unconditionally to wait
1702 * for completion. 1521 * for completion.
1703 * In 2.4 ->detect is called with the io_request_lock held.
1704 */ 1522 */
1705 spin_lock_irqsave(HOST_LOCK, flags); 1523 spin_lock_irqsave(ha->host->host_lock, flags);
1706#endif
1707 1524
1708 status = qla1280_load_firmware(ha); 1525 status = qla1280_load_firmware(ha);
1709 if (status) { 1526 if (status) {
@@ -1735,9 +1552,8 @@ qla1280_initialize_adapter(struct scsi_qla_host *ha)
1735 1552
1736 ha->flags.online = 1; 1553 ha->flags.online = 1;
1737 out: 1554 out:
1738#if LINUX_VERSION_CODE >= 0x020500 1555 spin_unlock_irqrestore(ha->host->host_lock, flags);
1739 spin_unlock_irqrestore(HOST_LOCK, flags); 1556
1740#endif
1741 if (status) 1557 if (status)
1742 dprintk(2, "qla1280_initialize_adapter: **** FAILED ****\n"); 1558 dprintk(2, "qla1280_initialize_adapter: **** FAILED ****\n");
1743 1559
@@ -2650,14 +2466,14 @@ qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb)
2650 timer.function = qla1280_mailbox_timeout; 2466 timer.function = qla1280_mailbox_timeout;
2651 add_timer(&timer); 2467 add_timer(&timer);
2652 2468
2653 spin_unlock_irq(HOST_LOCK); 2469 spin_unlock_irq(ha->host->host_lock);
2654 WRT_REG_WORD(&reg->host_cmd, HC_SET_HOST_INT); 2470 WRT_REG_WORD(&reg->host_cmd, HC_SET_HOST_INT);
2655 data = qla1280_debounce_register(&reg->istatus); 2471 data = qla1280_debounce_register(&reg->istatus);
2656 2472
2657 wait_for_completion(&wait); 2473 wait_for_completion(&wait);
2658 del_timer_sync(&timer); 2474 del_timer_sync(&timer);
2659 2475
2660 spin_lock_irq(HOST_LOCK); 2476 spin_lock_irq(ha->host->host_lock);
2661 2477
2662 ha->mailbox_wait = NULL; 2478 ha->mailbox_wait = NULL;
2663 2479
@@ -2770,9 +2586,9 @@ qla1280_bus_reset(struct scsi_qla_host *ha, int bus)
2770 ha->bus_settings[bus].scsi_bus_dead = 1; 2586 ha->bus_settings[bus].scsi_bus_dead = 1;
2771 ha->bus_settings[bus].failed_reset_count++; 2587 ha->bus_settings[bus].failed_reset_count++;
2772 } else { 2588 } else {
2773 spin_unlock_irq(HOST_LOCK); 2589 spin_unlock_irq(ha->host->host_lock);
2774 ssleep(reset_delay); 2590 ssleep(reset_delay);
2775 spin_lock_irq(HOST_LOCK); 2591 spin_lock_irq(ha->host->host_lock);
2776 2592
2777 ha->bus_settings[bus].scsi_bus_dead = 0; 2593 ha->bus_settings[bus].scsi_bus_dead = 0;
2778 ha->bus_settings[bus].failed_reset_count = 0; 2594 ha->bus_settings[bus].failed_reset_count = 0;
@@ -3078,7 +2894,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
3078 (SCSI_TCN_32(cmd) | BIT_7) : SCSI_TCN_32(cmd); 2894 (SCSI_TCN_32(cmd) | BIT_7) : SCSI_TCN_32(cmd);
3079 2895
3080 /* Enable simple tag queuing if device supports it. */ 2896 /* Enable simple tag queuing if device supports it. */
3081 if (DEV_SIMPLE_TAGS(cmd->device)) 2897 if (cmd->device->simple_tags)
3082 pkt->control_flags |= cpu_to_le16(BIT_3); 2898 pkt->control_flags |= cpu_to_le16(BIT_3);
3083 2899
3084 /* Load SCSI command packet. */ 2900 /* Load SCSI command packet. */
@@ -3377,7 +3193,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
3377 (SCSI_TCN_32(cmd) | BIT_7) : SCSI_TCN_32(cmd); 3193 (SCSI_TCN_32(cmd) | BIT_7) : SCSI_TCN_32(cmd);
3378 3194
3379 /* Enable simple tag queuing if device supports it. */ 3195 /* Enable simple tag queuing if device supports it. */
3380 if (DEV_SIMPLE_TAGS(cmd->device)) 3196 if (cmd->device->simple_tags)
3381 pkt->control_flags |= cpu_to_le16(BIT_3); 3197 pkt->control_flags |= cpu_to_le16(BIT_3);
3382 3198
3383 /* Load SCSI command packet. */ 3199 /* Load SCSI command packet. */
@@ -3889,50 +3705,6 @@ qla1280_rst_aen(struct scsi_qla_host *ha)
3889} 3705}
3890 3706
3891 3707
3892#if LINUX_VERSION_CODE < 0x020500
3893/*
3894 *
3895 */
3896static void
3897qla1280_get_target_options(struct scsi_cmnd *cmd, struct scsi_qla_host *ha)
3898{
3899 unsigned char *result;
3900 struct nvram *n;
3901 int bus, target, lun;
3902
3903 bus = SCSI_BUS_32(cmd);
3904 target = SCSI_TCN_32(cmd);
3905 lun = SCSI_LUN_32(cmd);
3906
3907 /*
3908 * Make sure to not touch anything if someone is using the
3909 * sg interface.
3910 */
3911 if (cmd->use_sg || (CMD_RESULT(cmd) >> 16) != DID_OK || lun)
3912 return;
3913
3914 result = cmd->request_buffer;
3915 n = &ha->nvram;
3916
3917 n->bus[bus].target[target].parameter.enable_wide = 0;
3918 n->bus[bus].target[target].parameter.enable_sync = 0;
3919 n->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0;
3920
3921 if (result[7] & 0x60)
3922 n->bus[bus].target[target].parameter.enable_wide = 1;
3923 if (result[7] & 0x10)
3924 n->bus[bus].target[target].parameter.enable_sync = 1;
3925 if ((result[2] >= 3) && (result[4] + 5 > 56) &&
3926 (result[56] & 0x4))
3927 n->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 1;
3928
3929 dprintk(2, "get_target_options(): wide %i, sync %i, ppr %i\n",
3930 n->bus[bus].target[target].parameter.enable_wide,
3931 n->bus[bus].target[target].parameter.enable_sync,
3932 n->bus[bus].target[target].ppr_1x160.flags.enable_ppr);
3933}
3934#endif
3935
3936/* 3708/*
3937 * qla1280_status_entry 3709 * qla1280_status_entry
3938 * Processes received ISP status entry. 3710 * Processes received ISP status entry.
@@ -4271,7 +4043,7 @@ qla1280_get_target_parameters(struct scsi_qla_host *ha,
4271 } else 4043 } else
4272 printk(" Async"); 4044 printk(" Async");
4273 4045
4274 if (DEV_SIMPLE_TAGS(device)) 4046 if (device->simple_tags)
4275 printk(", Tagged queuing: depth %d", device->queue_depth); 4047 printk(", Tagged queuing: depth %d", device->queue_depth);
4276 printk("\n"); 4048 printk("\n");
4277} 4049}
@@ -4485,7 +4257,7 @@ qla1280_get_token(char *str)
4485 return ret; 4257 return ret;
4486} 4258}
4487 4259
4488#if LINUX_VERSION_CODE >= 0x020600 4260
4489static struct scsi_host_template qla1280_driver_template = { 4261static struct scsi_host_template qla1280_driver_template = {
4490 .module = THIS_MODULE, 4262 .module = THIS_MODULE,
4491 .proc_name = "qla1280", 4263 .proc_name = "qla1280",
@@ -4504,27 +4276,7 @@ static struct scsi_host_template qla1280_driver_template = {
4504 .cmd_per_lun = 1, 4276 .cmd_per_lun = 1,
4505 .use_clustering = ENABLE_CLUSTERING, 4277 .use_clustering = ENABLE_CLUSTERING,
4506}; 4278};
4507#else 4279
4508static struct scsi_host_template qla1280_driver_template = {
4509 .proc_name = "qla1280",
4510 .name = "Qlogic ISP 1280/12160",
4511 .detect = qla1280_detect,
4512 .release = qla1280_release,
4513 .info = qla1280_info,
4514 .queuecommand = qla1280_queuecommand,
4515 .eh_abort_handler = qla1280_eh_abort,
4516 .eh_device_reset_handler= qla1280_eh_device_reset,
4517 .eh_bus_reset_handler = qla1280_eh_bus_reset,
4518 .eh_host_reset_handler = qla1280_eh_adapter_reset,
4519 .bios_param = qla1280_biosparam_old,
4520 .can_queue = 0xfffff,
4521 .this_id = -1,
4522 .sg_tablesize = SG_ALL,
4523 .cmd_per_lun = 1,
4524 .use_clustering = ENABLE_CLUSTERING,
4525 .use_new_eh_code = 1,
4526};
4527#endif
4528 4280
4529static int __devinit 4281static int __devinit
4530qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) 4282qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
@@ -4615,10 +4367,6 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
4615 host->max_sectors = 1024; 4367 host->max_sectors = 1024;
4616 host->unique_id = host->host_no; 4368 host->unique_id = host->host_no;
4617 4369
4618#if LINUX_VERSION_CODE < 0x020545
4619 host->select_queue_depths = qla1280_select_queue_depth;
4620#endif
4621
4622 error = -ENODEV; 4370 error = -ENODEV;
4623 4371
4624#if MEMORY_MAPPED_IO 4372#if MEMORY_MAPPED_IO
@@ -4666,21 +4414,15 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
4666 4414
4667 pci_set_drvdata(pdev, host); 4415 pci_set_drvdata(pdev, host);
4668 4416
4669#if LINUX_VERSION_CODE >= 0x020600
4670 error = scsi_add_host(host, &pdev->dev); 4417 error = scsi_add_host(host, &pdev->dev);
4671 if (error) 4418 if (error)
4672 goto error_disable_adapter; 4419 goto error_disable_adapter;
4673 scsi_scan_host(host); 4420 scsi_scan_host(host);
4674#else
4675 scsi_set_pci_device(host, pdev);
4676#endif
4677 4421
4678 return 0; 4422 return 0;
4679 4423
4680#if LINUX_VERSION_CODE >= 0x020600
4681 error_disable_adapter: 4424 error_disable_adapter:
4682 qla1280_disable_intrs(ha); 4425 qla1280_disable_intrs(ha);
4683#endif
4684 error_free_irq: 4426 error_free_irq:
4685 free_irq(pdev->irq, ha); 4427 free_irq(pdev->irq, ha);
4686 error_release_region: 4428 error_release_region:
@@ -4712,9 +4454,7 @@ qla1280_remove_one(struct pci_dev *pdev)
4712 struct Scsi_Host *host = pci_get_drvdata(pdev); 4454 struct Scsi_Host *host = pci_get_drvdata(pdev);
4713 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; 4455 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
4714 4456
4715#if LINUX_VERSION_CODE >= 0x020600
4716 scsi_remove_host(host); 4457 scsi_remove_host(host);
4717#endif
4718 4458
4719 qla1280_disable_intrs(ha); 4459 qla1280_disable_intrs(ha);
4720 4460
@@ -4738,7 +4478,6 @@ qla1280_remove_one(struct pci_dev *pdev)
4738 scsi_host_put(host); 4478 scsi_host_put(host);
4739} 4479}
4740 4480
4741#if LINUX_VERSION_CODE >= 0x020600
4742static struct pci_driver qla1280_pci_driver = { 4481static struct pci_driver qla1280_pci_driver = {
4743 .name = "qla1280", 4482 .name = "qla1280",
4744 .id_table = qla1280_pci_tbl, 4483 .id_table = qla1280_pci_tbl,
@@ -4784,10 +4523,6 @@ qla1280_exit(void)
4784module_init(qla1280_init); 4523module_init(qla1280_init);
4785module_exit(qla1280_exit); 4524module_exit(qla1280_exit);
4786 4525
4787#else
4788# define driver_template qla1280_driver_template
4789# include "scsi_module.c"
4790#endif
4791 4526
4792MODULE_AUTHOR("Qlogic & Jes Sorensen"); 4527MODULE_AUTHOR("Qlogic & Jes Sorensen");
4793MODULE_DESCRIPTION("Qlogic ISP SCSI (qla1x80/qla1x160) driver"); 4528MODULE_DESCRIPTION("Qlogic ISP SCSI (qla1x80/qla1x160) driver");
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 79d8a914f9d0..bad066e5772a 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1680,7 +1680,8 @@ typedef struct fc_port {
1680 uint8_t mp_byte; /* multi-path byte (not used) */ 1680 uint8_t mp_byte; /* multi-path byte (not used) */
1681 uint8_t cur_path; /* current path id */ 1681 uint8_t cur_path; /* current path id */
1682 1682
1683 struct fc_rport *rport; 1683 spinlock_t rport_lock;
1684 struct fc_rport *rport, *drport;
1684 u32 supported_classes; 1685 u32 supported_classes;
1685 struct work_struct rport_add_work; 1686 struct work_struct rport_add_work;
1686 struct work_struct rport_del_work; 1687 struct work_struct rport_del_work;
@@ -2270,6 +2271,7 @@ typedef struct scsi_qla_host {
2270#define LOOP_RESET_NEEDED 24 2271#define LOOP_RESET_NEEDED 24
2271#define BEACON_BLINK_NEEDED 25 2272#define BEACON_BLINK_NEEDED 25
2272#define REGISTER_FDMI_NEEDED 26 2273#define REGISTER_FDMI_NEEDED 26
2274#define FCPORT_UPDATE_NEEDED 27
2273 2275
2274 uint32_t device_flags; 2276 uint32_t device_flags;
2275#define DFLG_LOCAL_DEVICES BIT_0 2277#define DFLG_LOCAL_DEVICES BIT_0
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 32be4c14cccb..35266bd5d538 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -47,9 +47,11 @@ extern int qla2x00_local_device_login(scsi_qla_host_t *, uint16_t);
47extern void qla2x00_restart_queues(scsi_qla_host_t *, uint8_t); 47extern void qla2x00_restart_queues(scsi_qla_host_t *, uint8_t);
48 48
49extern void qla2x00_rescan_fcports(scsi_qla_host_t *); 49extern void qla2x00_rescan_fcports(scsi_qla_host_t *);
50extern void qla2x00_update_fcports(scsi_qla_host_t *);
50 51
51extern int qla2x00_abort_isp(scsi_qla_host_t *); 52extern int qla2x00_abort_isp(scsi_qla_host_t *);
52 53
54extern void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *);
53extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *); 55extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *);
54 56
55/* 57/*
@@ -70,8 +72,8 @@ extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *);
70 72
71extern void qla2x00_cmd_timeout(srb_t *); 73extern void qla2x00_cmd_timeout(srb_t *);
72 74
73extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int); 75extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int, int);
74extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *); 76extern void qla2x00_mark_all_devices_lost(scsi_qla_host_t *, int);
75 77
76extern void qla2x00_blink_led(scsi_qla_host_t *); 78extern void qla2x00_blink_led(scsi_qla_host_t *);
77 79
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index a91fea69ad63..e67bb0997818 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -32,7 +32,6 @@ static int qla2x00_fw_ready(scsi_qla_host_t *);
32static int qla2x00_configure_hba(scsi_qla_host_t *); 32static int qla2x00_configure_hba(scsi_qla_host_t *);
33static int qla2x00_configure_loop(scsi_qla_host_t *); 33static int qla2x00_configure_loop(scsi_qla_host_t *);
34static int qla2x00_configure_local_loop(scsi_qla_host_t *); 34static int qla2x00_configure_local_loop(scsi_qla_host_t *);
35static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *);
36static int qla2x00_configure_fabric(scsi_qla_host_t *); 35static int qla2x00_configure_fabric(scsi_qla_host_t *);
37static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *); 36static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *);
38static int qla2x00_device_resync(scsi_qla_host_t *); 37static int qla2x00_device_resync(scsi_qla_host_t *);
@@ -1688,10 +1687,16 @@ static void
1688qla2x00_rport_del(void *data) 1687qla2x00_rport_del(void *data)
1689{ 1688{
1690 fc_port_t *fcport = data; 1689 fc_port_t *fcport = data;
1690 struct fc_rport *rport;
1691 unsigned long flags;
1692
1693 spin_lock_irqsave(&fcport->rport_lock, flags);
1694 rport = fcport->drport;
1695 fcport->drport = NULL;
1696 spin_unlock_irqrestore(&fcport->rport_lock, flags);
1697 if (rport)
1698 fc_remote_port_delete(rport);
1691 1699
1692 if (fcport->rport)
1693 fc_remote_port_delete(fcport->rport);
1694 fcport->rport = NULL;
1695} 1700}
1696 1701
1697/** 1702/**
@@ -1719,6 +1724,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags)
1719 atomic_set(&fcport->state, FCS_UNCONFIGURED); 1724 atomic_set(&fcport->state, FCS_UNCONFIGURED);
1720 fcport->flags = FCF_RLC_SUPPORT; 1725 fcport->flags = FCF_RLC_SUPPORT;
1721 fcport->supported_classes = FC_COS_UNSPECIFIED; 1726 fcport->supported_classes = FC_COS_UNSPECIFIED;
1727 spin_lock_init(&fcport->rport_lock);
1722 INIT_WORK(&fcport->rport_add_work, qla2x00_rport_add, fcport); 1728 INIT_WORK(&fcport->rport_add_work, qla2x00_rport_add, fcport);
1723 INIT_WORK(&fcport->rport_del_work, qla2x00_rport_del, fcport); 1729 INIT_WORK(&fcport->rport_del_work, qla2x00_rport_del, fcport);
1724 1730
@@ -2008,7 +2014,7 @@ qla2x00_probe_for_all_luns(scsi_qla_host_t *ha)
2008{ 2014{
2009 fc_port_t *fcport; 2015 fc_port_t *fcport;
2010 2016
2011 qla2x00_mark_all_devices_lost(ha); 2017 qla2x00_mark_all_devices_lost(ha, 0);
2012 list_for_each_entry(fcport, &ha->fcports, list) { 2018 list_for_each_entry(fcport, &ha->fcports, list) {
2013 if (fcport->port_type != FCT_TARGET) 2019 if (fcport->port_type != FCT_TARGET)
2014 continue; 2020 continue;
@@ -2032,13 +2038,9 @@ qla2x00_probe_for_all_luns(scsi_qla_host_t *ha)
2032 * Context: 2038 * Context:
2033 * Kernel context. 2039 * Kernel context.
2034 */ 2040 */
2035static void 2041void
2036qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) 2042qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
2037{ 2043{
2038 uint16_t index;
2039 unsigned long flags;
2040 srb_t *sp;
2041
2042 fcport->ha = ha; 2044 fcport->ha = ha;
2043 fcport->login_retry = 0; 2045 fcport->login_retry = 0;
2044 fcport->port_login_retry_count = ha->port_down_retry_count * 2046 fcport->port_login_retry_count = ha->port_down_retry_count *
@@ -2047,28 +2049,6 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
2047 PORT_RETRY_TIME); 2049 PORT_RETRY_TIME);
2048 fcport->flags &= ~FCF_LOGIN_NEEDED; 2050 fcport->flags &= ~FCF_LOGIN_NEEDED;
2049 2051
2050 /*
2051 * Check for outstanding cmd on tape Bypass LUN discovery if active
2052 * command on tape.
2053 */
2054 if (fcport->flags & FCF_TAPE_PRESENT) {
2055 spin_lock_irqsave(&ha->hardware_lock, flags);
2056 for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) {
2057 fc_port_t *sfcp;
2058
2059 if ((sp = ha->outstanding_cmds[index]) != 0) {
2060 sfcp = sp->fcport;
2061 if (sfcp == fcport) {
2062 atomic_set(&fcport->state, FCS_ONLINE);
2063 spin_unlock_irqrestore(
2064 &ha->hardware_lock, flags);
2065 return;
2066 }
2067 }
2068 }
2069 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2070 }
2071
2072 if (fcport->port_type == FCT_INITIATOR || 2052 if (fcport->port_type == FCT_INITIATOR ||
2073 fcport->port_type == FCT_BROADCAST) 2053 fcport->port_type == FCT_BROADCAST)
2074 fcport->device_type = TYPE_PROCESSOR; 2054 fcport->device_type = TYPE_PROCESSOR;
@@ -2084,24 +2064,29 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport)
2084{ 2064{
2085 struct fc_rport_identifiers rport_ids; 2065 struct fc_rport_identifiers rport_ids;
2086 struct fc_rport *rport; 2066 struct fc_rport *rport;
2067 unsigned long flags;
2087 2068
2088 if (fcport->rport) { 2069 if (fcport->drport)
2089 fc_remote_port_delete(fcport->rport); 2070 qla2x00_rport_del(fcport);
2090 fcport->rport = NULL; 2071 if (fcport->rport)
2091 } 2072 return;
2092 2073
2093 rport_ids.node_name = wwn_to_u64(fcport->node_name); 2074 rport_ids.node_name = wwn_to_u64(fcport->node_name);
2094 rport_ids.port_name = wwn_to_u64(fcport->port_name); 2075 rport_ids.port_name = wwn_to_u64(fcport->port_name);
2095 rport_ids.port_id = fcport->d_id.b.domain << 16 | 2076 rport_ids.port_id = fcport->d_id.b.domain << 16 |
2096 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; 2077 fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
2097 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; 2078 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
2098 fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids); 2079 rport = fc_remote_port_add(ha->host, 0, &rport_ids);
2099 if (!rport) { 2080 if (!rport) {
2100 qla_printk(KERN_WARNING, ha, 2081 qla_printk(KERN_WARNING, ha,
2101 "Unable to allocate fc remote port!\n"); 2082 "Unable to allocate fc remote port!\n");
2102 return; 2083 return;
2103 } 2084 }
2085 spin_lock_irqsave(&fcport->rport_lock, flags);
2086 fcport->rport = rport;
2104 *((fc_port_t **)rport->dd_data) = fcport; 2087 *((fc_port_t **)rport->dd_data) = fcport;
2088 spin_unlock_irqrestore(&fcport->rport_lock, flags);
2089
2105 rport->supported_classes = fcport->supported_classes; 2090 rport->supported_classes = fcport->supported_classes;
2106 2091
2107 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; 2092 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
@@ -2217,12 +2202,11 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha)
2217 2202
2218 if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) { 2203 if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
2219 qla2x00_mark_device_lost(ha, fcport, 2204 qla2x00_mark_device_lost(ha, fcport,
2220 ql2xplogiabsentdevice); 2205 ql2xplogiabsentdevice, 0);
2221 if (fcport->loop_id != FC_NO_LOOP_ID && 2206 if (fcport->loop_id != FC_NO_LOOP_ID &&
2222 (fcport->flags & FCF_TAPE_PRESENT) == 0 && 2207 (fcport->flags & FCF_TAPE_PRESENT) == 0 &&
2223 fcport->port_type != FCT_INITIATOR && 2208 fcport->port_type != FCT_INITIATOR &&
2224 fcport->port_type != FCT_BROADCAST) { 2209 fcport->port_type != FCT_BROADCAST) {
2225
2226 ha->isp_ops.fabric_logout(ha, 2210 ha->isp_ops.fabric_logout(ha,
2227 fcport->loop_id, 2211 fcport->loop_id,
2228 fcport->d_id.b.domain, 2212 fcport->d_id.b.domain,
@@ -2694,7 +2678,8 @@ qla2x00_device_resync(scsi_qla_host_t *ha)
2694 if (atomic_read(&fcport->state) == FCS_ONLINE) { 2678 if (atomic_read(&fcport->state) == FCS_ONLINE) {
2695 if (format != 3 || 2679 if (format != 3 ||
2696 fcport->port_type != FCT_INITIATOR) { 2680 fcport->port_type != FCT_INITIATOR) {
2697 qla2x00_mark_device_lost(ha, fcport, 0); 2681 qla2x00_mark_device_lost(ha, fcport,
2682 0, 0);
2698 } 2683 }
2699 } 2684 }
2700 fcport->flags &= ~FCF_FARP_DONE; 2685 fcport->flags &= ~FCF_FARP_DONE;
@@ -2741,8 +2726,7 @@ qla2x00_fabric_dev_login(scsi_qla_host_t *ha, fc_port_t *fcport,
2741 ha->isp_ops.fabric_logout(ha, fcport->loop_id, 2726 ha->isp_ops.fabric_logout(ha, fcport->loop_id,
2742 fcport->d_id.b.domain, fcport->d_id.b.area, 2727 fcport->d_id.b.domain, fcport->d_id.b.area,
2743 fcport->d_id.b.al_pa); 2728 fcport->d_id.b.al_pa);
2744 qla2x00_mark_device_lost(ha, fcport, 1); 2729 qla2x00_mark_device_lost(ha, fcport, 1, 0);
2745
2746 } else { 2730 } else {
2747 qla2x00_update_fcport(ha, fcport); 2731 qla2x00_update_fcport(ha, fcport);
2748 } 2732 }
@@ -2855,7 +2839,7 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport,
2855 ha->isp_ops.fabric_logout(ha, fcport->loop_id, 2839 ha->isp_ops.fabric_logout(ha, fcport->loop_id,
2856 fcport->d_id.b.domain, fcport->d_id.b.area, 2840 fcport->d_id.b.domain, fcport->d_id.b.area,
2857 fcport->d_id.b.al_pa); 2841 fcport->d_id.b.al_pa);
2858 qla2x00_mark_device_lost(ha, fcport, 1); 2842 qla2x00_mark_device_lost(ha, fcport, 1, 0);
2859 2843
2860 rval = 1; 2844 rval = 1;
2861 break; 2845 break;
@@ -2990,6 +2974,17 @@ qla2x00_rescan_fcports(scsi_qla_host_t *ha)
2990 qla2x00_probe_for_all_luns(ha); 2974 qla2x00_probe_for_all_luns(ha);
2991} 2975}
2992 2976
2977void
2978qla2x00_update_fcports(scsi_qla_host_t *ha)
2979{
2980 fc_port_t *fcport;
2981
2982 /* Go with deferred removal of rport references. */
2983 list_for_each_entry(fcport, &ha->fcports, list)
2984 if (fcport->drport)
2985 qla2x00_rport_del(fcport);
2986}
2987
2993/* 2988/*
2994* qla2x00_abort_isp 2989* qla2x00_abort_isp
2995* Resets ISP and aborts all outstanding commands. 2990* Resets ISP and aborts all outstanding commands.
@@ -3019,7 +3014,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3019 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); 3014 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
3020 if (atomic_read(&ha->loop_state) != LOOP_DOWN) { 3015 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
3021 atomic_set(&ha->loop_state, LOOP_DOWN); 3016 atomic_set(&ha->loop_state, LOOP_DOWN);
3022 qla2x00_mark_all_devices_lost(ha); 3017 qla2x00_mark_all_devices_lost(ha, 0);
3023 } else { 3018 } else {
3024 if (!atomic_read(&ha->loop_down_timer)) 3019 if (!atomic_read(&ha->loop_down_timer))
3025 atomic_set(&ha->loop_down_timer, 3020 atomic_set(&ha->loop_down_timer,
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index f63af081d4ff..71a46fcee8cc 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -389,7 +389,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
389 if (atomic_read(&ha->loop_state) != LOOP_DOWN) { 389 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
390 atomic_set(&ha->loop_state, LOOP_DOWN); 390 atomic_set(&ha->loop_state, LOOP_DOWN);
391 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); 391 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
392 qla2x00_mark_all_devices_lost(ha); 392 qla2x00_mark_all_devices_lost(ha, 1);
393 } 393 }
394 394
395 set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); 395 set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags);
@@ -432,7 +432,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
432 atomic_set(&ha->loop_state, LOOP_DOWN); 432 atomic_set(&ha->loop_state, LOOP_DOWN);
433 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); 433 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
434 ha->device_flags |= DFLG_NO_CABLE; 434 ha->device_flags |= DFLG_NO_CABLE;
435 qla2x00_mark_all_devices_lost(ha); 435 qla2x00_mark_all_devices_lost(ha, 1);
436 } 436 }
437 437
438 ha->flags.management_server_logged_in = 0; 438 ha->flags.management_server_logged_in = 0;
@@ -453,7 +453,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
453 if (atomic_read(&ha->loop_state) != LOOP_DOWN) { 453 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
454 atomic_set(&ha->loop_state, LOOP_DOWN); 454 atomic_set(&ha->loop_state, LOOP_DOWN);
455 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); 455 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
456 qla2x00_mark_all_devices_lost(ha); 456 qla2x00_mark_all_devices_lost(ha, 1);
457 } 457 }
458 458
459 set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); 459 set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
@@ -482,7 +482,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
482 if (!atomic_read(&ha->loop_down_timer)) 482 if (!atomic_read(&ha->loop_down_timer))
483 atomic_set(&ha->loop_down_timer, 483 atomic_set(&ha->loop_down_timer,
484 LOOP_DOWN_TIME); 484 LOOP_DOWN_TIME);
485 qla2x00_mark_all_devices_lost(ha); 485 qla2x00_mark_all_devices_lost(ha, 1);
486 } 486 }
487 487
488 if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) { 488 if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) {
@@ -506,7 +506,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
506 if (!atomic_read(&ha->loop_down_timer)) 506 if (!atomic_read(&ha->loop_down_timer))
507 atomic_set(&ha->loop_down_timer, 507 atomic_set(&ha->loop_down_timer,
508 LOOP_DOWN_TIME); 508 LOOP_DOWN_TIME);
509 qla2x00_mark_all_devices_lost(ha); 509 qla2x00_mark_all_devices_lost(ha, 1);
510 } 510 }
511 511
512 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); 512 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
@@ -580,7 +580,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
580 */ 580 */
581 atomic_set(&ha->loop_state, LOOP_UP); 581 atomic_set(&ha->loop_state, LOOP_UP);
582 582
583 qla2x00_mark_all_devices_lost(ha); 583 qla2x00_mark_all_devices_lost(ha, 1);
584 584
585 ha->flags.rscn_queue_overflow = 1; 585 ha->flags.rscn_queue_overflow = 1;
586 586
@@ -1091,7 +1091,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1091 1091
1092 cp->result = DID_BUS_BUSY << 16; 1092 cp->result = DID_BUS_BUSY << 16;
1093 if (atomic_read(&fcport->state) == FCS_ONLINE) { 1093 if (atomic_read(&fcport->state) == FCS_ONLINE) {
1094 qla2x00_mark_device_lost(ha, fcport, 1); 1094 qla2x00_mark_device_lost(ha, fcport, 1, 1);
1095 } 1095 }
1096 break; 1096 break;
1097 1097
@@ -1135,7 +1135,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1135 1135
1136 /* Check to see if logout occurred. */ 1136 /* Check to see if logout occurred. */
1137 if ((le16_to_cpu(sts->status_flags) & SF_LOGOUT_SENT)) 1137 if ((le16_to_cpu(sts->status_flags) & SF_LOGOUT_SENT))
1138 qla2x00_mark_device_lost(ha, fcport, 1); 1138 qla2x00_mark_device_lost(ha, fcport, 1, 1);
1139 break; 1139 break;
1140 1140
1141 case CS_QUEUE_FULL: 1141 case CS_QUEUE_FULL:
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 4916847d84ec..5866a7c706a8 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -756,7 +756,7 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
756 if (ret == SUCCESS) { 756 if (ret == SUCCESS) {
757 if (fcport->flags & FC_FABRIC_DEVICE) { 757 if (fcport->flags & FC_FABRIC_DEVICE) {
758 ha->isp_ops.fabric_logout(ha, fcport->loop_id); 758 ha->isp_ops.fabric_logout(ha, fcport->loop_id);
759 qla2x00_mark_device_lost(ha, fcport); 759 qla2x00_mark_device_lost(ha, fcport, 0, 0);
760 } 760 }
761 } 761 }
762#endif 762#endif
@@ -1642,6 +1642,31 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1642 pci_disable_device(ha->pdev); 1642 pci_disable_device(ha->pdev);
1643} 1643}
1644 1644
1645static inline void
1646qla2x00_schedule_rport_del(struct scsi_qla_host *ha, fc_port_t *fcport,
1647 int defer)
1648{
1649 unsigned long flags;
1650 struct fc_rport *rport;
1651
1652 if (!fcport->rport)
1653 return;
1654
1655 rport = fcport->rport;
1656 if (defer) {
1657 spin_lock_irqsave(&fcport->rport_lock, flags);
1658 fcport->drport = rport;
1659 fcport->rport = NULL;
1660 spin_unlock_irqrestore(&fcport->rport_lock, flags);
1661 set_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags);
1662 } else {
1663 spin_lock_irqsave(&fcport->rport_lock, flags);
1664 fcport->rport = NULL;
1665 spin_unlock_irqrestore(&fcport->rport_lock, flags);
1666 fc_remote_port_delete(rport);
1667 }
1668}
1669
1645/* 1670/*
1646 * qla2x00_mark_device_lost Updates fcport state when device goes offline. 1671 * qla2x00_mark_device_lost Updates fcport state when device goes offline.
1647 * 1672 *
@@ -1652,10 +1677,10 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1652 * Context: 1677 * Context:
1653 */ 1678 */
1654void qla2x00_mark_device_lost(scsi_qla_host_t *ha, fc_port_t *fcport, 1679void qla2x00_mark_device_lost(scsi_qla_host_t *ha, fc_port_t *fcport,
1655 int do_login) 1680 int do_login, int defer)
1656{ 1681{
1657 if (atomic_read(&fcport->state) == FCS_ONLINE && fcport->rport) 1682 if (atomic_read(&fcport->state) == FCS_ONLINE)
1658 schedule_work(&fcport->rport_del_work); 1683 qla2x00_schedule_rport_del(ha, fcport, defer);
1659 1684
1660 /* 1685 /*
1661 * We may need to retry the login, so don't change the state of the 1686 * We may need to retry the login, so don't change the state of the
@@ -1702,7 +1727,7 @@ void qla2x00_mark_device_lost(scsi_qla_host_t *ha, fc_port_t *fcport,
1702 * Context: 1727 * Context:
1703 */ 1728 */
1704void 1729void
1705qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha) 1730qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha, int defer)
1706{ 1731{
1707 fc_port_t *fcport; 1732 fc_port_t *fcport;
1708 1733
@@ -1716,10 +1741,13 @@ qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha)
1716 */ 1741 */
1717 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) 1742 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD)
1718 continue; 1743 continue;
1719 if (atomic_read(&fcport->state) == FCS_ONLINE && fcport->rport) 1744 if (atomic_read(&fcport->state) == FCS_ONLINE)
1720 schedule_work(&fcport->rport_del_work); 1745 qla2x00_schedule_rport_del(ha, fcport, defer);
1721 atomic_set(&fcport->state, FCS_DEVICE_LOST); 1746 atomic_set(&fcport->state, FCS_DEVICE_LOST);
1722 } 1747 }
1748
1749 if (defer && ha->dpc_wait && !ha->dpc_active)
1750 up(ha->dpc_wait);
1723} 1751}
1724 1752
1725/* 1753/*
@@ -2161,6 +2189,9 @@ qla2x00_do_dpc(void *data)
2161 ha->host_no)); 2189 ha->host_no));
2162 } 2190 }
2163 2191
2192 if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags))
2193 qla2x00_update_fcports(ha);
2194
2164 if (test_and_clear_bit(LOOP_RESET_NEEDED, &ha->dpc_flags)) { 2195 if (test_and_clear_bit(LOOP_RESET_NEEDED, &ha->dpc_flags)) {
2165 DEBUG(printk("scsi(%ld): dpc: sched loop_reset()\n", 2196 DEBUG(printk("scsi(%ld): dpc: sched loop_reset()\n",
2166 ha->host_no)); 2197 ha->host_no));
@@ -2219,13 +2250,8 @@ qla2x00_do_dpc(void *data)
2219 DEBUG(printk("scsi(%ld): port login OK: logged in ID 0x%x\n", 2250 DEBUG(printk("scsi(%ld): port login OK: logged in ID 0x%x\n",
2220 ha->host_no, fcport->loop_id)); 2251 ha->host_no, fcport->loop_id));
2221 2252
2222 fcport->port_login_retry_count = 2253 qla2x00_update_fcport(ha,
2223 ha->port_down_retry_count * PORT_RETRY_TIME; 2254 fcport);
2224 atomic_set(&fcport->state, FCS_ONLINE);
2225 atomic_set(&fcport->port_down_timer,
2226 ha->port_down_retry_count * PORT_RETRY_TIME);
2227
2228 fcport->login_retry = 0;
2229 } else if (status == 1) { 2255 } else if (status == 1) {
2230 set_bit(RELOGIN_NEEDED, &ha->dpc_flags); 2256 set_bit(RELOGIN_NEEDED, &ha->dpc_flags);
2231 /* retry the login again */ 2257 /* retry the login again */
@@ -2469,6 +2495,7 @@ qla2x00_timer(scsi_qla_host_t *ha)
2469 if ((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || 2495 if ((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) ||
2470 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || 2496 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) ||
2471 test_bit(LOOP_RESET_NEEDED, &ha->dpc_flags) || 2497 test_bit(LOOP_RESET_NEEDED, &ha->dpc_flags) ||
2498 test_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags) ||
2472 start_dpc || 2499 start_dpc ||
2473 test_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags) || 2500 test_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags) ||
2474 test_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) || 2501 test_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) ||
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 245ca99a641e..c551bb84dbfb 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -1245,7 +1245,7 @@ static int __init init_scsi(void)
1245 if (error) 1245 if (error)
1246 goto cleanup_sysctl; 1246 goto cleanup_sysctl;
1247 1247
1248 for (i = 0; i < NR_CPUS; i++) 1248 for_each_cpu(i)
1249 INIT_LIST_HEAD(&per_cpu(scsi_done_q, i)); 1249 INIT_LIST_HEAD(&per_cpu(scsi_done_q, i));
1250 1250
1251 devfs_mk_dir("scsi"); 1251 devfs_mk_dir("scsi");
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index a2333d2c7af0..5cc97b721661 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1350,7 +1350,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)
1350 cmnd[4] = SCSI_REMOVAL_PREVENT; 1350 cmnd[4] = SCSI_REMOVAL_PREVENT;
1351 cmnd[5] = 0; 1351 cmnd[5] = 0;
1352 1352
1353 scsi_execute_async(sdev, cmnd, DMA_NONE, NULL, 0, 0, 10 * HZ, 1353 scsi_execute_async(sdev, cmnd, 6, DMA_NONE, NULL, 0, 0, 10 * HZ,
1354 5, NULL, NULL, GFP_KERNEL); 1354 5, NULL, NULL, GFP_KERNEL);
1355} 1355}
1356 1356
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 3574ba935af8..4a602853a98e 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -436,6 +436,7 @@ free_bios:
436 * scsi_execute_async - insert request 436 * scsi_execute_async - insert request
437 * @sdev: scsi device 437 * @sdev: scsi device
438 * @cmd: scsi command 438 * @cmd: scsi command
439 * @cmd_len: length of scsi cdb
439 * @data_direction: data direction 440 * @data_direction: data direction
440 * @buffer: data buffer (this can be a kernel buffer or scatterlist) 441 * @buffer: data buffer (this can be a kernel buffer or scatterlist)
441 * @bufflen: len of buffer 442 * @bufflen: len of buffer
@@ -445,7 +446,7 @@ free_bios:
445 * @flags: or into request flags 446 * @flags: or into request flags
446 **/ 447 **/
447int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd, 448int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
448 int data_direction, void *buffer, unsigned bufflen, 449 int cmd_len, int data_direction, void *buffer, unsigned bufflen,
449 int use_sg, int timeout, int retries, void *privdata, 450 int use_sg, int timeout, int retries, void *privdata,
450 void (*done)(void *, char *, int, int), gfp_t gfp) 451 void (*done)(void *, char *, int, int), gfp_t gfp)
451{ 452{
@@ -472,7 +473,7 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
472 if (err) 473 if (err)
473 goto free_req; 474 goto free_req;
474 475
475 req->cmd_len = COMMAND_SIZE(cmd[0]); 476 req->cmd_len = cmd_len;
476 memcpy(req->cmd, cmd, req->cmd_len); 477 memcpy(req->cmd, cmd, req->cmd_len);
477 req->sense = sioc->sense; 478 req->sense = sioc->sense;
478 req->sense_len = 0; 479 req->sense_len = 0;
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index a3e0b7bc2d7b..210dab5879fa 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -377,7 +377,7 @@ static void sas_phy_release(struct device *dev)
377/** 377/**
378 * sas_phy_alloc -- allocates and initialize a SAS PHY structure 378 * sas_phy_alloc -- allocates and initialize a SAS PHY structure
379 * @parent: Parent device 379 * @parent: Parent device
380 * @number: Port number 380 * @number: Phy index
381 * 381 *
382 * Allocates an SAS PHY structure. It will be added in the device tree 382 * Allocates an SAS PHY structure. It will be added in the device tree
383 * below the device specified by @parent, which has to be either a Scsi_Host 383 * below the device specified by @parent, which has to be either a Scsi_Host
@@ -595,8 +595,8 @@ struct sas_rphy *sas_rphy_alloc(struct sas_phy *parent)
595 device_initialize(&rphy->dev); 595 device_initialize(&rphy->dev);
596 rphy->dev.parent = get_device(&parent->dev); 596 rphy->dev.parent = get_device(&parent->dev);
597 rphy->dev.release = sas_rphy_release; 597 rphy->dev.release = sas_rphy_release;
598 sprintf(rphy->dev.bus_id, "rphy-%d:%d", 598 sprintf(rphy->dev.bus_id, "rphy-%d:%d-%d",
599 shost->host_no, parent->number); 599 shost->host_no, parent->port_identifier, parent->number);
600 transport_setup_device(&rphy->dev); 600 transport_setup_device(&rphy->dev);
601 601
602 return rphy; 602 return rphy;
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 78aad9582bcf..7d0700091f3d 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -741,7 +741,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
741 hp->duration = jiffies_to_msecs(jiffies); 741 hp->duration = jiffies_to_msecs(jiffies);
742/* Now send everything of to mid-level. The next time we hear about this 742/* Now send everything of to mid-level. The next time we hear about this
743 packet is when sg_cmd_done() is called (i.e. a callback). */ 743 packet is when sg_cmd_done() is called (i.e. a callback). */
744 if (scsi_execute_async(sdp->device, cmnd, data_dir, srp->data.buffer, 744 if (scsi_execute_async(sdp->device, cmnd, hp->cmd_len, data_dir, srp->data.buffer,
745 hp->dxfer_len, srp->data.k_use_sg, timeout, 745 hp->dxfer_len, srp->data.k_use_sg, timeout,
746 SG_DEFAULT_RETRIES, srp, sg_cmd_done, 746 SG_DEFAULT_RETRIES, srp, sg_cmd_done,
747 GFP_ATOMIC)) { 747 GFP_ATOMIC)) {
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 13b1d3aac265..7f96f33c1bb1 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -508,7 +508,7 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd
508 STp->buffer->cmdstat.have_sense = 0; 508 STp->buffer->cmdstat.have_sense = 0;
509 STp->buffer->syscall_result = 0; 509 STp->buffer->syscall_result = 0;
510 510
511 if (scsi_execute_async(STp->device, cmd, direction, 511 if (scsi_execute_async(STp->device, cmd, COMMAND_SIZE(cmd[0]), direction,
512 &((STp->buffer)->sg[0]), bytes, (STp->buffer)->sg_segs, 512 &((STp->buffer)->sg[0]), bytes, (STp->buffer)->sg_segs,
513 timeout, retries, SRpnt, st_sleep_done, GFP_KERNEL)) { 513 timeout, retries, SRpnt, st_sleep_done, GFP_KERNEL)) {
514 /* could not allocate the buffer or request was too large */ 514 /* could not allocate the buffer or request was too large */
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c
index 221999bcf8fe..7aef7518b0d1 100644
--- a/drivers/serial/21285.c
+++ b/drivers/serial/21285.c
@@ -366,7 +366,7 @@ static struct uart_port serial21285_port = {
366 .irq = NO_IRQ, 366 .irq = NO_IRQ,
367 .fifosize = 16, 367 .fifosize = 16,
368 .ops = &serial21285_ops, 368 .ops = &serial21285_ops,
369 .flags = ASYNC_BOOT_AUTOCONF, 369 .flags = UPF_BOOT_AUTOCONF,
370}; 370};
371 371
372static void serial21285_setup_ports(void) 372static void serial21285_setup_ports(void)
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index bc36edff2058..179c1f065e60 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -31,7 +31,6 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/console.h> 32#include <linux/console.h>
33#include <linux/sysrq.h> 33#include <linux/sysrq.h>
34#include <linux/mca.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/platform_device.h> 35#include <linux/platform_device.h>
37#include <linux/tty.h> 36#include <linux/tty.h>
@@ -2027,12 +2026,6 @@ static void serial8250_config_port(struct uart_port *port, int flags)
2027 int ret; 2026 int ret;
2028 2027
2029 /* 2028 /*
2030 * Don't probe for MCA ports on non-MCA machines.
2031 */
2032 if (up->port.flags & UPF_BOOT_ONLYMCA && !MCA_bus)
2033 return;
2034
2035 /*
2036 * Find the region that we can probe for. This in turn 2029 * Find the region that we can probe for. This in turn
2037 * tells us whether we can probe for the type of port. 2030 * tells us whether we can probe for the type of port.
2038 */ 2031 */
@@ -2164,7 +2157,7 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev)
2164/* 2157/*
2165 * Wait for transmitter & holding register to empty 2158 * Wait for transmitter & holding register to empty
2166 */ 2159 */
2167static inline void wait_for_xmitr(struct uart_8250_port *up) 2160static inline void wait_for_xmitr(struct uart_8250_port *up, int bits)
2168{ 2161{
2169 unsigned int status, tmout = 10000; 2162 unsigned int status, tmout = 10000;
2170 2163
@@ -2178,7 +2171,7 @@ static inline void wait_for_xmitr(struct uart_8250_port *up)
2178 if (--tmout == 0) 2171 if (--tmout == 0)
2179 break; 2172 break;
2180 udelay(1); 2173 udelay(1);
2181 } while ((status & BOTH_EMPTY) != BOTH_EMPTY); 2174 } while ((status & bits) != bits);
2182 2175
2183 /* Wait up to 1s for flow control if necessary */ 2176 /* Wait up to 1s for flow control if necessary */
2184 if (up->port.flags & UPF_CONS_FLOW) { 2177 if (up->port.flags & UPF_CONS_FLOW) {
@@ -2218,7 +2211,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2218 * Now, do each character 2211 * Now, do each character
2219 */ 2212 */
2220 for (i = 0; i < count; i++, s++) { 2213 for (i = 0; i < count; i++, s++) {
2221 wait_for_xmitr(up); 2214 wait_for_xmitr(up, UART_LSR_THRE);
2222 2215
2223 /* 2216 /*
2224 * Send the character out. 2217 * Send the character out.
@@ -2226,7 +2219,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2226 */ 2219 */
2227 serial_out(up, UART_TX, *s); 2220 serial_out(up, UART_TX, *s);
2228 if (*s == 10) { 2221 if (*s == 10) {
2229 wait_for_xmitr(up); 2222 wait_for_xmitr(up, UART_LSR_THRE);
2230 serial_out(up, UART_TX, 13); 2223 serial_out(up, UART_TX, 13);
2231 } 2224 }
2232 } 2225 }
@@ -2235,8 +2228,8 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2235 * Finally, wait for transmitter to become empty 2228 * Finally, wait for transmitter to become empty
2236 * and restore the IER 2229 * and restore the IER
2237 */ 2230 */
2238 wait_for_xmitr(up); 2231 wait_for_xmitr(up, BOTH_EMPTY);
2239 serial_out(up, UART_IER, ier); 2232 serial_out(up, UART_IER, ier | UART_IER_THRI);
2240} 2233}
2241 2234
2242static int serial8250_console_setup(struct console *co, char *options) 2235static int serial8250_console_setup(struct console *co, char *options)
diff --git a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c
index a802bdce6e5d..809f89ab965c 100644
--- a/drivers/serial/8250_acpi.c
+++ b/drivers/serial/8250_acpi.c
@@ -27,7 +27,7 @@ struct serial_private {
27static acpi_status acpi_serial_mmio(struct uart_port *port, 27static acpi_status acpi_serial_mmio(struct uart_port *port,
28 struct acpi_resource_address64 *addr) 28 struct acpi_resource_address64 *addr)
29{ 29{
30 port->mapbase = addr->min_address_range; 30 port->mapbase = addr->minimum;
31 port->iotype = UPIO_MEM; 31 port->iotype = UPIO_MEM;
32 port->flags |= UPF_IOREMAP; 32 port->flags |= UPF_IOREMAP;
33 return AE_OK; 33 return AE_OK;
@@ -36,8 +36,8 @@ static acpi_status acpi_serial_mmio(struct uart_port *port,
36static acpi_status acpi_serial_port(struct uart_port *port, 36static acpi_status acpi_serial_port(struct uart_port *port,
37 struct acpi_resource_io *io) 37 struct acpi_resource_io *io)
38{ 38{
39 if (io->range_length) { 39 if (io->address_length) {
40 port->iobase = io->min_base_address; 40 port->iobase = io->minimum;
41 port->iotype = UPIO_PORT; 41 port->iotype = UPIO_PORT;
42 } else 42 } else
43 printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__); 43 printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__);
@@ -45,13 +45,13 @@ static acpi_status acpi_serial_port(struct uart_port *port,
45} 45}
46 46
47static acpi_status acpi_serial_ext_irq(struct uart_port *port, 47static acpi_status acpi_serial_ext_irq(struct uart_port *port,
48 struct acpi_resource_ext_irq *ext_irq) 48 struct acpi_resource_extended_irq *ext_irq)
49{ 49{
50 int rc; 50 int rc;
51 51
52 if (ext_irq->number_of_interrupts > 0) { 52 if (ext_irq->interrupt_count > 0) {
53 rc = acpi_register_gsi(ext_irq->interrupts[0], 53 rc = acpi_register_gsi(ext_irq->interrupts[0],
54 ext_irq->edge_level, ext_irq->active_high_low); 54 ext_irq->triggering, ext_irq->polarity);
55 if (rc < 0) 55 if (rc < 0)
56 return AE_ERROR; 56 return AE_ERROR;
57 port->irq = rc; 57 port->irq = rc;
@@ -64,9 +64,9 @@ static acpi_status acpi_serial_irq(struct uart_port *port,
64{ 64{
65 int rc; 65 int rc;
66 66
67 if (irq->number_of_interrupts > 0) { 67 if (irq->interrupt_count > 0) {
68 rc = acpi_register_gsi(irq->interrupts[0], 68 rc = acpi_register_gsi(irq->interrupts[0],
69 irq->edge_level, irq->active_high_low); 69 irq->triggering, irq->polarity);
70 if (rc < 0) 70 if (rc < 0)
71 return AE_ERROR; 71 return AE_ERROR;
72 port->irq = rc; 72 port->irq = rc;
@@ -83,11 +83,11 @@ static acpi_status acpi_serial_resource(struct acpi_resource *res, void *data)
83 status = acpi_resource_to_address64(res, &addr); 83 status = acpi_resource_to_address64(res, &addr);
84 if (ACPI_SUCCESS(status)) 84 if (ACPI_SUCCESS(status))
85 return acpi_serial_mmio(port, &addr); 85 return acpi_serial_mmio(port, &addr);
86 else if (res->id == ACPI_RSTYPE_IO) 86 else if (res->type == ACPI_RESOURCE_TYPE_IO)
87 return acpi_serial_port(port, &res->data.io); 87 return acpi_serial_port(port, &res->data.io);
88 else if (res->id == ACPI_RSTYPE_EXT_IRQ) 88 else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ)
89 return acpi_serial_ext_irq(port, &res->data.extended_irq); 89 return acpi_serial_ext_irq(port, &res->data.extended_irq);
90 else if (res->id == ACPI_RSTYPE_IRQ) 90 else if (res->type == ACPI_RESOURCE_TYPE_IRQ)
91 return acpi_serial_irq(port, &res->data.irq); 91 return acpi_serial_irq(port, &res->data.irq);
92 return AE_OK; 92 return AE_OK;
93} 93}
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 2a912153321e..bb9ec28ccc2b 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -439,6 +439,20 @@ static int pci_siig_init(struct pci_dev *dev)
439 return -ENODEV; 439 return -ENODEV;
440} 440}
441 441
442static int pci_siig_setup(struct serial_private *priv,
443 struct pciserial_board *board,
444 struct uart_port *port, int idx)
445{
446 unsigned int bar = FL_GET_BASE(board->flags) + idx, offset = 0;
447
448 if (idx > 3) {
449 bar = 4;
450 offset = (idx - 4) * 8;
451 }
452
453 return setup_port(priv, port, bar, offset, 0);
454}
455
442/* 456/*
443 * Timedia has an explosion of boards, and to avoid the PCI table from 457 * Timedia has an explosion of boards, and to avoid the PCI table from
444 * growing *huge*, we use this function to collapse some 70 entries 458 * growing *huge*, we use this function to collapse some 70 entries
@@ -748,7 +762,7 @@ static struct pci_serial_quirk pci_serial_quirks[] = {
748 .subvendor = PCI_ANY_ID, 762 .subvendor = PCI_ANY_ID,
749 .subdevice = PCI_ANY_ID, 763 .subdevice = PCI_ANY_ID,
750 .init = pci_siig_init, 764 .init = pci_siig_init,
751 .setup = pci_default_setup, 765 .setup = pci_siig_setup,
752 }, 766 },
753 /* 767 /*
754 * Titan cards 768 * Titan cards
@@ -2141,6 +2155,15 @@ static struct pci_device_id serial_pci_tbl[] = {
2141 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_4S_20x_850, 2155 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_4S_20x_850,
2142 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2156 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2143 pbn_b0_bt_4_921600 }, 2157 pbn_b0_bt_4_921600 },
2158 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_8S_20x_550,
2159 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2160 pbn_b0_bt_8_921600 },
2161 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_8S_20x_650,
2162 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2163 pbn_b0_bt_8_921600 },
2164 { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_8S_20x_850,
2165 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2166 pbn_b0_bt_8_921600 },
2144 2167
2145 /* 2168 /*
2146 * Computone devices submitted by Doug McNash dmcnash@computone.com 2169 * Computone devices submitted by Doug McNash dmcnash@computone.com
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 9fd1925de361..0f4361c8466b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -23,7 +23,7 @@ config SERIAL_8250
23 work.) 23 work.)
24 24
25 To compile this driver as a module, choose M here: the 25 To compile this driver as a module, choose M here: the
26 module will be called serial. 26 module will be called 8250.
27 [WARNING: Do not compile this driver as a module if you are using 27 [WARNING: Do not compile this driver as a module if you are using
28 non-standard serial ports, since the configuration information will 28 non-standard serial ports, since the configuration information will
29 be lost when the driver is unloaded. This limitation may be lifted 29 be lost when the driver is unloaded. This limitation may be lifted
@@ -98,6 +98,7 @@ config SERIAL_8250_NR_UARTS
98config SERIAL_8250_RUNTIME_UARTS 98config SERIAL_8250_RUNTIME_UARTS
99 int "Number of 8250/16550 serial ports to register at runtime" 99 int "Number of 8250/16550 serial ports to register at runtime"
100 depends on SERIAL_8250 100 depends on SERIAL_8250
101 range 0 SERIAL_8250_NR_UARTS
101 default "4" 102 default "4"
102 help 103 help
103 Set this to the maximum number of serial ports you want 104 Set this to the maximum number of serial ports you want
@@ -892,20 +893,20 @@ config SERIAL_VR41XX_CONSOLE
892 a console on a serial port, say Y. Otherwise, say N. 893 a console on a serial port, say Y. Otherwise, say N.
893 894
894config SERIAL_JSM 895config SERIAL_JSM
895 tristate "Digi International NEO PCI Support" 896 tristate "Digi International NEO PCI Support"
896 depends on PCI && BROKEN 897 depends on PCI
897 select SERIAL_CORE 898 select SERIAL_CORE
898 help 899 help
899 This is a driver for Digi International's Neo series 900 This is a driver for Digi International's Neo series
900 of cards which provide multiple serial ports. You would need 901 of cards which provide multiple serial ports. You would need
901 something like this to connect more than two modems to your Linux 902 something like this to connect more than two modems to your Linux
902 box, for instance in order to become a dial-in server. This driver 903 box, for instance in order to become a dial-in server. This driver
903 supports PCI boards only. 904 supports PCI boards only.
904 If you have a card like this, say Y here and read the file 905 If you have a card like this, say Y here and read the file
905 <file:Documentation/jsm.txt>. 906 <file:Documentation/jsm.txt>.
906 907
907 To compile this driver as a module, choose M here: the 908 To compile this driver as a module, choose M here: the
908 module will be called jsm. 909 module will be called jsm.
909 910
910config SERIAL_SGI_IOC4 911config SERIAL_SGI_IOC4
911 tristate "SGI IOC4 controller serial support" 912 tristate "SGI IOC4 controller serial support"
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 3490022e9fdc..429de2723a1c 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -566,7 +566,7 @@ static struct uart_amba_port amba_ports[UART_NR] = {
566 .uartclk = 14745600, 566 .uartclk = 14745600,
567 .fifosize = 16, 567 .fifosize = 16,
568 .ops = &amba_pl010_pops, 568 .ops = &amba_pl010_pops,
569 .flags = ASYNC_BOOT_AUTOCONF, 569 .flags = UPF_BOOT_AUTOCONF,
570 .line = 0, 570 .line = 0,
571 }, 571 },
572 .dtr_mask = 1 << 5, 572 .dtr_mask = 1 << 5,
@@ -581,7 +581,7 @@ static struct uart_amba_port amba_ports[UART_NR] = {
581 .uartclk = 14745600, 581 .uartclk = 14745600,
582 .fifosize = 16, 582 .fifosize = 16,
583 .ops = &amba_pl010_pops, 583 .ops = &amba_pl010_pops,
584 .flags = ASYNC_BOOT_AUTOCONF, 584 .flags = UPF_BOOT_AUTOCONF,
585 .line = 1, 585 .line = 1,
586 }, 586 },
587 .dtr_mask = 1 << 7, 587 .dtr_mask = 1 << 7,
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index 8ef999481f93..ce7b2e4ecd17 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -410,7 +410,7 @@ static struct uart_port clps711x_ports[UART_NR] = {
410 .fifosize = 16, 410 .fifosize = 16,
411 .ops = &clps711x_pops, 411 .ops = &clps711x_pops,
412 .line = 0, 412 .line = 0,
413 .flags = ASYNC_BOOT_AUTOCONF, 413 .flags = UPF_BOOT_AUTOCONF,
414 }, 414 },
415 { 415 {
416 .iobase = SYSCON2, 416 .iobase = SYSCON2,
@@ -419,7 +419,7 @@ static struct uart_port clps711x_ports[UART_NR] = {
419 .fifosize = 16, 419 .fifosize = 16,
420 .ops = &clps711x_pops, 420 .ops = &clps711x_pops,
421 .line = 1, 421 .line = 1,
422 .flags = ASYNC_BOOT_AUTOCONF, 422 .flags = UPF_BOOT_AUTOCONF,
423 } 423 }
424}; 424};
425 425
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 587cc6a95114..858048efe1ed 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -402,10 +402,10 @@ static int imx_startup(struct uart_port *port)
402 DRIVER_NAME, sport); 402 DRIVER_NAME, sport);
403 if (retval) goto error_out2; 403 if (retval) goto error_out2;
404 404
405 retval = request_irq(sport->rtsirq, imx_rtsint, 0, 405 retval = request_irq(sport->rtsirq, imx_rtsint,
406 SA_TRIGGER_FALLING | SA_TRIGGER_RISING,
406 DRIVER_NAME, sport); 407 DRIVER_NAME, sport);
407 if (retval) goto error_out3; 408 if (retval) goto error_out3;
408 set_irq_type(sport->rtsirq, IRQT_BOTHEDGE);
409 409
410 /* 410 /*
411 * Finally, clear and enable interrupts 411 * Finally, clear and enable interrupts
@@ -674,7 +674,7 @@ static struct imx_port imx_ports[] = {
674 .irq = UART1_MINT_RX, 674 .irq = UART1_MINT_RX,
675 .uartclk = 16000000, 675 .uartclk = 16000000,
676 .fifosize = 8, 676 .fifosize = 8,
677 .flags = ASYNC_BOOT_AUTOCONF, 677 .flags = UPF_BOOT_AUTOCONF,
678 .ops = &imx_pops, 678 .ops = &imx_pops,
679 .line = 0, 679 .line = 0,
680 }, 680 },
@@ -690,7 +690,7 @@ static struct imx_port imx_ports[] = {
690 .irq = UART2_MINT_RX, 690 .irq = UART2_MINT_RX,
691 .uartclk = 16000000, 691 .uartclk = 16000000,
692 .fifosize = 8, 692 .fifosize = 8,
693 .flags = ASYNC_BOOT_AUTOCONF, 693 .flags = UPF_BOOT_AUTOCONF,
694 .ops = &imx_pops, 694 .ops = &imx_pops,
695 .line = 1, 695 .line = 1,
696 }, 696 },
diff --git a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
index 18753193f59b..dfc1e86d3aa1 100644
--- a/drivers/serial/jsm/jsm.h
+++ b/drivers/serial/jsm/jsm.h
@@ -380,7 +380,6 @@ struct neo_uart_struct {
380extern struct uart_driver jsm_uart_driver; 380extern struct uart_driver jsm_uart_driver;
381extern struct board_ops jsm_neo_ops; 381extern struct board_ops jsm_neo_ops;
382extern int jsm_debug; 382extern int jsm_debug;
383extern int jsm_rawreadok;
384 383
385/************************************************************************* 384/*************************************************************************
386 * 385 *
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c
index 7e56c7824194..b1b66e71d281 100644
--- a/drivers/serial/jsm/jsm_driver.c
+++ b/drivers/serial/jsm/jsm_driver.c
@@ -49,11 +49,8 @@ struct uart_driver jsm_uart_driver = {
49}; 49};
50 50
51int jsm_debug; 51int jsm_debug;
52int jsm_rawreadok;
53module_param(jsm_debug, int, 0); 52module_param(jsm_debug, int, 0);
54module_param(jsm_rawreadok, int, 0);
55MODULE_PARM_DESC(jsm_debug, "Driver debugging level"); 53MODULE_PARM_DESC(jsm_debug, "Driver debugging level");
56MODULE_PARM_DESC(jsm_rawreadok, "Bypass flip buffers on input");
57 54
58static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent) 55static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
59{ 56{
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/serial/jsm/jsm_neo.c
index 6f22b42d9337..87e4e2cf8ce7 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/serial/jsm/jsm_neo.c
@@ -965,56 +965,47 @@ static void neo_param(struct jsm_channel *ch)
965 baud = ch->ch_custom_speed; 965 baud = ch->ch_custom_speed;
966 if (ch->ch_flags & CH_BAUD0) 966 if (ch->ch_flags & CH_BAUD0)
967 ch->ch_flags &= ~(CH_BAUD0); 967 ch->ch_flags &= ~(CH_BAUD0);
968 } else { 968 } else {
969 int iindex = 0; 969 int i;
970 int jindex = 0; 970 unsigned int cflag;
971 971 static struct {
972 const u64 bauds[4][16] = { 972 unsigned int rate;
973 { 973 unsigned int cflag;
974 0, 50, 75, 110, 974 } baud_rates[] = {
975 134, 150, 200, 300, 975 { 921600, B921600 },
976 600, 1200, 1800, 2400, 976 { 460800, B460800 },
977 4800, 9600, 19200, 38400 }, 977 { 230400, B230400 },
978 { 978 { 115200, B115200 },
979 0, 57600, 115200, 230400, 979 { 57600, B57600 },
980 460800, 150, 200, 921600, 980 { 38400, B38400 },
981 600, 1200, 1800, 2400, 981 { 19200, B19200 },
982 4800, 9600, 19200, 38400 }, 982 { 9600, B9600 },
983 { 983 { 4800, B4800 },
984 0, 57600, 76800, 115200, 984 { 2400, B2400 },
985 131657, 153600, 230400, 460800, 985 { 1200, B1200 },
986 921600, 1200, 1800, 2400, 986 { 600, B600 },
987 4800, 9600, 19200, 38400 }, 987 { 300, B300 },
988 { 988 { 200, B200 },
989 0, 57600, 115200, 230400, 989 { 150, B150 },
990 460800, 150, 200, 921600, 990 { 134, B134 },
991 600, 1200, 1800, 2400, 991 { 110, B110 },
992 4800, 9600, 19200, 38400 } 992 { 75, B75 },
993 }; 993 { 50, B50 },
994 994 };
995 baud = C_BAUD(ch->uart_port.info->tty) & 0xff; 995
996 996 cflag = C_BAUD(ch->uart_port.info->tty);
997 if (ch->ch_c_cflag & CBAUDEX) 997 baud = 9600;
998 iindex = 1; 998 for (i = 0; i < ARRAY_SIZE(baud_rates); i++) {
999 999 if (baud_rates[i].cflag == cflag) {
1000 jindex = baud; 1000 baud = baud_rates[i].rate;
1001 1001 break;
1002 if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16))
1003 baud = bauds[iindex][jindex];
1004 else {
1005 jsm_printk(IOCTL, DEBUG, &ch->ch_bd->pci_dev,
1006 "baud indices were out of range (%d)(%d)",
1007 iindex, jindex);
1008 baud = 0;
1009 } 1002 }
1010
1011 if (baud == 0)
1012 baud = 9600;
1013
1014 if (ch->ch_flags & CH_BAUD0)
1015 ch->ch_flags &= ~(CH_BAUD0);
1016 } 1003 }
1017 1004
1005 if (ch->ch_flags & CH_BAUD0)
1006 ch->ch_flags &= ~(CH_BAUD0);
1007 }
1008
1018 if (ch->ch_c_cflag & PARENB) 1009 if (ch->ch_c_cflag & PARENB)
1019 lcr |= UART_LCR_PARITY; 1010 lcr |= UART_LCR_PARITY;
1020 1011
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 6fa0d62d6f68..4d48b625cd3d 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -20,8 +20,10 @@
20 * 20 *
21 * Contact Information: 21 * Contact Information:
22 * Scott H Kilau <Scott_Kilau@digi.com> 22 * Scott H Kilau <Scott_Kilau@digi.com>
23 * Wendy Xiong <wendyx@us.ltcfwd.linux.ibm.com> 23 * Ananda Venkatarman <mansarov@us.ibm.com>
24 * 24 * Modifications:
25 * 01/19/06: changed jsm_input routine to use the dynamically allocated
26 * tty_buffer changes. Contributors: Scott Kilau and Ananda V.
25 ***********************************************************************/ 27 ***********************************************************************/
26#include <linux/tty.h> 28#include <linux/tty.h>
27#include <linux/tty_flip.h> 29#include <linux/tty_flip.h>
@@ -497,16 +499,15 @@ void jsm_input(struct jsm_channel *ch)
497{ 499{
498 struct jsm_board *bd; 500 struct jsm_board *bd;
499 struct tty_struct *tp; 501 struct tty_struct *tp;
502 struct tty_ldisc *ld;
500 u32 rmask; 503 u32 rmask;
501 u16 head; 504 u16 head;
502 u16 tail; 505 u16 tail;
503 int data_len; 506 int data_len;
504 unsigned long lock_flags; 507 unsigned long lock_flags;
505 int flip_len; 508 int flip_len = 0;
506 int len = 0; 509 int len = 0;
507 int n = 0; 510 int n = 0;
508 char *buf = NULL;
509 char *buf2 = NULL;
510 int s = 0; 511 int s = 0;
511 int i = 0; 512 int i = 0;
512 513
@@ -574,56 +575,50 @@ void jsm_input(struct jsm_channel *ch)
574 575
575 /* 576 /*
576 * If the rxbuf is empty and we are not throttled, put as much 577 * If the rxbuf is empty and we are not throttled, put as much
577 * as we can directly into the linux TTY flip buffer. 578 * as we can directly into the linux TTY buffer.
578 * The jsm_rawreadok case takes advantage of carnal knowledge that
579 * the char_buf and the flag_buf are next to each other and
580 * are each of (2 * TTY_FLIPBUF_SIZE) size.
581 * 579 *
582 * NOTE: if(!tty->real_raw), the call to ldisc.receive_buf
583 *actually still uses the flag buffer, so you can't
584 *use it for input data
585 */ 580 */
586 if (jsm_rawreadok) { 581 flip_len = TTY_FLIPBUF_SIZE;
587 if (tp->real_raw)
588 flip_len = MYFLIPLEN;
589 else
590 flip_len = 2 * TTY_FLIPBUF_SIZE;
591 } else
592 flip_len = TTY_FLIPBUF_SIZE - tp->flip.count;
593 582
594 len = min(data_len, flip_len); 583 len = min(data_len, flip_len);
595 len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt); 584 len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt);
585 ld = tty_ldisc_ref(tp);
596 586
597 if (len <= 0) { 587 /*
598 spin_unlock_irqrestore(&ch->ch_lock, lock_flags); 588 * If the DONT_FLIP flag is on, don't flush our buffer, and act
599 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "jsm_input 1\n"); 589 * like the ld doesn't have any space to put the data right now.
600 return; 590 */
601 } 591 if (test_bit(TTY_DONT_FLIP, &tp->flags))
592 len = 0;
602 593
603 /* 594 /*
604 * If we're bypassing flip buffers on rx, we can blast it 595 * If we were unable to get a reference to the ld,
605 * right into the beginning of the buffer. 596 * don't flush our buffer, and act like the ld doesn't
597 * have any space to put the data right now.
606 */ 598 */
607 if (jsm_rawreadok) { 599 if (!ld) {
608 if (tp->real_raw) { 600 len = 0;
609 if (ch->ch_flags & CH_FLIPBUF_IN_USE) {
610 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
611 "JSM - FLIPBUF in use. delaying input\n");
612 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
613 return;
614 }
615 ch->ch_flags |= CH_FLIPBUF_IN_USE;
616 buf = ch->ch_bd->flipbuf;
617 buf2 = NULL;
618 } else {
619 buf = tp->flip.char_buf;
620 buf2 = tp->flip.flag_buf;
621 }
622 } else { 601 } else {
623 buf = tp->flip.char_buf_ptr; 602 /*
624 buf2 = tp->flip.flag_buf_ptr; 603 * If ld doesn't have a pointer to a receive_buf function,
604 * flush the data, then act like the ld doesn't have any
605 * space to put the data right now.
606 */
607 if (!ld->receive_buf) {
608 ch->ch_r_head = ch->ch_r_tail;
609 len = 0;
610 }
625 } 611 }
626 612
613 if (len <= 0) {
614 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
615 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "jsm_input 1\n");
616 if (ld)
617 tty_ldisc_deref(ld);
618 return;
619 }
620
621 len = tty_buffer_request_room(tp, len);
627 n = len; 622 n = len;
628 623
629 /* 624 /*
@@ -638,121 +633,47 @@ void jsm_input(struct jsm_channel *ch)
638 if (s <= 0) 633 if (s <= 0)
639 break; 634 break;
640 635
641 memcpy(buf, ch->ch_rqueue + tail, s); 636 /*
642 637 * If conditions are such that ld needs to see all
643 /* buf2 is only set when port isn't raw */ 638 * UART errors, we will have to walk each character
644 if (buf2) 639 * and error byte and send them to the buffer one at
645 memcpy(buf2, ch->ch_equeue + tail, s); 640 * a time.
646 641 */
647 tail += s;
648 buf += s;
649 if (buf2)
650 buf2 += s;
651 n -= s;
652 /* Flip queue if needed */
653 tail &= rmask;
654 }
655 642
656 /*
657 * In high performance mode, we don't have to update
658 * flag_buf or any of the counts or pointers into flip buf.
659 */
660 if (!jsm_rawreadok) {
661 if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { 643 if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) {
662 for (i = 0; i < len; i++) { 644 for (i = 0; i < s; i++) {
663 /* 645 /*
664 * Give the Linux ld the flags in the 646 * Give the Linux ld the flags in the
665 * format it likes. 647 * format it likes.
666 */ 648 */
667 if (tp->flip.flag_buf_ptr[i] & UART_LSR_BI) 649 if (*(ch->ch_equeue +tail +i) & UART_LSR_BI)
668 tp->flip.flag_buf_ptr[i] = TTY_BREAK; 650 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_BREAK);
669 else if (tp->flip.flag_buf_ptr[i] & UART_LSR_PE) 651 else if (*(ch->ch_equeue +tail +i) & UART_LSR_PE)
670 tp->flip.flag_buf_ptr[i] = TTY_PARITY; 652 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_PARITY);
671 else if (tp->flip.flag_buf_ptr[i] & UART_LSR_FE) 653 else if (*(ch->ch_equeue +tail +i) & UART_LSR_FE)
672 tp->flip.flag_buf_ptr[i] = TTY_FRAME; 654 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_FRAME);
673 else 655 else
674 tp->flip.flag_buf_ptr[i] = TTY_NORMAL; 656 tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_NORMAL);
675 } 657 }
676 } else { 658 } else {
677 memset(tp->flip.flag_buf_ptr, 0, len); 659 tty_insert_flip_string(tp, ch->ch_rqueue + tail, s) ;
678 } 660 }
679 661 tail += s;
680 tp->flip.char_buf_ptr += len; 662 n -= s;
681 tp->flip.flag_buf_ptr += len; 663 /* Flip queue if needed */
682 tp->flip.count += len; 664 tail &= rmask;
683 }
684 else if (!tp->real_raw) {
685 if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) {
686 for (i = 0; i < len; i++) {
687 /*
688 * Give the Linux ld the flags in the
689 * format it likes.
690 */
691 if (tp->flip.flag_buf_ptr[i] & UART_LSR_BI)
692 tp->flip.flag_buf_ptr[i] = TTY_BREAK;
693 else if (tp->flip.flag_buf_ptr[i] & UART_LSR_PE)
694 tp->flip.flag_buf_ptr[i] = TTY_PARITY;
695 else if (tp->flip.flag_buf_ptr[i] & UART_LSR_FE)
696 tp->flip.flag_buf_ptr[i] = TTY_FRAME;
697 else
698 tp->flip.flag_buf_ptr[i] = TTY_NORMAL;
699 }
700 } else
701 memset(tp->flip.flag_buf, 0, len);
702 } 665 }
703 666
704 /* 667 ch->ch_r_tail = tail & rmask;
705 * If we're doing raw reads, jam it right into the 668 ch->ch_e_tail = tail & rmask;
706 * line disc bypassing the flip buffers. 669 jsm_check_queue_flow_control(ch);
707 */ 670 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
708 if (jsm_rawreadok) {
709 if (tp->real_raw) {
710 ch->ch_r_tail = tail & rmask;
711 ch->ch_e_tail = tail & rmask;
712
713 jsm_check_queue_flow_control(ch);
714
715 /* !!! WE *MUST* LET GO OF ALL LOCKS BEFORE CALLING RECEIVE BUF !!! */
716 671
717 spin_unlock_irqrestore(&ch->ch_lock, lock_flags); 672 /* Tell the tty layer its okay to "eat" the data now */
673 tty_flip_buffer_push(tp);
718 674
719 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 675 if (ld)
720 "jsm_input. %d real_raw len:%d calling receive_buf for board %d\n", 676 tty_ldisc_deref(ld);
721 __LINE__, len, ch->ch_bd->boardnum);
722 tp->ldisc.receive_buf(tp, ch->ch_bd->flipbuf, NULL, len);
723
724 /* Allow use of channel flip buffer again */
725 spin_lock_irqsave(&ch->ch_lock, lock_flags);
726 ch->ch_flags &= ~CH_FLIPBUF_IN_USE;
727 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
728
729 } else {
730 ch->ch_r_tail = tail & rmask;
731 ch->ch_e_tail = tail & rmask;
732
733 jsm_check_queue_flow_control(ch);
734
735 /* !!! WE *MUST* LET GO OF ALL LOCKS BEFORE CALLING RECEIVE BUF !!! */
736 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
737
738 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
739 "jsm_input. %d not real_raw len:%d calling receive_buf for board %d\n",
740 __LINE__, len, ch->ch_bd->boardnum);
741
742 tp->ldisc.receive_buf(tp, tp->flip.char_buf, tp->flip.flag_buf, len);
743 }
744 } else {
745 ch->ch_r_tail = tail & rmask;
746 ch->ch_e_tail = tail & rmask;
747
748 jsm_check_queue_flow_control(ch);
749
750 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
751
752 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev,
753 "jsm_input. %d not jsm_read raw okay scheduling flip\n", __LINE__);
754 tty_schedule_flip(tp);
755 }
756 677
757 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n"); 678 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n");
758} 679}
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index d957a3a9edf1..0ef648fa4b2d 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -350,8 +350,7 @@ static inline void receive_chars(struct mcf_serial *info)
350 } 350 }
351 tty_insert_flip_char(tty, ch, flag); 351 tty_insert_flip_char(tty, ch, flag);
352 } 352 }
353 353 tty_flip_buffer_push(tty);
354 schedule_work(&tty->flip.work);
355 return; 354 return;
356} 355}
357 356
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index eb4883efb7c6..0a2dd6c5b95f 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -1060,7 +1060,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1060 dbg("resource %p (%lx..%lx)\n", res, res->start, res->end); 1060 dbg("resource %p (%lx..%lx)\n", res, res->start, res->end);
1061 1061
1062 port->mapbase = res->start; 1062 port->mapbase = res->start;
1063 port->membase = S3C24XX_VA_UART + (res->start - S3C2410_PA_UART); 1063 port->membase = S3C24XX_VA_UART + (res->start - S3C24XX_PA_UART);
1064 port->irq = platform_get_irq(platdev, 0); 1064 port->irq = platform_get_irq(platdev, 0);
1065 1065
1066 ourport->clk = clk_get(&platdev->dev, "uart"); 1066 ourport->clk = clk_get(&platdev->dev, "uart");
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 1bd93168f504..ff7b60b4de37 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -665,21 +665,21 @@ void __init sa1100_register_uart(int idx, int port)
665 sa1100_ports[idx].port.membase = (void __iomem *)&Ser1UTCR0; 665 sa1100_ports[idx].port.membase = (void __iomem *)&Ser1UTCR0;
666 sa1100_ports[idx].port.mapbase = _Ser1UTCR0; 666 sa1100_ports[idx].port.mapbase = _Ser1UTCR0;
667 sa1100_ports[idx].port.irq = IRQ_Ser1UART; 667 sa1100_ports[idx].port.irq = IRQ_Ser1UART;
668 sa1100_ports[idx].port.flags = ASYNC_BOOT_AUTOCONF; 668 sa1100_ports[idx].port.flags = UPF_BOOT_AUTOCONF;
669 break; 669 break;
670 670
671 case 2: 671 case 2:
672 sa1100_ports[idx].port.membase = (void __iomem *)&Ser2UTCR0; 672 sa1100_ports[idx].port.membase = (void __iomem *)&Ser2UTCR0;
673 sa1100_ports[idx].port.mapbase = _Ser2UTCR0; 673 sa1100_ports[idx].port.mapbase = _Ser2UTCR0;
674 sa1100_ports[idx].port.irq = IRQ_Ser2ICP; 674 sa1100_ports[idx].port.irq = IRQ_Ser2ICP;
675 sa1100_ports[idx].port.flags = ASYNC_BOOT_AUTOCONF; 675 sa1100_ports[idx].port.flags = UPF_BOOT_AUTOCONF;
676 break; 676 break;
677 677
678 case 3: 678 case 3:
679 sa1100_ports[idx].port.membase = (void __iomem *)&Ser3UTCR0; 679 sa1100_ports[idx].port.membase = (void __iomem *)&Ser3UTCR0;
680 sa1100_ports[idx].port.mapbase = _Ser3UTCR0; 680 sa1100_ports[idx].port.mapbase = _Ser3UTCR0;
681 sa1100_ports[idx].port.irq = IRQ_Ser3UART; 681 sa1100_ports[idx].port.irq = IRQ_Ser3UART;
682 sa1100_ports[idx].port.flags = ASYNC_BOOT_AUTOCONF; 682 sa1100_ports[idx].port.flags = UPF_BOOT_AUTOCONF;
683 break; 683 break;
684 684
685 default: 685 default:
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 943770470b9d..95fb4939c675 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -332,7 +332,7 @@ uart_get_baud_rate(struct uart_port *port, struct termios *termios,
332 struct termios *old, unsigned int min, unsigned int max) 332 struct termios *old, unsigned int min, unsigned int max)
333{ 333{
334 unsigned int try, baud, altbaud = 38400; 334 unsigned int try, baud, altbaud = 38400;
335 unsigned int flags = port->flags & UPF_SPD_MASK; 335 upf_t flags = port->flags & UPF_SPD_MASK;
336 336
337 if (flags == UPF_SPD_HI) 337 if (flags == UPF_SPD_HI)
338 altbaud = 57600; 338 altbaud = 57600;
@@ -615,8 +615,9 @@ static int uart_set_info(struct uart_state *state,
615 struct serial_struct new_serial; 615 struct serial_struct new_serial;
616 struct uart_port *port = state->port; 616 struct uart_port *port = state->port;
617 unsigned long new_port; 617 unsigned long new_port;
618 unsigned int change_irq, change_port, old_flags, closing_wait; 618 unsigned int change_irq, change_port, closing_wait;
619 unsigned int old_custom_divisor, close_delay; 619 unsigned int old_custom_divisor, close_delay;
620 upf_t old_flags, new_flags;
620 int retval = 0; 621 int retval = 0;
621 622
622 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 623 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
@@ -655,6 +656,7 @@ static int uart_set_info(struct uart_state *state,
655 new_serial.type != port->type; 656 new_serial.type != port->type;
656 657
657 old_flags = port->flags; 658 old_flags = port->flags;
659 new_flags = new_serial.flags;
658 old_custom_divisor = port->custom_divisor; 660 old_custom_divisor = port->custom_divisor;
659 661
660 if (!capable(CAP_SYS_ADMIN)) { 662 if (!capable(CAP_SYS_ADMIN)) {
@@ -664,10 +666,10 @@ static int uart_set_info(struct uart_state *state,
664 (close_delay != state->close_delay) || 666 (close_delay != state->close_delay) ||
665 (closing_wait != state->closing_wait) || 667 (closing_wait != state->closing_wait) ||
666 (new_serial.xmit_fifo_size != port->fifosize) || 668 (new_serial.xmit_fifo_size != port->fifosize) ||
667 (((new_serial.flags ^ old_flags) & ~UPF_USR_MASK) != 0)) 669 (((new_flags ^ old_flags) & ~UPF_USR_MASK) != 0))
668 goto exit; 670 goto exit;
669 port->flags = ((port->flags & ~UPF_USR_MASK) | 671 port->flags = ((port->flags & ~UPF_USR_MASK) |
670 (new_serial.flags & UPF_USR_MASK)); 672 (new_flags & UPF_USR_MASK));
671 port->custom_divisor = new_serial.custom_divisor; 673 port->custom_divisor = new_serial.custom_divisor;
672 goto check_and_exit; 674 goto check_and_exit;
673 } 675 }
@@ -764,7 +766,7 @@ static int uart_set_info(struct uart_state *state,
764 port->irq = new_serial.irq; 766 port->irq = new_serial.irq;
765 port->uartclk = new_serial.baud_base * 16; 767 port->uartclk = new_serial.baud_base * 16;
766 port->flags = (port->flags & ~UPF_CHANGE_MASK) | 768 port->flags = (port->flags & ~UPF_CHANGE_MASK) |
767 (new_serial.flags & UPF_CHANGE_MASK); 769 (new_flags & UPF_CHANGE_MASK);
768 port->custom_divisor = new_serial.custom_divisor; 770 port->custom_divisor = new_serial.custom_divisor;
769 state->close_delay = close_delay; 771 state->close_delay = close_delay;
770 state->closing_wait = closing_wait; 772 state->closing_wait = closing_wait;
@@ -1870,7 +1872,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port)
1870 mutex_lock(&state->mutex); 1872 mutex_lock(&state->mutex);
1871 1873
1872 if (state->info && state->info->flags & UIF_INITIALIZED) { 1874 if (state->info && state->info->flags & UIF_INITIALIZED) {
1873 struct uart_ops *ops = port->ops; 1875 const struct uart_ops *ops = port->ops;
1874 1876
1875 spin_lock_irq(&port->lock); 1877 spin_lock_irq(&port->lock);
1876 ops->stop_tx(port); 1878 ops->stop_tx(port);
@@ -1932,7 +1934,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port)
1932 } 1934 }
1933 1935
1934 if (state->info && state->info->flags & UIF_INITIALIZED) { 1936 if (state->info && state->info->flags & UIF_INITIALIZED) {
1935 struct uart_ops *ops = port->ops; 1937 const struct uart_ops *ops = port->ops;
1936 int ret; 1938 int ret;
1937 1939
1938 ops->set_mctrl(port, 0); 1940 ops->set_mctrl(port, 0);
@@ -2235,7 +2237,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port)
2235 * If this port is a console, then the spinlock is already 2237 * If this port is a console, then the spinlock is already
2236 * initialised. 2238 * initialised.
2237 */ 2239 */
2238 if (!uart_console(port)) 2240 if (!(uart_console(port) && (port->cons->flags & CON_ENABLED)))
2239 spin_lock_init(&port->lock); 2241 spin_lock_init(&port->lock);
2240 2242
2241 uart_configure_port(drv, state, port); 2243 uart_configure_port(drv, state, port);
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c
index d4a1f0e798c1..d0490f67f597 100644
--- a/drivers/serial/serial_lh7a40x.c
+++ b/drivers/serial/serial_lh7a40x.c
@@ -506,7 +506,7 @@ static struct uart_port_lh7a40x lh7a40x_ports[DEV_NR] = {
506 .uartclk = 14745600/2, 506 .uartclk = 14745600/2,
507 .fifosize = 16, 507 .fifosize = 16,
508 .ops = &lh7a40x_uart_ops, 508 .ops = &lh7a40x_uart_ops,
509 .flags = ASYNC_BOOT_AUTOCONF, 509 .flags = UPF_BOOT_AUTOCONF,
510 .line = 0, 510 .line = 0,
511 }, 511 },
512 }, 512 },
@@ -519,7 +519,7 @@ static struct uart_port_lh7a40x lh7a40x_ports[DEV_NR] = {
519 .uartclk = 14745600/2, 519 .uartclk = 14745600/2,
520 .fifosize = 16, 520 .fifosize = 16,
521 .ops = &lh7a40x_uart_ops, 521 .ops = &lh7a40x_uart_ops,
522 .flags = ASYNC_BOOT_AUTOCONF, 522 .flags = UPF_BOOT_AUTOCONF,
523 .line = 1, 523 .line = 1,
524 }, 524 },
525 }, 525 },
@@ -532,7 +532,7 @@ static struct uart_port_lh7a40x lh7a40x_ports[DEV_NR] = {
532 .uartclk = 14745600/2, 532 .uartclk = 14745600/2,
533 .fifosize = 16, 533 .fifosize = 16,
534 .ops = &lh7a40x_uart_ops, 534 .ops = &lh7a40x_uart_ops,
535 .flags = ASYNC_BOOT_AUTOCONF, 535 .flags = UPF_BOOT_AUTOCONF,
536 .line = 2, 536 .line = 2,
537 }, 537 },
538 }, 538 },
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index a9e070759628..80737c131ce7 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -42,6 +42,7 @@
42#include <linux/delay.h> 42#include <linux/delay.h>
43#include <linux/console.h> 43#include <linux/console.h>
44#include <linux/bitops.h> 44#include <linux/bitops.h>
45#include <linux/generic_serial.h>
45 46
46#ifdef CONFIG_CPU_FREQ 47#ifdef CONFIG_CPU_FREQ
47#include <linux/notifier.h> 48#include <linux/notifier.h>
@@ -53,7 +54,9 @@
53#include <asm/irq.h> 54#include <asm/irq.h>
54#include <asm/uaccess.h> 55#include <asm/uaccess.h>
55 56
56#include <linux/generic_serial.h> 57#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
58#include <asm/clock.h>
59#endif
57 60
58#ifdef CONFIG_SH_STANDARD_BIOS 61#ifdef CONFIG_SH_STANDARD_BIOS
59#include <asm/sh_bios.h> 62#include <asm/sh_bios.h>
@@ -86,9 +89,11 @@ static void sci_stop_rx(struct uart_port *port);
86static int sci_request_irq(struct sci_port *port); 89static int sci_request_irq(struct sci_port *port);
87static void sci_free_irq(struct sci_port *port); 90static void sci_free_irq(struct sci_port *port);
88 91
89static struct sci_port sci_ports[SCI_NPORTS]; 92static struct sci_port sci_ports[];
90static struct uart_driver sci_uart_driver; 93static struct uart_driver sci_uart_driver;
91 94
95#define SCI_NPORTS sci_uart_driver.nr
96
92#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB) 97#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
93 98
94static void handle_error(struct uart_port *port) 99static void handle_error(struct uart_port *port)
@@ -168,7 +173,7 @@ static void put_string(struct sci_port *sci_port, const char *buffer, int count)
168 int usegdb=0; 173 int usegdb=0;
169 174
170#ifdef CONFIG_SH_STANDARD_BIOS 175#ifdef CONFIG_SH_STANDARD_BIOS
171 /* This call only does a trap the first time it is 176 /* This call only does a trap the first time it is
172 * called, and so is safe to do here unconditionally 177 * called, and so is safe to do here unconditionally
173 */ 178 */
174 usegdb |= sh_bios_in_gdb_mode(); 179 usegdb |= sh_bios_in_gdb_mode();
@@ -324,47 +329,46 @@ static void sci_init_pins_sci(struct uart_port* port, unsigned int cflag)
324 /* tx mark output*/ 329 /* tx mark output*/
325 H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx; 330 H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx;
326} 331}
327#else
328static void sci_init_pins_sci(struct uart_port *port, unsigned int cflag)
329{
330}
331#endif 332#endif
332#endif 333#endif
333 334
334#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF) 335#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF)
335#if defined(CONFIG_CPU_SH3) 336#if defined(CONFIG_CPU_SUBTYPE_SH7300)
336/* For SH7705, SH7707, SH7709, SH7709A, SH7729, SH7300*/ 337/* SH7300 doesn't use RTS/CTS */
338static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
339{
340 sci_out(port, SCFCR, 0);
341}
342#elif defined(CONFIG_CPU_SH3)
343/* For SH7705, SH7707, SH7709, SH7709A, SH7729 */
337static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) 344static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
338{ 345{
339 unsigned int fcr_val = 0; 346 unsigned int fcr_val = 0;
340#if !defined(CONFIG_CPU_SUBTYPE_SH7300) /* SH7300 doesn't use RTS/CTS */ 347 unsigned short data;
341 { 348
342 unsigned short data; 349 /* We need to set SCPCR to enable RTS/CTS */
350 data = ctrl_inw(SCPCR);
351 /* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/
352 ctrl_outw(data & 0x0fcf, SCPCR);
343 353
344 /* We need to set SCPCR to enable RTS/CTS */
345 data = ctrl_inw(SCPCR);
346 /* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/
347 ctrl_outw(data&0x0fcf, SCPCR);
348 }
349 if (cflag & CRTSCTS) 354 if (cflag & CRTSCTS)
350 fcr_val |= SCFCR_MCE; 355 fcr_val |= SCFCR_MCE;
351 else { 356 else {
352 unsigned short data;
353
354 /* We need to set SCPCR to enable RTS/CTS */ 357 /* We need to set SCPCR to enable RTS/CTS */
355 data = ctrl_inw(SCPCR); 358 data = ctrl_inw(SCPCR);
356 /* Clear out SCP7MD1,0, SCP4MD1,0, 359 /* Clear out SCP7MD1,0, SCP4MD1,0,
357 Set SCP6MD1,0 = {01} (output) */ 360 Set SCP6MD1,0 = {01} (output) */
358 ctrl_outw((data&0x0fcf)|0x1000, SCPCR); 361 ctrl_outw((data & 0x0fcf) | 0x1000, SCPCR);
359 362
360 data = ctrl_inb(SCPDR); 363 data = ctrl_inb(SCPDR);
361 /* Set /RTS2 (bit6) = 0 */ 364 /* Set /RTS2 (bit6) = 0 */
362 ctrl_outb(data&0xbf, SCPDR); 365 ctrl_outb(data & 0xbf, SCPDR);
363 } 366 }
364#endif 367
365 sci_out(port, SCFCR, fcr_val); 368 sci_out(port, SCFCR, fcr_val);
366} 369}
367 370
371#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
368static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag) 372static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag)
369{ 373{
370 unsigned int fcr_val = 0; 374 unsigned int fcr_val = 0;
@@ -374,7 +378,7 @@ static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag)
374 378
375 sci_out(port, SCFCR, fcr_val); 379 sci_out(port, SCFCR, fcr_val);
376} 380}
377 381#endif
378#else 382#else
379 383
380/* For SH7750 */ 384/* For SH7750 */
@@ -385,7 +389,11 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
385 if (cflag & CRTSCTS) { 389 if (cflag & CRTSCTS) {
386 fcr_val |= SCFCR_MCE; 390 fcr_val |= SCFCR_MCE;
387 } else { 391 } else {
392#ifdef CONFIG_CPU_SUBTYPE_SH7780
393 ctrl_outw(0x0080, SCSPTR0); /* Set RTS = 1 */
394#else
388 ctrl_outw(0x0080, SCSPTR2); /* Set RTS = 1 */ 395 ctrl_outw(0x0080, SCSPTR2); /* Set RTS = 1 */
396#endif
389 } 397 }
390 sci_out(port, SCFCR, fcr_val); 398 sci_out(port, SCFCR, fcr_val);
391} 399}
@@ -422,7 +430,11 @@ static void sci_transmit_chars(struct uart_port *port)
422 430
423#if !defined(SCI_ONLY) 431#if !defined(SCI_ONLY)
424 if (port->type == PORT_SCIF) { 432 if (port->type == PORT_SCIF) {
433#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780)
434 txroom = SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0x7f);
435#else
425 txroom = SCIF_TXROOM_MAX - (sci_in(port, SCFDR)>>8); 436 txroom = SCIF_TXROOM_MAX - (sci_in(port, SCFDR)>>8);
437#endif
426 } else { 438 } else {
427 txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0; 439 txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0;
428 } 440 }
@@ -491,7 +503,11 @@ static inline void sci_receive_chars(struct uart_port *port,
491 while (1) { 503 while (1) {
492#if !defined(SCI_ONLY) 504#if !defined(SCI_ONLY)
493 if (port->type == PORT_SCIF) { 505 if (port->type == PORT_SCIF) {
506#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780)
507 count = sci_in(port, SCRFDR) & 0x7f;
508#else
494 count = sci_in(port, SCFDR)&SCIF_RFDC_MASK ; 509 count = sci_in(port, SCFDR)&SCIF_RFDC_MASK ;
510#endif
495 } else { 511 } else {
496 count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0; 512 count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0;
497 } 513 }
@@ -652,7 +668,7 @@ static inline int sci_handle_breaks(struct uart_port *port)
652 struct tty_struct *tty = port->info->tty; 668 struct tty_struct *tty = port->info->tty;
653 struct sci_port *s = &sci_ports[port->line]; 669 struct sci_port *s = &sci_ports[port->line];
654 670
655 if (!s->break_flag && status & SCxSR_BRK(port)) 671 if (!s->break_flag && status & SCxSR_BRK(port)) {
656#if defined(CONFIG_CPU_SH3) 672#if defined(CONFIG_CPU_SH3)
657 /* Debounce break */ 673 /* Debounce break */
658 s->break_flag = 1; 674 s->break_flag = 1;
@@ -783,6 +799,7 @@ static int sci_notifier(struct notifier_block *self, unsigned long phase, void *
783 (phase == CPUFREQ_RESUMECHANGE)){ 799 (phase == CPUFREQ_RESUMECHANGE)){
784 for (i = 0; i < SCI_NPORTS; i++) { 800 for (i = 0; i < SCI_NPORTS; i++) {
785 struct uart_port *port = &sci_ports[i].port; 801 struct uart_port *port = &sci_ports[i].port;
802 struct clk *clk;
786 803
787 /* 804 /*
788 * Update the uartclk per-port if frequency has 805 * Update the uartclk per-port if frequency has
@@ -795,7 +812,9 @@ static int sci_notifier(struct notifier_block *self, unsigned long phase, void *
795 * 812 *
796 * Clean this up later.. 813 * Clean this up later..
797 */ 814 */
798 port->uartclk = current_cpu_data.module_clock * 16; 815 clk = clk_get("module_clk");
816 port->uartclk = clk_get_rate(clk) * 16;
817 clk_put(clk);
799 } 818 }
800 819
801 printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n", 820 printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n",
@@ -1008,15 +1027,20 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios,
1008 sci_out(port, SCSMR, smr_val); 1027 sci_out(port, SCSMR, smr_val);
1009 1028
1010 switch (baud) { 1029 switch (baud) {
1011 case 0: t = -1; break; 1030 case 0:
1012 case 2400: t = BPS_2400; break; 1031 t = -1;
1013 case 4800: t = BPS_4800; break; 1032 break;
1014 case 9600: t = BPS_9600; break; 1033 default:
1015 case 19200: t = BPS_19200; break; 1034 {
1016 case 38400: t = BPS_38400; break; 1035#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
1017 case 57600: t = BPS_57600; break; 1036 struct clk *clk = clk_get("module_clk");
1018 case 115200: t = BPS_115200; break; 1037 t = SCBRR_VALUE(baud, clk_get_rate(clk));
1019 default: t = SCBRR_VALUE(baud); break; 1038 clk_put(clk);
1039#else
1040 t = SCBRR_VALUE(baud);
1041#endif
1042 }
1043 break;
1020 } 1044 }
1021 1045
1022 if (t > 0) { 1046 if (t > 0) {
@@ -1030,7 +1054,9 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios,
1030 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */ 1054 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
1031 } 1055 }
1032 1056
1033 s->init_pins(port, termios->c_cflag); 1057 if (likely(s->init_pins))
1058 s->init_pins(port, termios->c_cflag);
1059
1034 sci_out(port, SCSCR, SCSCR_INIT(port)); 1060 sci_out(port, SCSCR, SCSCR_INIT(port));
1035 1061
1036 if ((termios->c_cflag & CREAD) != 0) 1062 if ((termios->c_cflag & CREAD) != 0)
@@ -1107,31 +1133,30 @@ static struct uart_ops sci_uart_ops = {
1107 .verify_port = sci_verify_port, 1133 .verify_port = sci_verify_port,
1108}; 1134};
1109 1135
1110static struct sci_port sci_ports[SCI_NPORTS] = { 1136static struct sci_port sci_ports[] = {
1111#if defined(CONFIG_CPU_SUBTYPE_SH7708) 1137#if defined(CONFIG_CPU_SUBTYPE_SH7708)
1112 { 1138 {
1113 .port = { 1139 .port = {
1114 .membase = (void *)0xfffffe80, 1140 .membase = (void *)0xfffffe80,
1115 .mapbase = 0xfffffe80, 1141 .mapbase = 0xfffffe80,
1116 .iotype = SERIAL_IO_MEM, 1142 .iotype = UPIO_MEM,
1117 .irq = 25, 1143 .irq = 25,
1118 .ops = &sci_uart_ops, 1144 .ops = &sci_uart_ops,
1119 .flags = ASYNC_BOOT_AUTOCONF, 1145 .flags = UPF_BOOT_AUTOCONF,
1120 .line = 0, 1146 .line = 0,
1121 }, 1147 },
1122 .type = PORT_SCI, 1148 .type = PORT_SCI,
1123 .irqs = SCI_IRQS, 1149 .irqs = SCI_IRQS,
1124 .init_pins = sci_init_pins_sci,
1125 }, 1150 },
1126#elif defined(CONFIG_CPU_SUBTYPE_SH7705) 1151#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
1127 { 1152 {
1128 .port = { 1153 .port = {
1129 .membase = (void *)SCIF0, 1154 .membase = (void *)SCIF0,
1130 .mapbase = SCIF0, 1155 .mapbase = SCIF0,
1131 .iotype = SERIAL_IO_MEM, 1156 .iotype = UPIO_MEM,
1132 .irq = 55, 1157 .irq = 55,
1133 .ops = &sci_uart_ops, 1158 .ops = &sci_uart_ops,
1134 .flags = ASYNC_BOOT_AUTOCONF, 1159 .flags = UPF_BOOT_AUTOCONF,
1135 .line = 0, 1160 .line = 0,
1136 }, 1161 },
1137 .type = PORT_SCIF, 1162 .type = PORT_SCIF,
@@ -1142,10 +1167,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1142 .port = { 1167 .port = {
1143 .membase = (void *)SCIF2, 1168 .membase = (void *)SCIF2,
1144 .mapbase = SCIF2, 1169 .mapbase = SCIF2,
1145 .iotype = SERIAL_IO_MEM, 1170 .iotype = UPIO_MEM,
1146 .irq = 59, 1171 .irq = 59,
1147 .ops = &sci_uart_ops, 1172 .ops = &sci_uart_ops,
1148 .flags = ASYNC_BOOT_AUTOCONF, 1173 .flags = UPF_BOOT_AUTOCONF,
1149 .line = 1, 1174 .line = 1,
1150 }, 1175 },
1151 .type = PORT_SCIF, 1176 .type = PORT_SCIF,
@@ -1157,24 +1182,23 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1157 .port = { 1182 .port = {
1158 .membase = (void *)0xfffffe80, 1183 .membase = (void *)0xfffffe80,
1159 .mapbase = 0xfffffe80, 1184 .mapbase = 0xfffffe80,
1160 .iotype = SERIAL_IO_MEM, 1185 .iotype = UPIO_MEM,
1161 .irq = 25, 1186 .irq = 25,
1162 .ops = &sci_uart_ops, 1187 .ops = &sci_uart_ops,
1163 .flags = ASYNC_BOOT_AUTOCONF, 1188 .flags = UPF_BOOT_AUTOCONF,
1164 .line = 0, 1189 .line = 0,
1165 }, 1190 },
1166 .type = PORT_SCI, 1191 .type = PORT_SCI,
1167 .irqs = SCI_IRQS, 1192 .irqs = SCI_IRQS,
1168 .init_pins = sci_init_pins_sci,
1169 }, 1193 },
1170 { 1194 {
1171 .port = { 1195 .port = {
1172 .membase = (void *)0xa4000150, 1196 .membase = (void *)0xa4000150,
1173 .mapbase = 0xa4000150, 1197 .mapbase = 0xa4000150,
1174 .iotype = SERIAL_IO_MEM, 1198 .iotype = UPIO_MEM,
1175 .irq = 59, 1199 .irq = 59,
1176 .ops = &sci_uart_ops, 1200 .ops = &sci_uart_ops,
1177 .flags = ASYNC_BOOT_AUTOCONF, 1201 .flags = UPF_BOOT_AUTOCONF,
1178 .line = 1, 1202 .line = 1,
1179 }, 1203 },
1180 .type = PORT_SCIF, 1204 .type = PORT_SCIF,
@@ -1185,10 +1209,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1185 .port = { 1209 .port = {
1186 .membase = (void *)0xa4000140, 1210 .membase = (void *)0xa4000140,
1187 .mapbase = 0xa4000140, 1211 .mapbase = 0xa4000140,
1188 .iotype = SERIAL_IO_MEM, 1212 .iotype = UPIO_MEM,
1189 .irq = 55, 1213 .irq = 55,
1190 .ops = &sci_uart_ops, 1214 .ops = &sci_uart_ops,
1191 .flags = ASYNC_BOOT_AUTOCONF, 1215 .flags = UPF_BOOT_AUTOCONF,
1192 .line = 2, 1216 .line = 2,
1193 }, 1217 },
1194 .type = PORT_IRDA, 1218 .type = PORT_IRDA,
@@ -1200,10 +1224,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1200 .port = { 1224 .port = {
1201 .membase = (void *)0xA4430000, 1225 .membase = (void *)0xA4430000,
1202 .mapbase = 0xA4430000, 1226 .mapbase = 0xA4430000,
1203 .iotype = SERIAL_IO_MEM, 1227 .iotype = UPIO_MEM,
1204 .irq = 25, 1228 .irq = 25,
1205 .ops = &sci_uart_ops, 1229 .ops = &sci_uart_ops,
1206 .flags = ASYNC_BOOT_AUTOCONF, 1230 .flags = UPF_BOOT_AUTOCONF,
1207 .line = 0, 1231 .line = 0,
1208 }, 1232 },
1209 .type = PORT_SCIF, 1233 .type = PORT_SCIF,
@@ -1215,25 +1239,25 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1215 .port = { 1239 .port = {
1216 .membase = (void *)0xffe00000, 1240 .membase = (void *)0xffe00000,
1217 .mapbase = 0xffe00000, 1241 .mapbase = 0xffe00000,
1218 .iotype = SERIAL_IO_MEM, 1242 .iotype = UPIO_MEM,
1219 .irq = 25, 1243 .irq = 25,
1220 .ops = &sci_uart_ops, 1244 .ops = &sci_uart_ops,
1221 .flags = ASYNC_BOOT_AUTOCONF, 1245 .flags = UPF_BOOT_AUTOCONF,
1222 .line = 0, 1246 .line = 0,
1223 }, 1247 },
1224 .type = PORT_SCIF, 1248 .type = PORT_SCIF,
1225 .irqs = SH73180_SCIF_IRQS, 1249 .irqs = SH73180_SCIF_IRQS,
1226 .init_pins = sci_init_pins_scif, 1250 .init_pins = sci_init_pins_scif,
1227 }, 1251 },
1228#elif defined(CONFIG_SH_RTS7751R2D) 1252#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
1229 { 1253 {
1230 .port = { 1254 .port = {
1231 .membase = (void *)0xffe80000, 1255 .membase = (void *)0xffe80000,
1232 .mapbase = 0xffe80000, 1256 .mapbase = 0xffe80000,
1233 .iotype = SERIAL_IO_MEM, 1257 .iotype = UPIO_MEM,
1234 .irq = 43, 1258 .irq = 43,
1235 .ops = &sci_uart_ops, 1259 .ops = &sci_uart_ops,
1236 .flags = ASYNC_BOOT_AUTOCONF, 1260 .flags = UPF_BOOT_AUTOCONF,
1237 .line = 0, 1261 .line = 0,
1238 }, 1262 },
1239 .type = PORT_SCIF, 1263 .type = PORT_SCIF,
@@ -1245,24 +1269,23 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1245 .port = { 1269 .port = {
1246 .membase = (void *)0xffe00000, 1270 .membase = (void *)0xffe00000,
1247 .mapbase = 0xffe00000, 1271 .mapbase = 0xffe00000,
1248 .iotype = SERIAL_IO_MEM, 1272 .iotype = UPIO_MEM,
1249 .irq = 25, 1273 .irq = 25,
1250 .ops = &sci_uart_ops, 1274 .ops = &sci_uart_ops,
1251 .flags = ASYNC_BOOT_AUTOCONF, 1275 .flags = UPF_BOOT_AUTOCONF,
1252 .line = 0, 1276 .line = 0,
1253 }, 1277 },
1254 .type = PORT_SCI, 1278 .type = PORT_SCI,
1255 .irqs = SCI_IRQS, 1279 .irqs = SCI_IRQS,
1256 .init_pins = sci_init_pins_sci,
1257 }, 1280 },
1258 { 1281 {
1259 .port = { 1282 .port = {
1260 .membase = (void *)0xffe80000, 1283 .membase = (void *)0xffe80000,
1261 .mapbase = 0xffe80000, 1284 .mapbase = 0xffe80000,
1262 .iotype = SERIAL_IO_MEM, 1285 .iotype = UPIO_MEM,
1263 .irq = 43, 1286 .irq = 43,
1264 .ops = &sci_uart_ops, 1287 .ops = &sci_uart_ops,
1265 .flags = ASYNC_BOOT_AUTOCONF, 1288 .flags = UPF_BOOT_AUTOCONF,
1266 .line = 1, 1289 .line = 1,
1267 }, 1290 },
1268 .type = PORT_SCIF, 1291 .type = PORT_SCIF,
@@ -1274,10 +1297,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1274 .port = { 1297 .port = {
1275 .membase = (void *)0xfe600000, 1298 .membase = (void *)0xfe600000,
1276 .mapbase = 0xfe600000, 1299 .mapbase = 0xfe600000,
1277 .iotype = SERIAL_IO_MEM, 1300 .iotype = UPIO_MEM,
1278 .irq = 55, 1301 .irq = 55,
1279 .ops = &sci_uart_ops, 1302 .ops = &sci_uart_ops,
1280 .flags = ASYNC_BOOT_AUTOCONF, 1303 .flags = UPF_BOOT_AUTOCONF,
1281 .line = 0, 1304 .line = 0,
1282 }, 1305 },
1283 .type = PORT_SCIF, 1306 .type = PORT_SCIF,
@@ -1288,10 +1311,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1288 .port = { 1311 .port = {
1289 .membase = (void *)0xfe610000, 1312 .membase = (void *)0xfe610000,
1290 .mapbase = 0xfe610000, 1313 .mapbase = 0xfe610000,
1291 .iotype = SERIAL_IO_MEM, 1314 .iotype = UPIO_MEM,
1292 .irq = 75, 1315 .irq = 75,
1293 .ops = &sci_uart_ops, 1316 .ops = &sci_uart_ops,
1294 .flags = ASYNC_BOOT_AUTOCONF, 1317 .flags = UPF_BOOT_AUTOCONF,
1295 .line = 1, 1318 .line = 1,
1296 }, 1319 },
1297 .type = PORT_SCIF, 1320 .type = PORT_SCIF,
@@ -1302,40 +1325,25 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1302 .port = { 1325 .port = {
1303 .membase = (void *)0xfe620000, 1326 .membase = (void *)0xfe620000,
1304 .mapbase = 0xfe620000, 1327 .mapbase = 0xfe620000,
1305 .iotype = SERIAL_IO_MEM, 1328 .iotype = UPIO_MEM,
1306 .irq = 79, 1329 .irq = 79,
1307 .ops = &sci_uart_ops, 1330 .ops = &sci_uart_ops,
1308 .flags = ASYNC_BOOT_AUTOCONF, 1331 .flags = UPF_BOOT_AUTOCONF,
1309 .line = 2, 1332 .line = 2,
1310 }, 1333 },
1311 .type = PORT_SCIF, 1334 .type = PORT_SCIF,
1312 .irqs = SH7760_SCIF2_IRQS, 1335 .irqs = SH7760_SCIF2_IRQS,
1313 .init_pins = sci_init_pins_scif, 1336 .init_pins = sci_init_pins_scif,
1314 }, 1337 },
1315#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
1316 {
1317 .port = {
1318 .membase = (void *)0xffe80000,
1319 .mapbase = 0xffe80000,
1320 .iotype = SERIAL_IO_MEM,
1321 .irq = 43,
1322 .ops = &sci_uart_ops,
1323 .flags = ASYNC_BOOT_AUTOCONF,
1324 .line = 0,
1325 },
1326 .type = PORT_SCIF,
1327 .irqs = SH4_SCIF_IRQS,
1328 .init_pins = sci_init_pins_scif,
1329 },
1330#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) 1338#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
1331 { 1339 {
1332 .port = { 1340 .port = {
1333 .membase = (void *)0xffe00000, 1341 .membase = (void *)0xffe00000,
1334 .mapbase = 0xffe00000, 1342 .mapbase = 0xffe00000,
1335 .iotype = SERIAL_IO_MEM, 1343 .iotype = UPIO_MEM,
1336 .irq = 26, 1344 .irq = 26,
1337 .ops = &sci_uart_ops, 1345 .ops = &sci_uart_ops,
1338 .flags = ASYNC_BOOT_AUTOCONF, 1346 .flags = UPF_BOOT_AUTOCONF,
1339 .line = 0, 1347 .line = 0,
1340 }, 1348 },
1341 .type = PORT_SCIF, 1349 .type = PORT_SCIF,
@@ -1346,10 +1354,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1346 .port = { 1354 .port = {
1347 .membase = (void *)0xffe80000, 1355 .membase = (void *)0xffe80000,
1348 .mapbase = 0xffe80000, 1356 .mapbase = 0xffe80000,
1349 .iotype = SERIAL_IO_MEM, 1357 .iotype = UPIO_MEM,
1350 .irq = 43, 1358 .irq = 43,
1351 .ops = &sci_uart_ops, 1359 .ops = &sci_uart_ops,
1352 .flags = ASYNC_BOOT_AUTOCONF, 1360 .flags = UPF_BOOT_AUTOCONF,
1353 .line = 1, 1361 .line = 1,
1354 }, 1362 },
1355 .type = PORT_SCIF, 1363 .type = PORT_SCIF,
@@ -1359,10 +1367,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1359#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) 1367#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
1360 { 1368 {
1361 .port = { 1369 .port = {
1362 .iotype = SERIAL_IO_MEM, 1370 .iotype = UPIO_MEM,
1363 .irq = 42, 1371 .irq = 42,
1364 .ops = &sci_uart_ops, 1372 .ops = &sci_uart_ops,
1365 .flags = ASYNC_BOOT_AUTOCONF, 1373 .flags = UPF_BOOT_AUTOCONF,
1366 .line = 0, 1374 .line = 0,
1367 }, 1375 },
1368 .type = PORT_SCIF, 1376 .type = PORT_SCIF,
@@ -1374,10 +1382,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1374 .port = { 1382 .port = {
1375 .membase = (void *)0x00ffffb0, 1383 .membase = (void *)0x00ffffb0,
1376 .mapbase = 0x00ffffb0, 1384 .mapbase = 0x00ffffb0,
1377 .iotype = SERIAL_IO_MEM, 1385 .iotype = UPIO_MEM,
1378 .irq = 54, 1386 .irq = 54,
1379 .ops = &sci_uart_ops, 1387 .ops = &sci_uart_ops,
1380 .flags = ASYNC_BOOT_AUTOCONF, 1388 .flags = UPF_BOOT_AUTOCONF,
1381 .line = 0, 1389 .line = 0,
1382 }, 1390 },
1383 .type = PORT_SCI, 1391 .type = PORT_SCI,
@@ -1388,10 +1396,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1388 .port = { 1396 .port = {
1389 .membase = (void *)0x00ffffb8, 1397 .membase = (void *)0x00ffffb8,
1390 .mapbase = 0x00ffffb8, 1398 .mapbase = 0x00ffffb8,
1391 .iotype = SERIAL_IO_MEM, 1399 .iotype = UPIO_MEM,
1392 .irq = 58, 1400 .irq = 58,
1393 .ops = &sci_uart_ops, 1401 .ops = &sci_uart_ops,
1394 .flags = ASYNC_BOOT_AUTOCONF, 1402 .flags = UPF_BOOT_AUTOCONF,
1395 .line = 1, 1403 .line = 1,
1396 }, 1404 },
1397 .type = PORT_SCI, 1405 .type = PORT_SCI,
@@ -1402,10 +1410,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1402 .port = { 1410 .port = {
1403 .membase = (void *)0x00ffffc0, 1411 .membase = (void *)0x00ffffc0,
1404 .mapbase = 0x00ffffc0, 1412 .mapbase = 0x00ffffc0,
1405 .iotype = SERIAL_IO_MEM, 1413 .iotype = UPIO_MEM,
1406 .irq = 62, 1414 .irq = 62,
1407 .ops = &sci_uart_ops, 1415 .ops = &sci_uart_ops,
1408 .flags = ASYNC_BOOT_AUTOCONF, 1416 .flags = UPF_BOOT_AUTOCONF,
1409 .line = 2, 1417 .line = 2,
1410 }, 1418 },
1411 .type = PORT_SCI, 1419 .type = PORT_SCI,
@@ -1417,10 +1425,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1417 .port = { 1425 .port = {
1418 .membase = (void *)0x00ffff78, 1426 .membase = (void *)0x00ffff78,
1419 .mapbase = 0x00ffff78, 1427 .mapbase = 0x00ffff78,
1420 .iotype = SERIAL_IO_MEM, 1428 .iotype = UPIO_MEM,
1421 .irq = 90, 1429 .irq = 90,
1422 .ops = &sci_uart_ops, 1430 .ops = &sci_uart_ops,
1423 .flags = ASYNC_BOOT_AUTOCONF, 1431 .flags = UPF_BOOT_AUTOCONF,
1424 .line = 0, 1432 .line = 0,
1425 }, 1433 },
1426 .type = PORT_SCI, 1434 .type = PORT_SCI,
@@ -1431,10 +1439,10 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1431 .port = { 1439 .port = {
1432 .membase = (void *)0x00ffff80, 1440 .membase = (void *)0x00ffff80,
1433 .mapbase = 0x00ffff80, 1441 .mapbase = 0x00ffff80,
1434 .iotype = SERIAL_IO_MEM, 1442 .iotype = UPIO_MEM,
1435 .irq = 94, 1443 .irq = 94,
1436 .ops = &sci_uart_ops, 1444 .ops = &sci_uart_ops,
1437 .flags = ASYNC_BOOT_AUTOCONF, 1445 .flags = UPF_BOOT_AUTOCONF,
1438 .line = 1, 1446 .line = 1,
1439 }, 1447 },
1440 .type = PORT_SCI, 1448 .type = PORT_SCI,
@@ -1445,16 +1453,88 @@ static struct sci_port sci_ports[SCI_NPORTS] = {
1445 .port = { 1453 .port = {
1446 .membase = (void *)0x00ffff88, 1454 .membase = (void *)0x00ffff88,
1447 .mapbase = 0x00ffff88, 1455 .mapbase = 0x00ffff88,
1448 .iotype = SERIAL_IO_MEM, 1456 .iotype = UPIO_MEM,
1449 .irq = 98, 1457 .irq = 98,
1450 .ops = &sci_uart_ops, 1458 .ops = &sci_uart_ops,
1451 .flags = ASYNC_BOOT_AUTOCONF, 1459 .flags = UPF_BOOT_AUTOCONF,
1452 .line = 2, 1460 .line = 2,
1453 }, 1461 },
1454 .type = PORT_SCI, 1462 .type = PORT_SCI,
1455 .irqs = H8S_SCI_IRQS2, 1463 .irqs = H8S_SCI_IRQS2,
1456 .init_pins = sci_init_pins_sci, 1464 .init_pins = sci_init_pins_sci,
1457 }, 1465 },
1466#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
1467 {
1468 .port = {
1469 .membase = (void *)0xff923000,
1470 .mapbase = 0xff923000,
1471 .iotype = SERIAL_IO_MEM,
1472 .irq = 61,
1473 .ops = &sci_uart_ops,
1474 .flags = ASYNC_BOOT_AUTOCONF,
1475 .line = 0,
1476 },
1477 .type = PORT_SCIF,
1478 .irqs = SH7770_SCIF0_IRQS,
1479 .init_pins = sci_init_pins_scif,
1480 },
1481 {
1482 .port = {
1483 .membase = (void *)0xff924000,
1484 .mapbase = 0xff924000,
1485 .iotype = SERIAL_IO_MEM,
1486 .irq = 62,
1487 .ops = &sci_uart_ops,
1488 .flags = ASYNC_BOOT_AUTOCONF,
1489 .line = 1,
1490 },
1491 .type = PORT_SCIF,
1492 .irqs = SH7770_SCIF1_IRQS,
1493 .init_pins = sci_init_pins_scif,
1494 },
1495 {
1496 .port = {
1497 .membase = (void *)0xff925000,
1498 .mapbase = 0xff925000,
1499 .iotype = SERIAL_IO_MEM,
1500 .irq = 63,
1501 .ops = &sci_uart_ops,
1502 .flags = ASYNC_BOOT_AUTOCONF,
1503 .line = 2,
1504 },
1505 .type = PORT_SCIF,
1506 .irqs = SH7770_SCIF2_IRQS,
1507 .init_pins = sci_init_pins_scif,
1508 },
1509#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
1510 {
1511 .port = {
1512 .membase = (void *)0xffe00000,
1513 .mapbase = 0xffe00000,
1514 .iotype = SERIAL_IO_MEM,
1515 .irq = 43,
1516 .ops = &sci_uart_ops,
1517 .flags = ASYNC_BOOT_AUTOCONF,
1518 .line = 0,
1519 },
1520 .type = PORT_SCIF,
1521 .irqs = SH7780_SCIF0_IRQS,
1522 .init_pins = sci_init_pins_scif,
1523 },
1524 {
1525 .port = {
1526 .membase = (void *)0xffe10000,
1527 .mapbase = 0xffe10000,
1528 .iotype = SERIAL_IO_MEM,
1529 .irq = 79,
1530 .ops = &sci_uart_ops,
1531 .flags = ASYNC_BOOT_AUTOCONF,
1532 .line = 1,
1533 },
1534 .type = PORT_SCIF,
1535 .irqs = SH7780_SCIF1_IRQS,
1536 .init_pins = sci_init_pins_scif,
1537 },
1458#else 1538#else
1459#error "CPU subtype not defined" 1539#error "CPU subtype not defined"
1460#endif 1540#endif
@@ -1480,9 +1560,6 @@ static int __init serial_console_setup(struct console *co, char *options)
1480 int flow = 'n'; 1560 int flow = 'n';
1481 int ret; 1561 int ret;
1482 1562
1483 if (co->index >= SCI_NPORTS)
1484 co->index = 0;
1485
1486 serial_console_port = &sci_ports[co->index]; 1563 serial_console_port = &sci_ports[co->index];
1487 port = &serial_console_port->port; 1564 port = &serial_console_port->port;
1488 port->type = serial_console_port->type; 1565 port->type = serial_console_port->type;
@@ -1496,14 +1573,21 @@ static int __init serial_console_setup(struct console *co, char *options)
1496 * We need to set the initial uartclk here, since otherwise it will 1573 * We need to set the initial uartclk here, since otherwise it will
1497 * only ever be setup at sci_init() time. 1574 * only ever be setup at sci_init() time.
1498 */ 1575 */
1499#if !defined(__H8300H__) && !defined(__H8300S__) 1576#if defined(__H8300H__) || defined(__H8300S__)
1500 port->uartclk = current_cpu_data.module_clock * 16;
1501#else
1502 port->uartclk = CONFIG_CPU_CLOCK; 1577 port->uartclk = CONFIG_CPU_CLOCK;
1503#endif 1578
1504#if defined(__H8300S__) 1579#if defined(__H8300S__)
1505 h8300_sci_enable(port, sci_enable); 1580 h8300_sci_enable(port, sci_enable);
1506#endif 1581#endif
1582#elif defined(CONFIG_SUPERH64)
1583 port->uartclk = current_cpu_info.module_clock * 16;
1584#else
1585 {
1586 struct clk *clk = clk_get("module_clk");
1587 port->uartclk = clk_get_rate(clk) * 16;
1588 clk_put(clk);
1589 }
1590#endif
1507 if (options) 1591 if (options)
1508 uart_parse_options(options, &baud, &parity, &bits, &flow); 1592 uart_parse_options(options, &baud, &parity, &bits, &flow);
1509 1593
@@ -1566,7 +1650,7 @@ int __init kgdb_console_setup(struct console *co, char *options)
1566 int parity = 'n'; 1650 int parity = 'n';
1567 int flow = 'n'; 1651 int flow = 'n';
1568 1652
1569 if (co->index >= SCI_NPORTS || co->index != kgdb_portnum) 1653 if (co->index != kgdb_portnum)
1570 co->index = kgdb_portnum; 1654 co->index = kgdb_portnum;
1571 1655
1572 if (options) 1656 if (options)
@@ -1606,7 +1690,7 @@ console_initcall(kgdb_console_init);
1606#elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE) 1690#elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
1607#define SCI_CONSOLE &serial_console 1691#define SCI_CONSOLE &serial_console
1608#else 1692#else
1609#define SCI_CONSOLE 0 1693#define SCI_CONSOLE 0
1610#endif 1694#endif
1611 1695
1612static char banner[] __initdata = 1696static char banner[] __initdata =
@@ -1621,7 +1705,6 @@ static struct uart_driver sci_uart_driver = {
1621 .dev_name = "ttySC", 1705 .dev_name = "ttySC",
1622 .major = SCI_MAJOR, 1706 .major = SCI_MAJOR,
1623 .minor = SCI_MINOR_START, 1707 .minor = SCI_MINOR_START,
1624 .nr = SCI_NPORTS,
1625 .cons = SCI_CONSOLE, 1708 .cons = SCI_CONSOLE,
1626}; 1709};
1627 1710
@@ -1631,15 +1714,21 @@ static int __init sci_init(void)
1631 1714
1632 printk("%s", banner); 1715 printk("%s", banner);
1633 1716
1717 sci_uart_driver.nr = ARRAY_SIZE(sci_ports);
1718
1634 ret = uart_register_driver(&sci_uart_driver); 1719 ret = uart_register_driver(&sci_uart_driver);
1635 if (ret == 0) { 1720 if (ret == 0) {
1636 for (chan = 0; chan < SCI_NPORTS; chan++) { 1721 for (chan = 0; chan < SCI_NPORTS; chan++) {
1637 struct sci_port *sciport = &sci_ports[chan]; 1722 struct sci_port *sciport = &sci_ports[chan];
1638 1723
1639#if !defined(__H8300H__) && !defined(__H8300S__) 1724#if defined(__H8300H__) || defined(__H8300S__)
1640 sciport->port.uartclk = (current_cpu_data.module_clock * 16);
1641#else
1642 sciport->port.uartclk = CONFIG_CPU_CLOCK; 1725 sciport->port.uartclk = CONFIG_CPU_CLOCK;
1726#elif defined(CONFIG_SUPERH64)
1727 sciport->port.uartclk = current_cpu_info.module_clock * 16;
1728#else
1729 struct clk *clk = clk_get("module_clk");
1730 sciport->port.uartclk = clk_get_rate(clk) * 16;
1731 clk_put(clk);
1643#endif 1732#endif
1644 uart_add_one_port(&sci_uart_driver, &sciport->port); 1733 uart_add_one_port(&sci_uart_driver, &sciport->port);
1645 sciport->break_timer.data = (unsigned long)sciport; 1734 sciport->break_timer.data = (unsigned long)sciport;
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 2892169eff05..1f14bb4382f6 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -46,14 +46,17 @@
46#define H8S_SCI_IRQS1 {92, 93, 94, 0 } 46#define H8S_SCI_IRQS1 {92, 93, 94, 0 }
47#define H8S_SCI_IRQS2 {96, 97, 98, 0 } 47#define H8S_SCI_IRQS2 {96, 97, 98, 0 }
48#define SH5_SCIF_IRQS {39, 40, 42, 0 } 48#define SH5_SCIF_IRQS {39, 40, 42, 0 }
49#define SH7770_SCIF0_IRQS {61, 61, 61, 61 }
50#define SH7770_SCIF1_IRQS {62, 62, 62, 62 }
51#define SH7770_SCIF2_IRQS {63, 63, 63, 63 }
52#define SH7780_SCIF0_IRQS {40, 41, 43, 42 }
53#define SH7780_SCIF1_IRQS {76, 77, 79, 78 }
49 54
50#if defined(CONFIG_CPU_SUBTYPE_SH7708) 55#if defined(CONFIG_CPU_SUBTYPE_SH7708)
51# define SCI_NPORTS 1
52# define SCSPTR 0xffffff7c /* 8 bit */ 56# define SCSPTR 0xffffff7c /* 8 bit */
53# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 57# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
54# define SCI_ONLY 58# define SCI_ONLY
55#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) 59#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
56# define SCI_NPORTS 3
57# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */ 60# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */
58# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */ 61# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */
59# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 62# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
@@ -61,9 +64,8 @@
61#elif defined(CONFIG_CPU_SUBTYPE_SH7705) 64#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
62# define SCIF0 0xA4400000 65# define SCIF0 0xA4400000
63# define SCIF2 0xA4410000 66# define SCIF2 0xA4410000
64# define SCSMR_Ir 0xA44A0000 67# define SCSMR_Ir 0xA44A0000
65# define IRDA_SCIF SCIF0 68# define IRDA_SCIF SCIF0
66# define SCI_NPORTS 2
67# define SCPCR 0xA4000116 69# define SCPCR 0xA4000116
68# define SCPDR 0xA4000136 70# define SCPDR 0xA4000136
69 71
@@ -74,14 +76,11 @@
74# define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 76# define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0
75# define SCIF_ONLY 77# define SCIF_ONLY
76#elif defined(CONFIG_SH_RTS7751R2D) 78#elif defined(CONFIG_SH_RTS7751R2D)
77# define SCI_NPORTS 1
78# define SCSPTR1 0xffe0001c /* 8 bit SCI */
79# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ 79# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
80# define SCIF_ORER 0x0001 /* overrun error bit */ 80# define SCIF_ORER 0x0001 /* overrun error bit */
81# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 81# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
82# define SCIF_ONLY 82# define SCIF_ONLY
83#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) 83#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
84# define SCI_NPORTS 2
85# define SCSPTR1 0xffe0001c /* 8 bit SCI */ 84# define SCSPTR1 0xffe0001c /* 8 bit SCI */
86# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ 85# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
87# define SCIF_ORER 0x0001 /* overrun error bit */ 86# define SCIF_ORER 0x0001 /* overrun error bit */
@@ -90,34 +89,29 @@
90 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ ) 89 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ )
91# define SCI_AND_SCIF 90# define SCI_AND_SCIF
92#elif defined(CONFIG_CPU_SUBTYPE_SH7760) 91#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
93# define SCI_NPORTS 3 92# define SCSPTR0 0xfe600024 /* 16 bit SCIF */
94# define SCSPTR0 0xfe600000 /* 16 bit SCIF */ 93# define SCSPTR1 0xfe610024 /* 16 bit SCIF */
95# define SCSPTR1 0xfe610000 /* 16 bit SCIF */ 94# define SCSPTR2 0xfe620024 /* 16 bit SCIF */
96# define SCSPTR2 0xfe620000 /* 16 bit SCIF */
97# define SCIF_ORER 0x0001 /* overrun error bit */ 95# define SCIF_ORER 0x0001 /* overrun error bit */
98# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 96# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
99# define SCIF_ONLY 97# define SCIF_ONLY
100#elif defined(CONFIG_CPU_SUBTYPE_SH7300) 98#elif defined(CONFIG_CPU_SUBTYPE_SH7300)
101# define SCI_NPORTS 1
102# define SCPCR 0xA4050116 /* 16 bit SCIF */ 99# define SCPCR 0xA4050116 /* 16 bit SCIF */
103# define SCPDR 0xA4050136 /* 16 bit SCIF */ 100# define SCPDR 0xA4050136 /* 16 bit SCIF */
104# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ 101# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
105# define SCIF_ONLY 102# define SCIF_ONLY
106#elif defined(CONFIG_CPU_SUBTYPE_SH73180) 103#elif defined(CONFIG_CPU_SUBTYPE_SH73180)
107# define SCI_NPORTS 1
108# define SCPDR 0xA4050138 /* 16 bit SCIF */ 104# define SCPDR 0xA4050138 /* 16 bit SCIF */
109# define SCSPTR2 SCPDR 105# define SCSPTR2 SCPDR
110# define SCIF_ORER 0x0001 /* overrun error bit */ 106# define SCIF_ORER 0x0001 /* overrun error bit */
111# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */ 107# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */
112# define SCIF_ONLY 108# define SCIF_ONLY
113#elif defined(CONFIG_CPU_SUBTYPE_SH4_202) 109#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
114# define SCI_NPORTS 1
115# define SCSPTR2 0xffe80020 /* 16 bit SCIF */ 110# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
116# define SCIF_ORER 0x0001 /* overrun error bit */ 111# define SCIF_ORER 0x0001 /* overrun error bit */
117# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 112# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
118# define SCIF_ONLY 113# define SCIF_ONLY
119#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) 114#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
120# define SCI_NPORTS 2
121# define SCSPTR1 0xffe00020 /* 16 bit SCIF */ 115# define SCSPTR1 0xffe00020 /* 16 bit SCIF */
122# define SCSPTR2 0xffe80020 /* 16 bit SCIF */ 116# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
123# define SCIF_ORER 0x0001 /* overrun error bit */ 117# define SCIF_ORER 0x0001 /* overrun error bit */
@@ -129,26 +123,32 @@
129# define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR 123# define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR
130# define SCIF_PTR2_OFFS 0x0000020 124# define SCIF_PTR2_OFFS 0x0000020
131# define SCIF_LSR2_OFFS 0x0000024 125# define SCIF_LSR2_OFFS 0x0000024
132# define SCI_NPORTS 1
133# define SCI_INIT { \
134 { {}, PORT_SCIF, 0, \
135 SH5_SCIF_IRQS, sci_init_pins_scif } \
136}
137# define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */ 126# define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */
138# define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */ 127# define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */
139# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, 128# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,
140 TE=1,RE=1,REIE=1 */ 129 TE=1,RE=1,REIE=1 */
141# define SCIF_ONLY 130# define SCIF_ONLY
142#elif defined(CONFIG_H83007) || defined(CONFIG_H83068) 131#elif defined(CONFIG_H83007) || defined(CONFIG_H83068)
143# define SCI_NPORTS 3
144# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 132# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
145# define SCI_ONLY 133# define SCI_ONLY
146# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) 134# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
147#elif defined(CONFIG_H8S2678) 135#elif defined(CONFIG_H8S2678)
148# define SCI_NPORTS 3
149# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 136# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
150# define SCI_ONLY 137# define SCI_ONLY
151# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) 138# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
139#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
140# define SCSPTR0 0xff923020 /* 16 bit SCIF */
141# define SCSPTR1 0xff924020 /* 16 bit SCIF */
142# define SCSPTR2 0xff925020 /* 16 bit SCIF */
143# define SCIF_ORER 0x0001 /* overrun error bit */
144# define SCSCR_INIT(port) 0x3c /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,cke=2 */
145# define SCIF_ONLY
146#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
147# define SCSPTR0 0xffe00024 /* 16 bit SCIF */
148# define SCSPTR1 0xffe10024 /* 16 bit SCIF */
149# define SCIF_OPER 0x0001 /* Overrun error bit */
150# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
151# define SCIF_ONLY
152#else 152#else
153# error CPU subtype not defined 153# error CPU subtype not defined
154#endif 154#endif
@@ -158,7 +158,7 @@
158#define SCI_CTRL_FLAGS_RIE 0x40 /* all */ 158#define SCI_CTRL_FLAGS_RIE 0x40 /* all */
159#define SCI_CTRL_FLAGS_TE 0x20 /* all */ 159#define SCI_CTRL_FLAGS_TE 0x20 /* all */
160#define SCI_CTRL_FLAGS_RE 0x10 /* all */ 160#define SCI_CTRL_FLAGS_RE 0x10 /* all */
161#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) 161#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7780)
162#define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ 162#define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */
163#else 163#else
164#define SCI_CTRL_FLAGS_REIE 0 164#define SCI_CTRL_FLAGS_REIE 0
@@ -213,7 +213,7 @@
213# define SCxSR_RDxF_CLEAR(port) 0xbc 213# define SCxSR_RDxF_CLEAR(port) 0xbc
214# define SCxSR_ERROR_CLEAR(port) 0xc4 214# define SCxSR_ERROR_CLEAR(port) 0xc4
215# define SCxSR_TDxE_CLEAR(port) 0x78 215# define SCxSR_TDxE_CLEAR(port) 0x78
216# define SCxSR_BREAK_CLEAR(port) 0xc4 216# define SCxSR_BREAK_CLEAR(port) 0xc4
217#elif defined(SCIF_ONLY) 217#elif defined(SCIF_ONLY)
218# define SCxSR_TEND(port) SCIF_TEND 218# define SCxSR_TEND(port) SCIF_TEND
219# define SCxSR_ERRORS(port) SCIF_ERRORS 219# define SCxSR_ERRORS(port) SCIF_ERRORS
@@ -237,7 +237,7 @@
237# define SCxSR_RDxF_CLEAR(port) 0x00fc 237# define SCxSR_RDxF_CLEAR(port) 0x00fc
238# define SCxSR_ERROR_CLEAR(port) 0x0073 238# define SCxSR_ERROR_CLEAR(port) 0x0073
239# define SCxSR_TDxE_CLEAR(port) 0x00df 239# define SCxSR_TDxE_CLEAR(port) 0x00df
240# define SCxSR_BREAK_CLEAR(port) 0x00e3 240# define SCxSR_BREAK_CLEAR(port) 0x00e3
241#endif 241#endif
242#else 242#else
243# define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) 243# define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
@@ -285,14 +285,14 @@ struct sci_port {
285 285
286#define SCI_IN(size, offset) \ 286#define SCI_IN(size, offset) \
287 unsigned int addr = port->mapbase + (offset); \ 287 unsigned int addr = port->mapbase + (offset); \
288 if ((size) == 8) { \ 288 if ((size) == 8) { \
289 return ctrl_inb(addr); \ 289 return ctrl_inb(addr); \
290 } else { \ 290 } else { \
291 return ctrl_inw(addr); \ 291 return ctrl_inw(addr); \
292 } 292 }
293#define SCI_OUT(size, offset, value) \ 293#define SCI_OUT(size, offset, value) \
294 unsigned int addr = port->mapbase + (offset); \ 294 unsigned int addr = port->mapbase + (offset); \
295 if ((size) == 8) { \ 295 if ((size) == 8) { \
296 ctrl_outb(value, addr); \ 296 ctrl_outb(value, addr); \
297 } else { \ 297 } else { \
298 ctrl_outw(value, addr); \ 298 ctrl_outw(value, addr); \
@@ -301,10 +301,10 @@ struct sci_port {
301#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ 301#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
302 static inline unsigned int sci_##name##_in(struct uart_port *port) \ 302 static inline unsigned int sci_##name##_in(struct uart_port *port) \
303 { \ 303 { \
304 if (port->type == PORT_SCI) { \ 304 if (port->type == PORT_SCI) { \
305 SCI_IN(sci_size, sci_offset) \ 305 SCI_IN(sci_size, sci_offset) \
306 } else { \ 306 } else { \
307 SCI_IN(scif_size, scif_offset); \ 307 SCI_IN(scif_size, scif_offset); \
308 } \ 308 } \
309 } \ 309 } \
310 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ 310 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
@@ -319,7 +319,7 @@ struct sci_port {
319#define CPU_SCIF_FNS(name, scif_offset, scif_size) \ 319#define CPU_SCIF_FNS(name, scif_offset, scif_size) \
320 static inline unsigned int sci_##name##_in(struct uart_port *port) \ 320 static inline unsigned int sci_##name##_in(struct uart_port *port) \
321 { \ 321 { \
322 SCI_IN(scif_size, scif_offset); \ 322 SCI_IN(scif_size, scif_offset); \
323 } \ 323 } \
324 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ 324 static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \
325 { \ 325 { \
@@ -329,7 +329,7 @@ struct sci_port {
329#define CPU_SCI_FNS(name, sci_offset, sci_size) \ 329#define CPU_SCI_FNS(name, sci_offset, sci_size) \
330 static inline unsigned int sci_##name##_in(struct uart_port* port) \ 330 static inline unsigned int sci_##name##_in(struct uart_port* port) \
331 { \ 331 { \
332 SCI_IN(sci_size, sci_offset); \ 332 SCI_IN(sci_size, sci_offset); \
333 } \ 333 } \
334 static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \ 334 static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \
335 { \ 335 { \
@@ -385,10 +385,17 @@ SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8)
385SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8) 385SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
386SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) 386SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
387SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) 387SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
388#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780)
389SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
390SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
391SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
392SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
393#else
388SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) 394SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
389SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) 395SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
390SCIF_FNS(SCLSR, 0, 0, 0x24, 16) 396SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
391#endif 397#endif
398#endif
392#define sci_in(port, reg) sci_##reg##_in(port) 399#define sci_in(port, reg) sci_##reg##_in(port)
393#define sci_out(port, reg, value) sci_##reg##_out(port, value) 400#define sci_out(port, reg, value) sci_##reg##_out(port, value)
394 401
@@ -518,6 +525,24 @@ static inline int sci_rxd_in(struct uart_port *port)
518 int ch = (port->mapbase - SMR0) >> 3; 525 int ch = (port->mapbase - SMR0) >> 3;
519 return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0; 526 return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0;
520} 527}
528#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
529static inline int sci_rxd_in(struct uart_port *port)
530{
531 if (port->mapbase == 0xff923000)
532 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
533 if (port->mapbase == 0xff924000)
534 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
535 if (port->mapbase == 0xff925000)
536 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
537}
538#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
539static inline int sci_rxd_in(struct uart_port *port)
540{
541 if (port->mapbase == 0xffe00000)
542 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
543 if (port->mapbase == 0xffe10000)
544 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
545}
521#endif 546#endif
522 547
523/* 548/*
@@ -552,22 +577,15 @@ static inline int sci_rxd_in(struct uart_port *port)
552 * -- Mitch Davis - 15 Jul 2000 577 * -- Mitch Davis - 15 Jul 2000
553 */ 578 */
554 579
555#define PCLK (current_cpu_data.module_clock) 580#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7780)
556 581#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1)
557#if defined(CONFIG_CPU_SUBTYPE_SH7300)
558#define SCBRR_VALUE(bps) ((PCLK+16*bps)/(16*bps)-1)
559#elif defined(CONFIG_CPU_SUBTYPE_SH7705) 582#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
560#define SCBRR_VALUE(bps) (((PCLK*2)+16*bps)/(32*bps)-1) 583#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
561#elif !defined(__H8300H__) && !defined(__H8300S__) 584#elif defined(__H8300H__) || defined(__H8300S__)
562#define SCBRR_VALUE(bps) ((PCLK+16*bps)/(32*bps)-1)
563#else
564#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1) 585#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1)
586#elif defined(CONFIG_SUPERH64)
587#define SCBRR_VALUE(bps) ((current_cpu_data.module_clock+16*bps)/(32*bps)-1)
588#else /* Generic SH */
589#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1)
565#endif 590#endif
566#define BPS_2400 SCBRR_VALUE(2400)
567#define BPS_4800 SCBRR_VALUE(4800)
568#define BPS_9600 SCBRR_VALUE(9600)
569#define BPS_19200 SCBRR_VALUE(19200)
570#define BPS_38400 SCBRR_VALUE(38400)
571#define BPS_57600 SCBRR_VALUE(57600)
572#define BPS_115200 SCBRR_VALUE(115200)
573 591
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 9a3665b34d97..bc67442c6b4c 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -669,7 +669,7 @@ static int sunsu_startup(struct uart_port *port)
669 * if it is, then bail out, because there's likely no UART 669 * if it is, then bail out, because there's likely no UART
670 * here. 670 * here.
671 */ 671 */
672 if (!(up->port.flags & ASYNC_BUGGY_UART) && 672 if (!(up->port.flags & UPF_BUGGY_UART) &&
673 (serial_inp(up, UART_LSR) == 0xff)) { 673 (serial_inp(up, UART_LSR) == 0xff)) {
674 printk("ttyS%d: LSR safety check engaged!\n", up->port.line); 674 printk("ttyS%d: LSR safety check engaged!\n", up->port.line);
675 return -ENODEV; 675 return -ENODEV;
@@ -707,7 +707,7 @@ static int sunsu_startup(struct uart_port *port)
707 up->ier = UART_IER_RLSI | UART_IER_RDI; 707 up->ier = UART_IER_RLSI | UART_IER_RDI;
708 serial_outp(up, UART_IER, up->ier); 708 serial_outp(up, UART_IER, up->ier);
709 709
710 if (up->port.flags & ASYNC_FOURPORT) { 710 if (up->port.flags & UPF_FOURPORT) {
711 unsigned int icp; 711 unsigned int icp;
712 /* 712 /*
713 * Enable interrupts on the AST Fourport board 713 * Enable interrupts on the AST Fourport board
@@ -740,7 +740,7 @@ static void sunsu_shutdown(struct uart_port *port)
740 serial_outp(up, UART_IER, 0); 740 serial_outp(up, UART_IER, 0);
741 741
742 spin_lock_irqsave(&up->port.lock, flags); 742 spin_lock_irqsave(&up->port.lock, flags);
743 if (up->port.flags & ASYNC_FOURPORT) { 743 if (up->port.flags & UPF_FOURPORT) {
744 /* reset interrupts on the AST Fourport board */ 744 /* reset interrupts on the AST Fourport board */
745 inb((up->port.iobase & 0xfe0) | 0x1f); 745 inb((up->port.iobase & 0xfe0) | 0x1f);
746 up->port.mctrl |= TIOCM_OUT1; 746 up->port.mctrl |= TIOCM_OUT1;
@@ -1132,7 +1132,7 @@ ebus_done:
1132 1132
1133 spin_lock_irqsave(&up->port.lock, flags); 1133 spin_lock_irqsave(&up->port.lock, flags);
1134 1134
1135 if (!(up->port.flags & ASYNC_BUGGY_UART)) { 1135 if (!(up->port.flags & UPF_BUGGY_UART)) {
1136 /* 1136 /*
1137 * Do a simple existence test first; if we fail this, there's 1137 * Do a simple existence test first; if we fail this, there's
1138 * no point trying anything else. 1138 * no point trying anything else.
@@ -1170,7 +1170,7 @@ ebus_done:
1170 * manufacturer would be stupid enough to design a board 1170 * manufacturer would be stupid enough to design a board
1171 * that conflicts with COM 1-4 --- we hope! 1171 * that conflicts with COM 1-4 --- we hope!
1172 */ 1172 */
1173 if (!(up->port.flags & ASYNC_SKIP_TEST)) { 1173 if (!(up->port.flags & UPF_SKIP_TEST)) {
1174 serial_outp(up, UART_MCR, UART_MCR_LOOP | 0x0A); 1174 serial_outp(up, UART_MCR, UART_MCR_LOOP | 0x0A);
1175 status1 = serial_inp(up, UART_MSR) & 0xF0; 1175 status1 = serial_inp(up, UART_MSR) & 0xF0;
1176 serial_outp(up, UART_MCR, save_mcr); 1176 serial_outp(up, UART_MCR, save_mcr);
@@ -1371,7 +1371,7 @@ static __inline__ void wait_for_xmitr(struct uart_sunsu_port *up)
1371 } while ((status & BOTH_EMPTY) != BOTH_EMPTY); 1371 } while ((status & BOTH_EMPTY) != BOTH_EMPTY);
1372 1372
1373 /* Wait up to 1s for flow control if necessary */ 1373 /* Wait up to 1s for flow control if necessary */
1374 if (up->port.flags & ASYNC_CONS_FLOW) { 1374 if (up->port.flags & UPF_CONS_FLOW) {
1375 tmout = 1000000; 1375 tmout = 1000000;
1376 while (--tmout && 1376 while (--tmout &&
1377 ((serial_in(up, UART_MSR) & UART_MSR_CTS) == 0)) 1377 ((serial_in(up, UART_MSR) & UART_MSR_CTS) == 0))
@@ -1513,7 +1513,7 @@ static int __init sunsu_serial_init(void)
1513 up->su_type == SU_PORT_KBD) 1513 up->su_type == SU_PORT_KBD)
1514 continue; 1514 continue;
1515 1515
1516 up->port.flags |= ASYNC_BOOT_AUTOCONF; 1516 up->port.flags |= UPF_BOOT_AUTOCONF;
1517 up->port.type = PORT_UNKNOWN; 1517 up->port.type = PORT_UNKNOWN;
1518 up->port.uartclk = (SU_BASE_BAUD * 16); 1518 up->port.uartclk = (SU_BASE_BAUD * 16);
1519 1519
diff --git a/drivers/sn/ioc3.c b/drivers/sn/ioc3.c
index aaa009f4a7bf..c70ae81b5d98 100644
--- a/drivers/sn/ioc3.c
+++ b/drivers/sn/ioc3.c
@@ -843,9 +843,9 @@ MODULE_AUTHOR("Stanislaw Skowronek <skylark@linux-mips.org>");
843MODULE_DESCRIPTION("PCI driver for SGI IOC3"); 843MODULE_DESCRIPTION("PCI driver for SGI IOC3");
844MODULE_LICENSE("GPL"); 844MODULE_LICENSE("GPL");
845 845
846EXPORT_SYMBOL(ioc3_register_submodule); 846EXPORT_SYMBOL_GPL(ioc3_register_submodule);
847EXPORT_SYMBOL(ioc3_unregister_submodule); 847EXPORT_SYMBOL_GPL(ioc3_unregister_submodule);
848EXPORT_SYMBOL(ioc3_ack); 848EXPORT_SYMBOL_GPL(ioc3_ack);
849EXPORT_SYMBOL(ioc3_gpcr_set); 849EXPORT_SYMBOL_GPL(ioc3_gpcr_set);
850EXPORT_SYMBOL(ioc3_disable); 850EXPORT_SYMBOL_GPL(ioc3_disable);
851EXPORT_SYMBOL(ioc3_enable); 851EXPORT_SYMBOL_GPL(ioc3_enable);
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index f6704688ee8c..5578a9dd04e8 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -3558,10 +3558,16 @@ static void ixj_write_frame(IXJ *j)
3558 } 3558 }
3559 /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */ 3559 /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */
3560 if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) { 3560 if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
3561 if(j->write_buffer_rp + cnt == 0 && j->write_buffer_rp + cnt + 1 == 0 && j->write_buffer_rp + cnt + 2 == 0 && 3561 if (j->write_buffer_rp[cnt] == 0 &&
3562 j->write_buffer_rp + cnt + 3 == 0 && j->write_buffer_rp + cnt + 4 == 0 && j->write_buffer_rp + cnt + 5 == 0 && 3562 j->write_buffer_rp[cnt + 1] == 0 &&
3563 j->write_buffer_rp + cnt + 6 == 0 && j->write_buffer_rp + cnt + 7 == 0 && j->write_buffer_rp + cnt + 8 == 0 && 3563 j->write_buffer_rp[cnt + 2] == 0 &&
3564 j->write_buffer_rp + cnt + 9 == 0) { 3564 j->write_buffer_rp[cnt + 3] == 0 &&
3565 j->write_buffer_rp[cnt + 4] == 0 &&
3566 j->write_buffer_rp[cnt + 5] == 0 &&
3567 j->write_buffer_rp[cnt + 6] == 0 &&
3568 j->write_buffer_rp[cnt + 7] == 0 &&
3569 j->write_buffer_rp[cnt + 8] == 0 &&
3570 j->write_buffer_rp[cnt + 9] == 0) {
3565 /* someone is trying to write silence lets make this a type 0 frame. */ 3571 /* someone is trying to write silence lets make this a type 0 frame. */
3566 outb_p(0x00, j->DSPbase + 0x0C); 3572 outb_p(0x00, j->DSPbase + 0x0C);
3567 outb_p(0x00, j->DSPbase + 0x0D); 3573 outb_p(0x00, j->DSPbase + 0x0D);
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 3639c3f8d357..36e476dd9123 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_USB_XPAD) += input/
38 38
39obj-$(CONFIG_USB_DABUSB) += media/ 39obj-$(CONFIG_USB_DABUSB) += media/
40obj-$(CONFIG_USB_DSBR) += media/ 40obj-$(CONFIG_USB_DSBR) += media/
41obj-$(CONFIG_USB_ET61X251) += media/
41obj-$(CONFIG_USB_IBMCAM) += media/ 42obj-$(CONFIG_USB_IBMCAM) += media/
42obj-$(CONFIG_USB_KONICAWC) += media/ 43obj-$(CONFIG_USB_KONICAWC) += media/
43obj-$(CONFIG_USB_OV511) += media/ 44obj-$(CONFIG_USB_OV511) += media/
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index af0a41e7870e..04631dcbabbc 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -36,6 +36,7 @@
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/device.h> /* FIXME: linux/firmware.h should include it itself */ 37#include <linux/device.h> /* FIXME: linux/firmware.h should include it itself */
38#include <linux/firmware.h> 38#include <linux/firmware.h>
39#include <linux/mutex.h>
39 40
40#include "usbatm.h" 41#include "usbatm.h"
41 42
@@ -160,7 +161,7 @@ struct cxacru_data {
160 struct work_struct poll_work; 161 struct work_struct poll_work;
161 162
162 /* contol handles */ 163 /* contol handles */
163 struct semaphore cm_serialize; 164 struct mutex cm_serialize;
164 u8 *rcv_buf; 165 u8 *rcv_buf;
165 u8 *snd_buf; 166 u8 *snd_buf;
166 struct urb *rcv_urb; 167 struct urb *rcv_urb;
@@ -219,7 +220,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
219 goto fail; 220 goto fail;
220 } 221 }
221 222
222 down(&instance->cm_serialize); 223 mutex_lock(&instance->cm_serialize);
223 224
224 /* submit reading urb before the writing one */ 225 /* submit reading urb before the writing one */
225 init_completion(&instance->rcv_done); 226 init_completion(&instance->rcv_done);
@@ -288,7 +289,7 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
288 ret = offd; 289 ret = offd;
289 dbg("cm %#x", cm); 290 dbg("cm %#x", cm);
290fail: 291fail:
291 up(&instance->cm_serialize); 292 mutex_unlock(&instance->cm_serialize);
292 return ret; 293 return ret;
293} 294}
294 295
@@ -352,7 +353,6 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
352 struct atm_dev *atm_dev) 353 struct atm_dev *atm_dev)
353{ 354{
354 struct cxacru_data *instance = usbatm_instance->driver_data; 355 struct cxacru_data *instance = usbatm_instance->driver_data;
355 struct device *dev = &usbatm_instance->usb_intf->dev;
356 /* 356 /*
357 struct atm_dev *atm_dev = usbatm_instance->atm_dev; 357 struct atm_dev *atm_dev = usbatm_instance->atm_dev;
358 */ 358 */
@@ -364,14 +364,14 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
364 ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_MAC_ADDRESS, NULL, 0, 364 ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_MAC_ADDRESS, NULL, 0,
365 atm_dev->esi, sizeof(atm_dev->esi)); 365 atm_dev->esi, sizeof(atm_dev->esi));
366 if (ret < 0) { 366 if (ret < 0) {
367 dev_err(dev, "cxacru_atm_start: CARD_GET_MAC_ADDRESS returned %d\n", ret); 367 atm_err(usbatm_instance, "cxacru_atm_start: CARD_GET_MAC_ADDRESS returned %d\n", ret);
368 return ret; 368 return ret;
369 } 369 }
370 370
371 /* start ADSL */ 371 /* start ADSL */
372 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0); 372 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
373 if (ret < 0) { 373 if (ret < 0) {
374 dev_err(dev, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret); 374 atm_err(usbatm_instance, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret);
375 return ret; 375 return ret;
376 } 376 }
377 377
@@ -383,13 +383,13 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
383static void cxacru_poll_status(struct cxacru_data *instance) 383static void cxacru_poll_status(struct cxacru_data *instance)
384{ 384{
385 u32 buf[CXINF_MAX] = {}; 385 u32 buf[CXINF_MAX] = {};
386 struct device *dev = &instance->usbatm->usb_intf->dev; 386 struct usbatm_data *usbatm = instance->usbatm;
387 struct atm_dev *atm_dev = instance->usbatm->atm_dev; 387 struct atm_dev *atm_dev = usbatm->atm_dev;
388 int ret; 388 int ret;
389 389
390 ret = cxacru_cm_get_array(instance, CM_REQUEST_CARD_INFO_GET, buf, CXINF_MAX); 390 ret = cxacru_cm_get_array(instance, CM_REQUEST_CARD_INFO_GET, buf, CXINF_MAX);
391 if (ret < 0) { 391 if (ret < 0) {
392 dev_warn(dev, "poll status: error %d\n", ret); 392 atm_warn(usbatm, "poll status: error %d\n", ret);
393 goto reschedule; 393 goto reschedule;
394 } 394 }
395 395
@@ -400,50 +400,50 @@ static void cxacru_poll_status(struct cxacru_data *instance)
400 switch (instance->line_status) { 400 switch (instance->line_status) {
401 case 0: 401 case 0:
402 atm_dev->signal = ATM_PHY_SIG_LOST; 402 atm_dev->signal = ATM_PHY_SIG_LOST;
403 dev_info(dev, "ADSL line: down\n"); 403 atm_info(usbatm, "ADSL line: down\n");
404 break; 404 break;
405 405
406 case 1: 406 case 1:
407 atm_dev->signal = ATM_PHY_SIG_LOST; 407 atm_dev->signal = ATM_PHY_SIG_LOST;
408 dev_info(dev, "ADSL line: attemtping to activate\n"); 408 atm_info(usbatm, "ADSL line: attempting to activate\n");
409 break; 409 break;
410 410
411 case 2: 411 case 2:
412 atm_dev->signal = ATM_PHY_SIG_LOST; 412 atm_dev->signal = ATM_PHY_SIG_LOST;
413 dev_info(dev, "ADSL line: training\n"); 413 atm_info(usbatm, "ADSL line: training\n");
414 break; 414 break;
415 415
416 case 3: 416 case 3:
417 atm_dev->signal = ATM_PHY_SIG_LOST; 417 atm_dev->signal = ATM_PHY_SIG_LOST;
418 dev_info(dev, "ADSL line: channel analysis\n"); 418 atm_info(usbatm, "ADSL line: channel analysis\n");
419 break; 419 break;
420 420
421 case 4: 421 case 4:
422 atm_dev->signal = ATM_PHY_SIG_LOST; 422 atm_dev->signal = ATM_PHY_SIG_LOST;
423 dev_info(dev, "ADSL line: exchange\n"); 423 atm_info(usbatm, "ADSL line: exchange\n");
424 break; 424 break;
425 425
426 case 5: 426 case 5:
427 atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424; 427 atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424;
428 atm_dev->signal = ATM_PHY_SIG_FOUND; 428 atm_dev->signal = ATM_PHY_SIG_FOUND;
429 429
430 dev_info(dev, "ADSL line: up (%d kb/s down | %d kb/s up)\n", 430 atm_info(usbatm, "ADSL line: up (%d kb/s down | %d kb/s up)\n",
431 buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]); 431 buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]);
432 break; 432 break;
433 433
434 case 6: 434 case 6:
435 atm_dev->signal = ATM_PHY_SIG_LOST; 435 atm_dev->signal = ATM_PHY_SIG_LOST;
436 dev_info(dev, "ADSL line: waiting\n"); 436 atm_info(usbatm, "ADSL line: waiting\n");
437 break; 437 break;
438 438
439 case 7: 439 case 7:
440 atm_dev->signal = ATM_PHY_SIG_LOST; 440 atm_dev->signal = ATM_PHY_SIG_LOST;
441 dev_info(dev, "ADSL line: initializing\n"); 441 atm_info(usbatm, "ADSL line: initializing\n");
442 break; 442 break;
443 443
444 default: 444 default:
445 atm_dev->signal = ATM_PHY_SIG_UNKNOWN; 445 atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
446 dev_info(dev, "Unknown line state %02x\n", instance->line_status); 446 atm_info(usbatm, "Unknown line state %02x\n", instance->line_status);
447 break; 447 break;
448 } 448 }
449reschedule: 449reschedule:
@@ -504,8 +504,8 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
504{ 504{
505 int ret; 505 int ret;
506 int off; 506 int off;
507 struct usb_device *usb_dev = instance->usbatm->usb_dev; 507 struct usbatm_data *usbatm = instance->usbatm;
508 struct device *dev = &instance->usbatm->usb_intf->dev; 508 struct usb_device *usb_dev = usbatm->usb_dev;
509 u16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct }; 509 u16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct };
510 u32 val; 510 u32 val;
511 511
@@ -515,7 +515,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
515 val = cpu_to_le32(instance->modem_type->pll_f_clk); 515 val = cpu_to_le32(instance->modem_type->pll_f_clk);
516 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLFCLK_ADDR, (u8 *) &val, 4); 516 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLFCLK_ADDR, (u8 *) &val, 4);
517 if (ret) { 517 if (ret) {
518 dev_err(dev, "FirmwarePllFClkValue failed: %d\n", ret); 518 usb_err(usbatm, "FirmwarePllFClkValue failed: %d\n", ret);
519 return; 519 return;
520 } 520 }
521 521
@@ -523,7 +523,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
523 val = cpu_to_le32(instance->modem_type->pll_b_clk); 523 val = cpu_to_le32(instance->modem_type->pll_b_clk);
524 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLBCLK_ADDR, (u8 *) &val, 4); 524 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLBCLK_ADDR, (u8 *) &val, 4);
525 if (ret) { 525 if (ret) {
526 dev_err(dev, "FirmwarePllBClkValue failed: %d\n", ret); 526 usb_err(usbatm, "FirmwarePllBClkValue failed: %d\n", ret);
527 return; 527 return;
528 } 528 }
529 529
@@ -531,14 +531,14 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
531 val = cpu_to_le32(SDRAM_ENA); 531 val = cpu_to_le32(SDRAM_ENA);
532 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SDRAMEN_ADDR, (u8 *) &val, 4); 532 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SDRAMEN_ADDR, (u8 *) &val, 4);
533 if (ret) { 533 if (ret) {
534 dev_err(dev, "Enable SDRAM failed: %d\n", ret); 534 usb_err(usbatm, "Enable SDRAM failed: %d\n", ret);
535 return; 535 return;
536 } 536 }
537 537
538 /* Firmware */ 538 /* Firmware */
539 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size); 539 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size);
540 if (ret) { 540 if (ret) {
541 dev_err(dev, "Firmware upload failed: %d\n", ret); 541 usb_err(usbatm, "Firmware upload failed: %d\n", ret);
542 return; 542 return;
543 } 543 }
544 544
@@ -546,7 +546,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
546 if (instance->modem_type->boot_rom_patch) { 546 if (instance->modem_type->boot_rom_patch) {
547 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size); 547 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size);
548 if (ret) { 548 if (ret) {
549 dev_err(dev, "Boot ROM patching failed: %d\n", ret); 549 usb_err(usbatm, "Boot ROM patching failed: %d\n", ret);
550 return; 550 return;
551 } 551 }
552 } 552 }
@@ -554,7 +554,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
554 /* Signature */ 554 /* Signature */
555 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SIG_ADDR, (u8 *) signature, 4); 555 ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SIG_ADDR, (u8 *) signature, 4);
556 if (ret) { 556 if (ret) {
557 dev_err(dev, "Signature storing failed: %d\n", ret); 557 usb_err(usbatm, "Signature storing failed: %d\n", ret);
558 return; 558 return;
559 } 559 }
560 560
@@ -566,7 +566,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
566 ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0); 566 ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0);
567 } 567 }
568 if (ret) { 568 if (ret) {
569 dev_err(dev, "Passing control to firmware failed: %d\n", ret); 569 usb_err(usbatm, "Passing control to firmware failed: %d\n", ret);
570 return; 570 return;
571 } 571 }
572 572
@@ -580,7 +580,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
580 580
581 ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0); 581 ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0);
582 if (ret < 0) { 582 if (ret < 0) {
583 dev_err(dev, "modem failed to initialize: %d\n", ret); 583 usb_err(usbatm, "modem failed to initialize: %d\n", ret);
584 return; 584 return;
585 } 585 }
586 586
@@ -597,7 +597,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
597 ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET, 597 ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET,
598 (u8 *) buf, len, NULL, 0); 598 (u8 *) buf, len, NULL, 0);
599 if (ret < 0) { 599 if (ret < 0) {
600 dev_err(dev, "load config data failed: %d\n", ret); 600 usb_err(usbatm, "load config data failed: %d\n", ret);
601 return; 601 return;
602 } 602 }
603 } 603 }
@@ -608,18 +608,19 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
608static int cxacru_find_firmware(struct cxacru_data *instance, 608static int cxacru_find_firmware(struct cxacru_data *instance,
609 char* phase, const struct firmware **fw_p) 609 char* phase, const struct firmware **fw_p)
610{ 610{
611 struct device *dev = &instance->usbatm->usb_intf->dev; 611 struct usbatm_data *usbatm = instance->usbatm;
612 struct device *dev = &usbatm->usb_intf->dev;
612 char buf[16]; 613 char buf[16];
613 614
614 sprintf(buf, "cxacru-%s.bin", phase); 615 sprintf(buf, "cxacru-%s.bin", phase);
615 dbg("cxacru_find_firmware: looking for %s", buf); 616 dbg("cxacru_find_firmware: looking for %s", buf);
616 617
617 if (request_firmware(fw_p, buf, dev)) { 618 if (request_firmware(fw_p, buf, dev)) {
618 dev_dbg(dev, "no stage %s firmware found\n", phase); 619 usb_dbg(usbatm, "no stage %s firmware found\n", phase);
619 return -ENOENT; 620 return -ENOENT;
620 } 621 }
621 622
622 dev_info(dev, "found firmware %s\n", buf); 623 usb_info(usbatm, "found firmware %s\n", buf);
623 624
624 return 0; 625 return 0;
625} 626}
@@ -627,20 +628,19 @@ static int cxacru_find_firmware(struct cxacru_data *instance,
627static int cxacru_heavy_init(struct usbatm_data *usbatm_instance, 628static int cxacru_heavy_init(struct usbatm_data *usbatm_instance,
628 struct usb_interface *usb_intf) 629 struct usb_interface *usb_intf)
629{ 630{
630 struct device *dev = &usbatm_instance->usb_intf->dev;
631 const struct firmware *fw, *bp, *cf; 631 const struct firmware *fw, *bp, *cf;
632 struct cxacru_data *instance = usbatm_instance->driver_data; 632 struct cxacru_data *instance = usbatm_instance->driver_data;
633 633
634 int ret = cxacru_find_firmware(instance, "fw", &fw); 634 int ret = cxacru_find_firmware(instance, "fw", &fw);
635 if (ret) { 635 if (ret) {
636 dev_warn(dev, "firmware (cxacru-fw.bin) unavailable (hotplug misconfiguration?)\n"); 636 usb_warn(usbatm_instance, "firmware (cxacru-fw.bin) unavailable (system misconfigured?)\n");
637 return ret; 637 return ret;
638 } 638 }
639 639
640 if (instance->modem_type->boot_rom_patch) { 640 if (instance->modem_type->boot_rom_patch) {
641 ret = cxacru_find_firmware(instance, "bp", &bp); 641 ret = cxacru_find_firmware(instance, "bp", &bp);
642 if (ret) { 642 if (ret) {
643 dev_warn(dev, "boot ROM patch (cxacru-bp.bin) unavailable (hotplug misconfiguration?)\n"); 643 usb_warn(usbatm_instance, "boot ROM patch (cxacru-bp.bin) unavailable (system misconfigured?)\n");
644 release_firmware(fw); 644 release_firmware(fw);
645 return ret; 645 return ret;
646 } 646 }
@@ -667,22 +667,19 @@ static int cxacru_heavy_init(struct usbatm_data *usbatm_instance,
667} 667}
668 668
669static int cxacru_bind(struct usbatm_data *usbatm_instance, 669static int cxacru_bind(struct usbatm_data *usbatm_instance,
670 struct usb_interface *intf, const struct usb_device_id *id, 670 struct usb_interface *intf, const struct usb_device_id *id)
671 int *need_heavy_init)
672{ 671{
673 struct cxacru_data *instance; 672 struct cxacru_data *instance;
674 struct usb_device *usb_dev = interface_to_usbdev(intf); 673 struct usb_device *usb_dev = interface_to_usbdev(intf);
675 int ret; 674 int ret;
676 675
677 /* instance init */ 676 /* instance init */
678 instance = kmalloc(sizeof(*instance), GFP_KERNEL); 677 instance = kzalloc(sizeof(*instance), GFP_KERNEL);
679 if (!instance) { 678 if (!instance) {
680 dbg("cxacru_bind: no memory for instance data"); 679 dbg("cxacru_bind: no memory for instance data");
681 return -ENOMEM; 680 return -ENOMEM;
682 } 681 }
683 682
684 memset(instance, 0, sizeof(*instance));
685
686 instance->usbatm = usbatm_instance; 683 instance->usbatm = usbatm_instance;
687 instance->modem_type = (struct cxacru_modem_type *) id->driver_info; 684 instance->modem_type = (struct cxacru_modem_type *) id->driver_info;
688 685
@@ -721,13 +718,13 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
721 instance->snd_buf, PAGE_SIZE, 718 instance->snd_buf, PAGE_SIZE,
722 cxacru_blocking_completion, &instance->snd_done, 4); 719 cxacru_blocking_completion, &instance->snd_done, 4);
723 720
724 init_MUTEX(&instance->cm_serialize); 721 mutex_init(&instance->cm_serialize);
725 722
726 INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance); 723 INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance);
727 724
728 usbatm_instance->driver_data = instance; 725 usbatm_instance->driver_data = instance;
729 726
730 *need_heavy_init = cxacru_card_status(instance); 727 usbatm_instance->flags = (cxacru_card_status(instance) ? 0 : UDSL_SKIP_HEAVY_INIT);
731 728
732 return 0; 729 return 0;
733 730
@@ -787,12 +784,12 @@ static const struct usb_device_id cxacru_usb_ids[] = {
787 { /* V = Conexant P = ADSL modem (Hasbani project) */ 784 { /* V = Conexant P = ADSL modem (Hasbani project) */
788 USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00 785 USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00
789 }, 786 },
790 { /* V = Conexant P = ADSL modem (Well PTI-800 */
791 USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00
792 },
793 { /* V = Conexant P = ADSL modem */ 787 { /* V = Conexant P = ADSL modem */
794 USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00 788 USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00
795 }, 789 },
790 { /* V = Conexant P = ADSL modem (Well PTI-800) */
791 USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00
792 },
796 { /* V = Conexant P = ADSL modem */ 793 { /* V = Conexant P = ADSL modem */
797 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00 794 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00
798 }, 795 },
@@ -835,14 +832,13 @@ static const struct usb_device_id cxacru_usb_ids[] = {
835MODULE_DEVICE_TABLE(usb, cxacru_usb_ids); 832MODULE_DEVICE_TABLE(usb, cxacru_usb_ids);
836 833
837static struct usbatm_driver cxacru_driver = { 834static struct usbatm_driver cxacru_driver = {
838 .owner = THIS_MODULE,
839 .driver_name = cxacru_driver_name, 835 .driver_name = cxacru_driver_name,
840 .bind = cxacru_bind, 836 .bind = cxacru_bind,
841 .heavy_init = cxacru_heavy_init, 837 .heavy_init = cxacru_heavy_init,
842 .unbind = cxacru_unbind, 838 .unbind = cxacru_unbind,
843 .atm_start = cxacru_atm_start, 839 .atm_start = cxacru_atm_start,
844 .in = CXACRU_EP_DATA, 840 .bulk_in = CXACRU_EP_DATA,
845 .out = CXACRU_EP_DATA, 841 .bulk_out = CXACRU_EP_DATA,
846 .rx_padding = 3, 842 .rx_padding = 3,
847 .tx_padding = 11, 843 .tx_padding = 11,
848}; 844};
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index c1b47d74e206..7860c8a5800d 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -35,12 +35,14 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/stat.h> 36#include <linux/stat.h>
37#include <linux/timer.h> 37#include <linux/timer.h>
38#include <linux/types.h>
39#include <linux/usb_ch9.h>
38#include <linux/workqueue.h> 40#include <linux/workqueue.h>
39 41
40#include "usbatm.h" 42#include "usbatm.h"
41 43
42#define DRIVER_AUTHOR "Johan Verrept, Duncan Sands <duncan.sands@free.fr>" 44#define DRIVER_AUTHOR "Johan Verrept, Duncan Sands <duncan.sands@free.fr>"
43#define DRIVER_VERSION "1.9" 45#define DRIVER_VERSION "1.10"
44#define DRIVER_DESC "Alcatel SpeedTouch USB driver version " DRIVER_VERSION 46#define DRIVER_DESC "Alcatel SpeedTouch USB driver version " DRIVER_VERSION
45 47
46static const char speedtch_driver_name[] = "speedtch"; 48static const char speedtch_driver_name[] = "speedtch";
@@ -66,31 +68,42 @@ static const char speedtch_driver_name[] = "speedtch";
66 68
67#define RESUBMIT_DELAY 1000 /* milliseconds */ 69#define RESUBMIT_DELAY 1000 /* milliseconds */
68 70
69#define DEFAULT_ALTSETTING 1 71#define DEFAULT_BULK_ALTSETTING 1
72#define DEFAULT_ISOC_ALTSETTING 2
70#define DEFAULT_DL_512_FIRST 0 73#define DEFAULT_DL_512_FIRST 0
74#define DEFAULT_ENABLE_ISOC 0
71#define DEFAULT_SW_BUFFERING 0 75#define DEFAULT_SW_BUFFERING 0
72 76
73static int altsetting = DEFAULT_ALTSETTING; 77static unsigned int altsetting = 0; /* zero means: use the default */
74static int dl_512_first = DEFAULT_DL_512_FIRST; 78static int dl_512_first = DEFAULT_DL_512_FIRST;
79static int enable_isoc = DEFAULT_ENABLE_ISOC;
75static int sw_buffering = DEFAULT_SW_BUFFERING; 80static int sw_buffering = DEFAULT_SW_BUFFERING;
76 81
77module_param(altsetting, int, S_IRUGO | S_IWUSR); 82module_param(altsetting, uint, S_IRUGO | S_IWUSR);
78MODULE_PARM_DESC(altsetting, 83MODULE_PARM_DESC(altsetting,
79 "Alternative setting for data interface (default: " 84 "Alternative setting for data interface (bulk_default: "
80 __MODULE_STRING(DEFAULT_ALTSETTING) ")"); 85 __MODULE_STRING(DEFAULT_BULK_ALTSETTING) "; isoc_default: "
86 __MODULE_STRING(DEFAULT_ISOC_ALTSETTING) ")");
81 87
82module_param(dl_512_first, bool, S_IRUGO | S_IWUSR); 88module_param(dl_512_first, bool, S_IRUGO | S_IWUSR);
83MODULE_PARM_DESC(dl_512_first, 89MODULE_PARM_DESC(dl_512_first,
84 "Read 512 bytes before sending firmware (default: " 90 "Read 512 bytes before sending firmware (default: "
85 __MODULE_STRING(DEFAULT_DL_512_FIRST) ")"); 91 __MODULE_STRING(DEFAULT_DL_512_FIRST) ")");
86 92
93module_param(enable_isoc, bool, S_IRUGO | S_IWUSR);
94MODULE_PARM_DESC(enable_isoc,
95 "Use isochronous transfers if available (default: "
96 __MODULE_STRING(DEFAULT_ENABLE_ISOC) ")");
97
87module_param(sw_buffering, bool, S_IRUGO | S_IWUSR); 98module_param(sw_buffering, bool, S_IRUGO | S_IWUSR);
88MODULE_PARM_DESC(sw_buffering, 99MODULE_PARM_DESC(sw_buffering,
89 "Enable software buffering (default: " 100 "Enable software buffering (default: "
90 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")"); 101 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")");
91 102
103#define INTERFACE_DATA 1
92#define ENDPOINT_INT 0x81 104#define ENDPOINT_INT 0x81
93#define ENDPOINT_DATA 0x07 105#define ENDPOINT_BULK_DATA 0x07
106#define ENDPOINT_ISOC_DATA 0x07
94#define ENDPOINT_FIRMWARE 0x05 107#define ENDPOINT_FIRMWARE 0x05
95 108
96#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) ) 109#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) )
@@ -98,6 +111,8 @@ MODULE_PARM_DESC(sw_buffering,
98struct speedtch_instance_data { 111struct speedtch_instance_data {
99 struct usbatm_data *usbatm; 112 struct usbatm_data *usbatm;
100 113
114 unsigned int altsetting;
115
101 struct work_struct status_checker; 116 struct work_struct status_checker;
102 117
103 unsigned char last_status; 118 unsigned char last_status;
@@ -205,7 +220,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
205 buffer, 0x200, &actual_length, 2000); 220 buffer, 0x200, &actual_length, 2000);
206 221
207 if (ret < 0 && ret != -ETIMEDOUT) 222 if (ret < 0 && ret != -ETIMEDOUT)
208 usb_dbg(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret); 223 usb_warn(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret);
209 else 224 else
210 usb_dbg(usbatm, "%s: BLOCK0 downloaded (%d bytes)\n", __func__, ret); 225 usb_dbg(usbatm, "%s: BLOCK0 downloaded (%d bytes)\n", __func__, ret);
211 } 226 }
@@ -219,7 +234,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
219 buffer, thislen, &actual_length, DATA_TIMEOUT); 234 buffer, thislen, &actual_length, DATA_TIMEOUT);
220 235
221 if (ret < 0) { 236 if (ret < 0) {
222 usb_dbg(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret); 237 usb_err(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret);
223 goto out_free; 238 goto out_free;
224 } 239 }
225 usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size); 240 usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size);
@@ -232,7 +247,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
232 buffer, 0x200, &actual_length, DATA_TIMEOUT); 247 buffer, 0x200, &actual_length, DATA_TIMEOUT);
233 248
234 if (ret < 0) { 249 if (ret < 0) {
235 usb_dbg(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret); 250 usb_err(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret);
236 goto out_free; 251 goto out_free;
237 } 252 }
238 usb_dbg(usbatm, "%s: BLOCK2 downloaded (%d bytes)\n", __func__, actual_length); 253 usb_dbg(usbatm, "%s: BLOCK2 downloaded (%d bytes)\n", __func__, actual_length);
@@ -246,7 +261,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
246 buffer, thislen, &actual_length, DATA_TIMEOUT); 261 buffer, thislen, &actual_length, DATA_TIMEOUT);
247 262
248 if (ret < 0) { 263 if (ret < 0) {
249 usb_dbg(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret); 264 usb_err(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret);
250 goto out_free; 265 goto out_free;
251 } 266 }
252 } 267 }
@@ -259,7 +274,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
259 buffer, 0x200, &actual_length, DATA_TIMEOUT); 274 buffer, 0x200, &actual_length, DATA_TIMEOUT);
260 275
261 if (ret < 0) { 276 if (ret < 0) {
262 usb_dbg(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret); 277 usb_err(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret);
263 goto out_free; 278 goto out_free;
264 } 279 }
265 280
@@ -270,6 +285,11 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
270 because we're in our own kernel thread anyway. */ 285 because we're in our own kernel thread anyway. */
271 msleep_interruptible(1000); 286 msleep_interruptible(1000);
272 287
288 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) {
289 usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->altsetting, ret);
290 goto out_free;
291 }
292
273 /* Enable software buffering, if requested */ 293 /* Enable software buffering, if requested */
274 if (sw_buffering) 294 if (sw_buffering)
275 speedtch_set_swbuff(instance, 1); 295 speedtch_set_swbuff(instance, 1);
@@ -285,8 +305,8 @@ out:
285 return ret; 305 return ret;
286} 306}
287 307
288static int speedtch_find_firmware(struct usb_interface *intf, int phase, 308static int speedtch_find_firmware(struct usbatm_data *usbatm, struct usb_interface *intf,
289 const struct firmware **fw_p) 309 int phase, const struct firmware **fw_p)
290{ 310{
291 struct device *dev = &intf->dev; 311 struct device *dev = &intf->dev;
292 const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice); 312 const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice);
@@ -295,24 +315,24 @@ static int speedtch_find_firmware(struct usb_interface *intf, int phase,
295 char buf[24]; 315 char buf[24];
296 316
297 sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision); 317 sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision);
298 dev_dbg(dev, "%s: looking for %s\n", __func__, buf); 318 usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
299 319
300 if (request_firmware(fw_p, buf, dev)) { 320 if (request_firmware(fw_p, buf, dev)) {
301 sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision); 321 sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision);
302 dev_dbg(dev, "%s: looking for %s\n", __func__, buf); 322 usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
303 323
304 if (request_firmware(fw_p, buf, dev)) { 324 if (request_firmware(fw_p, buf, dev)) {
305 sprintf(buf, "speedtch-%d.bin", phase); 325 sprintf(buf, "speedtch-%d.bin", phase);
306 dev_dbg(dev, "%s: looking for %s\n", __func__, buf); 326 usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
307 327
308 if (request_firmware(fw_p, buf, dev)) { 328 if (request_firmware(fw_p, buf, dev)) {
309 dev_warn(dev, "no stage %d firmware found!\n", phase); 329 usb_err(usbatm, "%s: no stage %d firmware found!\n", __func__, phase);
310 return -ENOENT; 330 return -ENOENT;
311 } 331 }
312 } 332 }
313 } 333 }
314 334
315 dev_info(dev, "found stage %d firmware %s\n", phase, buf); 335 usb_info(usbatm, "found stage %d firmware %s\n", phase, buf);
316 336
317 return 0; 337 return 0;
318} 338}
@@ -323,15 +343,16 @@ static int speedtch_heavy_init(struct usbatm_data *usbatm, struct usb_interface
323 struct speedtch_instance_data *instance = usbatm->driver_data; 343 struct speedtch_instance_data *instance = usbatm->driver_data;
324 int ret; 344 int ret;
325 345
326 if ((ret = speedtch_find_firmware(intf, 1, &fw1)) < 0) 346 if ((ret = speedtch_find_firmware(usbatm, intf, 1, &fw1)) < 0)
327 return ret; 347 return ret;
328 348
329 if ((ret = speedtch_find_firmware(intf, 2, &fw2)) < 0) { 349 if ((ret = speedtch_find_firmware(usbatm, intf, 2, &fw2)) < 0) {
330 release_firmware(fw1); 350 release_firmware(fw1);
331 return ret; 351 return ret;
332 } 352 }
333 353
334 ret = speedtch_upload_firmware(instance, fw1, fw2); 354 if ((ret = speedtch_upload_firmware(instance, fw1, fw2)) < 0)
355 usb_err(usbatm, "%s: firmware upload failed (%d)!\n", __func__, ret);
335 356
336 release_firmware(fw2); 357 release_firmware(fw2);
337 release_firmware(fw1); 358 release_firmware(fw1);
@@ -428,7 +449,9 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
428 int down_speed, up_speed, ret; 449 int down_speed, up_speed, ret;
429 unsigned char status; 450 unsigned char status;
430 451
452#ifdef VERBOSE_DEBUG
431 atm_dbg(usbatm, "%s entered\n", __func__); 453 atm_dbg(usbatm, "%s entered\n", __func__);
454#endif
432 455
433 ret = speedtch_read_status(instance); 456 ret = speedtch_read_status(instance);
434 if (ret < 0) { 457 if (ret < 0) {
@@ -441,9 +464,9 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
441 464
442 status = buf[OFFSET_7]; 465 status = buf[OFFSET_7];
443 466
444 atm_dbg(usbatm, "%s: line state %02x\n", __func__, status);
445
446 if ((status != instance->last_status) || !status) { 467 if ((status != instance->last_status) || !status) {
468 atm_dbg(usbatm, "%s: line state 0x%02x\n", __func__, status);
469
447 switch (status) { 470 switch (status) {
448 case 0: 471 case 0:
449 atm_dev->signal = ATM_PHY_SIG_LOST; 472 atm_dev->signal = ATM_PHY_SIG_LOST;
@@ -484,7 +507,7 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
484 507
485 default: 508 default:
486 atm_dev->signal = ATM_PHY_SIG_UNKNOWN; 509 atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
487 atm_info(usbatm, "Unknown line state %02x\n", status); 510 atm_info(usbatm, "unknown line state %02x\n", status);
488 break; 511 break;
489 } 512 }
490 513
@@ -583,11 +606,6 @@ static int speedtch_atm_start(struct usbatm_data *usbatm, struct atm_dev *atm_de
583 606
584 atm_dbg(usbatm, "%s entered\n", __func__); 607 atm_dbg(usbatm, "%s entered\n", __func__);
585 608
586 if ((ret = usb_set_interface(usb_dev, 1, altsetting)) < 0) {
587 atm_dbg(usbatm, "%s: usb_set_interface returned %d!\n", __func__, ret);
588 return ret;
589 }
590
591 /* Set MAC address, it is stored in the serial number */ 609 /* Set MAC address, it is stored in the serial number */
592 memset(atm_dev->esi, 0, sizeof(atm_dev->esi)); 610 memset(atm_dev->esi, 0, sizeof(atm_dev->esi));
593 if (usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, mac_str, sizeof(mac_str)) == 12) { 611 if (usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, mac_str, sizeof(mac_str)) == 12) {
@@ -678,20 +696,27 @@ static void speedtch_release_interfaces(struct usb_device *usb_dev, int num_inte
678 696
679static int speedtch_bind(struct usbatm_data *usbatm, 697static int speedtch_bind(struct usbatm_data *usbatm,
680 struct usb_interface *intf, 698 struct usb_interface *intf,
681 const struct usb_device_id *id, 699 const struct usb_device_id *id)
682 int *need_heavy_init)
683{ 700{
684 struct usb_device *usb_dev = interface_to_usbdev(intf); 701 struct usb_device *usb_dev = interface_to_usbdev(intf);
685 struct usb_interface *cur_intf; 702 struct usb_interface *cur_intf, *data_intf;
686 struct speedtch_instance_data *instance; 703 struct speedtch_instance_data *instance;
687 int ifnum = intf->altsetting->desc.bInterfaceNumber; 704 int ifnum = intf->altsetting->desc.bInterfaceNumber;
688 int num_interfaces = usb_dev->actconfig->desc.bNumInterfaces; 705 int num_interfaces = usb_dev->actconfig->desc.bNumInterfaces;
689 int i, ret; 706 int i, ret;
707 int use_isoc;
690 708
691 usb_dbg(usbatm, "%s entered\n", __func__); 709 usb_dbg(usbatm, "%s entered\n", __func__);
692 710
711 /* sanity checks */
712
693 if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) { 713 if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) {
694 usb_dbg(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass); 714 usb_err(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass);
715 return -ENODEV;
716 }
717
718 if (!(data_intf = usb_ifnum_to_if(usb_dev, INTERFACE_DATA))) {
719 usb_err(usbatm, "%s: data interface not found!\n", __func__);
695 return -ENODEV; 720 return -ENODEV;
696 } 721 }
697 722
@@ -704,25 +729,71 @@ static int speedtch_bind(struct usbatm_data *usbatm,
704 ret = usb_driver_claim_interface(&speedtch_usb_driver, cur_intf, usbatm); 729 ret = usb_driver_claim_interface(&speedtch_usb_driver, cur_intf, usbatm);
705 730
706 if (ret < 0) { 731 if (ret < 0) {
707 usb_dbg(usbatm, "%s: failed to claim interface %d (%d)\n", __func__, i, ret); 732 usb_err(usbatm, "%s: failed to claim interface %2d (%d)!\n", __func__, i, ret);
708 speedtch_release_interfaces(usb_dev, i); 733 speedtch_release_interfaces(usb_dev, i);
709 return ret; 734 return ret;
710 } 735 }
711 } 736 }
712 } 737 }
713 738
714 instance = kmalloc(sizeof(*instance), GFP_KERNEL); 739 instance = kzalloc(sizeof(*instance), GFP_KERNEL);
715 740
716 if (!instance) { 741 if (!instance) {
717 usb_dbg(usbatm, "%s: no memory for instance data!\n", __func__); 742 usb_err(usbatm, "%s: no memory for instance data!\n", __func__);
718 ret = -ENOMEM; 743 ret = -ENOMEM;
719 goto fail_release; 744 goto fail_release;
720 } 745 }
721 746
722 memset(instance, 0, sizeof(struct speedtch_instance_data));
723
724 instance->usbatm = usbatm; 747 instance->usbatm = usbatm;
725 748
749 /* altsetting and enable_isoc may change at any moment, so take a snapshot */
750 instance->altsetting = altsetting;
751 use_isoc = enable_isoc;
752
753 if (instance->altsetting)
754 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) {
755 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->altsetting, ret);
756 instance->altsetting = 0; /* fall back to default */
757 }
758
759 if (!instance->altsetting && use_isoc)
760 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ISOC_ALTSETTING)) < 0) {
761 usb_dbg(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ISOC_ALTSETTING, ret);
762 use_isoc = 0; /* fall back to bulk */
763 }
764
765 if (use_isoc) {
766 const struct usb_host_interface *desc = data_intf->cur_altsetting;
767 const __u8 target_address = USB_DIR_IN | usbatm->driver->isoc_in;
768 int i;
769
770 use_isoc = 0; /* fall back to bulk if endpoint not found */
771
772 for (i=0; i<desc->desc.bNumEndpoints; i++) {
773 const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc;
774
775 if ((endpoint_desc->bEndpointAddress == target_address)) {
776 use_isoc = (endpoint_desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
777 USB_ENDPOINT_XFER_ISOC;
778 break;
779 }
780 }
781
782 if (!use_isoc)
783 usb_info(usbatm, "isochronous transfer not supported - using bulk\n");
784 }
785
786 if (!use_isoc && !instance->altsetting)
787 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_BULK_ALTSETTING)) < 0) {
788 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_BULK_ALTSETTING, ret);
789 goto fail_free;
790 }
791
792 if (!instance->altsetting)
793 instance->altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING;
794
795 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
796
726 INIT_WORK(&instance->status_checker, (void *)speedtch_check_status, instance); 797 INIT_WORK(&instance->status_checker, (void *)speedtch_check_status, instance);
727 798
728 instance->status_checker.timer.function = speedtch_status_poll; 799 instance->status_checker.timer.function = speedtch_status_poll;
@@ -749,13 +820,15 @@ static int speedtch_bind(struct usbatm_data *usbatm,
749 0x12, 0xc0, 0x07, 0x00, 820 0x12, 0xc0, 0x07, 0x00,
750 instance->scratch_buffer + OFFSET_7, SIZE_7, 500); 821 instance->scratch_buffer + OFFSET_7, SIZE_7, 500);
751 822
752 *need_heavy_init = (ret != SIZE_7); 823 usbatm->flags |= (ret == SIZE_7 ? UDSL_SKIP_HEAVY_INIT : 0);
753 824
754 usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, need_heavy_init ? "not" : "already"); 825 usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, usbatm->flags & UDSL_SKIP_HEAVY_INIT ? "already" : "not");
755 826
756 if (*need_heavy_init) 827 if (!(usbatm->flags & UDSL_SKIP_HEAVY_INIT))
757 if ((ret = usb_reset_device(usb_dev)) < 0) 828 if ((ret = usb_reset_device(usb_dev)) < 0) {
829 usb_err(usbatm, "%s: device reset failed (%d)!\n", __func__, ret);
758 goto fail_free; 830 goto fail_free;
831 }
759 832
760 usbatm->driver_data = instance; 833 usbatm->driver_data = instance;
761 834
@@ -787,15 +860,15 @@ static void speedtch_unbind(struct usbatm_data *usbatm, struct usb_interface *in
787***********/ 860***********/
788 861
789static struct usbatm_driver speedtch_usbatm_driver = { 862static struct usbatm_driver speedtch_usbatm_driver = {
790 .owner = THIS_MODULE,
791 .driver_name = speedtch_driver_name, 863 .driver_name = speedtch_driver_name,
792 .bind = speedtch_bind, 864 .bind = speedtch_bind,
793 .heavy_init = speedtch_heavy_init, 865 .heavy_init = speedtch_heavy_init,
794 .unbind = speedtch_unbind, 866 .unbind = speedtch_unbind,
795 .atm_start = speedtch_atm_start, 867 .atm_start = speedtch_atm_start,
796 .atm_stop = speedtch_atm_stop, 868 .atm_stop = speedtch_atm_stop,
797 .in = ENDPOINT_DATA, 869 .bulk_in = ENDPOINT_BULK_DATA,
798 .out = ENDPOINT_DATA 870 .bulk_out = ENDPOINT_BULK_DATA,
871 .isoc_in = ENDPOINT_ISOC_DATA
799}; 872};
800 873
801static int speedtch_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) 874static int speedtch_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 7d2a679989ed..830d2c982670 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -63,11 +63,12 @@
63#include <linux/ctype.h> 63#include <linux/ctype.h>
64#include <linux/kthread.h> 64#include <linux/kthread.h>
65#include <linux/version.h> 65#include <linux/version.h>
66#include <linux/mutex.h>
66#include <asm/unaligned.h> 67#include <asm/unaligned.h>
67 68
68#include "usbatm.h" 69#include "usbatm.h"
69 70
70#define EAGLEUSBVERSION "ueagle 1.1" 71#define EAGLEUSBVERSION "ueagle 1.2"
71 72
72 73
73/* 74/*
@@ -358,16 +359,19 @@ struct intr_pkt {
358#define INTR_PKT_SIZE 28 359#define INTR_PKT_SIZE 28
359 360
360static struct usb_driver uea_driver; 361static struct usb_driver uea_driver;
361static DECLARE_MUTEX(uea_semaphore); 362static DEFINE_MUTEX(uea_mutex);
362static const char *chip_name[] = {"ADI930", "Eagle I", "Eagle II", "Eagle III"}; 363static const char *chip_name[] = {"ADI930", "Eagle I", "Eagle II", "Eagle III"};
363 364
364static int modem_index; 365static int modem_index;
365static unsigned int debug; 366static unsigned int debug;
367static int use_iso[NB_MODEM] = {[0 ... (NB_MODEM - 1)] = 1};
366static int sync_wait[NB_MODEM]; 368static int sync_wait[NB_MODEM];
367static char *cmv_file[NB_MODEM]; 369static char *cmv_file[NB_MODEM];
368 370
369module_param(debug, uint, 0644); 371module_param(debug, uint, 0644);
370MODULE_PARM_DESC(debug, "module debug level (0=off,1=on,2=verbose)"); 372MODULE_PARM_DESC(debug, "module debug level (0=off,1=on,2=verbose)");
373module_param_array(use_iso, bool, NULL, 0644);
374MODULE_PARM_DESC(use_iso, "use isochronous usb pipe for incoming traffic");
371module_param_array(sync_wait, bool, NULL, 0644); 375module_param_array(sync_wait, bool, NULL, 0644);
372MODULE_PARM_DESC(sync_wait, "wait the synchronisation before starting ATM"); 376MODULE_PARM_DESC(sync_wait, "wait the synchronisation before starting ATM");
373module_param_array(cmv_file, charp, NULL, 0644); 377module_param_array(cmv_file, charp, NULL, 0644);
@@ -628,8 +632,7 @@ static int request_dsp(struct uea_softc *sc)
628 dsp_name = FW_DIR "DSPep.bin"; 632 dsp_name = FW_DIR "DSPep.bin";
629 } 633 }
630 634
631 ret = request_firmware(&sc->dsp_firm, 635 ret = request_firmware(&sc->dsp_firm, dsp_name, &sc->usb_dev->dev);
632 dsp_name, &sc->usb_dev->dev);
633 if (ret < 0) { 636 if (ret < 0) {
634 uea_err(INS_TO_USBDEV(sc), 637 uea_err(INS_TO_USBDEV(sc),
635 "requesting firmware %s failed with error %d\n", 638 "requesting firmware %s failed with error %d\n",
@@ -744,7 +747,6 @@ static inline int wait_cmv_ack(struct uea_softc *sc)
744 return ret; 747 return ret;
745 748
746 return (ret == 0) ? -ETIMEDOUT : 0; 749 return (ret == 0) ? -ETIMEDOUT : 0;
747
748} 750}
749 751
750#define UCDC_SEND_ENCAPSULATED_COMMAND 0x00 752#define UCDC_SEND_ENCAPSULATED_COMMAND 0x00
@@ -935,6 +937,7 @@ static int uea_stat(struct uea_softc *sc)
935 * ADI930 don't support it (-EPIPE error). 937 * ADI930 don't support it (-EPIPE error).
936 */ 938 */
937 if (UEA_CHIP_VERSION(sc) != ADI930 939 if (UEA_CHIP_VERSION(sc) != ADI930
940 && !use_iso[sc->modem_index]
938 && sc->stats.phy.dsrate != (data >> 16) * 32) { 941 && sc->stats.phy.dsrate != (data >> 16) * 32) {
939 /* Original timming from ADI(used in windows driver) 942 /* Original timming from ADI(used in windows driver)
940 * 0x20ffff>>16 * 32 = 32 * 32 = 1Mbits 943 * 0x20ffff>>16 * 32 = 32 * 32 = 1Mbits
@@ -1010,7 +1013,7 @@ static int request_cmvs(struct uea_softc *sc,
1010 int ret, size; 1013 int ret, size;
1011 u8 *data; 1014 u8 *data;
1012 char *file; 1015 char *file;
1013 static char cmv_name[256] = FW_DIR; 1016 char cmv_name[FIRMWARE_NAME_MAX]; /* 30 bytes stack variable */
1014 1017
1015 if (cmv_file[sc->modem_index] == NULL) { 1018 if (cmv_file[sc->modem_index] == NULL) {
1016 if (UEA_CHIP_VERSION(sc) == ADI930) 1019 if (UEA_CHIP_VERSION(sc) == ADI930)
@@ -1184,8 +1187,7 @@ static int load_XILINX_firmware(struct uea_softc *sc)
1184 } 1187 }
1185 } 1188 }
1186 1189
1187 /* finish to send the fpga 1190 /* finish to send the fpga */
1188 */
1189 ret = uea_request(sc, 0xe, 1, 0, NULL); 1191 ret = uea_request(sc, 0xe, 1, 0, NULL);
1190 if (ret < 0) { 1192 if (ret < 0) {
1191 uea_err(INS_TO_USBDEV(sc), 1193 uea_err(INS_TO_USBDEV(sc),
@@ -1193,9 +1195,7 @@ static int load_XILINX_firmware(struct uea_softc *sc)
1193 goto err1; 1195 goto err1;
1194 } 1196 }
1195 1197
1196 /* 1198 /* Tell the modem we finish : de-assert reset */
1197 * Tell the modem we finish : de-assert reset
1198 */
1199 value = 0; 1199 value = 0;
1200 ret = uea_send_modem_cmd(sc->usb_dev, 0xe, 1, &value); 1200 ret = uea_send_modem_cmd(sc->usb_dev, 0xe, 1, &value);
1201 if (ret < 0) 1201 if (ret < 0)
@@ -1209,6 +1209,7 @@ err0:
1209 return ret; 1209 return ret;
1210} 1210}
1211 1211
1212/* The modem send us an ack. First with check if it right */
1212static void uea_dispatch_cmv(struct uea_softc *sc, struct cmv* cmv) 1213static void uea_dispatch_cmv(struct uea_softc *sc, struct cmv* cmv)
1213{ 1214{
1214 uea_enters(INS_TO_USBDEV(sc)); 1215 uea_enters(INS_TO_USBDEV(sc));
@@ -1268,23 +1269,19 @@ bad1:
1268 */ 1269 */
1269static void uea_intr(struct urb *urb, struct pt_regs *regs) 1270static void uea_intr(struct urb *urb, struct pt_regs *regs)
1270{ 1271{
1271 struct uea_softc *sc = (struct uea_softc *)urb->context; 1272 struct uea_softc *sc = urb->context;
1272 struct intr_pkt *intr; 1273 struct intr_pkt *intr = urb->transfer_buffer;
1273 uea_enters(INS_TO_USBDEV(sc)); 1274 uea_enters(INS_TO_USBDEV(sc));
1274 1275
1275 if (urb->status < 0) { 1276 if (unlikely(urb->status < 0)) {
1276 uea_err(INS_TO_USBDEV(sc), "uea_intr() failed with %d\n", 1277 uea_err(INS_TO_USBDEV(sc), "uea_intr() failed with %d\n",
1277 urb->status); 1278 urb->status);
1278 return; 1279 return;
1279 } 1280 }
1280 1281
1281 intr = (struct intr_pkt *) urb->transfer_buffer;
1282
1283 /* device-to-host interrupt */ 1282 /* device-to-host interrupt */
1284 if (intr->bType != 0x08 || sc->booting) { 1283 if (intr->bType != 0x08 || sc->booting) {
1285 uea_err(INS_TO_USBDEV(sc), "wrong intr\n"); 1284 uea_err(INS_TO_USBDEV(sc), "wrong interrupt\n");
1286 // rebooting ?
1287 // sc->reset = 1;
1288 goto resubmit; 1285 goto resubmit;
1289 } 1286 }
1290 1287
@@ -1300,7 +1297,7 @@ static void uea_intr(struct urb *urb, struct pt_regs *regs)
1300 break; 1297 break;
1301 1298
1302 default: 1299 default:
1303 uea_err(INS_TO_USBDEV(sc), "unknown intr %u\n", 1300 uea_err(INS_TO_USBDEV(sc), "unknown interrupt %u\n",
1304 le16_to_cpu(intr->wInterrupt)); 1301 le16_to_cpu(intr->wInterrupt));
1305 } 1302 }
1306 1303
@@ -1379,7 +1376,7 @@ static void uea_stop(struct uea_softc *sc)
1379 int ret; 1376 int ret;
1380 uea_enters(INS_TO_USBDEV(sc)); 1377 uea_enters(INS_TO_USBDEV(sc));
1381 ret = kthread_stop(sc->kthread); 1378 ret = kthread_stop(sc->kthread);
1382 uea_info(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret); 1379 uea_dbg(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret);
1383 1380
1384 /* stop any pending boot process */ 1381 /* stop any pending boot process */
1385 flush_scheduled_work(); 1382 flush_scheduled_work();
@@ -1418,13 +1415,13 @@ static ssize_t read_status(struct device *dev, struct device_attribute *attr,
1418 int ret = -ENODEV; 1415 int ret = -ENODEV;
1419 struct uea_softc *sc; 1416 struct uea_softc *sc;
1420 1417
1421 down(&uea_semaphore); 1418 mutex_lock(&uea_mutex);
1422 sc = dev_to_uea(dev); 1419 sc = dev_to_uea(dev);
1423 if (!sc) 1420 if (!sc)
1424 goto out; 1421 goto out;
1425 ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state); 1422 ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state);
1426out: 1423out:
1427 up(&uea_semaphore); 1424 mutex_unlock(&uea_mutex);
1428 return ret; 1425 return ret;
1429} 1426}
1430 1427
@@ -1434,14 +1431,14 @@ static ssize_t reboot(struct device *dev, struct device_attribute *attr,
1434 int ret = -ENODEV; 1431 int ret = -ENODEV;
1435 struct uea_softc *sc; 1432 struct uea_softc *sc;
1436 1433
1437 down(&uea_semaphore); 1434 mutex_lock(&uea_mutex);
1438 sc = dev_to_uea(dev); 1435 sc = dev_to_uea(dev);
1439 if (!sc) 1436 if (!sc)
1440 goto out; 1437 goto out;
1441 sc->reset = 1; 1438 sc->reset = 1;
1442 ret = count; 1439 ret = count;
1443out: 1440out:
1444 up(&uea_semaphore); 1441 mutex_unlock(&uea_mutex);
1445 return ret; 1442 return ret;
1446} 1443}
1447 1444
@@ -1453,7 +1450,7 @@ static ssize_t read_human_status(struct device *dev, struct device_attribute *at
1453 int ret = -ENODEV; 1450 int ret = -ENODEV;
1454 struct uea_softc *sc; 1451 struct uea_softc *sc;
1455 1452
1456 down(&uea_semaphore); 1453 mutex_lock(&uea_mutex);
1457 sc = dev_to_uea(dev); 1454 sc = dev_to_uea(dev);
1458 if (!sc) 1455 if (!sc)
1459 goto out; 1456 goto out;
@@ -1473,7 +1470,7 @@ static ssize_t read_human_status(struct device *dev, struct device_attribute *at
1473 break; 1470 break;
1474 } 1471 }
1475out: 1472out:
1476 up(&uea_semaphore); 1473 mutex_unlock(&uea_mutex);
1477 return ret; 1474 return ret;
1478} 1475}
1479 1476
@@ -1485,7 +1482,7 @@ static ssize_t read_delin(struct device *dev, struct device_attribute *attr,
1485 int ret = -ENODEV; 1482 int ret = -ENODEV;
1486 struct uea_softc *sc; 1483 struct uea_softc *sc;
1487 1484
1488 down(&uea_semaphore); 1485 mutex_lock(&uea_mutex);
1489 sc = dev_to_uea(dev); 1486 sc = dev_to_uea(dev);
1490 if (!sc) 1487 if (!sc)
1491 goto out; 1488 goto out;
@@ -1497,7 +1494,7 @@ static ssize_t read_delin(struct device *dev, struct device_attribute *attr,
1497 else 1494 else
1498 ret = sprintf(buf, "GOOD\n"); 1495 ret = sprintf(buf, "GOOD\n");
1499out: 1496out:
1500 up(&uea_semaphore); 1497 mutex_unlock(&uea_mutex);
1501 return ret; 1498 return ret;
1502} 1499}
1503 1500
@@ -1511,7 +1508,7 @@ static ssize_t read_##name(struct device *dev, \
1511 int ret = -ENODEV; \ 1508 int ret = -ENODEV; \
1512 struct uea_softc *sc; \ 1509 struct uea_softc *sc; \
1513 \ 1510 \
1514 down(&uea_semaphore); \ 1511 mutex_lock(&uea_mutex); \
1515 sc = dev_to_uea(dev); \ 1512 sc = dev_to_uea(dev); \
1516 if (!sc) \ 1513 if (!sc) \
1517 goto out; \ 1514 goto out; \
@@ -1519,7 +1516,7 @@ static ssize_t read_##name(struct device *dev, \
1519 if (reset) \ 1516 if (reset) \
1520 sc->stats.phy.name = 0; \ 1517 sc->stats.phy.name = 0; \
1521out: \ 1518out: \
1522 up(&uea_semaphore); \ 1519 mutex_unlock(&uea_mutex); \
1523 return ret; \ 1520 return ret; \
1524} \ 1521} \
1525 \ 1522 \
@@ -1617,7 +1614,7 @@ static void create_fs_entries(struct uea_softc *sc, struct usb_interface *intf)
1617} 1614}
1618 1615
1619static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, 1616static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1620 const struct usb_device_id *id, int *heavy) 1617 const struct usb_device_id *id)
1621{ 1618{
1622 struct usb_device *usb = interface_to_usbdev(intf); 1619 struct usb_device *usb = interface_to_usbdev(intf);
1623 struct uea_softc *sc; 1620 struct uea_softc *sc;
@@ -1629,16 +1626,14 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1629 if (ifnum != UEA_INTR_IFACE_NO) 1626 if (ifnum != UEA_INTR_IFACE_NO)
1630 return -ENODEV; 1627 return -ENODEV;
1631 1628
1632 *heavy = sync_wait[modem_index]; 1629 usbatm->flags = (sync_wait[modem_index] ? 0 : UDSL_SKIP_HEAVY_INIT);
1633 1630
1634 /* interface 1 is for outbound traffic */ 1631 /* interface 1 is for outbound traffic */
1635 ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO); 1632 ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO);
1636 if (ret < 0) 1633 if (ret < 0)
1637 return ret; 1634 return ret;
1638 1635
1639 /* ADI930 has only 2 interfaces and inbound traffic 1636 /* ADI930 has only 2 interfaces and inbound traffic is on interface 1 */
1640 * is on interface 1
1641 */
1642 if (UEA_CHIP_VERSION(id) != ADI930) { 1637 if (UEA_CHIP_VERSION(id) != ADI930) {
1643 /* interface 2 is for inbound traffic */ 1638 /* interface 2 is for inbound traffic */
1644 ret = claim_interface(usb, usbatm, UEA_DS_IFACE_NO); 1639 ret = claim_interface(usb, usbatm, UEA_DS_IFACE_NO);
@@ -1658,6 +1653,25 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1658 sc->modem_index = (modem_index < NB_MODEM) ? modem_index++ : 0; 1653 sc->modem_index = (modem_index < NB_MODEM) ? modem_index++ : 0;
1659 sc->driver_info = id->driver_info; 1654 sc->driver_info = id->driver_info;
1660 1655
1656 /* ADI930 don't support iso */
1657 if (UEA_CHIP_VERSION(id) != ADI930 && use_iso[sc->modem_index]) {
1658 int i;
1659
1660 /* try set fastest alternate for inbound traffic interface */
1661 for (i = FASTEST_ISO_INTF; i > 0; i--)
1662 if (usb_set_interface(usb, UEA_DS_IFACE_NO, i) == 0)
1663 break;
1664
1665 if (i > 0) {
1666 uea_dbg(usb, "set alternate %d for 2 interface\n", i);
1667 uea_info(usb, "using iso mode\n");
1668 usbatm->flags |= UDSL_USE_ISOC | UDSL_IGNORE_EILSEQ;
1669 } else {
1670 uea_err(usb, "setting any alternate failed for "
1671 "2 interface, using bulk mode\n");
1672 }
1673 }
1674
1661 ret = uea_boot(sc); 1675 ret = uea_boot(sc);
1662 if (ret < 0) { 1676 if (ret < 0) {
1663 kfree(sc); 1677 kfree(sc);
@@ -1701,13 +1715,13 @@ static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
1701 1715
1702static struct usbatm_driver uea_usbatm_driver = { 1716static struct usbatm_driver uea_usbatm_driver = {
1703 .driver_name = "ueagle-atm", 1717 .driver_name = "ueagle-atm",
1704 .owner = THIS_MODULE,
1705 .bind = uea_bind, 1718 .bind = uea_bind,
1706 .atm_start = uea_atm_open, 1719 .atm_start = uea_atm_open,
1707 .unbind = uea_unbind, 1720 .unbind = uea_unbind,
1708 .heavy_init = uea_heavy, 1721 .heavy_init = uea_heavy,
1709 .in = UEA_BULK_DATA_PIPE, 1722 .bulk_in = UEA_BULK_DATA_PIPE,
1710 .out = UEA_BULK_DATA_PIPE, 1723 .bulk_out = UEA_BULK_DATA_PIPE,
1724 .isoc_in = UEA_ISO_DATA_PIPE,
1711}; 1725};
1712 1726
1713static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id) 1727static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
@@ -1738,9 +1752,9 @@ static void uea_disconnect(struct usb_interface *intf)
1738 * Pre-firmware device has one interface 1752 * Pre-firmware device has one interface
1739 */ 1753 */
1740 if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) { 1754 if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
1741 down(&uea_semaphore); 1755 mutex_lock(&uea_mutex);
1742 usbatm_usb_disconnect(intf); 1756 usbatm_usb_disconnect(intf);
1743 up(&uea_semaphore); 1757 mutex_unlock(&uea_mutex);
1744 uea_info(usb, "ADSL device removed\n"); 1758 uea_info(usb, "ADSL device removed\n");
1745 } 1759 }
1746 1760
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 7af1883d4bf9..c1211fc037d9 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -72,6 +72,7 @@
72#include <linux/kernel.h> 72#include <linux/kernel.h>
73#include <linux/module.h> 73#include <linux/module.h>
74#include <linux/moduleparam.h> 74#include <linux/moduleparam.h>
75#include <linux/netdevice.h>
75#include <linux/proc_fs.h> 76#include <linux/proc_fs.h>
76#include <linux/sched.h> 77#include <linux/sched.h>
77#include <linux/signal.h> 78#include <linux/signal.h>
@@ -91,19 +92,18 @@ static int usbatm_print_packet(const unsigned char *data, int len);
91#endif 92#endif
92 93
93#define DRIVER_AUTHOR "Johan Verrept, Duncan Sands <duncan.sands@free.fr>" 94#define DRIVER_AUTHOR "Johan Verrept, Duncan Sands <duncan.sands@free.fr>"
94#define DRIVER_VERSION "1.9" 95#define DRIVER_VERSION "1.10"
95#define DRIVER_DESC "Generic USB ATM/DSL I/O, version " DRIVER_VERSION 96#define DRIVER_DESC "Generic USB ATM/DSL I/O, version " DRIVER_VERSION
96 97
97static const char usbatm_driver_name[] = "usbatm"; 98static const char usbatm_driver_name[] = "usbatm";
98 99
99#define UDSL_MAX_RCV_URBS 16 100#define UDSL_MAX_RCV_URBS 16
100#define UDSL_MAX_SND_URBS 16 101#define UDSL_MAX_SND_URBS 16
101#define UDSL_MAX_RCV_BUF_SIZE 1024 /* ATM cells */ 102#define UDSL_MAX_BUF_SIZE 64 * 1024 /* bytes */
102#define UDSL_MAX_SND_BUF_SIZE 1024 /* ATM cells */
103#define UDSL_DEFAULT_RCV_URBS 4 103#define UDSL_DEFAULT_RCV_URBS 4
104#define UDSL_DEFAULT_SND_URBS 4 104#define UDSL_DEFAULT_SND_URBS 4
105#define UDSL_DEFAULT_RCV_BUF_SIZE 64 /* ATM cells */ 105#define UDSL_DEFAULT_RCV_BUF_SIZE 64 * ATM_CELL_SIZE /* bytes */
106#define UDSL_DEFAULT_SND_BUF_SIZE 64 /* ATM cells */ 106#define UDSL_DEFAULT_SND_BUF_SIZE 64 * ATM_CELL_SIZE /* bytes */
107 107
108#define ATM_CELL_HEADER (ATM_CELL_SIZE - ATM_CELL_PAYLOAD) 108#define ATM_CELL_HEADER (ATM_CELL_SIZE - ATM_CELL_PAYLOAD)
109 109
@@ -111,8 +111,8 @@ static const char usbatm_driver_name[] = "usbatm";
111 111
112static unsigned int num_rcv_urbs = UDSL_DEFAULT_RCV_URBS; 112static unsigned int num_rcv_urbs = UDSL_DEFAULT_RCV_URBS;
113static unsigned int num_snd_urbs = UDSL_DEFAULT_SND_URBS; 113static unsigned int num_snd_urbs = UDSL_DEFAULT_SND_URBS;
114static unsigned int rcv_buf_size = UDSL_DEFAULT_RCV_BUF_SIZE; 114static unsigned int rcv_buf_bytes = UDSL_DEFAULT_RCV_BUF_SIZE;
115static unsigned int snd_buf_size = UDSL_DEFAULT_SND_BUF_SIZE; 115static unsigned int snd_buf_bytes = UDSL_DEFAULT_SND_BUF_SIZE;
116 116
117module_param(num_rcv_urbs, uint, S_IRUGO); 117module_param(num_rcv_urbs, uint, S_IRUGO);
118MODULE_PARM_DESC(num_rcv_urbs, 118MODULE_PARM_DESC(num_rcv_urbs,
@@ -126,15 +126,15 @@ MODULE_PARM_DESC(num_snd_urbs,
126 __MODULE_STRING(UDSL_MAX_SND_URBS) ", default: " 126 __MODULE_STRING(UDSL_MAX_SND_URBS) ", default: "
127 __MODULE_STRING(UDSL_DEFAULT_SND_URBS) ")"); 127 __MODULE_STRING(UDSL_DEFAULT_SND_URBS) ")");
128 128
129module_param(rcv_buf_size, uint, S_IRUGO); 129module_param(rcv_buf_bytes, uint, S_IRUGO);
130MODULE_PARM_DESC(rcv_buf_size, 130MODULE_PARM_DESC(rcv_buf_bytes,
131 "Size of the buffers used for reception in ATM cells (range: 1-" 131 "Size of the buffers used for reception, in bytes (range: 1-"
132 __MODULE_STRING(UDSL_MAX_RCV_BUF_SIZE) ", default: " 132 __MODULE_STRING(UDSL_MAX_BUF_SIZE) ", default: "
133 __MODULE_STRING(UDSL_DEFAULT_RCV_BUF_SIZE) ")"); 133 __MODULE_STRING(UDSL_DEFAULT_RCV_BUF_SIZE) ")");
134 134
135module_param(snd_buf_size, uint, S_IRUGO); 135module_param(snd_buf_bytes, uint, S_IRUGO);
136MODULE_PARM_DESC(snd_buf_size, 136MODULE_PARM_DESC(snd_buf_bytes,
137 "Size of the buffers used for transmission in ATM cells (range: 1-" 137 "Size of the buffers used for transmission, in bytes (range: 1-"
138 __MODULE_STRING(UDSL_MAX_SND_BUF_SIZE) ", default: " 138 __MODULE_STRING(UDSL_MAX_SND_BUF_SIZE) ", default: "
139 __MODULE_STRING(UDSL_DEFAULT_SND_BUF_SIZE) ")"); 139 __MODULE_STRING(UDSL_DEFAULT_SND_BUF_SIZE) ")");
140 140
@@ -166,10 +166,10 @@ struct usbatm_control {
166 166
167/* ATM */ 167/* ATM */
168 168
169static void usbatm_atm_dev_close(struct atm_dev *dev); 169static void usbatm_atm_dev_close(struct atm_dev *atm_dev);
170static int usbatm_atm_open(struct atm_vcc *vcc); 170static int usbatm_atm_open(struct atm_vcc *vcc);
171static void usbatm_atm_close(struct atm_vcc *vcc); 171static void usbatm_atm_close(struct atm_vcc *vcc);
172static int usbatm_atm_ioctl(struct atm_dev *dev, unsigned int cmd, void __user * arg); 172static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void __user * arg);
173static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb); 173static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb);
174static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page); 174static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page);
175 175
@@ -199,7 +199,7 @@ static inline void usbatm_pop(struct atm_vcc *vcc, struct sk_buff *skb)
199 if (vcc->pop) 199 if (vcc->pop)
200 vcc->pop(vcc, skb); 200 vcc->pop(vcc, skb);
201 else 201 else
202 dev_kfree_skb(skb); 202 dev_kfree_skb_any(skb);
203} 203}
204 204
205 205
@@ -234,8 +234,9 @@ static int usbatm_submit_urb(struct urb *urb)
234 234
235 ret = usb_submit_urb(urb, GFP_ATOMIC); 235 ret = usb_submit_urb(urb, GFP_ATOMIC);
236 if (ret) { 236 if (ret) {
237 atm_dbg(channel->usbatm, "%s: urb 0x%p submission failed (%d)!\n", 237 if (printk_ratelimit())
238 __func__, urb, ret); 238 atm_warn(channel->usbatm, "%s: urb 0x%p submission failed (%d)!\n",
239 __func__, urb, ret);
239 240
240 /* consider all errors transient and return the buffer back to the queue */ 241 /* consider all errors transient and return the buffer back to the queue */
241 urb->status = -EAGAIN; 242 urb->status = -EAGAIN;
@@ -269,10 +270,16 @@ static void usbatm_complete(struct urb *urb, struct pt_regs *regs)
269 270
270 spin_unlock_irqrestore(&channel->lock, flags); 271 spin_unlock_irqrestore(&channel->lock, flags);
271 272
272 if (unlikely(urb->status)) 273 if (unlikely(urb->status) &&
274 (!(channel->usbatm->flags & UDSL_IGNORE_EILSEQ) ||
275 urb->status != -EILSEQ ))
276 {
277 if (printk_ratelimit())
278 atm_warn(channel->usbatm, "%s: urb 0x%p failed (%d)!\n",
279 __func__, urb, urb->status);
273 /* throttle processing in case of an error */ 280 /* throttle processing in case of an error */
274 mod_timer(&channel->delay, jiffies + msecs_to_jiffies(THROTTLE_MSECS)); 281 mod_timer(&channel->delay, jiffies + msecs_to_jiffies(THROTTLE_MSECS));
275 else 282 } else
276 tasklet_schedule(&channel->tasklet); 283 tasklet_schedule(&channel->tasklet);
277} 284}
278 285
@@ -284,129 +291,167 @@ static void usbatm_complete(struct urb *urb, struct pt_regs *regs)
284static inline struct usbatm_vcc_data *usbatm_find_vcc(struct usbatm_data *instance, 291static inline struct usbatm_vcc_data *usbatm_find_vcc(struct usbatm_data *instance,
285 short vpi, int vci) 292 short vpi, int vci)
286{ 293{
287 struct usbatm_vcc_data *vcc; 294 struct usbatm_vcc_data *vcc_data;
288 295
289 list_for_each_entry(vcc, &instance->vcc_list, list) 296 list_for_each_entry(vcc_data, &instance->vcc_list, list)
290 if ((vcc->vci == vci) && (vcc->vpi == vpi)) 297 if ((vcc_data->vci == vci) && (vcc_data->vpi == vpi))
291 return vcc; 298 return vcc_data;
292 return NULL; 299 return NULL;
293} 300}
294 301
295static void usbatm_extract_cells(struct usbatm_data *instance, 302static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char *source)
296 unsigned char *source, unsigned int avail_data)
297{ 303{
298 struct usbatm_vcc_data *cached_vcc = NULL;
299 struct atm_vcc *vcc; 304 struct atm_vcc *vcc;
300 struct sk_buff *sarb; 305 struct sk_buff *sarb;
301 unsigned int stride = instance->rx_channel.stride; 306 short vpi = ((source[0] & 0x0f) << 4) | (source[1] >> 4);
302 int vci, cached_vci = 0; 307 int vci = ((source[1] & 0x0f) << 12) | (source[2] << 4) | (source[3] >> 4);
303 short vpi, cached_vpi = 0; 308 u8 pti = ((source[3] & 0xe) >> 1);
304 u8 pti;
305 309
306 for (; avail_data >= stride; avail_data -= stride, source += stride) { 310 vdbg("%s: vpi %hd, vci %d, pti %d", __func__, vpi, vci, pti);
307 vpi = ((source[0] & 0x0f) << 4) | (source[1] >> 4);
308 vci = ((source[1] & 0x0f) << 12) | (source[2] << 4) | (source[3] >> 4);
309 pti = ((source[3] & 0xe) >> 1);
310 311
311 vdbg("%s: vpi %hd, vci %d, pti %d", __func__, vpi, vci, pti); 312 if ((vci != instance->cached_vci) || (vpi != instance->cached_vpi)) {
313 instance->cached_vpi = vpi;
314 instance->cached_vci = vci;
312 315
313 if ((vci != cached_vci) || (vpi != cached_vpi)) { 316 instance->cached_vcc = usbatm_find_vcc(instance, vpi, vci);
314 cached_vpi = vpi;
315 cached_vci = vci;
316 317
317 cached_vcc = usbatm_find_vcc(instance, vpi, vci); 318 if (!instance->cached_vcc)
319 atm_rldbg(instance, "%s: unknown vpi/vci (%hd/%d)!\n", __func__, vpi, vci);
320 }
318 321
319 if (!cached_vcc) 322 if (!instance->cached_vcc)
320 atm_dbg(instance, "%s: unknown vpi/vci (%hd/%d)!\n", __func__, vpi, vci); 323 return;
321 }
322 324
323 if (!cached_vcc) 325 vcc = instance->cached_vcc->vcc;
324 continue;
325 326
326 vcc = cached_vcc->vcc; 327 /* OAM F5 end-to-end */
328 if (pti == ATM_PTI_E2EF5) {
329 if (printk_ratelimit())
330 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
331 __func__, vpi, vci);
332 atomic_inc(&vcc->stats->rx_err);
333 return;
334 }
327 335
328 /* OAM F5 end-to-end */ 336 sarb = instance->cached_vcc->sarb;
329 if (pti == ATM_PTI_E2EF5) {
330 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n", __func__, vpi, vci);
331 atomic_inc(&vcc->stats->rx_err);
332 continue;
333 }
334 337
335 sarb = cached_vcc->sarb; 338 if (sarb->tail + ATM_CELL_PAYLOAD > sarb->end) {
339 atm_rldbg(instance, "%s: buffer overrun (sarb->len %u, vcc: 0x%p)!\n",
340 __func__, sarb->len, vcc);
341 /* discard cells already received */
342 skb_trim(sarb, 0);
343 UDSL_ASSERT(sarb->tail + ATM_CELL_PAYLOAD <= sarb->end);
344 }
336 345
337 if (sarb->tail + ATM_CELL_PAYLOAD > sarb->end) { 346 memcpy(sarb->tail, source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD);
338 atm_dbg(instance, "%s: buffer overrun (sarb->len %u, vcc: 0x%p)!\n", 347 __skb_put(sarb, ATM_CELL_PAYLOAD);
339 __func__, sarb->len, vcc);
340 /* discard cells already received */
341 skb_trim(sarb, 0);
342 UDSL_ASSERT(sarb->tail + ATM_CELL_PAYLOAD <= sarb->end);
343 }
344 348
345 memcpy(sarb->tail, source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD); 349 if (pti & 1) {
346 __skb_put(sarb, ATM_CELL_PAYLOAD); 350 struct sk_buff *skb;
351 unsigned int length;
352 unsigned int pdu_length;
347 353
348 if (pti & 1) { 354 length = (source[ATM_CELL_SIZE - 6] << 8) + source[ATM_CELL_SIZE - 5];
349 struct sk_buff *skb;
350 unsigned int length;
351 unsigned int pdu_length;
352 355
353 length = (source[ATM_CELL_SIZE - 6] << 8) + source[ATM_CELL_SIZE - 5]; 356 /* guard against overflow */
357 if (length > ATM_MAX_AAL5_PDU) {
358 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
359 __func__, length, vcc);
360 atomic_inc(&vcc->stats->rx_err);
361 goto out;
362 }
354 363
355 /* guard against overflow */ 364 pdu_length = usbatm_pdu_length(length);
356 if (length > ATM_MAX_AAL5_PDU) {
357 atm_dbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
358 __func__, length, vcc);
359 atomic_inc(&vcc->stats->rx_err);
360 goto out;
361 }
362 365
363 pdu_length = usbatm_pdu_length(length); 366 if (sarb->len < pdu_length) {
367 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
368 __func__, pdu_length, sarb->len, vcc);
369 atomic_inc(&vcc->stats->rx_err);
370 goto out;
371 }
364 372
365 if (sarb->len < pdu_length) { 373 if (crc32_be(~0, sarb->tail - pdu_length, pdu_length) != 0xc704dd7b) {
366 atm_dbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n", 374 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
367 __func__, pdu_length, sarb->len, vcc); 375 __func__, vcc);
368 atomic_inc(&vcc->stats->rx_err); 376 atomic_inc(&vcc->stats->rx_err);
369 goto out; 377 goto out;
370 } 378 }
371 379
372 if (crc32_be(~0, sarb->tail - pdu_length, pdu_length) != 0xc704dd7b) { 380 vdbg("%s: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", __func__, length, pdu_length, vcc);
373 atm_dbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
374 __func__, vcc);
375 atomic_inc(&vcc->stats->rx_err);
376 goto out;
377 }
378 381
379 vdbg("%s: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", __func__, length, pdu_length, vcc); 382 if (!(skb = dev_alloc_skb(length))) {
383 if (printk_ratelimit())
384 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
385 __func__, length);
386 atomic_inc(&vcc->stats->rx_drop);
387 goto out;
388 }
380 389
381 if (!(skb = dev_alloc_skb(length))) { 390 vdbg("%s: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", __func__, skb, skb->truesize);
382 atm_dbg(instance, "%s: no memory for skb (length: %u)!\n", __func__, length);
383 atomic_inc(&vcc->stats->rx_drop);
384 goto out;
385 }
386 391
387 vdbg("%s: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", __func__, skb, skb->truesize); 392 if (!atm_charge(vcc, skb->truesize)) {
393 atm_rldbg(instance, "%s: failed atm_charge (skb->truesize: %u)!\n",
394 __func__, skb->truesize);
395 dev_kfree_skb_any(skb);
396 goto out; /* atm_charge increments rx_drop */
397 }
388 398
389 if (!atm_charge(vcc, skb->truesize)) { 399 memcpy(skb->data, sarb->tail - pdu_length, length);
390 atm_dbg(instance, "%s: failed atm_charge (skb->truesize: %u)!\n", __func__, skb->truesize); 400 __skb_put(skb, length);
391 dev_kfree_skb(skb);
392 goto out; /* atm_charge increments rx_drop */
393 }
394 401
395 memcpy(skb->data, sarb->tail - pdu_length, length); 402 vdbg("%s: sending skb 0x%p, skb->len %u, skb->truesize %u",
396 __skb_put(skb, length); 403 __func__, skb, skb->len, skb->truesize);
397 404
398 vdbg("%s: sending skb 0x%p, skb->len %u, skb->truesize %u", 405 PACKETDEBUG(skb->data, skb->len);
399 __func__, skb, skb->len, skb->truesize);
400 406
401 PACKETDEBUG(skb->data, skb->len); 407 vcc->push(vcc, skb);
402 408
403 vcc->push(vcc, skb); 409 atomic_inc(&vcc->stats->rx);
410 out:
411 skb_trim(sarb, 0);
412 }
413}
404 414
405 atomic_inc(&vcc->stats->rx); 415static void usbatm_extract_cells(struct usbatm_data *instance,
406 out: 416 unsigned char *source, unsigned int avail_data)
407 skb_trim(sarb, 0); 417{
418 unsigned int stride = instance->rx_channel.stride;
419 unsigned int buf_usage = instance->buf_usage;
420
421 /* extract cells from incoming data, taking into account that
422 * the length of avail data may not be a multiple of stride */
423
424 if (buf_usage > 0) {
425 /* we have a partially received atm cell */
426 unsigned char *cell_buf = instance->cell_buf;
427 unsigned int space_left = stride - buf_usage;
428
429 UDSL_ASSERT(buf_usage <= stride);
430
431 if (avail_data >= space_left) {
432 /* add new data and process cell */
433 memcpy(cell_buf + buf_usage, source, space_left);
434 source += space_left;
435 avail_data -= space_left;
436 usbatm_extract_one_cell(instance, cell_buf);
437 instance->buf_usage = 0;
438 } else {
439 /* not enough data to fill the cell */
440 memcpy(cell_buf + buf_usage, source, avail_data);
441 instance->buf_usage = buf_usage + avail_data;
442 return;
408 } 443 }
409 } 444 }
445
446 for (; avail_data >= stride; avail_data -= stride, source += stride)
447 usbatm_extract_one_cell(instance, source);
448
449 if (avail_data > 0) {
450 /* length was not a multiple of stride -
451 * save remaining data for next call */
452 memcpy(instance->cell_buf, source, avail_data);
453 instance->buf_usage = avail_data;
454 }
410} 455}
411 456
412 457
@@ -420,14 +465,14 @@ static unsigned int usbatm_write_cells(struct usbatm_data *instance,
420{ 465{
421 struct usbatm_control *ctrl = UDSL_SKB(skb); 466 struct usbatm_control *ctrl = UDSL_SKB(skb);
422 struct atm_vcc *vcc = ctrl->atm.vcc; 467 struct atm_vcc *vcc = ctrl->atm.vcc;
423 unsigned int num_written; 468 unsigned int bytes_written;
424 unsigned int stride = instance->tx_channel.stride; 469 unsigned int stride = instance->tx_channel.stride;
425 470
426 vdbg("%s: skb->len=%d, avail_space=%u", __func__, skb->len, avail_space); 471 vdbg("%s: skb->len=%d, avail_space=%u", __func__, skb->len, avail_space);
427 UDSL_ASSERT(!(avail_space % stride)); 472 UDSL_ASSERT(!(avail_space % stride));
428 473
429 for (num_written = 0; num_written < avail_space && ctrl->len; 474 for (bytes_written = 0; bytes_written < avail_space && ctrl->len;
430 num_written += stride, target += stride) { 475 bytes_written += stride, target += stride) {
431 unsigned int data_len = min_t(unsigned int, skb->len, ATM_CELL_PAYLOAD); 476 unsigned int data_len = min_t(unsigned int, skb->len, ATM_CELL_PAYLOAD);
432 unsigned int left = ATM_CELL_PAYLOAD - data_len; 477 unsigned int left = ATM_CELL_PAYLOAD - data_len;
433 u8 *ptr = target; 478 u8 *ptr = target;
@@ -470,7 +515,7 @@ static unsigned int usbatm_write_cells(struct usbatm_data *instance,
470 ctrl->crc = crc32_be(ctrl->crc, ptr, left); 515 ctrl->crc = crc32_be(ctrl->crc, ptr, left);
471 } 516 }
472 517
473 return num_written; 518 return bytes_written;
474} 519}
475 520
476 521
@@ -487,16 +532,40 @@ static void usbatm_rx_process(unsigned long data)
487 vdbg("%s: processing urb 0x%p", __func__, urb); 532 vdbg("%s: processing urb 0x%p", __func__, urb);
488 533
489 if (usb_pipeisoc(urb->pipe)) { 534 if (usb_pipeisoc(urb->pipe)) {
535 unsigned char *merge_start = NULL;
536 unsigned int merge_length = 0;
537 const unsigned int packet_size = instance->rx_channel.packet_size;
490 int i; 538 int i;
491 for (i = 0; i < urb->number_of_packets; i++) 539
492 if (!urb->iso_frame_desc[i].status) 540 for (i = 0; i < urb->number_of_packets; i++) {
493 usbatm_extract_cells(instance, 541 if (!urb->iso_frame_desc[i].status) {
494 (u8 *)urb->transfer_buffer + urb->iso_frame_desc[i].offset, 542 unsigned int actual_length = urb->iso_frame_desc[i].actual_length;
495 urb->iso_frame_desc[i].actual_length); 543
496 } 544 UDSL_ASSERT(actual_length <= packet_size);
497 else 545
546 if (!merge_length)
547 merge_start = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset;
548 merge_length += actual_length;
549 if (merge_length && (actual_length < packet_size)) {
550 usbatm_extract_cells(instance, merge_start, merge_length);
551 merge_length = 0;
552 }
553 } else {
554 atm_rldbg(instance, "%s: status %d in frame %d!\n", __func__, urb->status, i);
555 if (merge_length)
556 usbatm_extract_cells(instance, merge_start, merge_length);
557 merge_length = 0;
558 instance->buf_usage = 0;
559 }
560 }
561
562 if (merge_length)
563 usbatm_extract_cells(instance, merge_start, merge_length);
564 } else
498 if (!urb->status) 565 if (!urb->status)
499 usbatm_extract_cells(instance, urb->transfer_buffer, urb->actual_length); 566 usbatm_extract_cells(instance, urb->transfer_buffer, urb->actual_length);
567 else
568 instance->buf_usage = 0;
500 569
501 if (usbatm_submit_urb(urb)) 570 if (usbatm_submit_urb(urb))
502 return; 571 return;
@@ -514,7 +583,7 @@ static void usbatm_tx_process(unsigned long data)
514 struct sk_buff *skb = instance->current_skb; 583 struct sk_buff *skb = instance->current_skb;
515 struct urb *urb = NULL; 584 struct urb *urb = NULL;
516 const unsigned int buf_size = instance->tx_channel.buf_size; 585 const unsigned int buf_size = instance->tx_channel.buf_size;
517 unsigned int num_written = 0; 586 unsigned int bytes_written = 0;
518 u8 *buffer = NULL; 587 u8 *buffer = NULL;
519 588
520 if (!skb) 589 if (!skb)
@@ -526,16 +595,16 @@ static void usbatm_tx_process(unsigned long data)
526 if (!urb) 595 if (!urb)
527 break; /* no more senders */ 596 break; /* no more senders */
528 buffer = urb->transfer_buffer; 597 buffer = urb->transfer_buffer;
529 num_written = (urb->status == -EAGAIN) ? 598 bytes_written = (urb->status == -EAGAIN) ?
530 urb->transfer_buffer_length : 0; 599 urb->transfer_buffer_length : 0;
531 } 600 }
532 601
533 num_written += usbatm_write_cells(instance, skb, 602 bytes_written += usbatm_write_cells(instance, skb,
534 buffer + num_written, 603 buffer + bytes_written,
535 buf_size - num_written); 604 buf_size - bytes_written);
536 605
537 vdbg("%s: wrote %u bytes from skb 0x%p to urb 0x%p", 606 vdbg("%s: wrote %u bytes from skb 0x%p to urb 0x%p",
538 __func__, num_written, skb, urb); 607 __func__, bytes_written, skb, urb);
539 608
540 if (!UDSL_SKB(skb)->len) { 609 if (!UDSL_SKB(skb)->len) {
541 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc; 610 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
@@ -546,8 +615,8 @@ static void usbatm_tx_process(unsigned long data)
546 skb = skb_dequeue(&instance->sndqueue); 615 skb = skb_dequeue(&instance->sndqueue);
547 } 616 }
548 617
549 if (num_written == buf_size || (!skb && num_written)) { 618 if (bytes_written == buf_size || (!skb && bytes_written)) {
550 urb->transfer_buffer_length = num_written; 619 urb->transfer_buffer_length = bytes_written;
551 620
552 if (usbatm_submit_urb(urb)) 621 if (usbatm_submit_urb(urb))
553 break; 622 break;
@@ -593,20 +662,24 @@ static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
593 662
594 vdbg("%s called (skb 0x%p, len %u)", __func__, skb, skb->len); 663 vdbg("%s called (skb 0x%p, len %u)", __func__, skb, skb->len);
595 664
596 if (!instance) { 665 /* racy disconnection check - fine */
597 dbg("%s: NULL data!", __func__); 666 if (!instance || instance->disconnected) {
667#ifdef DEBUG
668 if (printk_ratelimit())
669 printk(KERN_DEBUG "%s: %s!\n", __func__, instance ? "disconnected" : "NULL instance");
670#endif
598 err = -ENODEV; 671 err = -ENODEV;
599 goto fail; 672 goto fail;
600 } 673 }
601 674
602 if (vcc->qos.aal != ATM_AAL5) { 675 if (vcc->qos.aal != ATM_AAL5) {
603 atm_dbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal); 676 atm_rldbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal);
604 err = -EINVAL; 677 err = -EINVAL;
605 goto fail; 678 goto fail;
606 } 679 }
607 680
608 if (skb->len > ATM_MAX_AAL5_PDU) { 681 if (skb->len > ATM_MAX_AAL5_PDU) {
609 atm_dbg(instance, "%s: packet too long (%d vs %d)!\n", 682 atm_rldbg(instance, "%s: packet too long (%d vs %d)!\n",
610 __func__, skb->len, ATM_MAX_AAL5_PDU); 683 __func__, skb->len, ATM_MAX_AAL5_PDU);
611 err = -EINVAL; 684 err = -EINVAL;
612 goto fail; 685 goto fail;
@@ -665,16 +738,16 @@ static void usbatm_put_instance(struct usbatm_data *instance)
665** ATM ** 738** ATM **
666**********/ 739**********/
667 740
668static void usbatm_atm_dev_close(struct atm_dev *dev) 741static void usbatm_atm_dev_close(struct atm_dev *atm_dev)
669{ 742{
670 struct usbatm_data *instance = dev->dev_data; 743 struct usbatm_data *instance = atm_dev->dev_data;
671 744
672 dbg("%s", __func__); 745 dbg("%s", __func__);
673 746
674 if (!instance) 747 if (!instance)
675 return; 748 return;
676 749
677 dev->dev_data = NULL; 750 atm_dev->dev_data = NULL; /* catch bugs */
678 usbatm_put_instance(instance); /* taken in usbatm_atm_init */ 751 usbatm_put_instance(instance); /* taken in usbatm_atm_init */
679} 752}
680 753
@@ -706,15 +779,19 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
706 atomic_read(&atm_dev->stats.aal5.rx_err), 779 atomic_read(&atm_dev->stats.aal5.rx_err),
707 atomic_read(&atm_dev->stats.aal5.rx_drop)); 780 atomic_read(&atm_dev->stats.aal5.rx_drop));
708 781
709 if (!left--) 782 if (!left--) {
710 switch (atm_dev->signal) { 783 if (instance->disconnected)
711 case ATM_PHY_SIG_FOUND: 784 return sprintf(page, "Disconnected\n");
712 return sprintf(page, "Line up\n"); 785 else
713 case ATM_PHY_SIG_LOST: 786 switch (atm_dev->signal) {
714 return sprintf(page, "Line down\n"); 787 case ATM_PHY_SIG_FOUND:
715 default: 788 return sprintf(page, "Line up\n");
716 return sprintf(page, "Line state unknown\n"); 789 case ATM_PHY_SIG_LOST:
717 } 790 return sprintf(page, "Line down\n");
791 default:
792 return sprintf(page, "Line state unknown\n");
793 }
794 }
718 795
719 return 0; 796 return 0;
720} 797}
@@ -735,13 +812,24 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
735 atm_dbg(instance, "%s: vpi %hd, vci %d\n", __func__, vpi, vci); 812 atm_dbg(instance, "%s: vpi %hd, vci %d\n", __func__, vpi, vci);
736 813
737 /* only support AAL5 */ 814 /* only support AAL5 */
738 if ((vcc->qos.aal != ATM_AAL5) || (vcc->qos.rxtp.max_sdu < 0) 815 if ((vcc->qos.aal != ATM_AAL5)) {
739 || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) { 816 atm_warn(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal);
740 atm_dbg(instance, "%s: unsupported ATM type %d!\n", __func__, vcc->qos.aal); 817 return -EINVAL;
818 }
819
820 /* sanity checks */
821 if ((vcc->qos.rxtp.max_sdu < 0) || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) {
822 atm_dbg(instance, "%s: max_sdu %d out of range!\n", __func__, vcc->qos.rxtp.max_sdu);
741 return -EINVAL; 823 return -EINVAL;
742 } 824 }
743 825
744 down(&instance->serialize); /* vs self, usbatm_atm_close */ 826 mutex_lock(&instance->serialize); /* vs self, usbatm_atm_close, usbatm_usb_disconnect */
827
828 if (instance->disconnected) {
829 atm_dbg(instance, "%s: disconnected!\n", __func__);
830 ret = -ENODEV;
831 goto fail;
832 }
745 833
746 if (usbatm_find_vcc(instance, vpi, vci)) { 834 if (usbatm_find_vcc(instance, vpi, vci)) {
747 atm_dbg(instance, "%s: %hd/%d already in use!\n", __func__, vpi, vci); 835 atm_dbg(instance, "%s: %hd/%d already in use!\n", __func__, vpi, vci);
@@ -749,20 +837,19 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
749 goto fail; 837 goto fail;
750 } 838 }
751 839
752 if (!(new = kmalloc(sizeof(struct usbatm_vcc_data), GFP_KERNEL))) { 840 if (!(new = kzalloc(sizeof(struct usbatm_vcc_data), GFP_KERNEL))) {
753 atm_dbg(instance, "%s: no memory for vcc_data!\n", __func__); 841 atm_err(instance, "%s: no memory for vcc_data!\n", __func__);
754 ret = -ENOMEM; 842 ret = -ENOMEM;
755 goto fail; 843 goto fail;
756 } 844 }
757 845
758 memset(new, 0, sizeof(struct usbatm_vcc_data));
759 new->vcc = vcc; 846 new->vcc = vcc;
760 new->vpi = vpi; 847 new->vpi = vpi;
761 new->vci = vci; 848 new->vci = vci;
762 849
763 new->sarb = alloc_skb(usbatm_pdu_length(vcc->qos.rxtp.max_sdu), GFP_KERNEL); 850 new->sarb = alloc_skb(usbatm_pdu_length(vcc->qos.rxtp.max_sdu), GFP_KERNEL);
764 if (!new->sarb) { 851 if (!new->sarb) {
765 atm_dbg(instance, "%s: no memory for SAR buffer!\n", __func__); 852 atm_err(instance, "%s: no memory for SAR buffer!\n", __func__);
766 ret = -ENOMEM; 853 ret = -ENOMEM;
767 goto fail; 854 goto fail;
768 } 855 }
@@ -770,6 +857,9 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
770 vcc->dev_data = new; 857 vcc->dev_data = new;
771 858
772 tasklet_disable(&instance->rx_channel.tasklet); 859 tasklet_disable(&instance->rx_channel.tasklet);
860 instance->cached_vcc = new;
861 instance->cached_vpi = vpi;
862 instance->cached_vci = vci;
773 list_add(&new->list, &instance->vcc_list); 863 list_add(&new->list, &instance->vcc_list);
774 tasklet_enable(&instance->rx_channel.tasklet); 864 tasklet_enable(&instance->rx_channel.tasklet);
775 865
@@ -777,7 +867,7 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
777 set_bit(ATM_VF_PARTIAL, &vcc->flags); 867 set_bit(ATM_VF_PARTIAL, &vcc->flags);
778 set_bit(ATM_VF_READY, &vcc->flags); 868 set_bit(ATM_VF_READY, &vcc->flags);
779 869
780 up(&instance->serialize); 870 mutex_unlock(&instance->serialize);
781 871
782 atm_dbg(instance, "%s: allocated vcc data 0x%p\n", __func__, new); 872 atm_dbg(instance, "%s: allocated vcc data 0x%p\n", __func__, new);
783 873
@@ -785,7 +875,7 @@ static int usbatm_atm_open(struct atm_vcc *vcc)
785 875
786fail: 876fail:
787 kfree(new); 877 kfree(new);
788 up(&instance->serialize); 878 mutex_unlock(&instance->serialize);
789 return ret; 879 return ret;
790} 880}
791 881
@@ -806,9 +896,14 @@ static void usbatm_atm_close(struct atm_vcc *vcc)
806 896
807 usbatm_cancel_send(instance, vcc); 897 usbatm_cancel_send(instance, vcc);
808 898
809 down(&instance->serialize); /* vs self, usbatm_atm_open */ 899 mutex_lock(&instance->serialize); /* vs self, usbatm_atm_open, usbatm_usb_disconnect */
810 900
811 tasklet_disable(&instance->rx_channel.tasklet); 901 tasklet_disable(&instance->rx_channel.tasklet);
902 if (instance->cached_vcc == vcc_data) {
903 instance->cached_vcc = NULL;
904 instance->cached_vpi = ATM_VPI_UNSPEC;
905 instance->cached_vci = ATM_VCI_UNSPEC;
906 }
812 list_del(&vcc_data->list); 907 list_del(&vcc_data->list);
813 tasklet_enable(&instance->rx_channel.tasklet); 908 tasklet_enable(&instance->rx_channel.tasklet);
814 909
@@ -824,14 +919,21 @@ static void usbatm_atm_close(struct atm_vcc *vcc)
824 clear_bit(ATM_VF_PARTIAL, &vcc->flags); 919 clear_bit(ATM_VF_PARTIAL, &vcc->flags);
825 clear_bit(ATM_VF_ADDR, &vcc->flags); 920 clear_bit(ATM_VF_ADDR, &vcc->flags);
826 921
827 up(&instance->serialize); 922 mutex_unlock(&instance->serialize);
828 923
829 atm_dbg(instance, "%s successful\n", __func__); 924 atm_dbg(instance, "%s successful\n", __func__);
830} 925}
831 926
832static int usbatm_atm_ioctl(struct atm_dev *dev, unsigned int cmd, 927static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd,
833 void __user * arg) 928 void __user * arg)
834{ 929{
930 struct usbatm_data *instance = atm_dev->dev_data;
931
932 if (!instance || instance->disconnected) {
933 dbg("%s: %s!", __func__, instance ? "disconnected" : "NULL instance");
934 return -ENODEV;
935 }
936
835 switch (cmd) { 937 switch (cmd) {
836 case ATM_QUERYLOOP: 938 case ATM_QUERYLOOP:
837 return put_user(ATM_LM_NONE, (int __user *)arg) ? -EFAULT : 0; 939 return put_user(ATM_LM_NONE, (int __user *)arg) ? -EFAULT : 0;
@@ -845,10 +947,13 @@ static int usbatm_atm_init(struct usbatm_data *instance)
845 struct atm_dev *atm_dev; 947 struct atm_dev *atm_dev;
846 int ret, i; 948 int ret, i;
847 949
848 /* ATM init */ 950 /* ATM init. The ATM initialization scheme suffers from an intrinsic race
951 * condition: callbacks we register can be executed at once, before we have
952 * initialized the struct atm_dev. To protect against this, all callbacks
953 * abort if atm_dev->dev_data is NULL. */
849 atm_dev = atm_dev_register(instance->driver_name, &usbatm_atm_devops, -1, NULL); 954 atm_dev = atm_dev_register(instance->driver_name, &usbatm_atm_devops, -1, NULL);
850 if (!atm_dev) { 955 if (!atm_dev) {
851 usb_dbg(instance, "%s: failed to register ATM device!\n", __func__); 956 usb_err(instance, "%s: failed to register ATM device!\n", __func__);
852 return -1; 957 return -1;
853 } 958 }
854 959
@@ -862,12 +967,13 @@ static int usbatm_atm_init(struct usbatm_data *instance)
862 atm_dev->link_rate = 128 * 1000 / 424; 967 atm_dev->link_rate = 128 * 1000 / 424;
863 968
864 if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) { 969 if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) {
865 atm_dbg(instance, "%s: atm_start failed: %d!\n", __func__, ret); 970 atm_err(instance, "%s: atm_start failed: %d!\n", __func__, ret);
866 goto fail; 971 goto fail;
867 } 972 }
868 973
869 /* ready for ATM callbacks */
870 usbatm_get_instance(instance); /* dropped in usbatm_atm_dev_close */ 974 usbatm_get_instance(instance); /* dropped in usbatm_atm_dev_close */
975
976 /* ready for ATM callbacks */
871 mb(); 977 mb();
872 atm_dev->dev_data = instance; 978 atm_dev->dev_data = instance;
873 979
@@ -903,9 +1009,9 @@ static int usbatm_do_heavy_init(void *arg)
903 if (!ret) 1009 if (!ret)
904 ret = usbatm_atm_init(instance); 1010 ret = usbatm_atm_init(instance);
905 1011
906 down(&instance->serialize); 1012 mutex_lock(&instance->serialize);
907 instance->thread_pid = -1; 1013 instance->thread_pid = -1;
908 up(&instance->serialize); 1014 mutex_unlock(&instance->serialize);
909 1015
910 complete_and_exit(&instance->thread_exited, ret); 1016 complete_and_exit(&instance->thread_exited, ret);
911} 1017}
@@ -915,13 +1021,13 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
915 int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_KERNEL); 1021 int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_KERNEL);
916 1022
917 if (ret < 0) { 1023 if (ret < 0) {
918 usb_dbg(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret); 1024 usb_err(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret);
919 return ret; 1025 return ret;
920 } 1026 }
921 1027
922 down(&instance->serialize); 1028 mutex_lock(&instance->serialize);
923 instance->thread_pid = ret; 1029 instance->thread_pid = ret;
924 up(&instance->serialize); 1030 mutex_unlock(&instance->serialize);
925 1031
926 wait_for_completion(&instance->thread_started); 1032 wait_for_completion(&instance->thread_started);
927 1033
@@ -951,9 +1057,9 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
951 char *buf; 1057 char *buf;
952 int error = -ENOMEM; 1058 int error = -ENOMEM;
953 int i, length; 1059 int i, length;
954 int need_heavy; 1060 unsigned int maxpacket, num_packets;
955 1061
956 dev_dbg(dev, "%s: trying driver %s with vendor=0x%x, product=0x%x, ifnum %d\n", 1062 dev_dbg(dev, "%s: trying driver %s with vendor=%04x, product=%04x, ifnum %2d\n",
957 __func__, driver->driver_name, 1063 __func__, driver->driver_name,
958 le16_to_cpu(usb_dev->descriptor.idVendor), 1064 le16_to_cpu(usb_dev->descriptor.idVendor),
959 le16_to_cpu(usb_dev->descriptor.idProduct), 1065 le16_to_cpu(usb_dev->descriptor.idProduct),
@@ -962,7 +1068,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
962 /* instance init */ 1068 /* instance init */
963 instance = kzalloc(sizeof(*instance) + sizeof(struct urb *) * (num_rcv_urbs + num_snd_urbs), GFP_KERNEL); 1069 instance = kzalloc(sizeof(*instance) + sizeof(struct urb *) * (num_rcv_urbs + num_snd_urbs), GFP_KERNEL);
964 if (!instance) { 1070 if (!instance) {
965 dev_dbg(dev, "%s: no memory for instance data!\n", __func__); 1071 dev_err(dev, "%s: no memory for instance data!\n", __func__);
966 return -ENOMEM; 1072 return -ENOMEM;
967 } 1073 }
968 1074
@@ -996,66 +1102,96 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
996 snprintf(buf, length, ")"); 1102 snprintf(buf, length, ")");
997 1103
998 bind: 1104 bind:
999 need_heavy = 1; 1105 if (driver->bind && (error = driver->bind(instance, intf, id)) < 0) {
1000 if (driver->bind && (error = driver->bind(instance, intf, id, &need_heavy)) < 0) { 1106 dev_err(dev, "%s: bind failed: %d!\n", __func__, error);
1001 dev_dbg(dev, "%s: bind failed: %d!\n", __func__, error);
1002 goto fail_free; 1107 goto fail_free;
1003 } 1108 }
1004 1109
1005 /* private fields */ 1110 /* private fields */
1006 1111
1007 kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */ 1112 kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */
1008 init_MUTEX(&instance->serialize); 1113 mutex_init(&instance->serialize);
1009 1114
1010 instance->thread_pid = -1; 1115 instance->thread_pid = -1;
1011 init_completion(&instance->thread_started); 1116 init_completion(&instance->thread_started);
1012 init_completion(&instance->thread_exited); 1117 init_completion(&instance->thread_exited);
1013 1118
1014 INIT_LIST_HEAD(&instance->vcc_list); 1119 INIT_LIST_HEAD(&instance->vcc_list);
1120 skb_queue_head_init(&instance->sndqueue);
1015 1121
1016 usbatm_init_channel(&instance->rx_channel); 1122 usbatm_init_channel(&instance->rx_channel);
1017 usbatm_init_channel(&instance->tx_channel); 1123 usbatm_init_channel(&instance->tx_channel);
1018 tasklet_init(&instance->rx_channel.tasklet, usbatm_rx_process, (unsigned long)instance); 1124 tasklet_init(&instance->rx_channel.tasklet, usbatm_rx_process, (unsigned long)instance);
1019 tasklet_init(&instance->tx_channel.tasklet, usbatm_tx_process, (unsigned long)instance); 1125 tasklet_init(&instance->tx_channel.tasklet, usbatm_tx_process, (unsigned long)instance);
1020 instance->rx_channel.endpoint = usb_rcvbulkpipe(usb_dev, driver->in);
1021 instance->tx_channel.endpoint = usb_sndbulkpipe(usb_dev, driver->out);
1022 instance->rx_channel.stride = ATM_CELL_SIZE + driver->rx_padding; 1126 instance->rx_channel.stride = ATM_CELL_SIZE + driver->rx_padding;
1023 instance->tx_channel.stride = ATM_CELL_SIZE + driver->tx_padding; 1127 instance->tx_channel.stride = ATM_CELL_SIZE + driver->tx_padding;
1024 instance->rx_channel.buf_size = rcv_buf_size * instance->rx_channel.stride;
1025 instance->tx_channel.buf_size = snd_buf_size * instance->tx_channel.stride;
1026 instance->rx_channel.usbatm = instance->tx_channel.usbatm = instance; 1128 instance->rx_channel.usbatm = instance->tx_channel.usbatm = instance;
1027 1129
1028 skb_queue_head_init(&instance->sndqueue); 1130 if ((instance->flags & UDSL_USE_ISOC) && driver->isoc_in)
1131 instance->rx_channel.endpoint = usb_rcvisocpipe(usb_dev, driver->isoc_in);
1132 else
1133 instance->rx_channel.endpoint = usb_rcvbulkpipe(usb_dev, driver->bulk_in);
1134
1135 instance->tx_channel.endpoint = usb_sndbulkpipe(usb_dev, driver->bulk_out);
1136
1137 /* tx buffer size must be a positive multiple of the stride */
1138 instance->tx_channel.buf_size = max (instance->tx_channel.stride,
1139 snd_buf_bytes - (snd_buf_bytes % instance->tx_channel.stride));
1140
1141 /* rx buffer size must be a positive multiple of the endpoint maxpacket */
1142 maxpacket = usb_maxpacket(usb_dev, instance->rx_channel.endpoint, 0);
1143
1144 if ((maxpacket < 1) || (maxpacket > UDSL_MAX_BUF_SIZE)) {
1145 dev_err(dev, "%s: invalid endpoint %02x!\n", __func__,
1146 usb_pipeendpoint(instance->rx_channel.endpoint));
1147 error = -EINVAL;
1148 goto fail_unbind;
1149 }
1150
1151 num_packets = max (1U, (rcv_buf_bytes + maxpacket / 2) / maxpacket); /* round */
1152
1153 if (num_packets * maxpacket > UDSL_MAX_BUF_SIZE)
1154 num_packets--;
1155
1156 instance->rx_channel.buf_size = num_packets * maxpacket;
1157 instance->rx_channel.packet_size = maxpacket;
1158
1159#ifdef DEBUG
1160 for (i = 0; i < 2; i++) {
1161 struct usbatm_channel *channel = i ?
1162 &instance->tx_channel : &instance->rx_channel;
1163
1164 dev_dbg(dev, "%s: using %d byte buffer for %s channel 0x%p\n", __func__, channel->buf_size, i ? "tx" : "rx", channel);
1165 }
1166#endif
1167
1168 /* initialize urbs */
1029 1169
1030 for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) { 1170 for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {
1031 struct urb *urb;
1032 u8 *buffer; 1171 u8 *buffer;
1033 unsigned int iso_packets = 0, iso_size = 0;
1034 struct usbatm_channel *channel = i < num_rcv_urbs ? 1172 struct usbatm_channel *channel = i < num_rcv_urbs ?
1035 &instance->rx_channel : &instance->tx_channel; 1173 &instance->rx_channel : &instance->tx_channel;
1174 struct urb *urb;
1175 unsigned int iso_packets = usb_pipeisoc(channel->endpoint) ? channel->buf_size / channel->packet_size : 0;
1036 1176
1037 if (usb_pipeisoc(channel->endpoint)) { 1177 UDSL_ASSERT(!usb_pipeisoc(channel->endpoint) || usb_pipein(channel->endpoint));
1038 /* don't expect iso out endpoints */
1039 iso_size = usb_maxpacket(instance->usb_dev, channel->endpoint, 0);
1040 iso_size -= iso_size % channel->stride; /* alignment */
1041 BUG_ON(!iso_size);
1042 iso_packets = (channel->buf_size - 1) / iso_size + 1;
1043 }
1044 1178
1045 urb = usb_alloc_urb(iso_packets, GFP_KERNEL); 1179 urb = usb_alloc_urb(iso_packets, GFP_KERNEL);
1046 if (!urb) { 1180 if (!urb) {
1047 dev_dbg(dev, "%s: no memory for urb %d!\n", __func__, i); 1181 dev_err(dev, "%s: no memory for urb %d!\n", __func__, i);
1182 error = -ENOMEM;
1048 goto fail_unbind; 1183 goto fail_unbind;
1049 } 1184 }
1050 1185
1051 instance->urbs[i] = urb; 1186 instance->urbs[i] = urb;
1052 1187
1053 buffer = kmalloc(channel->buf_size, GFP_KERNEL); 1188 /* zero the tx padding to avoid leaking information */
1189 buffer = kzalloc(channel->buf_size, GFP_KERNEL);
1054 if (!buffer) { 1190 if (!buffer) {
1055 dev_dbg(dev, "%s: no memory for buffer %d!\n", __func__, i); 1191 dev_err(dev, "%s: no memory for buffer %d!\n", __func__, i);
1192 error = -ENOMEM;
1056 goto fail_unbind; 1193 goto fail_unbind;
1057 } 1194 }
1058 memset(buffer, 0, channel->buf_size);
1059 1195
1060 usb_fill_bulk_urb(urb, instance->usb_dev, channel->endpoint, 1196 usb_fill_bulk_urb(urb, instance->usb_dev, channel->endpoint,
1061 buffer, channel->buf_size, usbatm_complete, channel); 1197 buffer, channel->buf_size, usbatm_complete, channel);
@@ -1065,9 +1201,8 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
1065 urb->transfer_flags = URB_ISO_ASAP; 1201 urb->transfer_flags = URB_ISO_ASAP;
1066 urb->number_of_packets = iso_packets; 1202 urb->number_of_packets = iso_packets;
1067 for (j = 0; j < iso_packets; j++) { 1203 for (j = 0; j < iso_packets; j++) {
1068 urb->iso_frame_desc[j].offset = iso_size * j; 1204 urb->iso_frame_desc[j].offset = channel->packet_size * j;
1069 urb->iso_frame_desc[j].length = min_t(int, iso_size, 1205 urb->iso_frame_desc[j].length = channel->packet_size;
1070 channel->buf_size - urb->iso_frame_desc[j].offset);
1071 } 1206 }
1072 } 1207 }
1073 1208
@@ -1079,7 +1214,17 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
1079 __func__, urb->transfer_buffer, urb->transfer_buffer_length, urb); 1214 __func__, urb->transfer_buffer, urb->transfer_buffer_length, urb);
1080 } 1215 }
1081 1216
1082 if (need_heavy && driver->heavy_init) { 1217 instance->cached_vpi = ATM_VPI_UNSPEC;
1218 instance->cached_vci = ATM_VCI_UNSPEC;
1219 instance->cell_buf = kmalloc(instance->rx_channel.stride, GFP_KERNEL);
1220
1221 if (!instance->cell_buf) {
1222 dev_err(dev, "%s: no memory for cell buffer!\n", __func__);
1223 error = -ENOMEM;
1224 goto fail_unbind;
1225 }
1226
1227 if (!(instance->flags & UDSL_SKIP_HEAVY_INIT) && driver->heavy_init) {
1083 error = usbatm_heavy_init(instance); 1228 error = usbatm_heavy_init(instance);
1084 } else { 1229 } else {
1085 complete(&instance->thread_exited); /* pretend that heavy_init was run */ 1230 complete(&instance->thread_exited); /* pretend that heavy_init was run */
@@ -1098,6 +1243,8 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
1098 if (instance->driver->unbind) 1243 if (instance->driver->unbind)
1099 instance->driver->unbind(instance, intf); 1244 instance->driver->unbind(instance, intf);
1100 fail_free: 1245 fail_free:
1246 kfree(instance->cell_buf);
1247
1101 for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) { 1248 for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {
1102 if (instance->urbs[i]) 1249 if (instance->urbs[i])
1103 kfree(instance->urbs[i]->transfer_buffer); 1250 kfree(instance->urbs[i]->transfer_buffer);
@@ -1114,6 +1261,7 @@ void usbatm_usb_disconnect(struct usb_interface *intf)
1114{ 1261{
1115 struct device *dev = &intf->dev; 1262 struct device *dev = &intf->dev;
1116 struct usbatm_data *instance = usb_get_intfdata(intf); 1263 struct usbatm_data *instance = usb_get_intfdata(intf);
1264 struct usbatm_vcc_data *vcc_data;
1117 int i; 1265 int i;
1118 1266
1119 dev_dbg(dev, "%s entered\n", __func__); 1267 dev_dbg(dev, "%s entered\n", __func__);
@@ -1125,13 +1273,19 @@ void usbatm_usb_disconnect(struct usb_interface *intf)
1125 1273
1126 usb_set_intfdata(intf, NULL); 1274 usb_set_intfdata(intf, NULL);
1127 1275
1128 down(&instance->serialize); 1276 mutex_lock(&instance->serialize);
1277 instance->disconnected = 1;
1129 if (instance->thread_pid >= 0) 1278 if (instance->thread_pid >= 0)
1130 kill_proc(instance->thread_pid, SIGTERM, 1); 1279 kill_proc(instance->thread_pid, SIGTERM, 1);
1131 up(&instance->serialize); 1280 mutex_unlock(&instance->serialize);
1132 1281
1133 wait_for_completion(&instance->thread_exited); 1282 wait_for_completion(&instance->thread_exited);
1134 1283
1284 mutex_lock(&instance->serialize);
1285 list_for_each_entry(vcc_data, &instance->vcc_list, list)
1286 vcc_release_async(vcc_data->vcc, -EPIPE);
1287 mutex_unlock(&instance->serialize);
1288
1135 tasklet_disable(&instance->rx_channel.tasklet); 1289 tasklet_disable(&instance->rx_channel.tasklet);
1136 tasklet_disable(&instance->tx_channel.tasklet); 1290 tasklet_disable(&instance->tx_channel.tasklet);
1137 1291
@@ -1141,6 +1295,14 @@ void usbatm_usb_disconnect(struct usb_interface *intf)
1141 del_timer_sync(&instance->rx_channel.delay); 1295 del_timer_sync(&instance->rx_channel.delay);
1142 del_timer_sync(&instance->tx_channel.delay); 1296 del_timer_sync(&instance->tx_channel.delay);
1143 1297
1298 /* turn usbatm_[rt]x_process into something close to a no-op */
1299 /* no need to take the spinlock */
1300 INIT_LIST_HEAD(&instance->rx_channel.list);
1301 INIT_LIST_HEAD(&instance->tx_channel.list);
1302
1303 tasklet_enable(&instance->rx_channel.tasklet);
1304 tasklet_enable(&instance->tx_channel.tasklet);
1305
1144 if (instance->atm_dev && instance->driver->atm_stop) 1306 if (instance->atm_dev && instance->driver->atm_stop)
1145 instance->driver->atm_stop(instance, instance->atm_dev); 1307 instance->driver->atm_stop(instance, instance->atm_dev);
1146 1308
@@ -1149,19 +1311,13 @@ void usbatm_usb_disconnect(struct usb_interface *intf)
1149 1311
1150 instance->driver_data = NULL; 1312 instance->driver_data = NULL;
1151 1313
1152 /* turn usbatm_[rt]x_process into noop */
1153 /* no need to take the spinlock */
1154 INIT_LIST_HEAD(&instance->rx_channel.list);
1155 INIT_LIST_HEAD(&instance->tx_channel.list);
1156
1157 tasklet_enable(&instance->rx_channel.tasklet);
1158 tasklet_enable(&instance->tx_channel.tasklet);
1159
1160 for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) { 1314 for (i = 0; i < num_rcv_urbs + num_snd_urbs; i++) {
1161 kfree(instance->urbs[i]->transfer_buffer); 1315 kfree(instance->urbs[i]->transfer_buffer);
1162 usb_free_urb(instance->urbs[i]); 1316 usb_free_urb(instance->urbs[i]);
1163 } 1317 }
1164 1318
1319 kfree(instance->cell_buf);
1320
1165 /* ATM finalize */ 1321 /* ATM finalize */
1166 if (instance->atm_dev) 1322 if (instance->atm_dev)
1167 atm_dev_deregister(instance->atm_dev); 1323 atm_dev_deregister(instance->atm_dev);
@@ -1186,10 +1342,10 @@ static int __init usbatm_usb_init(void)
1186 1342
1187 if ((num_rcv_urbs > UDSL_MAX_RCV_URBS) 1343 if ((num_rcv_urbs > UDSL_MAX_RCV_URBS)
1188 || (num_snd_urbs > UDSL_MAX_SND_URBS) 1344 || (num_snd_urbs > UDSL_MAX_SND_URBS)
1189 || (rcv_buf_size < 1) 1345 || (rcv_buf_bytes < 1)
1190 || (rcv_buf_size > UDSL_MAX_RCV_BUF_SIZE) 1346 || (rcv_buf_bytes > UDSL_MAX_BUF_SIZE)
1191 || (snd_buf_size < 1) 1347 || (snd_buf_bytes < 1)
1192 || (snd_buf_size > UDSL_MAX_SND_BUF_SIZE)) 1348 || (snd_buf_bytes > UDSL_MAX_BUF_SIZE))
1193 return -EINVAL; 1349 return -EINVAL;
1194 1350
1195 return 0; 1351 return 0;
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
index 1adacd60d713..ff8551e93372 100644
--- a/drivers/usb/atm/usbatm.h
+++ b/drivers/usb/atm/usbatm.h
@@ -24,21 +24,21 @@
24#ifndef _USBATM_H_ 24#ifndef _USBATM_H_
25#define _USBATM_H_ 25#define _USBATM_H_
26 26
27#include <linux/config.h>
28
29/*
30#define VERBOSE_DEBUG
31*/
32
33#include <asm/semaphore.h> 27#include <asm/semaphore.h>
34#include <linux/atm.h> 28#include <linux/atm.h>
35#include <linux/atmdev.h> 29#include <linux/atmdev.h>
36#include <linux/completion.h> 30#include <linux/completion.h>
37#include <linux/device.h> 31#include <linux/device.h>
32#include <linux/kernel.h>
38#include <linux/kref.h> 33#include <linux/kref.h>
39#include <linux/list.h> 34#include <linux/list.h>
40#include <linux/stringify.h> 35#include <linux/stringify.h>
41#include <linux/usb.h> 36#include <linux/usb.h>
37#include <linux/mutex.h>
38
39/*
40#define VERBOSE_DEBUG
41*/
42 42
43#ifdef DEBUG 43#ifdef DEBUG
44#define UDSL_ASSERT(x) BUG_ON(!(x)) 44#define UDSL_ASSERT(x) BUG_ON(!(x))
@@ -52,8 +52,13 @@
52 dev_info(&(instance)->usb_intf->dev , format , ## arg) 52 dev_info(&(instance)->usb_intf->dev , format , ## arg)
53#define usb_warn(instance, format, arg...) \ 53#define usb_warn(instance, format, arg...) \
54 dev_warn(&(instance)->usb_intf->dev , format , ## arg) 54 dev_warn(&(instance)->usb_intf->dev , format , ## arg)
55#ifdef DEBUG
55#define usb_dbg(instance, format, arg...) \ 56#define usb_dbg(instance, format, arg...) \
56 dev_dbg(&(instance)->usb_intf->dev , format , ## arg) 57 dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg)
58#else
59#define usb_dbg(instance, format, arg...) \
60 do {} while (0)
61#endif
57 62
58/* FIXME: move to dev_* once ATM is driver model aware */ 63/* FIXME: move to dev_* once ATM is driver model aware */
59#define atm_printk(level, instance, format, arg...) \ 64#define atm_printk(level, instance, format, arg...) \
@@ -69,12 +74,24 @@
69#ifdef DEBUG 74#ifdef DEBUG
70#define atm_dbg(instance, format, arg...) \ 75#define atm_dbg(instance, format, arg...) \
71 atm_printk(KERN_DEBUG, instance , format , ## arg) 76 atm_printk(KERN_DEBUG, instance , format , ## arg)
77#define atm_rldbg(instance, format, arg...) \
78 if (printk_ratelimit()) \
79 atm_printk(KERN_DEBUG, instance , format , ## arg)
72#else 80#else
73#define atm_dbg(instance, format, arg...) \ 81#define atm_dbg(instance, format, arg...) \
74 do {} while (0) 82 do {} while (0)
83#define atm_rldbg(instance, format, arg...) \
84 do {} while (0)
75#endif 85#endif
76 86
77 87
88/* flags, set by mini-driver in bind() */
89
90#define UDSL_SKIP_HEAVY_INIT (1<<0)
91#define UDSL_USE_ISOC (1<<1)
92#define UDSL_IGNORE_EILSEQ (1<<2)
93
94
78/* mini driver */ 95/* mini driver */
79 96
80struct usbatm_data; 97struct usbatm_data;
@@ -86,16 +103,11 @@ struct usbatm_data;
86*/ 103*/
87 104
88struct usbatm_driver { 105struct usbatm_driver {
89 struct module *owner;
90
91 const char *driver_name; 106 const char *driver_name;
92 107
93 /* 108 /* init device ... can sleep, or cause probe() failure */
94 * init device ... can sleep, or cause probe() failure. Drivers with a heavy_init
95 * method can avoid having it called by setting need_heavy_init to zero.
96 */
97 int (*bind) (struct usbatm_data *, struct usb_interface *, 109 int (*bind) (struct usbatm_data *, struct usb_interface *,
98 const struct usb_device_id *id, int *need_heavy_init); 110 const struct usb_device_id *id);
99 111
100 /* additional device initialization that is too slow to be done in probe() */ 112 /* additional device initialization that is too slow to be done in probe() */
101 int (*heavy_init) (struct usbatm_data *, struct usb_interface *); 113 int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
@@ -109,8 +121,9 @@ struct usbatm_driver {
109 /* cleanup ATM device ... can sleep, but can't fail */ 121 /* cleanup ATM device ... can sleep, but can't fail */
110 void (*atm_stop) (struct usbatm_data *, struct atm_dev *); 122 void (*atm_stop) (struct usbatm_data *, struct atm_dev *);
111 123
112 int in; /* rx endpoint */ 124 int bulk_in; /* bulk rx endpoint */
113 int out; /* tx endpoint */ 125 int isoc_in; /* isochronous rx endpoint */
126 int bulk_out; /* bulk tx endpoint */
114 127
115 unsigned rx_padding; 128 unsigned rx_padding;
116 unsigned tx_padding; 129 unsigned tx_padding;
@@ -125,6 +138,7 @@ struct usbatm_channel {
125 int endpoint; /* usb pipe */ 138 int endpoint; /* usb pipe */
126 unsigned int stride; /* ATM cell size + padding */ 139 unsigned int stride; /* ATM cell size + padding */
127 unsigned int buf_size; /* urb buffer size */ 140 unsigned int buf_size; /* urb buffer size */
141 unsigned int packet_size; /* endpoint maxpacket */
128 spinlock_t lock; 142 spinlock_t lock;
129 struct list_head list; 143 struct list_head list;
130 struct tasklet_struct tasklet; 144 struct tasklet_struct tasklet;
@@ -143,6 +157,7 @@ struct usbatm_data {
143 struct usbatm_driver *driver; 157 struct usbatm_driver *driver;
144 void *driver_data; 158 void *driver_data;
145 char driver_name[16]; 159 char driver_name[16];
160 unsigned int flags; /* set by mini-driver in bind() */
146 161
147 /* USB device */ 162 /* USB device */
148 struct usb_device *usb_dev; 163 struct usb_device *usb_dev;
@@ -157,7 +172,8 @@ struct usbatm_data {
157 ********************************/ 172 ********************************/
158 173
159 struct kref refcount; 174 struct kref refcount;
160 struct semaphore serialize; 175 struct mutex serialize;
176 int disconnected;
161 177
162 /* heavy init */ 178 /* heavy init */
163 int thread_pid; 179 int thread_pid;
@@ -171,7 +187,14 @@ struct usbatm_data {
171 struct usbatm_channel tx_channel; 187 struct usbatm_channel tx_channel;
172 188
173 struct sk_buff_head sndqueue; 189 struct sk_buff_head sndqueue;
174 struct sk_buff *current_skb; /* being emptied */ 190 struct sk_buff *current_skb; /* being emptied */
191
192 struct usbatm_vcc_data *cached_vcc;
193 int cached_vci;
194 short cached_vpi;
195
196 unsigned char *cell_buf; /* holds partial rx cell */
197 unsigned int buf_usage;
175 198
176 struct urb *urbs[0]; 199 struct urb *urbs[0];
177}; 200};
diff --git a/drivers/usb/atm/xusbatm.c b/drivers/usb/atm/xusbatm.c
index 5c76e3aaaa5e..42d6823b82b3 100644
--- a/drivers/usb/atm/xusbatm.c
+++ b/drivers/usb/atm/xusbatm.c
@@ -41,6 +41,8 @@ XUSBATM_PARM(rx_endpoint, unsigned char, byte, "rx endpoint number");
41XUSBATM_PARM(tx_endpoint, unsigned char, byte, "tx endpoint number"); 41XUSBATM_PARM(tx_endpoint, unsigned char, byte, "tx endpoint number");
42XUSBATM_PARM(rx_padding, unsigned char, byte, "rx padding (default 0)"); 42XUSBATM_PARM(rx_padding, unsigned char, byte, "rx padding (default 0)");
43XUSBATM_PARM(tx_padding, unsigned char, byte, "tx padding (default 0)"); 43XUSBATM_PARM(tx_padding, unsigned char, byte, "tx padding (default 0)");
44XUSBATM_PARM(rx_altsetting, unsigned char, byte, "rx altsetting (default 0)");
45XUSBATM_PARM(tx_altsetting, unsigned char, byte, "rx altsetting (default 0)");
44 46
45static const char xusbatm_driver_name[] = "xusbatm"; 47static const char xusbatm_driver_name[] = "xusbatm";
46 48
@@ -48,82 +50,118 @@ static struct usbatm_driver xusbatm_drivers[XUSBATM_DRIVERS_MAX];
48static struct usb_device_id xusbatm_usb_ids[XUSBATM_DRIVERS_MAX + 1]; 50static struct usb_device_id xusbatm_usb_ids[XUSBATM_DRIVERS_MAX + 1];
49static struct usb_driver xusbatm_usb_driver; 51static struct usb_driver xusbatm_usb_driver;
50 52
51static int usb_intf_has_ep(const struct usb_interface *intf, u8 ep) 53static struct usb_interface *xusbatm_find_intf (struct usb_device *usb_dev, int altsetting, u8 ep)
52{ 54{
55 struct usb_host_interface *alt;
56 struct usb_interface *intf;
53 int i, j; 57 int i, j;
54 58
55 for (i = 0; i < intf->num_altsetting; i++) { 59 for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++)
56 struct usb_host_interface *alt = intf->altsetting; 60 if ((intf = usb_dev->actconfig->interface[i]) && (alt = usb_altnum_to_altsetting(intf, altsetting)))
57 for (j = 0; j < alt->desc.bNumEndpoints; j++) 61 for (j = 0; j < alt->desc.bNumEndpoints; j++)
58 if ((alt->endpoint[i].desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK) == ep) 62 if (alt->endpoint[j].desc.bEndpointAddress == ep)
59 return 1; 63 return intf;
64 return NULL;
65}
66
67static int xusbatm_capture_intf (struct usbatm_data *usbatm, struct usb_device *usb_dev,
68 struct usb_interface *intf, int altsetting, int claim)
69{
70 int ifnum = intf->altsetting->desc.bInterfaceNumber;
71 int ret;
72
73 if (claim && (ret = usb_driver_claim_interface(&xusbatm_usb_driver, intf, usbatm))) {
74 usb_err(usbatm, "%s: failed to claim interface %2d (%d)!\n", __func__, ifnum, ret);
75 return ret;
76 }
77 if ((ret = usb_set_interface(usb_dev, ifnum, altsetting))) {
78 usb_err(usbatm, "%s: altsetting %2d for interface %2d failed (%d)!\n", __func__, altsetting, ifnum, ret);
79 return ret;
60 } 80 }
61 return 0; 81 return 0;
62} 82}
63 83
64static int xusbatm_bind(struct usbatm_data *usbatm_instance, 84static void xusbatm_release_intf (struct usb_device *usb_dev, struct usb_interface *intf, int claimed)
65 struct usb_interface *intf, const struct usb_device_id *id, 85{
66 int *need_heavy_init) 86 if (claimed) {
87 usb_set_intfdata(intf, NULL);
88 usb_driver_release_interface(&xusbatm_usb_driver, intf);
89 }
90}
91
92static int xusbatm_bind(struct usbatm_data *usbatm,
93 struct usb_interface *intf, const struct usb_device_id *id)
67{ 94{
68 struct usb_device *usb_dev = interface_to_usbdev(intf); 95 struct usb_device *usb_dev = interface_to_usbdev(intf);
69 int drv_ix = id - xusbatm_usb_ids; 96 int drv_ix = id - xusbatm_usb_ids;
70 int rx_ep_present = usb_intf_has_ep(intf, rx_endpoint[drv_ix]); 97 int rx_alt = rx_altsetting[drv_ix];
71 int tx_ep_present = usb_intf_has_ep(intf, tx_endpoint[drv_ix]); 98 int tx_alt = tx_altsetting[drv_ix];
72 u8 searched_ep = rx_ep_present ? tx_endpoint[drv_ix] : rx_endpoint[drv_ix]; 99 struct usb_interface *rx_intf = xusbatm_find_intf(usb_dev, rx_alt, rx_endpoint[drv_ix]);
73 int i, ret; 100 struct usb_interface *tx_intf = xusbatm_find_intf(usb_dev, tx_alt, tx_endpoint[drv_ix]);
74 101 int ret;
75 usb_dbg(usbatm_instance, "%s: binding driver %d: vendor %#x product %#x" 102
76 " rx: ep %#x padd %d tx: ep %#x padd %d\n", 103 usb_dbg(usbatm, "%s: binding driver %d: vendor %04x product %04x"
104 " rx: ep %02x padd %d alt %2d tx: ep %02x padd %d alt %2d\n",
77 __func__, drv_ix, vendor[drv_ix], product[drv_ix], 105 __func__, drv_ix, vendor[drv_ix], product[drv_ix],
78 rx_endpoint[drv_ix], rx_padding[drv_ix], 106 rx_endpoint[drv_ix], rx_padding[drv_ix], rx_alt,
79 tx_endpoint[drv_ix], tx_padding[drv_ix]); 107 tx_endpoint[drv_ix], tx_padding[drv_ix], tx_alt);
108
109 if (!rx_intf || !tx_intf) {
110 if (!rx_intf)
111 usb_dbg(usbatm, "%s: no interface contains endpoint %02x in altsetting %2d\n",
112 __func__, rx_endpoint[drv_ix], rx_alt);
113 if (!tx_intf)
114 usb_dbg(usbatm, "%s: no interface contains endpoint %02x in altsetting %2d\n",
115 __func__, tx_endpoint[drv_ix], tx_alt);
116 return -ENODEV;
117 }
80 118
81 if (!rx_ep_present && !tx_ep_present) { 119 if ((rx_intf != intf) && (tx_intf != intf))
82 usb_dbg(usbatm_instance, "%s: intf #%d has neither rx (%#x) nor tx (%#x) endpoint\n",
83 __func__, intf->altsetting->desc.bInterfaceNumber,
84 rx_endpoint[drv_ix], tx_endpoint[drv_ix]);
85 return -ENODEV; 120 return -ENODEV;
121
122 if ((rx_intf == tx_intf) && (rx_alt != tx_alt)) {
123 usb_err(usbatm, "%s: altsettings clash on interface %2d (%2d vs %2d)!\n", __func__,
124 rx_intf->altsetting->desc.bInterfaceNumber, rx_alt, tx_alt);
125 return -EINVAL;
86 } 126 }
87 127
88 if (rx_ep_present && tx_ep_present) 128 usb_dbg(usbatm, "%s: rx If#=%2d; tx If#=%2d\n", __func__,
89 return 0; 129 rx_intf->altsetting->desc.bInterfaceNumber,
130 tx_intf->altsetting->desc.bInterfaceNumber);
90 131
91 for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) { 132 if ((ret = xusbatm_capture_intf(usbatm, usb_dev, rx_intf, rx_alt, rx_intf != intf)))
92 struct usb_interface *cur_if = usb_dev->actconfig->interface[i]; 133 return ret;
93 134
94 if (cur_if != intf && usb_intf_has_ep(cur_if, searched_ep)) { 135 if ((tx_intf != rx_intf) && (ret = xusbatm_capture_intf(usbatm, usb_dev, tx_intf, tx_alt, tx_intf != intf))) {
95 ret = usb_driver_claim_interface(&xusbatm_usb_driver, 136 xusbatm_release_intf(usb_dev, rx_intf, rx_intf != intf);
96 cur_if, usbatm_instance); 137 return ret;
97 if (!ret)
98 usb_err(usbatm_instance, "%s: failed to claim interface #%d (%d)\n",
99 __func__, cur_if->altsetting->desc.bInterfaceNumber, ret);
100 return ret;
101 }
102 } 138 }
103 139
104 usb_err(usbatm_instance, "%s: no interface has endpoint %#x\n", 140 return 0;
105 __func__, searched_ep);
106 return -ENODEV;
107} 141}
108 142
109static void xusbatm_unbind(struct usbatm_data *usbatm_instance, 143static void xusbatm_unbind(struct usbatm_data *usbatm,
110 struct usb_interface *intf) 144 struct usb_interface *intf)
111{ 145{
112 struct usb_device *usb_dev = interface_to_usbdev(intf); 146 struct usb_device *usb_dev = interface_to_usbdev(intf);
113 int i; 147 int i;
114 usb_dbg(usbatm_instance, "%s entered\n", __func__); 148
149 usb_dbg(usbatm, "%s entered\n", __func__);
115 150
116 for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) { 151 for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) {
117 struct usb_interface *cur_if = usb_dev->actconfig->interface[i]; 152 struct usb_interface *cur_intf = usb_dev->actconfig->interface[i];
118 usb_set_intfdata(cur_if, NULL); 153
119 usb_driver_release_interface(&xusbatm_usb_driver, cur_if); 154 if (cur_intf && (usb_get_intfdata(cur_intf) == usbatm)) {
155 usb_set_intfdata(cur_intf, NULL);
156 usb_driver_release_interface(&xusbatm_usb_driver, cur_intf);
157 }
120 } 158 }
121} 159}
122 160
123static int xusbatm_atm_start(struct usbatm_data *usbatm_instance, 161static int xusbatm_atm_start(struct usbatm_data *usbatm,
124 struct atm_dev *atm_dev) 162 struct atm_dev *atm_dev)
125{ 163{
126 atm_dbg(usbatm_instance, "%s entered\n", __func__); 164 atm_dbg(usbatm, "%s entered\n", __func__);
127 165
128 /* use random MAC as we've no way to get it from the device */ 166 /* use random MAC as we've no way to get it from the device */
129 random_ether_addr(atm_dev->esi); 167 random_ether_addr(atm_dev->esi);
@@ -161,18 +199,19 @@ static int __init xusbatm_init(void)
161 } 199 }
162 200
163 for (i = 0; i < num_vendor; i++) { 201 for (i = 0; i < num_vendor; i++) {
202 rx_endpoint[i] |= USB_DIR_IN;
203 tx_endpoint[i] &= USB_ENDPOINT_NUMBER_MASK;
204
164 xusbatm_usb_ids[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE; 205 xusbatm_usb_ids[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
165 xusbatm_usb_ids[i].idVendor = vendor[i]; 206 xusbatm_usb_ids[i].idVendor = vendor[i];
166 xusbatm_usb_ids[i].idProduct = product[i]; 207 xusbatm_usb_ids[i].idProduct = product[i];
167 208
168
169 xusbatm_drivers[i].owner = THIS_MODULE;
170 xusbatm_drivers[i].driver_name = xusbatm_driver_name; 209 xusbatm_drivers[i].driver_name = xusbatm_driver_name;
171 xusbatm_drivers[i].bind = xusbatm_bind; 210 xusbatm_drivers[i].bind = xusbatm_bind;
172 xusbatm_drivers[i].unbind = xusbatm_unbind; 211 xusbatm_drivers[i].unbind = xusbatm_unbind;
173 xusbatm_drivers[i].atm_start = xusbatm_atm_start; 212 xusbatm_drivers[i].atm_start = xusbatm_atm_start;
174 xusbatm_drivers[i].in = rx_endpoint[i]; 213 xusbatm_drivers[i].bulk_in = rx_endpoint[i];
175 xusbatm_drivers[i].out = tx_endpoint[i]; 214 xusbatm_drivers[i].bulk_out = tx_endpoint[i];
176 xusbatm_drivers[i].rx_padding = rx_padding[i]; 215 xusbatm_drivers[i].rx_padding = rx_padding[i];
177 xusbatm_drivers[i].tx_padding = tx_padding[i]; 216 xusbatm_drivers[i].tx_padding = tx_padding[i];
178 } 217 }
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index b9fd39fd1b5b..97bdeb1c2181 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1014,8 +1014,13 @@ static void acm_disconnect(struct usb_interface *intf)
1014 } 1014 }
1015 1015
1016 down(&open_sem); 1016 down(&open_sem);
1017 if (!usb_get_intfdata(intf)) {
1018 up(&open_sem);
1019 return;
1020 }
1017 acm->dev = NULL; 1021 acm->dev = NULL;
1018 usb_set_intfdata (intf, NULL); 1022 usb_set_intfdata(acm->control, NULL);
1023 usb_set_intfdata(acm->data, NULL);
1019 1024
1020 tasklet_disable(&acm->urb_task); 1025 tasklet_disable(&acm->urb_task);
1021 1026
@@ -1036,7 +1041,7 @@ static void acm_disconnect(struct usb_interface *intf)
1036 for (i = 0; i < ACM_NRB; i++) 1041 for (i = 0; i < ACM_NRB; i++)
1037 usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma); 1042 usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma);
1038 1043
1039 usb_driver_release_interface(&acm_driver, acm->data); 1044 usb_driver_release_interface(&acm_driver, intf == acm->control ? acm->data : intf);
1040 1045
1041 if (!acm->used) { 1046 if (!acm->used) {
1042 acm_tty_unregister(acm); 1047 acm_tty_unregister(acm);
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index dba4cc026077..d34848ac30b0 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -7,6 +7,7 @@
7 * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz> 7 * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz>
8 # Copyright (c) 2001 Pete Zaitcev <zaitcev@redhat.com> 8 # Copyright (c) 2001 Pete Zaitcev <zaitcev@redhat.com>
9 # Copyright (c) 2001 David Paschal <paschal@rcsis.com> 9 # Copyright (c) 2001 David Paschal <paschal@rcsis.com>
10 * Copyright (c) 2006 Oliver Neukum <oliver@neukum.name>
10 * 11 *
11 * USB Printer Device Class driver for USB printers and printer cables 12 * USB Printer Device Class driver for USB printers and printer cables
12 * 13 *
@@ -273,13 +274,16 @@ static void usblp_bulk_read(struct urb *urb, struct pt_regs *regs)
273{ 274{
274 struct usblp *usblp = urb->context; 275 struct usblp *usblp = urb->context;
275 276
276 if (!usblp || !usblp->dev || !usblp->used || !usblp->present) 277 if (unlikely(!usblp || !usblp->dev || !usblp->used))
277 return; 278 return;
278 279
280 if (unlikely(!usblp->present))
281 goto unplug;
279 if (unlikely(urb->status)) 282 if (unlikely(urb->status))
280 warn("usblp%d: nonzero read/write bulk status received: %d", 283 warn("usblp%d: nonzero read/write bulk status received: %d",
281 usblp->minor, urb->status); 284 usblp->minor, urb->status);
282 usblp->rcomplete = 1; 285 usblp->rcomplete = 1;
286unplug:
283 wake_up_interruptible(&usblp->wait); 287 wake_up_interruptible(&usblp->wait);
284} 288}
285 289
@@ -287,13 +291,15 @@ static void usblp_bulk_write(struct urb *urb, struct pt_regs *regs)
287{ 291{
288 struct usblp *usblp = urb->context; 292 struct usblp *usblp = urb->context;
289 293
290 if (!usblp || !usblp->dev || !usblp->used || !usblp->present) 294 if (unlikely(!usblp || !usblp->dev || !usblp->used))
291 return; 295 return;
292 296 if (unlikely(!usblp->present))
297 goto unplug;
293 if (unlikely(urb->status)) 298 if (unlikely(urb->status))
294 warn("usblp%d: nonzero read/write bulk status received: %d", 299 warn("usblp%d: nonzero read/write bulk status received: %d",
295 usblp->minor, urb->status); 300 usblp->minor, urb->status);
296 usblp->wcomplete = 1; 301 usblp->wcomplete = 1;
302unplug:
297 wake_up_interruptible(&usblp->wait); 303 wake_up_interruptible(&usblp->wait);
298} 304}
299 305
@@ -627,9 +633,8 @@ done:
627 633
628static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) 634static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
629{ 635{
630 DECLARE_WAITQUEUE(wait, current);
631 struct usblp *usblp = file->private_data; 636 struct usblp *usblp = file->private_data;
632 int timeout, err = 0, transfer_length = 0; 637 int timeout, rv, err = 0, transfer_length = 0;
633 size_t writecount = 0; 638 size_t writecount = 0;
634 639
635 while (writecount < count) { 640 while (writecount < count) {
@@ -641,24 +646,11 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
641 } 646 }
642 647
643 timeout = USBLP_WRITE_TIMEOUT; 648 timeout = USBLP_WRITE_TIMEOUT;
644 add_wait_queue(&usblp->wait, &wait);
645 while ( 1==1 ) {
646 649
647 if (signal_pending(current)) { 650 rv = wait_event_interruptible_timeout(usblp->wait, usblp->wcomplete || !usblp->present , timeout);
648 remove_wait_queue(&usblp->wait, &wait); 651 if (rv < 0)
649 return writecount ? writecount : -EINTR; 652 return writecount ? writecount : -EINTR;
650 }
651 set_current_state(TASK_INTERRUPTIBLE);
652 if (timeout && !usblp->wcomplete) {
653 timeout = schedule_timeout(timeout);
654 } else {
655 set_current_state(TASK_RUNNING);
656 break;
657 }
658 }
659 remove_wait_queue(&usblp->wait, &wait);
660 } 653 }
661
662 down (&usblp->sem); 654 down (&usblp->sem);
663 if (!usblp->present) { 655 if (!usblp->present) {
664 up (&usblp->sem); 656 up (&usblp->sem);
@@ -724,7 +716,7 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
724static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) 716static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
725{ 717{
726 struct usblp *usblp = file->private_data; 718 struct usblp *usblp = file->private_data;
727 DECLARE_WAITQUEUE(wait, current); 719 int rv;
728 720
729 if (!usblp->bidir) 721 if (!usblp->bidir)
730 return -EINVAL; 722 return -EINVAL;
@@ -742,26 +734,13 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count,
742 count = -EAGAIN; 734 count = -EAGAIN;
743 goto done; 735 goto done;
744 } 736 }
745 737 up(&usblp->sem);
746 add_wait_queue(&usblp->wait, &wait); 738 rv = wait_event_interruptible(usblp->wait, usblp->rcomplete || !usblp->present);
747 while (1==1) { 739 down(&usblp->sem);
748 if (signal_pending(current)) { 740 if (rv < 0) {
749 count = -EINTR; 741 count = -EINTR;
750 remove_wait_queue(&usblp->wait, &wait); 742 goto done;
751 goto done;
752 }
753 up (&usblp->sem);
754 set_current_state(TASK_INTERRUPTIBLE);
755 if (!usblp->rcomplete) {
756 schedule();
757 } else {
758 set_current_state(TASK_RUNNING);
759 down(&usblp->sem);
760 break;
761 }
762 down (&usblp->sem);
763 } 743 }
764 remove_wait_queue(&usblp->wait, &wait);
765 } 744 }
766 745
767 if (!usblp->present) { 746 if (!usblp->present) {
@@ -874,11 +853,10 @@ static int usblp_probe(struct usb_interface *intf,
874 853
875 /* Malloc and start initializing usblp structure so we can use it 854 /* Malloc and start initializing usblp structure so we can use it
876 * directly. */ 855 * directly. */
877 if (!(usblp = kmalloc(sizeof(struct usblp), GFP_KERNEL))) { 856 if (!(usblp = kzalloc(sizeof(struct usblp), GFP_KERNEL))) {
878 err("out of memory for usblp"); 857 err("out of memory for usblp");
879 goto abort; 858 goto abort;
880 } 859 }
881 memset(usblp, 0, sizeof(struct usblp));
882 usblp->dev = dev; 860 usblp->dev = dev;
883 init_MUTEX (&usblp->sem); 861 init_MUTEX (&usblp->sem);
884 init_waitqueue_head(&usblp->wait); 862 init_waitqueue_head(&usblp->wait);
@@ -1214,10 +1192,9 @@ static int __init usblp_init(void)
1214{ 1192{
1215 int retval; 1193 int retval;
1216 retval = usb_register(&usblp_driver); 1194 retval = usb_register(&usblp_driver);
1217 if (retval) 1195 if (!retval)
1218 goto out; 1196 info(DRIVER_VERSION ": " DRIVER_DESC);
1219 info(DRIVER_VERSION ": " DRIVER_DESC); 1197
1220out:
1221 return retval; 1198 return retval;
1222} 1199}
1223 1200
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 076462c8ba2a..dce9d987f0fc 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -378,7 +378,7 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface,
378 378
379 return NULL; 379 return NULL;
380} 380}
381EXPORT_SYMBOL_GPL(usb_match_id); 381EXPORT_SYMBOL(usb_match_id);
382 382
383int usb_device_match(struct device *dev, struct device_driver *drv) 383int usb_device_match(struct device *dev, struct device_driver *drv)
384{ 384{
@@ -446,7 +446,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner)
446 446
447 return retval; 447 return retval;
448} 448}
449EXPORT_SYMBOL_GPL(usb_register_driver); 449EXPORT_SYMBOL(usb_register_driver);
450 450
451/** 451/**
452 * usb_deregister - unregister a USB driver 452 * usb_deregister - unregister a USB driver
@@ -469,4 +469,4 @@ void usb_deregister(struct usb_driver *driver)
469 469
470 usbfs_update_special(); 470 usbfs_update_special();
471} 471}
472EXPORT_SYMBOL_GPL(usb_deregister); 472EXPORT_SYMBOL(usb_deregister);
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 319de03944e7..7135e542679d 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -13,6 +13,7 @@
13#include <linux/ctype.h> 13#include <linux/ctype.h>
14#include <linux/device.h> 14#include <linux/device.h>
15#include <asm/byteorder.h> 15#include <asm/byteorder.h>
16#include <asm/scatterlist.h>
16 17
17#include "hcd.h" /* for usbcore internals */ 18#include "hcd.h" /* for usbcore internals */
18#include "usb.h" 19#include "usb.h"
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 081796726b95..dad4d8fd8180 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -468,6 +468,7 @@ int usb_unlink_urb(struct urb *urb)
468 */ 468 */
469void usb_kill_urb(struct urb *urb) 469void usb_kill_urb(struct urb *urb)
470{ 470{
471 might_sleep();
471 if (!(urb && urb->dev && urb->dev->bus && urb->dev->bus->op)) 472 if (!(urb && urb->dev && urb->dev->bus && urb->dev->bus->op))
472 return; 473 return;
473 spin_lock_irq(&urb->lock); 474 spin_lock_irq(&urb->lock);
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 9a4edc5657aa..0aab7d24c768 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -135,6 +135,7 @@ struct dev_data {
135 setup_out_ready : 1, 135 setup_out_ready : 1,
136 setup_out_error : 1, 136 setup_out_error : 1,
137 setup_abort : 1; 137 setup_abort : 1;
138 unsigned setup_wLength;
138 139
139 /* the rest is basically write-once */ 140 /* the rest is basically write-once */
140 struct usb_config_descriptor *config, *hs_config; 141 struct usb_config_descriptor *config, *hs_config;
@@ -942,6 +943,7 @@ static int setup_req (struct usb_ep *ep, struct usb_request *req, u16 len)
942 } 943 }
943 req->complete = ep0_complete; 944 req->complete = ep0_complete;
944 req->length = len; 945 req->length = len;
946 req->zero = 0;
945 return 0; 947 return 0;
946} 948}
947 949
@@ -1161,10 +1163,13 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1161 spin_unlock_irq (&dev->lock); 1163 spin_unlock_irq (&dev->lock);
1162 if (copy_from_user (dev->req->buf, buf, len)) 1164 if (copy_from_user (dev->req->buf, buf, len))
1163 retval = -EFAULT; 1165 retval = -EFAULT;
1164 else 1166 else {
1167 if (len < dev->setup_wLength)
1168 dev->req->zero = 1;
1165 retval = usb_ep_queue ( 1169 retval = usb_ep_queue (
1166 dev->gadget->ep0, dev->req, 1170 dev->gadget->ep0, dev->req,
1167 GFP_KERNEL); 1171 GFP_KERNEL);
1172 }
1168 if (retval < 0) { 1173 if (retval < 0) {
1169 spin_lock_irq (&dev->lock); 1174 spin_lock_irq (&dev->lock);
1170 clean_req (dev->gadget->ep0, dev->req); 1175 clean_req (dev->gadget->ep0, dev->req);
@@ -1483,6 +1488,7 @@ unrecognized:
1483delegate: 1488delegate:
1484 dev->setup_in = (ctrl->bRequestType & USB_DIR_IN) 1489 dev->setup_in = (ctrl->bRequestType & USB_DIR_IN)
1485 ? 1 : 0; 1490 ? 1 : 0;
1491 dev->setup_wLength = w_length;
1486 dev->setup_out_ready = 0; 1492 dev->setup_out_ready = 0;
1487 dev->setup_out_error = 0; 1493 dev->setup_out_error = 0;
1488 value = 0; 1494 value = 0;
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index c32e1f7476da..67b13ab2f3f5 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -47,6 +47,7 @@
47#include <linux/config.h> 47#include <linux/config.h>
48#include <linux/module.h> 48#include <linux/module.h>
49#include <linux/pci.h> 49#include <linux/pci.h>
50#include <linux/dma-mapping.h>
50#include <linux/kernel.h> 51#include <linux/kernel.h>
51#include <linux/delay.h> 52#include <linux/delay.h>
52#include <linux/ioport.h> 53#include <linux/ioport.h>
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 2fc110d3ad5a..ae7a1c0f5748 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -165,8 +165,8 @@ static unsigned buflen = 4096;
165static unsigned qlen = 32; 165static unsigned qlen = 32;
166static unsigned pattern = 0; 166static unsigned pattern = 0;
167 167
168module_param (buflen, uint, S_IRUGO|S_IWUSR); 168module_param (buflen, uint, S_IRUGO);
169module_param (qlen, uint, S_IRUGO|S_IWUSR); 169module_param (qlen, uint, S_IRUGO);
170module_param (pattern, uint, S_IRUGO|S_IWUSR); 170module_param (pattern, uint, S_IRUGO|S_IWUSR);
171 171
172/* 172/*
@@ -1127,8 +1127,10 @@ zero_unbind (struct usb_gadget *gadget)
1127 DBG (dev, "unbind\n"); 1127 DBG (dev, "unbind\n");
1128 1128
1129 /* we've already been disconnected ... no i/o is active */ 1129 /* we've already been disconnected ... no i/o is active */
1130 if (dev->req) 1130 if (dev->req) {
1131 dev->req->length = USB_BUFSIZ;
1131 free_ep_req (gadget->ep0, dev->req); 1132 free_ep_req (gadget->ep0, dev->req);
1133 }
1132 del_timer_sync (&dev->resume); 1134 del_timer_sync (&dev->resume);
1133 kfree (dev); 1135 kfree (dev);
1134 set_gadget_data (gadget, NULL); 1136 set_gadget_data (gadget, NULL);
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 08ca0f849dab..3a6687df5594 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -24,46 +24,11 @@
24 24
25/*-------------------------------------------------------------------------*/ 25/*-------------------------------------------------------------------------*/
26 26
27/* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/...
28 * off the controller (maybe it can boot from highspeed USB disks).
29 */
30static int bios_handoff(struct ehci_hcd *ehci, int where, u32 cap)
31{
32 struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller);
33
34 /* always say Linux will own the hardware */
35 pci_write_config_byte(pdev, where + 3, 1);
36
37 /* maybe wait a while for BIOS to respond */
38 if (cap & (1 << 16)) {
39 int msec = 5000;
40
41 do {
42 msleep(10);
43 msec -= 10;
44 pci_read_config_dword(pdev, where, &cap);
45 } while ((cap & (1 << 16)) && msec);
46 if (cap & (1 << 16)) {
47 ehci_err(ehci, "BIOS handoff failed (%d, %08x)\n",
48 where, cap);
49 // some BIOS versions seem buggy...
50 // return 1;
51 ehci_warn(ehci, "continuing after BIOS bug...\n");
52 /* disable all SMIs, and clear "BIOS owns" flag */
53 pci_write_config_dword(pdev, where + 4, 0);
54 pci_write_config_byte(pdev, where + 2, 0);
55 } else
56 ehci_dbg(ehci, "BIOS handoff succeeded\n");
57 }
58 return 0;
59}
60
61/* called after powerup, by probe or system-pm "wakeup" */ 27/* called after powerup, by probe or system-pm "wakeup" */
62static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) 28static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
63{ 29{
64 u32 temp; 30 u32 temp;
65 int retval; 31 int retval;
66 unsigned count = 256/4;
67 32
68 /* optional debug port, normally in the first BAR */ 33 /* optional debug port, normally in the first BAR */
69 temp = pci_find_capability(pdev, 0x0a); 34 temp = pci_find_capability(pdev, 0x0a);
@@ -84,32 +49,9 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
84 } 49 }
85 } 50 }
86 51
87 temp = HCC_EXT_CAPS(readl(&ehci->caps->hcc_params)); 52 /* we expect static quirk code to handle the "extended capabilities"
88 53 * (currently just BIOS handoff) allowed starting with EHCI 0.96
89 /* EHCI 0.96 and later may have "extended capabilities" */ 54 */
90 while (temp && count--) {
91 u32 cap;
92
93 pci_read_config_dword(pdev, temp, &cap);
94 ehci_dbg(ehci, "capability %04x at %02x\n", cap, temp);
95 switch (cap & 0xff) {
96 case 1: /* BIOS/SMM/... handoff */
97 if (bios_handoff(ehci, temp, cap) != 0)
98 return -EOPNOTSUPP;
99 break;
100 case 0: /* illegal reserved capability */
101 ehci_dbg(ehci, "illegal capability!\n");
102 cap = 0;
103 /* FALLTHROUGH */
104 default: /* unknown */
105 break;
106 }
107 temp = (cap >> 8) & 0xff;
108 }
109 if (!count) {
110 ehci_err(ehci, "bogus capabilities ... PCI problems!\n");
111 return -EIO;
112 }
113 55
114 /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */ 56 /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */
115 retval = pci_set_mwi(pdev); 57 retval = pci_set_mwi(pdev);
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 57e77374d228..ebcca9700671 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1063,6 +1063,7 @@ sitd_slot_ok (
1063 1063
1064 /* for IN, check CSPLIT */ 1064 /* for IN, check CSPLIT */
1065 if (stream->c_usecs) { 1065 if (stream->c_usecs) {
1066 uf = uframe & 7;
1066 max_used = 100 - stream->c_usecs; 1067 max_used = 100 - stream->c_usecs;
1067 do { 1068 do {
1068 tmp = 1 << uf; 1069 tmp = 1 << uf;
@@ -1843,8 +1844,7 @@ done:
1843#else 1844#else
1844 1845
1845static inline int 1846static inline int
1846sitd_submit (struct ehci_hcd *ehci, struct urb *urb, 1847sitd_submit (struct ehci_hcd *ehci, struct urb *urb, gfp_t mem_flags)
1847 unsigned mem_flags)
1848{ 1848{
1849 ehci_dbg (ehci, "split iso support is disabled\n"); 1849 ehci_dbg (ehci, "split iso support is disabled\n");
1850 return -ENOSYS; 1850 return -ENOSYS;
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 584b8dc65119..972ce04889f8 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1420,20 +1420,22 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd)
1420 int ret = 0; 1420 int ret = 0;
1421 1421
1422 spin_lock_irqsave(&isp116x->lock, flags); 1422 spin_lock_irqsave(&isp116x->lock, flags);
1423
1424 val = isp116x_read_reg32(isp116x, HCCONTROL); 1423 val = isp116x_read_reg32(isp116x, HCCONTROL);
1424
1425 switch (val & HCCONTROL_HCFS) { 1425 switch (val & HCCONTROL_HCFS) {
1426 case HCCONTROL_USB_OPER: 1426 case HCCONTROL_USB_OPER:
1427 spin_unlock_irqrestore(&isp116x->lock, flags);
1427 val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE); 1428 val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE);
1428 val |= HCCONTROL_USB_SUSPEND; 1429 val |= HCCONTROL_USB_SUSPEND;
1429 if (device_may_wakeup(&hcd->self.root_hub->dev)) 1430 if (device_may_wakeup(&hcd->self.root_hub->dev))
1430 val |= HCCONTROL_RWE; 1431 val |= HCCONTROL_RWE;
1431 /* Wait for usb transfers to finish */ 1432 /* Wait for usb transfers to finish */
1432 mdelay(2); 1433 msleep(2);
1434 spin_lock_irqsave(&isp116x->lock, flags);
1433 isp116x_write_reg32(isp116x, HCCONTROL, val); 1435 isp116x_write_reg32(isp116x, HCCONTROL, val);
1436 spin_unlock_irqrestore(&isp116x->lock, flags);
1434 /* Wait for devices to suspend */ 1437 /* Wait for devices to suspend */
1435 mdelay(5); 1438 msleep(5);
1436 case HCCONTROL_USB_SUSPEND:
1437 break; 1439 break;
1438 case HCCONTROL_USB_RESUME: 1440 case HCCONTROL_USB_RESUME:
1439 isp116x_write_reg32(isp116x, HCCONTROL, 1441 isp116x_write_reg32(isp116x, HCCONTROL,
@@ -1441,12 +1443,11 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd)
1441 HCCONTROL_USB_RESET); 1443 HCCONTROL_USB_RESET);
1442 case HCCONTROL_USB_RESET: 1444 case HCCONTROL_USB_RESET:
1443 ret = -EBUSY; 1445 ret = -EBUSY;
1446 default: /* HCCONTROL_USB_SUSPEND */
1447 spin_unlock_irqrestore(&isp116x->lock, flags);
1444 break; 1448 break;
1445 default:
1446 ret = -EINVAL;
1447 } 1449 }
1448 1450
1449 spin_unlock_irqrestore(&isp116x->lock, flags);
1450 return ret; 1451 return ret;
1451} 1452}
1452 1453
@@ -1715,9 +1716,9 @@ static struct platform_driver isp116x_driver = {
1715 .remove = isp116x_remove, 1716 .remove = isp116x_remove,
1716 .suspend = isp116x_suspend, 1717 .suspend = isp116x_suspend,
1717 .resume = isp116x_resume, 1718 .resume = isp116x_resume,
1718 .driver = { 1719 .driver = {
1719 .name = (char *)hcd_name, 1720 .name = (char *)hcd_name,
1720 }, 1721 },
1721}; 1722};
1722 1723
1723/*-----------------------------------------------------------------*/ 1724/*-----------------------------------------------------------------*/
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index 77cd6ac07e3c..db280ca7b7a0 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -67,7 +67,7 @@ static void au1xxx_stop_hc(struct platform_device *dev)
67 ": stopping Au1xxx OHCI USB Controller\n"); 67 ": stopping Au1xxx OHCI USB Controller\n");
68 68
69 /* Disable clock */ 69 /* Disable clock */
70 au_writel(readl((void *)USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG); 70 au_writel(au_readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
71} 71}
72 72
73 73
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 3ef2c0cdf1db..e9e5bc178cef 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -190,7 +190,7 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
190 msleep(10); 190 msleep(10);
191 } 191 }
192 if (wait_time <= 0) 192 if (wait_time <= 0)
193 printk(KERN_WARNING "%s %s: early BIOS handoff " 193 printk(KERN_WARNING "%s %s: BIOS handoff "
194 "failed (BIOS bug ?)\n", 194 "failed (BIOS bug ?)\n",
195 pdev->dev.bus_id, "OHCI"); 195 pdev->dev.bus_id, "OHCI");
196 196
@@ -212,8 +212,9 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
212{ 212{
213 int wait_time, delta; 213 int wait_time, delta;
214 void __iomem *base, *op_reg_base; 214 void __iomem *base, *op_reg_base;
215 u32 hcc_params, val, temp; 215 u32 hcc_params, val;
216 u8 cap_length; 216 u8 offset, cap_length;
217 int count = 256/4;
217 218
218 if (!mmio_resource_enabled(pdev, 0)) 219 if (!mmio_resource_enabled(pdev, 0))
219 return; 220 return;
@@ -224,51 +225,80 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
224 225
225 cap_length = readb(base); 226 cap_length = readb(base);
226 op_reg_base = base + cap_length; 227 op_reg_base = base + cap_length;
228
229 /* EHCI 0.96 and later may have "extended capabilities"
230 * spec section 5.1 explains the bios handoff, e.g. for
231 * booting from USB disk or using a usb keyboard
232 */
227 hcc_params = readl(base + EHCI_HCC_PARAMS); 233 hcc_params = readl(base + EHCI_HCC_PARAMS);
228 hcc_params = (hcc_params >> 8) & 0xff; 234 offset = (hcc_params >> 8) & 0xff;
229 if (hcc_params) { 235 while (offset && count--) {
230 pci_read_config_dword(pdev, 236 u32 cap;
231 hcc_params + EHCI_USBLEGSUP, 237 int msec;
232 &val); 238
233 if (((val & 0xff) == 1) && (val & EHCI_USBLEGSUP_BIOS)) { 239 pci_read_config_dword(pdev, offset, &cap);
234 /* 240 switch (cap & 0xff) {
235 * Ok, BIOS is in smm mode, try to hand off... 241 case 1: /* BIOS/SMM/... handoff support */
242 if ((cap & EHCI_USBLEGSUP_BIOS)) {
243 pr_debug("%s %s: BIOS handoff\n",
244 pdev->dev.bus_id, "EHCI");
245
246 /* BIOS workaround (?): be sure the
247 * pre-Linux code receives the SMI
248 */
249 pci_read_config_dword(pdev,
250 offset + EHCI_USBLEGCTLSTS,
251 &val);
252 pci_write_config_dword(pdev,
253 offset + EHCI_USBLEGCTLSTS,
254 val | EHCI_USBLEGCTLSTS_SOOE);
255 }
256
257 /* always say Linux will own the hardware
258 * by setting EHCI_USBLEGSUP_OS.
236 */ 259 */
237 pci_read_config_dword(pdev, 260 pci_write_config_byte(pdev, offset + 3, 1);
238 hcc_params + EHCI_USBLEGCTLSTS,
239 &temp);
240 pci_write_config_dword(pdev,
241 hcc_params + EHCI_USBLEGCTLSTS,
242 temp | EHCI_USBLEGCTLSTS_SOOE);
243 val |= EHCI_USBLEGSUP_OS;
244 pci_write_config_dword(pdev,
245 hcc_params + EHCI_USBLEGSUP,
246 val);
247 261
248 wait_time = 500; 262 /* if boot firmware now owns EHCI, spin till
249 do { 263 * it hands it over.
264 */
265 msec = 5000;
266 while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) {
250 msleep(10); 267 msleep(10);
251 wait_time -= 10; 268 msec -= 10;
252 pci_read_config_dword(pdev, 269 pci_read_config_dword(pdev, offset, &cap);
253 hcc_params + EHCI_USBLEGSUP, 270 }
254 &val); 271
255 } while (wait_time && (val & EHCI_USBLEGSUP_BIOS)); 272 if (cap & EHCI_USBLEGSUP_BIOS) {
256 if (!wait_time) { 273 /* well, possibly buggy BIOS... try to shut
257 /* 274 * it down, and hope nothing goes too wrong
258 * well, possibly buggy BIOS...
259 */ 275 */
260 printk(KERN_WARNING "%s %s: early BIOS handoff " 276 printk(KERN_WARNING "%s %s: BIOS handoff "
261 "failed (BIOS bug ?)\n", 277 "failed (BIOS bug ?)\n",
262 pdev->dev.bus_id, "EHCI"); 278 pdev->dev.bus_id, "EHCI");
263 pci_write_config_dword(pdev, 279 pci_write_config_byte(pdev, offset + 2, 0);
264 hcc_params + EHCI_USBLEGSUP,
265 EHCI_USBLEGSUP_OS);
266 pci_write_config_dword(pdev,
267 hcc_params + EHCI_USBLEGCTLSTS,
268 0);
269 } 280 }
281
282 /* just in case, always disable EHCI SMIs */
283 pci_write_config_dword(pdev,
284 offset + EHCI_USBLEGCTLSTS,
285 0);
286 break;
287 case 0: /* illegal reserved capability */
288 cap = 0;
289 /* FALLTHROUGH */
290 default:
291 printk(KERN_WARNING "%s %s: unrecognized "
292 "capability %02x\n",
293 pdev->dev.bus_id, "EHCI",
294 cap & 0xff);
295 break;
270 } 296 }
297 offset = (cap >> 8) & 0xff;
271 } 298 }
299 if (!count)
300 printk(KERN_DEBUG "%s %s: capability loop?\n",
301 pdev->dev.bus_id, "EHCI");
272 302
273 /* 303 /*
274 * halt EHCI & disable its interrupts in any case 304 * halt EHCI & disable its interrupts in any case
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index b6076004a437..782398045f9f 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -672,9 +672,9 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
672 /* Low-speed transfers get a different queue, and won't hog the bus. 672 /* Low-speed transfers get a different queue, and won't hog the bus.
673 * Also, some devices enumerate better without FSBR; the easiest way 673 * Also, some devices enumerate better without FSBR; the easiest way
674 * to do that is to put URBs on the low-speed queue while the device 674 * to do that is to put URBs on the low-speed queue while the device
675 * is in the DEFAULT state. */ 675 * isn't in the CONFIGURED state. */
676 if (urb->dev->speed == USB_SPEED_LOW || 676 if (urb->dev->speed == USB_SPEED_LOW ||
677 urb->dev->state == USB_STATE_DEFAULT) 677 urb->dev->state != USB_STATE_CONFIGURED)
678 skelqh = uhci->skel_ls_control_qh; 678 skelqh = uhci->skel_ls_control_qh;
679 else { 679 else {
680 skelqh = uhci->skel_fs_control_qh; 680 skelqh = uhci->skel_fs_control_qh;
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index a91e72c41415..6f7a684c3e07 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1307,7 +1307,7 @@ void hid_init_reports(struct hid_device *hid)
1307 } 1307 }
1308 1308
1309 if (err) 1309 if (err)
1310 warn("timeout initializing reports\n"); 1310 warn("timeout initializing reports");
1311} 1311}
1312 1312
1313#define USB_VENDOR_ID_WACOM 0x056a 1313#define USB_VENDOR_ID_WACOM 0x056a
@@ -1453,6 +1453,9 @@ void hid_init_reports(struct hid_device *hid)
1453#define USB_VENDOR_ID_CHERRY 0x046a 1453#define USB_VENDOR_ID_CHERRY 0x046a
1454#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 1454#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
1455 1455
1456#define USB_VENDOR_ID_HP 0x03f0
1457#define USB_DEVICE_ID_HP_USBHUB_KB 0x020c
1458
1456/* 1459/*
1457 * Alphabetically sorted blacklist by quirk type. 1460 * Alphabetically sorted blacklist by quirk type.
1458 */ 1461 */
@@ -1566,6 +1569,7 @@ static const struct hid_blacklist {
1566 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, 1569 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
1567 { USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_KEYBOARD, HID_QUIRK_NOGET}, 1570 { USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_KEYBOARD, HID_QUIRK_NOGET},
1568 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, 1571 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET},
1572 { USB_VENDOR_ID_HP, USB_DEVICE_ID_HP_USBHUB_KB, HID_QUIRK_NOGET },
1569 { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, 1573 { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET },
1570 1574
1571 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_POWERMOUSE, HID_QUIRK_2WHEEL_POWERMOUSE }, 1575 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_POWERMOUSE, HID_QUIRK_2WHEEL_POWERMOUSE },
@@ -1828,9 +1832,6 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1828 hid->urbctrl->transfer_dma = hid->ctrlbuf_dma; 1832 hid->urbctrl->transfer_dma = hid->ctrlbuf_dma;
1829 hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); 1833 hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
1830 1834
1831 /* May be needed for some devices */
1832 usb_clear_halt(hid->dev, hid->urbin->pipe);
1833
1834 return hid; 1835 return hid;
1835 1836
1836fail: 1837fail:
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
index 4dff8473553d..925f5aba06f5 100644
--- a/drivers/usb/input/hiddev.c
+++ b/drivers/usb/input/hiddev.c
@@ -35,7 +35,6 @@
35#include <linux/usb.h> 35#include <linux/usb.h>
36#include "hid.h" 36#include "hid.h"
37#include <linux/hiddev.h> 37#include <linux/hiddev.h>
38#include <linux/devfs_fs_kernel.h>
39 38
40#ifdef CONFIG_USB_DYNAMIC_MINORS 39#ifdef CONFIG_USB_DYNAMIC_MINORS
41#define HIDDEV_MINOR_BASE 0 40#define HIDDEV_MINOR_BASE 0
@@ -632,7 +631,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
632 631
633 else if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) && 632 else if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
634 (uref_multi->num_values > HID_MAX_MULTI_USAGES || 633 (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
635 uref->usage_index + uref_multi->num_values >= field->report_count)) 634 uref->usage_index + uref_multi->num_values > field->report_count))
636 goto inval; 635 goto inval;
637 } 636 }
638 637
@@ -832,12 +831,10 @@ static /* const */ struct usb_driver hiddev_driver = {
832 831
833int __init hiddev_init(void) 832int __init hiddev_init(void)
834{ 833{
835 devfs_mk_dir("usb/hid");
836 return usb_register(&hiddev_driver); 834 return usb_register(&hiddev_driver);
837} 835}
838 836
839void hiddev_exit(void) 837void hiddev_exit(void)
840{ 838{
841 usb_deregister(&hiddev_driver); 839 usb_deregister(&hiddev_driver);
842 devfs_remove("usb/hid");
843} 840}
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 3b3c7b4120a2..697c5e573a11 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -337,6 +337,9 @@ static int touchkit_probe(struct usb_interface *intf,
337 touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, 337 touchkit->data, TOUCHKIT_REPORT_DATA_SIZE,
338 touchkit_irq, touchkit, endpoint->bInterval); 338 touchkit_irq, touchkit, endpoint->bInterval);
339 339
340 touchkit->irq->transfer_dma = touchkit->data_dma;
341 touchkit->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
342
340 input_register_device(touchkit->input); 343 input_register_device(touchkit->input);
341 344
342 usb_set_intfdata(intf, touchkit); 345 usb_set_intfdata(intf, touchkit);
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index 1bfc105ad4d6..37d2f0ba0319 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -59,7 +59,7 @@
59#include "map_to_7segment.h" 59#include "map_to_7segment.h"
60#include "yealink.h" 60#include "yealink.h"
61 61
62#define DRIVER_VERSION "yld-20050816" 62#define DRIVER_VERSION "yld-20051230"
63#define DRIVER_AUTHOR "Henk Vergonet" 63#define DRIVER_AUTHOR "Henk Vergonet"
64#define DRIVER_DESC "Yealink phone driver" 64#define DRIVER_DESC "Yealink phone driver"
65 65
@@ -786,16 +786,25 @@ static struct attribute_group yld_attr_group = {
786 * Linux interface and usb initialisation 786 * Linux interface and usb initialisation
787 ******************************************************************************/ 787 ******************************************************************************/
788 788
789static const struct yld_device { 789struct driver_info {
790 u16 idVendor;
791 u16 idProduct;
792 char *name; 790 char *name;
793} yld_device[] = {
794 { 0x6993, 0xb001, "Yealink usb-p1k" },
795}; 791};
796 792
797static struct usb_device_id usb_table [] = { 793static const struct driver_info info_P1K = {
798 { USB_INTERFACE_INFO(USB_CLASS_HID, 0, 0) }, 794 .name = "Yealink usb-p1k",
795};
796
797static const struct usb_device_id usb_table [] = {
798 {
799 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
800 USB_DEVICE_ID_MATCH_INT_INFO,
801 .idVendor = 0x6993,
802 .idProduct = 0xb001,
803 .bInterfaceClass = USB_CLASS_HID,
804 .bInterfaceSubClass = 0,
805 .bInterfaceProtocol = 0,
806 .driver_info = (kernel_ulong_t)&info_P1K
807 },
799 { } 808 { }
800}; 809};
801 810
@@ -842,33 +851,16 @@ static void usb_disconnect(struct usb_interface *intf)
842 usb_cleanup(yld, 0); 851 usb_cleanup(yld, 0);
843} 852}
844 853
845static int usb_match(struct usb_device *udev)
846{
847 int i;
848 u16 idVendor = le16_to_cpu(udev->descriptor.idVendor);
849 u16 idProduct = le16_to_cpu(udev->descriptor.idProduct);
850
851 for (i = 0; i < ARRAY_SIZE(yld_device); i++) {
852 if ((idVendor == yld_device[i].idVendor) &&
853 (idProduct == yld_device[i].idProduct))
854 return i;
855 }
856 return -ENODEV;
857}
858
859static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) 854static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
860{ 855{
861 struct usb_device *udev = interface_to_usbdev (intf); 856 struct usb_device *udev = interface_to_usbdev (intf);
857 struct driver_info *nfo = (struct driver_info *)id->driver_info;
862 struct usb_host_interface *interface; 858 struct usb_host_interface *interface;
863 struct usb_endpoint_descriptor *endpoint; 859 struct usb_endpoint_descriptor *endpoint;
864 struct yealink_dev *yld; 860 struct yealink_dev *yld;
865 struct input_dev *input_dev; 861 struct input_dev *input_dev;
866 int ret, pipe, i; 862 int ret, pipe, i;
867 863
868 i = usb_match(udev);
869 if (i < 0)
870 return -ENODEV;
871
872 interface = intf->cur_altsetting; 864 interface = intf->cur_altsetting;
873 endpoint = &interface->endpoint[0].desc; 865 endpoint = &interface->endpoint[0].desc;
874 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 866 if (!(endpoint->bEndpointAddress & USB_DIR_IN))
@@ -915,7 +907,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
915 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 907 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
916 ret = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 908 ret = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
917 if (ret != USB_PKT_LEN) 909 if (ret != USB_PKT_LEN)
918 err("invalid payload size %d, expected %d", ret, USB_PKT_LEN); 910 err("invalid payload size %d, expected %zd", ret, USB_PKT_LEN);
919 911
920 /* initialise irq urb */ 912 /* initialise irq urb */
921 usb_fill_int_urb(yld->urb_irq, udev, pipe, yld->irq_data, 913 usb_fill_int_urb(yld->urb_irq, udev, pipe, yld->irq_data,
@@ -948,7 +940,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
948 strlcat(yld->phys, "/input0", sizeof(yld->phys)); 940 strlcat(yld->phys, "/input0", sizeof(yld->phys));
949 941
950 /* register settings for the input device */ 942 /* register settings for the input device */
951 input_dev->name = yld_device[i].name; 943 input_dev->name = nfo->name;
952 input_dev->phys = yld->phys; 944 input_dev->phys = yld->phys;
953 usb_to_input_id(udev, &input_dev->id); 945 usb_to_input_id(udev, &input_dev->id);
954 input_dev->cdev.dev = &intf->dev; 946 input_dev->cdev.dev = &intf->dev;
diff --git a/drivers/usb/media/Kconfig b/drivers/usb/media/Kconfig
index 21232ee2974c..0d3d2cc5d7be 100644
--- a/drivers/usb/media/Kconfig
+++ b/drivers/usb/media/Kconfig
@@ -53,6 +53,21 @@ config USB_DSBR
53 To compile this driver as a module, choose M here: the 53 To compile this driver as a module, choose M here: the
54 module will be called dsbr100. 54 module will be called dsbr100.
55 55
56config USB_ET61X251
57 tristate "USB ET61X[12]51 PC Camera Controller support"
58 depends on USB && VIDEO_DEV
59 ---help---
60 Say Y here if you want support for cameras based on Etoms ET61X151
61 or ET61X251 PC Camera Controllers.
62
63 See <file:Documentation/usb/et61x251.txt> for more informations.
64
65 This driver uses the Video For Linux API. You must say Y or M to
66 "Video For Linux" to use this driver.
67
68 To compile this driver as a module, choose M here: the
69 module will be called et61x251.
70
56config USB_IBMCAM 71config USB_IBMCAM
57 tristate "USB IBM (Xirlink) C-it Camera support" 72 tristate "USB IBM (Xirlink) C-it Camera support"
58 depends on USB && VIDEO_DEV 73 depends on USB && VIDEO_DEV
@@ -209,5 +224,3 @@ config USB_PWC
209 224
210 To compile this driver as a module, choose M here: the 225 To compile this driver as a module, choose M here: the
211 module will be called pwc. 226 module will be called pwc.
212
213
diff --git a/drivers/usb/media/Makefile b/drivers/usb/media/Makefile
index d83adffa925f..3957aa1be0f2 100644
--- a/drivers/usb/media/Makefile
+++ b/drivers/usb/media/Makefile
@@ -3,9 +3,11 @@
3# 3#
4 4
5sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bcb.o sn9c102_tas5110c1b.o sn9c102_tas5130d1b.o 5sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bcb.o sn9c102_tas5110c1b.o sn9c102_tas5130d1b.o
6et61x251-objs := et61x251_core.o et61x251_tas5130d1b.o
6 7
7obj-$(CONFIG_USB_DABUSB) += dabusb.o 8obj-$(CONFIG_USB_DABUSB) += dabusb.o
8obj-$(CONFIG_USB_DSBR) += dsbr100.o 9obj-$(CONFIG_USB_DSBR) += dsbr100.o
10obj-$(CONFIG_USB_ET61X251) += et61x251.o
9obj-$(CONFIG_USB_IBMCAM) += ibmcam.o usbvideo.o ultracam.o 11obj-$(CONFIG_USB_IBMCAM) += ibmcam.o usbvideo.o ultracam.o
10obj-$(CONFIG_USB_KONICAWC) += konicawc.o usbvideo.o 12obj-$(CONFIG_USB_KONICAWC) += konicawc.o usbvideo.o
11obj-$(CONFIG_USB_OV511) += ov511.o 13obj-$(CONFIG_USB_OV511) += ov511.o
diff --git a/drivers/usb/media/et61x251.h b/drivers/usb/media/et61x251.h
new file mode 100644
index 000000000000..652238f329f3
--- /dev/null
+++ b/drivers/usb/media/et61x251.h
@@ -0,0 +1,220 @@
1/***************************************************************************
2 * V4L2 driver for ET61X[12]51 PC Camera Controllers *
3 * *
4 * Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
19 ***************************************************************************/
20
21#ifndef _ET61X251_H_
22#define _ET61X251_H_
23
24#include <linux/version.h>
25#include <linux/usb.h>
26#include <linux/videodev2.h>
27#include <media/v4l2-common.h>
28#include <linux/device.h>
29#include <linux/list.h>
30#include <linux/spinlock.h>
31#include <linux/time.h>
32#include <linux/wait.h>
33#include <linux/types.h>
34#include <linux/param.h>
35#include <linux/rwsem.h>
36#include <asm/semaphore.h>
37
38#include "et61x251_sensor.h"
39
40/*****************************************************************************/
41
42#define ET61X251_DEBUG
43#define ET61X251_DEBUG_LEVEL 2
44#define ET61X251_MAX_DEVICES 64
45#define ET61X251_PRESERVE_IMGSCALE 0
46#define ET61X251_FORCE_MUNMAP 0
47#define ET61X251_MAX_FRAMES 32
48#define ET61X251_COMPRESSION_QUALITY 0
49#define ET61X251_URBS 2
50#define ET61X251_ISO_PACKETS 7
51#define ET61X251_ALTERNATE_SETTING 13
52#define ET61X251_URB_TIMEOUT msecs_to_jiffies(2 * ET61X251_ISO_PACKETS)
53#define ET61X251_CTRL_TIMEOUT 100
54
55/*****************************************************************************/
56
57static const struct usb_device_id et61x251_id_table[] = {
58 { USB_DEVICE(0x102c, 0x6151), },
59 { USB_DEVICE(0x102c, 0x6251), },
60 { USB_DEVICE(0x102c, 0x6253), },
61 { USB_DEVICE(0x102c, 0x6254), },
62 { USB_DEVICE(0x102c, 0x6255), },
63 { USB_DEVICE(0x102c, 0x6256), },
64 { USB_DEVICE(0x102c, 0x6257), },
65 { USB_DEVICE(0x102c, 0x6258), },
66 { USB_DEVICE(0x102c, 0x6259), },
67 { USB_DEVICE(0x102c, 0x625a), },
68 { USB_DEVICE(0x102c, 0x625b), },
69 { USB_DEVICE(0x102c, 0x625c), },
70 { USB_DEVICE(0x102c, 0x625d), },
71 { USB_DEVICE(0x102c, 0x625e), },
72 { USB_DEVICE(0x102c, 0x625f), },
73 { USB_DEVICE(0x102c, 0x6260), },
74 { USB_DEVICE(0x102c, 0x6261), },
75 { USB_DEVICE(0x102c, 0x6262), },
76 { USB_DEVICE(0x102c, 0x6263), },
77 { USB_DEVICE(0x102c, 0x6264), },
78 { USB_DEVICE(0x102c, 0x6265), },
79 { USB_DEVICE(0x102c, 0x6266), },
80 { USB_DEVICE(0x102c, 0x6267), },
81 { USB_DEVICE(0x102c, 0x6268), },
82 { USB_DEVICE(0x102c, 0x6269), },
83 { }
84};
85
86ET61X251_SENSOR_TABLE
87
88/*****************************************************************************/
89
90enum et61x251_frame_state {
91 F_UNUSED,
92 F_QUEUED,
93 F_GRABBING,
94 F_DONE,
95 F_ERROR,
96};
97
98struct et61x251_frame_t {
99 void* bufmem;
100 struct v4l2_buffer buf;
101 enum et61x251_frame_state state;
102 struct list_head frame;
103 unsigned long vma_use_count;
104};
105
106enum et61x251_dev_state {
107 DEV_INITIALIZED = 0x01,
108 DEV_DISCONNECTED = 0x02,
109 DEV_MISCONFIGURED = 0x04,
110};
111
112enum et61x251_io_method {
113 IO_NONE,
114 IO_READ,
115 IO_MMAP,
116};
117
118enum et61x251_stream_state {
119 STREAM_OFF,
120 STREAM_INTERRUPT,
121 STREAM_ON,
122};
123
124struct et61x251_sysfs_attr {
125 u8 reg, i2c_reg;
126};
127
128struct et61x251_module_param {
129 u8 force_munmap;
130};
131
132static DECLARE_MUTEX(et61x251_sysfs_lock);
133static DECLARE_RWSEM(et61x251_disconnect);
134
135struct et61x251_device {
136 struct video_device* v4ldev;
137
138 struct et61x251_sensor* sensor;
139
140 struct usb_device* usbdev;
141 struct urb* urb[ET61X251_URBS];
142 void* transfer_buffer[ET61X251_URBS];
143 u8* control_buffer;
144
145 struct et61x251_frame_t *frame_current, frame[ET61X251_MAX_FRAMES];
146 struct list_head inqueue, outqueue;
147 u32 frame_count, nbuffers, nreadbuffers;
148
149 enum et61x251_io_method io;
150 enum et61x251_stream_state stream;
151
152 struct v4l2_jpegcompression compression;
153
154 struct et61x251_sysfs_attr sysfs;
155 struct et61x251_module_param module_param;
156
157 enum et61x251_dev_state state;
158 u8 users;
159
160 struct semaphore dev_sem, fileop_sem;
161 spinlock_t queue_lock;
162 wait_queue_head_t open, wait_frame, wait_stream;
163};
164
165/*****************************************************************************/
166
167void
168et61x251_attach_sensor(struct et61x251_device* cam,
169 struct et61x251_sensor* sensor)
170{
171 cam->sensor = sensor;
172 cam->sensor->usbdev = cam->usbdev;
173}
174
175/*****************************************************************************/
176
177#undef DBG
178#undef KDBG
179#ifdef ET61X251_DEBUG
180# define DBG(level, fmt, args...) \
181do { \
182 if (debug >= (level)) { \
183 if ((level) == 1) \
184 dev_err(&cam->usbdev->dev, fmt "\n", ## args); \
185 else if ((level) == 2) \
186 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
187 else if ((level) >= 3) \
188 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
189 __FUNCTION__, __LINE__ , ## args); \
190 } \
191} while (0)
192# define KDBG(level, fmt, args...) \
193do { \
194 if (debug >= (level)) { \
195 if ((level) == 1 || (level) == 2) \
196 pr_info("et61x251: " fmt "\n", ## args); \
197 else if ((level) == 3) \
198 pr_debug("et61x251: [%s:%d] " fmt "\n", __FUNCTION__, \
199 __LINE__ , ## args); \
200 } \
201} while (0)
202# define V4LDBG(level, name, cmd) \
203do { \
204 if (debug >= (level)) \
205 v4l_print_ioctl(name, cmd); \
206} while (0)
207#else
208# define DBG(level, fmt, args...) do {;} while(0)
209# define KDBG(level, fmt, args...) do {;} while(0)
210# define V4LDBG(level, name, cmd) do {;} while(0)
211#endif
212
213#undef PDBG
214#define PDBG(fmt, args...) \
215dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args)
216
217#undef PDBGG
218#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
219
220#endif /* _ET61X251_H_ */
diff --git a/drivers/usb/media/et61x251_core.c b/drivers/usb/media/et61x251_core.c
new file mode 100644
index 000000000000..2c0171a5ad62
--- /dev/null
+++ b/drivers/usb/media/et61x251_core.c
@@ -0,0 +1,2605 @@
1/***************************************************************************
2 * V4L2 driver for ET61X[12]51 PC Camera Controllers *
3 * *
4 * Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
19 ***************************************************************************/
20
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/kernel.h>
24#include <linux/param.h>
25#include <linux/moduleparam.h>
26#include <linux/errno.h>
27#include <linux/slab.h>
28#include <linux/string.h>
29#include <linux/device.h>
30#include <linux/fs.h>
31#include <linux/delay.h>
32#include <linux/stddef.h>
33#include <linux/compiler.h>
34#include <linux/ioctl.h>
35#include <linux/poll.h>
36#include <linux/stat.h>
37#include <linux/mm.h>
38#include <linux/vmalloc.h>
39#include <linux/page-flags.h>
40#include <linux/byteorder/generic.h>
41#include <asm/page.h>
42#include <asm/uaccess.h>
43
44#include "et61x251.h"
45
46/*****************************************************************************/
47
48#define ET61X251_MODULE_NAME "V4L2 driver for ET61X[12]51 " \
49 "PC Camera Controllers"
50#define ET61X251_MODULE_AUTHOR "(C) 2006 Luca Risolia"
51#define ET61X251_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
52#define ET61X251_MODULE_LICENSE "GPL"
53#define ET61X251_MODULE_VERSION "1:1.01"
54#define ET61X251_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 1)
55
56/*****************************************************************************/
57
58MODULE_DEVICE_TABLE(usb, et61x251_id_table);
59
60MODULE_AUTHOR(ET61X251_MODULE_AUTHOR " " ET61X251_AUTHOR_EMAIL);
61MODULE_DESCRIPTION(ET61X251_MODULE_NAME);
62MODULE_VERSION(ET61X251_MODULE_VERSION);
63MODULE_LICENSE(ET61X251_MODULE_LICENSE);
64
65static short video_nr[] = {[0 ... ET61X251_MAX_DEVICES-1] = -1};
66module_param_array(video_nr, short, NULL, 0444);
67MODULE_PARM_DESC(video_nr,
68 "\n<-1|n[,...]> Specify V4L2 minor mode number."
69 "\n -1 = use next available (default)"
70 "\n n = use minor number n (integer >= 0)"
71 "\nYou can specify up to "
72 __MODULE_STRING(ET61X251_MAX_DEVICES) " cameras this way."
73 "\nFor example:"
74 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
75 "\nthe second registered camera and use auto for the first"
76 "\none and for every other camera."
77 "\n");
78
79static short force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] =
80 ET61X251_FORCE_MUNMAP};
81module_param_array(force_munmap, bool, NULL, 0444);
82MODULE_PARM_DESC(force_munmap,
83 "\n<0|1[,...]> Force the application to unmap previously"
84 "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
85 "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
86 "\nthis feature. This parameter is specific for each"
87 "\ndetected camera."
88 "\n 0 = do not force memory unmapping"
89 "\n 1 = force memory unmapping (save memory)"
90 "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
91 "\n");
92
93#ifdef ET61X251_DEBUG
94static unsigned short debug = ET61X251_DEBUG_LEVEL;
95module_param(debug, ushort, 0644);
96MODULE_PARM_DESC(debug,
97 "\n<n> Debugging information level, from 0 to 3:"
98 "\n0 = none (use carefully)"
99 "\n1 = critical errors"
100 "\n2 = significant informations"
101 "\n3 = more verbose messages"
102 "\nLevel 3 is useful for testing only, when only "
103 "one device is used."
104 "\nDefault value is "__MODULE_STRING(ET61X251_DEBUG_LEVEL)"."
105 "\n");
106#endif
107
108/*****************************************************************************/
109
110static u32
111et61x251_request_buffers(struct et61x251_device* cam, u32 count,
112 enum et61x251_io_method io)
113{
114 struct v4l2_pix_format* p = &(cam->sensor->pix_format);
115 struct v4l2_rect* r = &(cam->sensor->cropcap.bounds);
116 const size_t imagesize = cam->module_param.force_munmap ||
117 io == IO_READ ?
118 (p->width * p->height * p->priv) / 8 :
119 (r->width * r->height * p->priv) / 8;
120 void* buff = NULL;
121 u32 i;
122
123 if (count > ET61X251_MAX_FRAMES)
124 count = ET61X251_MAX_FRAMES;
125
126 cam->nbuffers = count;
127 while (cam->nbuffers > 0) {
128 if ((buff = vmalloc_32(cam->nbuffers * PAGE_ALIGN(imagesize))))
129 break;
130 cam->nbuffers--;
131 }
132
133 for (i = 0; i < cam->nbuffers; i++) {
134 cam->frame[i].bufmem = buff + i*PAGE_ALIGN(imagesize);
135 cam->frame[i].buf.index = i;
136 cam->frame[i].buf.m.offset = i*PAGE_ALIGN(imagesize);
137 cam->frame[i].buf.length = imagesize;
138 cam->frame[i].buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
139 cam->frame[i].buf.sequence = 0;
140 cam->frame[i].buf.field = V4L2_FIELD_NONE;
141 cam->frame[i].buf.memory = V4L2_MEMORY_MMAP;
142 cam->frame[i].buf.flags = 0;
143 }
144
145 return cam->nbuffers;
146}
147
148
149static void et61x251_release_buffers(struct et61x251_device* cam)
150{
151 if (cam->nbuffers) {
152 vfree(cam->frame[0].bufmem);
153 cam->nbuffers = 0;
154 }
155 cam->frame_current = NULL;
156}
157
158
159static void et61x251_empty_framequeues(struct et61x251_device* cam)
160{
161 u32 i;
162
163 INIT_LIST_HEAD(&cam->inqueue);
164 INIT_LIST_HEAD(&cam->outqueue);
165
166 for (i = 0; i < ET61X251_MAX_FRAMES; i++) {
167 cam->frame[i].state = F_UNUSED;
168 cam->frame[i].buf.bytesused = 0;
169 }
170}
171
172
173static void et61x251_requeue_outqueue(struct et61x251_device* cam)
174{
175 struct et61x251_frame_t *i;
176
177 list_for_each_entry(i, &cam->outqueue, frame) {
178 i->state = F_QUEUED;
179 list_add(&i->frame, &cam->inqueue);
180 }
181
182 INIT_LIST_HEAD(&cam->outqueue);
183}
184
185
186static void et61x251_queue_unusedframes(struct et61x251_device* cam)
187{
188 unsigned long lock_flags;
189 u32 i;
190
191 for (i = 0; i < cam->nbuffers; i++)
192 if (cam->frame[i].state == F_UNUSED) {
193 cam->frame[i].state = F_QUEUED;
194 spin_lock_irqsave(&cam->queue_lock, lock_flags);
195 list_add_tail(&cam->frame[i].frame, &cam->inqueue);
196 spin_unlock_irqrestore(&cam->queue_lock, lock_flags);
197 }
198}
199
200/*****************************************************************************/
201
202int et61x251_write_reg(struct et61x251_device* cam, u8 value, u16 index)
203{
204 struct usb_device* udev = cam->usbdev;
205 u8* buff = cam->control_buffer;
206 int res;
207
208 *buff = value;
209
210 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
211 0, index, buff, 1, ET61X251_CTRL_TIMEOUT);
212 if (res < 0) {
213 DBG(3, "Failed to write a register (value 0x%02X, index "
214 "0x%02X, error %d)", value, index, res);
215 return -1;
216 }
217
218 return 0;
219}
220
221
222int et61x251_read_reg(struct et61x251_device* cam, u16 index)
223{
224 struct usb_device* udev = cam->usbdev;
225 u8* buff = cam->control_buffer;
226 int res;
227
228 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
229 0, index, buff, 1, ET61X251_CTRL_TIMEOUT);
230 if (res < 0)
231 DBG(3, "Failed to read a register (index 0x%02X, error %d)",
232 index, res);
233
234 return (res >= 0) ? (int)(*buff) : -1;
235}
236
237
238static int
239et61x251_i2c_wait(struct et61x251_device* cam, struct et61x251_sensor* sensor)
240{
241 int i, r;
242
243 for (i = 1; i <= 8; i++) {
244 if (sensor->interface == ET61X251_I2C_3WIRES) {
245 r = et61x251_read_reg(cam, 0x8e);
246 if (!(r & 0x02) && (r >= 0))
247 return 0;
248 } else {
249 r = et61x251_read_reg(cam, 0x8b);
250 if (!(r & 0x01) && (r >= 0))
251 return 0;
252 }
253 if (r < 0)
254 return -EIO;
255 udelay(8*8); /* minimum for sensors at 400kHz */
256 }
257
258 return -EBUSY;
259}
260
261
262int
263et61x251_i2c_try_read(struct et61x251_device* cam,
264 struct et61x251_sensor* sensor, u8 address)
265{
266 struct usb_device* udev = cam->usbdev;
267 u8* data = cam->control_buffer;
268 int err = 0, res;
269
270 data[0] = address;
271 data[1] = cam->sensor->i2c_slave_id;
272 data[2] = cam->sensor->rsta | 0x10;
273 data[3] = !(et61x251_read_reg(cam, 0x8b) & 0x02);
274 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
275 0, 0x88, data, 4, ET61X251_CTRL_TIMEOUT);
276 if (res < 0)
277 err += res;
278
279 err += et61x251_i2c_wait(cam, sensor);
280
281 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
282 0, 0x80, data, 8, ET61X251_CTRL_TIMEOUT);
283 if (res < 0)
284 err += res;
285
286 if (err)
287 DBG(3, "I2C read failed for %s image sensor", sensor->name);
288
289 PDBGG("I2C read: address 0x%02X, value: 0x%02X", address, data[0]);
290
291 return err ? -1 : (int)data[0];
292}
293
294
295int
296et61x251_i2c_try_write(struct et61x251_device* cam,
297 struct et61x251_sensor* sensor, u8 address, u8 value)
298{
299 struct usb_device* udev = cam->usbdev;
300 u8* data = cam->control_buffer;
301 int err = 0, res;
302
303 data[0] = address;
304 data[1] = cam->sensor->i2c_slave_id;
305 data[2] = cam->sensor->rsta | 0x12;
306 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
307 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT);
308 if (res < 0)
309 err += res;
310
311 data[0] = value;
312 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
313 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT);
314 if (res < 0)
315 err += res;
316
317 err += et61x251_i2c_wait(cam, sensor);
318
319 if (err)
320 DBG(3, "I2C write failed for %s image sensor", sensor->name);
321
322 PDBGG("I2C write: address 0x%02X, value: 0x%02X", address, value);
323
324 return err ? -1 : 0;
325}
326
327
328int
329et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2,
330 u8 data3, u8 data4, u8 data5, u8 data6, u8 data7,
331 u8 data8, u8 address)
332{
333 struct usb_device* udev = cam->usbdev;
334 u8* data = cam->control_buffer;
335 int err = 0, res;
336
337 if (!cam->sensor)
338 return -1;
339
340 data[0] = data2;
341 data[1] = data3;
342 data[2] = data4;
343 data[3] = data5;
344 data[4] = data6;
345 data[5] = data7;
346 data[6] = data8;
347 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
348 0, 0x81, data, n-1, ET61X251_CTRL_TIMEOUT);
349 if (res < 0)
350 err += res;
351
352 data[0] = address;
353 data[1] = cam->sensor->i2c_slave_id;
354 data[2] = cam->sensor->rsta | 0x02 | (n << 4);
355 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
356 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT);
357 if (res < 0)
358 err += res;
359
360 /* Start writing through the serial interface */
361 data[0] = data1;
362 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
363 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT);
364 if (res < 0)
365 err += res;
366
367 err += et61x251_i2c_wait(cam, cam->sensor);
368
369 if (err)
370 DBG(3, "I2C raw write failed for %s image sensor",
371 cam->sensor->name);
372
373 PDBGG("I2C raw write: %u bytes, address = 0x%02X, data1 = 0x%02X, "
374 "data2 = 0x%02X, data3 = 0x%02X, data4 = 0x%02X, data5 = 0x%02X,"
375 " data6 = 0x%02X, data7 = 0x%02X, data8 = 0x%02X", n, address,
376 data1, data2, data3, data4, data5, data6, data7, data8);
377
378 return err ? -1 : 0;
379
380}
381
382
383int et61x251_i2c_read(struct et61x251_device* cam, u8 address)
384{
385 if (!cam->sensor)
386 return -1;
387
388 return et61x251_i2c_try_read(cam, cam->sensor, address);
389}
390
391
392int et61x251_i2c_write(struct et61x251_device* cam, u8 address, u8 value)
393{
394 if (!cam->sensor)
395 return -1;
396
397 return et61x251_i2c_try_write(cam, cam->sensor, address, value);
398}
399
400/*****************************************************************************/
401
402static void et61x251_urb_complete(struct urb *urb, struct pt_regs* regs)
403{
404 struct et61x251_device* cam = urb->context;
405 struct et61x251_frame_t** f;
406 size_t imagesize;
407 u8 i;
408 int err = 0;
409
410 if (urb->status == -ENOENT)
411 return;
412
413 f = &cam->frame_current;
414
415 if (cam->stream == STREAM_INTERRUPT) {
416 cam->stream = STREAM_OFF;
417 if ((*f))
418 (*f)->state = F_QUEUED;
419 DBG(3, "Stream interrupted");
420 wake_up_interruptible(&cam->wait_stream);
421 }
422
423 if (cam->state & DEV_DISCONNECTED)
424 return;
425
426 if (cam->state & DEV_MISCONFIGURED) {
427 wake_up_interruptible(&cam->wait_frame);
428 return;
429 }
430
431 if (cam->stream == STREAM_OFF || list_empty(&cam->inqueue))
432 goto resubmit_urb;
433
434 if (!(*f))
435 (*f) = list_entry(cam->inqueue.next, struct et61x251_frame_t,
436 frame);
437
438 imagesize = (cam->sensor->pix_format.width *
439 cam->sensor->pix_format.height *
440 cam->sensor->pix_format.priv) / 8;
441
442 for (i = 0; i < urb->number_of_packets; i++) {
443 unsigned int len, status;
444 void *pos;
445 u8* b1, * b2, sof;
446 const u8 VOID_BYTES = 6;
447 size_t imglen;
448
449 len = urb->iso_frame_desc[i].actual_length;
450 status = urb->iso_frame_desc[i].status;
451 pos = urb->iso_frame_desc[i].offset + urb->transfer_buffer;
452
453 if (status) {
454 DBG(3, "Error in isochronous frame");
455 (*f)->state = F_ERROR;
456 continue;
457 }
458
459 b1 = pos++;
460 b2 = pos++;
461 sof = ((*b1 & 0x3f) == 63);
462 imglen = ((*b1 & 0xc0) << 2) | *b2;
463
464 PDBGG("Isochrnous frame: length %u, #%u i, image length %zu",
465 len, i, imglen);
466
467 if ((*f)->state == F_QUEUED || (*f)->state == F_ERROR)
468start_of_frame:
469 if (sof) {
470 (*f)->state = F_GRABBING;
471 (*f)->buf.bytesused = 0;
472 do_gettimeofday(&(*f)->buf.timestamp);
473 pos += 22;
474 DBG(3, "SOF detected: new video frame");
475 }
476
477 if ((*f)->state == F_GRABBING) {
478 if (sof && (*f)->buf.bytesused) {
479 if (cam->sensor->pix_format.pixelformat ==
480 V4L2_PIX_FMT_ET61X251)
481 goto end_of_frame;
482 else {
483 DBG(3, "Not expected SOF detected "
484 "after %lu bytes",
485 (unsigned long)(*f)->buf.bytesused);
486 (*f)->state = F_ERROR;
487 continue;
488 }
489 }
490
491 if ((*f)->buf.bytesused + imglen > imagesize) {
492 DBG(3, "Video frame size exceeded");
493 (*f)->state = F_ERROR;
494 continue;
495 }
496
497 pos += VOID_BYTES;
498
499 memcpy((*f)->bufmem+(*f)->buf.bytesused, pos, imglen);
500 (*f)->buf.bytesused += imglen;
501
502 if ((*f)->buf.bytesused == imagesize) {
503 u32 b;
504end_of_frame:
505 b = (*f)->buf.bytesused;
506 (*f)->state = F_DONE;
507 (*f)->buf.sequence= ++cam->frame_count;
508 spin_lock(&cam->queue_lock);
509 list_move_tail(&(*f)->frame, &cam->outqueue);
510 if (!list_empty(&cam->inqueue))
511 (*f) = list_entry(cam->inqueue.next,
512 struct et61x251_frame_t,
513 frame);
514 else
515 (*f) = NULL;
516 spin_unlock(&cam->queue_lock);
517 DBG(3, "Video frame captured: : %lu bytes",
518 (unsigned long)(b));
519
520 if (!(*f))
521 goto resubmit_urb;
522
523 if (sof &&
524 cam->sensor->pix_format.pixelformat ==
525 V4L2_PIX_FMT_ET61X251)
526 goto start_of_frame;
527 }
528 }
529 }
530
531resubmit_urb:
532 urb->dev = cam->usbdev;
533 err = usb_submit_urb(urb, GFP_ATOMIC);
534 if (err < 0 && err != -EPERM) {
535 cam->state |= DEV_MISCONFIGURED;
536 DBG(1, "usb_submit_urb() failed");
537 }
538
539 wake_up_interruptible(&cam->wait_frame);
540}
541
542
543static int et61x251_start_transfer(struct et61x251_device* cam)
544{
545 struct usb_device *udev = cam->usbdev;
546 struct urb* urb;
547 const unsigned int wMaxPacketSize[] = {0, 256, 384, 512, 640, 768, 832,
548 864, 896, 920, 956, 980, 1000,
549 1022};
550 const unsigned int psz = wMaxPacketSize[ET61X251_ALTERNATE_SETTING];
551 s8 i, j;
552 int err = 0;
553
554 for (i = 0; i < ET61X251_URBS; i++) {
555 cam->transfer_buffer[i] = kzalloc(ET61X251_ISO_PACKETS * psz,
556 GFP_KERNEL);
557 if (!cam->transfer_buffer[i]) {
558 err = -ENOMEM;
559 DBG(1, "Not enough memory");
560 goto free_buffers;
561 }
562 }
563
564 for (i = 0; i < ET61X251_URBS; i++) {
565 urb = usb_alloc_urb(ET61X251_ISO_PACKETS, GFP_KERNEL);
566 cam->urb[i] = urb;
567 if (!urb) {
568 err = -ENOMEM;
569 DBG(1, "usb_alloc_urb() failed");
570 goto free_urbs;
571 }
572 urb->dev = udev;
573 urb->context = cam;
574 urb->pipe = usb_rcvisocpipe(udev, 1);
575 urb->transfer_flags = URB_ISO_ASAP;
576 urb->number_of_packets = ET61X251_ISO_PACKETS;
577 urb->complete = et61x251_urb_complete;
578 urb->transfer_buffer = cam->transfer_buffer[i];
579 urb->transfer_buffer_length = psz * ET61X251_ISO_PACKETS;
580 urb->interval = 1;
581 for (j = 0; j < ET61X251_ISO_PACKETS; j++) {
582 urb->iso_frame_desc[j].offset = psz * j;
583 urb->iso_frame_desc[j].length = psz;
584 }
585 }
586
587 err = et61x251_write_reg(cam, 0x01, 0x03);
588 err = et61x251_write_reg(cam, 0x00, 0x03);
589 err = et61x251_write_reg(cam, 0x08, 0x03);
590 if (err) {
591 err = -EIO;
592 DBG(1, "I/O hardware error");
593 goto free_urbs;
594 }
595
596 err = usb_set_interface(udev, 0, ET61X251_ALTERNATE_SETTING);
597 if (err) {
598 DBG(1, "usb_set_interface() failed");
599 goto free_urbs;
600 }
601
602 cam->frame_current = NULL;
603
604 for (i = 0; i < ET61X251_URBS; i++) {
605 err = usb_submit_urb(cam->urb[i], GFP_KERNEL);
606 if (err) {
607 for (j = i-1; j >= 0; j--)
608 usb_kill_urb(cam->urb[j]);
609 DBG(1, "usb_submit_urb() failed, error %d", err);
610 goto free_urbs;
611 }
612 }
613
614 return 0;
615
616free_urbs:
617 for (i = 0; (i < ET61X251_URBS) && cam->urb[i]; i++)
618 usb_free_urb(cam->urb[i]);
619
620free_buffers:
621 for (i = 0; (i < ET61X251_URBS) && cam->transfer_buffer[i]; i++)
622 kfree(cam->transfer_buffer[i]);
623
624 return err;
625}
626
627
628static int et61x251_stop_transfer(struct et61x251_device* cam)
629{
630 struct usb_device *udev = cam->usbdev;
631 s8 i;
632 int err = 0;
633
634 if (cam->state & DEV_DISCONNECTED)
635 return 0;
636
637 for (i = ET61X251_URBS-1; i >= 0; i--) {
638 usb_kill_urb(cam->urb[i]);
639 usb_free_urb(cam->urb[i]);
640 kfree(cam->transfer_buffer[i]);
641 }
642
643 err = usb_set_interface(udev, 0, 0); /* 0 Mb/s */
644 if (err)
645 DBG(3, "usb_set_interface() failed");
646
647 return err;
648}
649
650
651static int et61x251_stream_interrupt(struct et61x251_device* cam)
652{
653 int err = 0;
654
655 cam->stream = STREAM_INTERRUPT;
656 err = wait_event_timeout(cam->wait_stream,
657 (cam->stream == STREAM_OFF) ||
658 (cam->state & DEV_DISCONNECTED),
659 ET61X251_URB_TIMEOUT);
660 if (cam->state & DEV_DISCONNECTED)
661 return -ENODEV;
662 else if (err) {
663 cam->state |= DEV_MISCONFIGURED;
664 DBG(1, "URB timeout reached. The camera is misconfigured. To "
665 "use it, close and open /dev/video%d again.",
666 cam->v4ldev->minor);
667 return err;
668 }
669
670 return 0;
671}
672
673/*****************************************************************************/
674
675#ifdef CONFIG_VIDEO_ADV_DEBUG
676static u8 et61x251_strtou8(const char* buff, size_t len, ssize_t* count)
677{
678 char str[5];
679 char* endp;
680 unsigned long val;
681
682 if (len < 4) {
683 strncpy(str, buff, len);
684 str[len+1] = '\0';
685 } else {
686 strncpy(str, buff, 4);
687 str[4] = '\0';
688 }
689
690 val = simple_strtoul(str, &endp, 0);
691
692 *count = 0;
693 if (val <= 0xff)
694 *count = (ssize_t)(endp - str);
695 if ((*count) && (len == *count+1) && (buff[*count] == '\n'))
696 *count += 1;
697
698 return (u8)val;
699}
700
701/*
702 NOTE 1: being inside one of the following methods implies that the v4l
703 device exists for sure (see kobjects and reference counters)
704 NOTE 2: buffers are PAGE_SIZE long
705*/
706
707static ssize_t et61x251_show_reg(struct class_device* cd, char* buf)
708{
709 struct et61x251_device* cam;
710 ssize_t count;
711
712 if (down_interruptible(&et61x251_sysfs_lock))
713 return -ERESTARTSYS;
714
715 cam = video_get_drvdata(to_video_device(cd));
716 if (!cam) {
717 up(&et61x251_sysfs_lock);
718 return -ENODEV;
719 }
720
721 count = sprintf(buf, "%u\n", cam->sysfs.reg);
722
723 up(&et61x251_sysfs_lock);
724
725 return count;
726}
727
728
729static ssize_t
730et61x251_store_reg(struct class_device* cd, const char* buf, size_t len)
731{
732 struct et61x251_device* cam;
733 u8 index;
734 ssize_t count;
735
736 if (down_interruptible(&et61x251_sysfs_lock))
737 return -ERESTARTSYS;
738
739 cam = video_get_drvdata(to_video_device(cd));
740 if (!cam) {
741 up(&et61x251_sysfs_lock);
742 return -ENODEV;
743 }
744
745 index = et61x251_strtou8(buf, len, &count);
746 if (index > 0x8e || !count) {
747 up(&et61x251_sysfs_lock);
748 return -EINVAL;
749 }
750
751 cam->sysfs.reg = index;
752
753 DBG(2, "Moved ET61X[12]51 register index to 0x%02X", cam->sysfs.reg);
754 DBG(3, "Written bytes: %zd", count);
755
756 up(&et61x251_sysfs_lock);
757
758 return count;
759}
760
761
762static ssize_t et61x251_show_val(struct class_device* cd, char* buf)
763{
764 struct et61x251_device* cam;
765 ssize_t count;
766 int val;
767
768 if (down_interruptible(&et61x251_sysfs_lock))
769 return -ERESTARTSYS;
770
771 cam = video_get_drvdata(to_video_device(cd));
772 if (!cam) {
773 up(&et61x251_sysfs_lock);
774 return -ENODEV;
775 }
776
777 if ((val = et61x251_read_reg(cam, cam->sysfs.reg)) < 0) {
778 up(&et61x251_sysfs_lock);
779 return -EIO;
780 }
781
782 count = sprintf(buf, "%d\n", val);
783
784 DBG(3, "Read bytes: %zd", count);
785
786 up(&et61x251_sysfs_lock);
787
788 return count;
789}
790
791
792static ssize_t
793et61x251_store_val(struct class_device* cd, const char* buf, size_t len)
794{
795 struct et61x251_device* cam;
796 u8 value;
797 ssize_t count;
798 int err;
799
800 if (down_interruptible(&et61x251_sysfs_lock))
801 return -ERESTARTSYS;
802
803 cam = video_get_drvdata(to_video_device(cd));
804 if (!cam) {
805 up(&et61x251_sysfs_lock);
806 return -ENODEV;
807 }
808
809 value = et61x251_strtou8(buf, len, &count);
810 if (!count) {
811 up(&et61x251_sysfs_lock);
812 return -EINVAL;
813 }
814
815 err = et61x251_write_reg(cam, value, cam->sysfs.reg);
816 if (err) {
817 up(&et61x251_sysfs_lock);
818 return -EIO;
819 }
820
821 DBG(2, "Written ET61X[12]51 reg. 0x%02X, val. 0x%02X",
822 cam->sysfs.reg, value);
823 DBG(3, "Written bytes: %zd", count);
824
825 up(&et61x251_sysfs_lock);
826
827 return count;
828}
829
830
831static ssize_t et61x251_show_i2c_reg(struct class_device* cd, char* buf)
832{
833 struct et61x251_device* cam;
834 ssize_t count;
835
836 if (down_interruptible(&et61x251_sysfs_lock))
837 return -ERESTARTSYS;
838
839 cam = video_get_drvdata(to_video_device(cd));
840 if (!cam) {
841 up(&et61x251_sysfs_lock);
842 return -ENODEV;
843 }
844
845 count = sprintf(buf, "%u\n", cam->sysfs.i2c_reg);
846
847 DBG(3, "Read bytes: %zd", count);
848
849 up(&et61x251_sysfs_lock);
850
851 return count;
852}
853
854
855static ssize_t
856et61x251_store_i2c_reg(struct class_device* cd, const char* buf, size_t len)
857{
858 struct et61x251_device* cam;
859 u8 index;
860 ssize_t count;
861
862 if (down_interruptible(&et61x251_sysfs_lock))
863 return -ERESTARTSYS;
864
865 cam = video_get_drvdata(to_video_device(cd));
866 if (!cam) {
867 up(&et61x251_sysfs_lock);
868 return -ENODEV;
869 }
870
871 index = et61x251_strtou8(buf, len, &count);
872 if (!count) {
873 up(&et61x251_sysfs_lock);
874 return -EINVAL;
875 }
876
877 cam->sysfs.i2c_reg = index;
878
879 DBG(2, "Moved sensor register index to 0x%02X", cam->sysfs.i2c_reg);
880 DBG(3, "Written bytes: %zd", count);
881
882 up(&et61x251_sysfs_lock);
883
884 return count;
885}
886
887
888static ssize_t et61x251_show_i2c_val(struct class_device* cd, char* buf)
889{
890 struct et61x251_device* cam;
891 ssize_t count;
892 int val;
893
894 if (down_interruptible(&et61x251_sysfs_lock))
895 return -ERESTARTSYS;
896
897 cam = video_get_drvdata(to_video_device(cd));
898 if (!cam) {
899 up(&et61x251_sysfs_lock);
900 return -ENODEV;
901 }
902
903 if (!(cam->sensor->sysfs_ops & ET61X251_I2C_READ)) {
904 up(&et61x251_sysfs_lock);
905 return -ENOSYS;
906 }
907
908 if ((val = et61x251_i2c_read(cam, cam->sysfs.i2c_reg)) < 0) {
909 up(&et61x251_sysfs_lock);
910 return -EIO;
911 }
912
913 count = sprintf(buf, "%d\n", val);
914
915 DBG(3, "Read bytes: %zd", count);
916
917 up(&et61x251_sysfs_lock);
918
919 return count;
920}
921
922
923static ssize_t
924et61x251_store_i2c_val(struct class_device* cd, const char* buf, size_t len)
925{
926 struct et61x251_device* cam;
927 u8 value;
928 ssize_t count;
929 int err;
930
931 if (down_interruptible(&et61x251_sysfs_lock))
932 return -ERESTARTSYS;
933
934 cam = video_get_drvdata(to_video_device(cd));
935 if (!cam) {
936 up(&et61x251_sysfs_lock);
937 return -ENODEV;
938 }
939
940 if (!(cam->sensor->sysfs_ops & ET61X251_I2C_READ)) {
941 up(&et61x251_sysfs_lock);
942 return -ENOSYS;
943 }
944
945 value = et61x251_strtou8(buf, len, &count);
946 if (!count) {
947 up(&et61x251_sysfs_lock);
948 return -EINVAL;
949 }
950
951 err = et61x251_i2c_write(cam, cam->sysfs.i2c_reg, value);
952 if (err) {
953 up(&et61x251_sysfs_lock);
954 return -EIO;
955 }
956
957 DBG(2, "Written sensor reg. 0x%02X, val. 0x%02X",
958 cam->sysfs.i2c_reg, value);
959 DBG(3, "Written bytes: %zd", count);
960
961 up(&et61x251_sysfs_lock);
962
963 return count;
964}
965
966
967static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR,
968 et61x251_show_reg, et61x251_store_reg);
969static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
970 et61x251_show_val, et61x251_store_val);
971static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR,
972 et61x251_show_i2c_reg, et61x251_store_i2c_reg);
973static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
974 et61x251_show_i2c_val, et61x251_store_i2c_val);
975
976
977static void et61x251_create_sysfs(struct et61x251_device* cam)
978{
979 struct video_device *v4ldev = cam->v4ldev;
980
981 video_device_create_file(v4ldev, &class_device_attr_reg);
982 video_device_create_file(v4ldev, &class_device_attr_val);
983 if (cam->sensor && cam->sensor->sysfs_ops) {
984 video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
985 video_device_create_file(v4ldev, &class_device_attr_i2c_val);
986 }
987}
988#endif /* CONFIG_VIDEO_ADV_DEBUG */
989
990/*****************************************************************************/
991
992static int
993et61x251_set_pix_format(struct et61x251_device* cam,
994 struct v4l2_pix_format* pix)
995{
996 int r, err = 0;
997
998 if ((r = et61x251_read_reg(cam, 0x12)) < 0)
999 err += r;
1000 if (pix->pixelformat == V4L2_PIX_FMT_ET61X251)
1001 err += et61x251_write_reg(cam, r & 0xfd, 0x12);
1002 else
1003 err += et61x251_write_reg(cam, r | 0x02, 0x12);
1004
1005 return err ? -EIO : 0;
1006}
1007
1008
1009static int
1010et61x251_set_compression(struct et61x251_device* cam,
1011 struct v4l2_jpegcompression* compression)
1012{
1013 int r, err = 0;
1014
1015 if ((r = et61x251_read_reg(cam, 0x12)) < 0)
1016 err += r;
1017 if (compression->quality == 0)
1018 err += et61x251_write_reg(cam, r & 0xfb, 0x12);
1019 else
1020 err += et61x251_write_reg(cam, r | 0x04, 0x12);
1021
1022 return err ? -EIO : 0;
1023}
1024
1025
1026static int et61x251_set_scale(struct et61x251_device* cam, u8 scale)
1027{
1028 int r = 0, err = 0;
1029
1030 r = et61x251_read_reg(cam, 0x12);
1031 if (r < 0)
1032 err += r;
1033
1034 if (scale == 1)
1035 err += et61x251_write_reg(cam, r & ~0x01, 0x12);
1036 else if (scale == 2)
1037 err += et61x251_write_reg(cam, r | 0x01, 0x12);
1038
1039 if (err)
1040 return -EIO;
1041
1042 PDBGG("Scaling factor: %u", scale);
1043
1044 return 0;
1045}
1046
1047
1048static int
1049et61x251_set_crop(struct et61x251_device* cam, struct v4l2_rect* rect)
1050{
1051 struct et61x251_sensor* s = cam->sensor;
1052 u16 fmw_sx = (u16)(rect->left - s->cropcap.bounds.left +
1053 s->active_pixel.left),
1054 fmw_sy = (u16)(rect->top - s->cropcap.bounds.top +
1055 s->active_pixel.top),
1056 fmw_length = (u16)(rect->width),
1057 fmw_height = (u16)(rect->height);
1058 int err = 0;
1059
1060 err += et61x251_write_reg(cam, fmw_sx & 0xff, 0x69);
1061 err += et61x251_write_reg(cam, fmw_sy & 0xff, 0x6a);
1062 err += et61x251_write_reg(cam, fmw_length & 0xff, 0x6b);
1063 err += et61x251_write_reg(cam, fmw_height & 0xff, 0x6c);
1064 err += et61x251_write_reg(cam, (fmw_sx >> 8) | ((fmw_sy & 0x300) >> 6)
1065 | ((fmw_length & 0x300) >> 4)
1066 | ((fmw_height & 0x300) >> 2), 0x6d);
1067 if (err)
1068 return -EIO;
1069
1070 PDBGG("fmw_sx, fmw_sy, fmw_length, fmw_height: %u %u %u %u",
1071 fmw_sx, fmw_sy, fmw_length, fmw_height);
1072
1073 return 0;
1074}
1075
1076
1077static int et61x251_init(struct et61x251_device* cam)
1078{
1079 struct et61x251_sensor* s = cam->sensor;
1080 struct v4l2_control ctrl;
1081 struct v4l2_queryctrl *qctrl;
1082 struct v4l2_rect* rect;
1083 u8 i = 0;
1084 int err = 0;
1085
1086 if (!(cam->state & DEV_INITIALIZED)) {
1087 init_waitqueue_head(&cam->open);
1088 qctrl = s->qctrl;
1089 rect = &(s->cropcap.defrect);
1090 cam->compression.quality = ET61X251_COMPRESSION_QUALITY;
1091 } else { /* use current values */
1092 qctrl = s->_qctrl;
1093 rect = &(s->_rect);
1094 }
1095
1096 err += et61x251_set_scale(cam, rect->width / s->pix_format.width);
1097 err += et61x251_set_crop(cam, rect);
1098 if (err)
1099 return err;
1100
1101 if (s->init) {
1102 err = s->init(cam);
1103 if (err) {
1104 DBG(3, "Sensor initialization failed");
1105 return err;
1106 }
1107 }
1108
1109 err += et61x251_set_compression(cam, &cam->compression);
1110 err += et61x251_set_pix_format(cam, &s->pix_format);
1111 if (s->set_pix_format)
1112 err += s->set_pix_format(cam, &s->pix_format);
1113 if (err)
1114 return err;
1115
1116 if (s->pix_format.pixelformat == V4L2_PIX_FMT_ET61X251)
1117 DBG(3, "Compressed video format is active, quality %d",
1118 cam->compression.quality);
1119 else
1120 DBG(3, "Uncompressed video format is active");
1121
1122 if (s->set_crop)
1123 if ((err = s->set_crop(cam, rect))) {
1124 DBG(3, "set_crop() failed");
1125 return err;
1126 }
1127
1128 if (s->set_ctrl) {
1129 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1130 if (s->qctrl[i].id != 0 &&
1131 !(s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED)) {
1132 ctrl.id = s->qctrl[i].id;
1133 ctrl.value = qctrl[i].default_value;
1134 err = s->set_ctrl(cam, &ctrl);
1135 if (err) {
1136 DBG(3, "Set %s control failed",
1137 s->qctrl[i].name);
1138 return err;
1139 }
1140 DBG(3, "Image sensor supports '%s' control",
1141 s->qctrl[i].name);
1142 }
1143 }
1144
1145 if (!(cam->state & DEV_INITIALIZED)) {
1146 init_MUTEX(&cam->fileop_sem);
1147 spin_lock_init(&cam->queue_lock);
1148 init_waitqueue_head(&cam->wait_frame);
1149 init_waitqueue_head(&cam->wait_stream);
1150 cam->nreadbuffers = 2;
1151 memcpy(s->_qctrl, s->qctrl, sizeof(s->qctrl));
1152 memcpy(&(s->_rect), &(s->cropcap.defrect),
1153 sizeof(struct v4l2_rect));
1154 cam->state |= DEV_INITIALIZED;
1155 }
1156
1157 DBG(2, "Initialization succeeded");
1158 return 0;
1159}
1160
1161
1162static void et61x251_release_resources(struct et61x251_device* cam)
1163{
1164 down(&et61x251_sysfs_lock);
1165
1166 DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->minor);
1167 video_set_drvdata(cam->v4ldev, NULL);
1168 video_unregister_device(cam->v4ldev);
1169
1170 up(&et61x251_sysfs_lock);
1171
1172 kfree(cam->control_buffer);
1173}
1174
1175/*****************************************************************************/
1176
1177static int et61x251_open(struct inode* inode, struct file* filp)
1178{
1179 struct et61x251_device* cam;
1180 int err = 0;
1181
1182 /*
1183 This is the only safe way to prevent race conditions with
1184 disconnect
1185 */
1186 if (!down_read_trylock(&et61x251_disconnect))
1187 return -ERESTARTSYS;
1188
1189 cam = video_get_drvdata(video_devdata(filp));
1190
1191 if (down_interruptible(&cam->dev_sem)) {
1192 up_read(&et61x251_disconnect);
1193 return -ERESTARTSYS;
1194 }
1195
1196 if (cam->users) {
1197 DBG(2, "Device /dev/video%d is busy...", cam->v4ldev->minor);
1198 if ((filp->f_flags & O_NONBLOCK) ||
1199 (filp->f_flags & O_NDELAY)) {
1200 err = -EWOULDBLOCK;
1201 goto out;
1202 }
1203 up(&cam->dev_sem);
1204 err = wait_event_interruptible_exclusive(cam->open,
1205 cam->state & DEV_DISCONNECTED
1206 || !cam->users);
1207 if (err) {
1208 up_read(&et61x251_disconnect);
1209 return err;
1210 }
1211 if (cam->state & DEV_DISCONNECTED) {
1212 up_read(&et61x251_disconnect);
1213 return -ENODEV;
1214 }
1215 down(&cam->dev_sem);
1216 }
1217
1218
1219 if (cam->state & DEV_MISCONFIGURED) {
1220 err = et61x251_init(cam);
1221 if (err) {
1222 DBG(1, "Initialization failed again. "
1223 "I will retry on next open().");
1224 goto out;
1225 }
1226 cam->state &= ~DEV_MISCONFIGURED;
1227 }
1228
1229 if ((err = et61x251_start_transfer(cam)))
1230 goto out;
1231
1232 filp->private_data = cam;
1233 cam->users++;
1234 cam->io = IO_NONE;
1235 cam->stream = STREAM_OFF;
1236 cam->nbuffers = 0;
1237 cam->frame_count = 0;
1238 et61x251_empty_framequeues(cam);
1239
1240 DBG(3, "Video device /dev/video%d is open", cam->v4ldev->minor);
1241
1242out:
1243 up(&cam->dev_sem);
1244 up_read(&et61x251_disconnect);
1245 return err;
1246}
1247
1248
1249static int et61x251_release(struct inode* inode, struct file* filp)
1250{
1251 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
1252
1253 down(&cam->dev_sem); /* prevent disconnect() to be called */
1254
1255 et61x251_stop_transfer(cam);
1256
1257 et61x251_release_buffers(cam);
1258
1259 if (cam->state & DEV_DISCONNECTED) {
1260 et61x251_release_resources(cam);
1261 up(&cam->dev_sem);
1262 kfree(cam);
1263 return 0;
1264 }
1265
1266 cam->users--;
1267 wake_up_interruptible_nr(&cam->open, 1);
1268
1269 DBG(3, "Video device /dev/video%d closed", cam->v4ldev->minor);
1270
1271 up(&cam->dev_sem);
1272
1273 return 0;
1274}
1275
1276
1277static ssize_t
1278et61x251_read(struct file* filp, char __user * buf,
1279 size_t count, loff_t* f_pos)
1280{
1281 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
1282 struct et61x251_frame_t* f, * i;
1283 unsigned long lock_flags;
1284 int err = 0;
1285
1286 if (down_interruptible(&cam->fileop_sem))
1287 return -ERESTARTSYS;
1288
1289 if (cam->state & DEV_DISCONNECTED) {
1290 DBG(1, "Device not present");
1291 up(&cam->fileop_sem);
1292 return -ENODEV;
1293 }
1294
1295 if (cam->state & DEV_MISCONFIGURED) {
1296 DBG(1, "The camera is misconfigured. Close and open it "
1297 "again.");
1298 up(&cam->fileop_sem);
1299 return -EIO;
1300 }
1301
1302 if (cam->io == IO_MMAP) {
1303 DBG(3, "Close and open the device again to choose the read "
1304 "method");
1305 up(&cam->fileop_sem);
1306 return -EINVAL;
1307 }
1308
1309 if (cam->io == IO_NONE) {
1310 if (!et61x251_request_buffers(cam, cam->nreadbuffers,
1311 IO_READ)) {
1312 DBG(1, "read() failed, not enough memory");
1313 up(&cam->fileop_sem);
1314 return -ENOMEM;
1315 }
1316 cam->io = IO_READ;
1317 cam->stream = STREAM_ON;
1318 }
1319
1320 if (list_empty(&cam->inqueue)) {
1321 if (!list_empty(&cam->outqueue))
1322 et61x251_empty_framequeues(cam);
1323 et61x251_queue_unusedframes(cam);
1324 }
1325
1326 if (!count) {
1327 up(&cam->fileop_sem);
1328 return 0;
1329 }
1330
1331 if (list_empty(&cam->outqueue)) {
1332 if (filp->f_flags & O_NONBLOCK) {
1333 up(&cam->fileop_sem);
1334 return -EAGAIN;
1335 }
1336 err = wait_event_interruptible
1337 ( cam->wait_frame,
1338 (!list_empty(&cam->outqueue)) ||
1339 (cam->state & DEV_DISCONNECTED) ||
1340 (cam->state & DEV_MISCONFIGURED) );
1341 if (err) {
1342 up(&cam->fileop_sem);
1343 return err;
1344 }
1345 if (cam->state & DEV_DISCONNECTED) {
1346 up(&cam->fileop_sem);
1347 return -ENODEV;
1348 }
1349 if (cam->state & DEV_MISCONFIGURED) {
1350 up(&cam->fileop_sem);
1351 return -EIO;
1352 }
1353 }
1354
1355 f = list_entry(cam->outqueue.prev, struct et61x251_frame_t, frame);
1356
1357 if (count > f->buf.bytesused)
1358 count = f->buf.bytesused;
1359
1360 if (copy_to_user(buf, f->bufmem, count)) {
1361 err = -EFAULT;
1362 goto exit;
1363 }
1364 *f_pos += count;
1365
1366exit:
1367 spin_lock_irqsave(&cam->queue_lock, lock_flags);
1368 list_for_each_entry(i, &cam->outqueue, frame)
1369 i->state = F_UNUSED;
1370 INIT_LIST_HEAD(&cam->outqueue);
1371 spin_unlock_irqrestore(&cam->queue_lock, lock_flags);
1372
1373 et61x251_queue_unusedframes(cam);
1374
1375 PDBGG("Frame #%lu, bytes read: %zu",
1376 (unsigned long)f->buf.index, count);
1377
1378 up(&cam->fileop_sem);
1379
1380 return err ? err : count;
1381}
1382
1383
1384static unsigned int et61x251_poll(struct file *filp, poll_table *wait)
1385{
1386 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
1387 struct et61x251_frame_t* f;
1388 unsigned long lock_flags;
1389 unsigned int mask = 0;
1390
1391 if (down_interruptible(&cam->fileop_sem))
1392 return POLLERR;
1393
1394 if (cam->state & DEV_DISCONNECTED) {
1395 DBG(1, "Device not present");
1396 goto error;
1397 }
1398
1399 if (cam->state & DEV_MISCONFIGURED) {
1400 DBG(1, "The camera is misconfigured. Close and open it "
1401 "again.");
1402 goto error;
1403 }
1404
1405 if (cam->io == IO_NONE) {
1406 if (!et61x251_request_buffers(cam, cam->nreadbuffers,
1407 IO_READ)) {
1408 DBG(1, "poll() failed, not enough memory");
1409 goto error;
1410 }
1411 cam->io = IO_READ;
1412 cam->stream = STREAM_ON;
1413 }
1414
1415 if (cam->io == IO_READ) {
1416 spin_lock_irqsave(&cam->queue_lock, lock_flags);
1417 list_for_each_entry(f, &cam->outqueue, frame)
1418 f->state = F_UNUSED;
1419 INIT_LIST_HEAD(&cam->outqueue);
1420 spin_unlock_irqrestore(&cam->queue_lock, lock_flags);
1421 et61x251_queue_unusedframes(cam);
1422 }
1423
1424 poll_wait(filp, &cam->wait_frame, wait);
1425
1426 if (!list_empty(&cam->outqueue))
1427 mask |= POLLIN | POLLRDNORM;
1428
1429 up(&cam->fileop_sem);
1430
1431 return mask;
1432
1433error:
1434 up(&cam->fileop_sem);
1435 return POLLERR;
1436}
1437
1438
1439static void et61x251_vm_open(struct vm_area_struct* vma)
1440{
1441 struct et61x251_frame_t* f = vma->vm_private_data;
1442 f->vma_use_count++;
1443}
1444
1445
1446static void et61x251_vm_close(struct vm_area_struct* vma)
1447{
1448 /* NOTE: buffers are not freed here */
1449 struct et61x251_frame_t* f = vma->vm_private_data;
1450 f->vma_use_count--;
1451}
1452
1453
1454static struct vm_operations_struct et61x251_vm_ops = {
1455 .open = et61x251_vm_open,
1456 .close = et61x251_vm_close,
1457};
1458
1459
1460static int et61x251_mmap(struct file* filp, struct vm_area_struct *vma)
1461{
1462 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
1463 unsigned long size = vma->vm_end - vma->vm_start,
1464 start = vma->vm_start;
1465 void *pos;
1466 u32 i;
1467
1468 if (down_interruptible(&cam->fileop_sem))
1469 return -ERESTARTSYS;
1470
1471 if (cam->state & DEV_DISCONNECTED) {
1472 DBG(1, "Device not present");
1473 up(&cam->fileop_sem);
1474 return -ENODEV;
1475 }
1476
1477 if (cam->state & DEV_MISCONFIGURED) {
1478 DBG(1, "The camera is misconfigured. Close and open it "
1479 "again.");
1480 up(&cam->fileop_sem);
1481 return -EIO;
1482 }
1483
1484 if (cam->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) ||
1485 size != PAGE_ALIGN(cam->frame[0].buf.length)) {
1486 up(&cam->fileop_sem);
1487 return -EINVAL;
1488 }
1489
1490 for (i = 0; i < cam->nbuffers; i++) {
1491 if ((cam->frame[i].buf.m.offset>>PAGE_SHIFT) == vma->vm_pgoff)
1492 break;
1493 }
1494 if (i == cam->nbuffers) {
1495 up(&cam->fileop_sem);
1496 return -EINVAL;
1497 }
1498
1499 vma->vm_flags |= VM_IO;
1500 vma->vm_flags |= VM_RESERVED;
1501
1502 pos = cam->frame[i].bufmem;
1503 while (size > 0) { /* size is page-aligned */
1504 if (vm_insert_page(vma, start, vmalloc_to_page(pos))) {
1505 up(&cam->fileop_sem);
1506 return -EAGAIN;
1507 }
1508 start += PAGE_SIZE;
1509 pos += PAGE_SIZE;
1510 size -= PAGE_SIZE;
1511 }
1512
1513 vma->vm_ops = &et61x251_vm_ops;
1514 vma->vm_private_data = &cam->frame[i];
1515
1516 et61x251_vm_open(vma);
1517
1518 up(&cam->fileop_sem);
1519
1520 return 0;
1521}
1522
1523/*****************************************************************************/
1524
1525static int
1526et61x251_vidioc_querycap(struct et61x251_device* cam, void __user * arg)
1527{
1528 struct v4l2_capability cap = {
1529 .driver = "et61x251",
1530 .version = ET61X251_MODULE_VERSION_CODE,
1531 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1532 V4L2_CAP_STREAMING,
1533 };
1534
1535 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
1536 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
1537 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
1538 sizeof(cap.bus_info));
1539
1540 if (copy_to_user(arg, &cap, sizeof(cap)))
1541 return -EFAULT;
1542
1543 return 0;
1544}
1545
1546
1547static int
1548et61x251_vidioc_enuminput(struct et61x251_device* cam, void __user * arg)
1549{
1550 struct v4l2_input i;
1551
1552 if (copy_from_user(&i, arg, sizeof(i)))
1553 return -EFAULT;
1554
1555 if (i.index)
1556 return -EINVAL;
1557
1558 memset(&i, 0, sizeof(i));
1559 strcpy(i.name, "Camera");
1560
1561 if (copy_to_user(arg, &i, sizeof(i)))
1562 return -EFAULT;
1563
1564 return 0;
1565}
1566
1567
1568static int
1569et61x251_vidioc_gs_input(struct et61x251_device* cam, void __user * arg)
1570{
1571 int index;
1572
1573 if (copy_from_user(&index, arg, sizeof(index)))
1574 return -EFAULT;
1575
1576 if (index != 0)
1577 return -EINVAL;
1578
1579 return 0;
1580}
1581
1582
1583static int
1584et61x251_vidioc_query_ctrl(struct et61x251_device* cam, void __user * arg)
1585{
1586 struct et61x251_sensor* s = cam->sensor;
1587 struct v4l2_queryctrl qc;
1588 u8 i;
1589
1590 if (copy_from_user(&qc, arg, sizeof(qc)))
1591 return -EFAULT;
1592
1593 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1594 if (qc.id && qc.id == s->qctrl[i].id) {
1595 memcpy(&qc, &(s->qctrl[i]), sizeof(qc));
1596 if (copy_to_user(arg, &qc, sizeof(qc)))
1597 return -EFAULT;
1598 return 0;
1599 }
1600
1601 return -EINVAL;
1602}
1603
1604
1605static int
1606et61x251_vidioc_g_ctrl(struct et61x251_device* cam, void __user * arg)
1607{
1608 struct et61x251_sensor* s = cam->sensor;
1609 struct v4l2_control ctrl;
1610 int err = 0;
1611 u8 i;
1612
1613 if (!s->get_ctrl && !s->set_ctrl)
1614 return -EINVAL;
1615
1616 if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
1617 return -EFAULT;
1618
1619 if (!s->get_ctrl) {
1620 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1621 if (ctrl.id == s->qctrl[i].id) {
1622 ctrl.value = s->_qctrl[i].default_value;
1623 goto exit;
1624 }
1625 return -EINVAL;
1626 } else
1627 err = s->get_ctrl(cam, &ctrl);
1628
1629exit:
1630 if (copy_to_user(arg, &ctrl, sizeof(ctrl)))
1631 return -EFAULT;
1632
1633 return err;
1634}
1635
1636
1637static int
1638et61x251_vidioc_s_ctrl(struct et61x251_device* cam, void __user * arg)
1639{
1640 struct et61x251_sensor* s = cam->sensor;
1641 struct v4l2_control ctrl;
1642 u8 i;
1643 int err = 0;
1644
1645 if (!s->set_ctrl)
1646 return -EINVAL;
1647
1648 if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
1649 return -EFAULT;
1650
1651 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1652 if (ctrl.id == s->qctrl[i].id) {
1653 if (ctrl.value < s->qctrl[i].minimum ||
1654 ctrl.value > s->qctrl[i].maximum)
1655 return -ERANGE;
1656 ctrl.value -= ctrl.value % s->qctrl[i].step;
1657 break;
1658 }
1659
1660 if ((err = s->set_ctrl(cam, &ctrl)))
1661 return err;
1662
1663 s->_qctrl[i].default_value = ctrl.value;
1664
1665 return 0;
1666}
1667
1668
1669static int
1670et61x251_vidioc_cropcap(struct et61x251_device* cam, void __user * arg)
1671{
1672 struct v4l2_cropcap* cc = &(cam->sensor->cropcap);
1673
1674 cc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1675 cc->pixelaspect.numerator = 1;
1676 cc->pixelaspect.denominator = 1;
1677
1678 if (copy_to_user(arg, cc, sizeof(*cc)))
1679 return -EFAULT;
1680
1681 return 0;
1682}
1683
1684
1685static int
1686et61x251_vidioc_g_crop(struct et61x251_device* cam, void __user * arg)
1687{
1688 struct et61x251_sensor* s = cam->sensor;
1689 struct v4l2_crop crop = {
1690 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
1691 };
1692
1693 memcpy(&(crop.c), &(s->_rect), sizeof(struct v4l2_rect));
1694
1695 if (copy_to_user(arg, &crop, sizeof(crop)))
1696 return -EFAULT;
1697
1698 return 0;
1699}
1700
1701
1702static int
1703et61x251_vidioc_s_crop(struct et61x251_device* cam, void __user * arg)
1704{
1705 struct et61x251_sensor* s = cam->sensor;
1706 struct v4l2_crop crop;
1707 struct v4l2_rect* rect;
1708 struct v4l2_rect* bounds = &(s->cropcap.bounds);
1709 struct v4l2_pix_format* pix_format = &(s->pix_format);
1710 u8 scale;
1711 const enum et61x251_stream_state stream = cam->stream;
1712 const u32 nbuffers = cam->nbuffers;
1713 u32 i;
1714 int err = 0;
1715
1716 if (copy_from_user(&crop, arg, sizeof(crop)))
1717 return -EFAULT;
1718
1719 rect = &(crop.c);
1720
1721 if (crop.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1722 return -EINVAL;
1723
1724 if (cam->module_param.force_munmap)
1725 for (i = 0; i < cam->nbuffers; i++)
1726 if (cam->frame[i].vma_use_count) {
1727 DBG(3, "VIDIOC_S_CROP failed. "
1728 "Unmap the buffers first.");
1729 return -EINVAL;
1730 }
1731
1732 /* Preserve R,G or B origin */
1733 rect->left = (s->_rect.left & 1L) ? rect->left | 1L : rect->left & ~1L;
1734 rect->top = (s->_rect.top & 1L) ? rect->top | 1L : rect->top & ~1L;
1735
1736 if (rect->width < 4)
1737 rect->width = 4;
1738 if (rect->height < 4)
1739 rect->height = 4;
1740 if (rect->width > bounds->width)
1741 rect->width = bounds->width;
1742 if (rect->height > bounds->height)
1743 rect->height = bounds->height;
1744 if (rect->left < bounds->left)
1745 rect->left = bounds->left;
1746 if (rect->top < bounds->top)
1747 rect->top = bounds->top;
1748 if (rect->left + rect->width > bounds->left + bounds->width)
1749 rect->left = bounds->left+bounds->width - rect->width;
1750 if (rect->top + rect->height > bounds->top + bounds->height)
1751 rect->top = bounds->top+bounds->height - rect->height;
1752
1753 rect->width &= ~3L;
1754 rect->height &= ~3L;
1755
1756 if (ET61X251_PRESERVE_IMGSCALE) {
1757 /* Calculate the actual scaling factor */
1758 u32 a, b;
1759 a = rect->width * rect->height;
1760 b = pix_format->width * pix_format->height;
1761 scale = b ? (u8)((a / b) < 4 ? 1 : 2) : 1;
1762 } else
1763 scale = 1;
1764
1765 if (cam->stream == STREAM_ON)
1766 if ((err = et61x251_stream_interrupt(cam)))
1767 return err;
1768
1769 if (copy_to_user(arg, &crop, sizeof(crop))) {
1770 cam->stream = stream;
1771 return -EFAULT;
1772 }
1773
1774 if (cam->module_param.force_munmap || cam->io == IO_READ)
1775 et61x251_release_buffers(cam);
1776
1777 err = et61x251_set_crop(cam, rect);
1778 if (s->set_crop)
1779 err += s->set_crop(cam, rect);
1780 err += et61x251_set_scale(cam, scale);
1781
1782 if (err) { /* atomic, no rollback in ioctl() */
1783 cam->state |= DEV_MISCONFIGURED;
1784 DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To "
1785 "use the camera, close and open /dev/video%d again.",
1786 cam->v4ldev->minor);
1787 return -EIO;
1788 }
1789
1790 s->pix_format.width = rect->width/scale;
1791 s->pix_format.height = rect->height/scale;
1792 memcpy(&(s->_rect), rect, sizeof(*rect));
1793
1794 if ((cam->module_param.force_munmap || cam->io == IO_READ) &&
1795 nbuffers != et61x251_request_buffers(cam, nbuffers, cam->io)) {
1796 cam->state |= DEV_MISCONFIGURED;
1797 DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To "
1798 "use the camera, close and open /dev/video%d again.",
1799 cam->v4ldev->minor);
1800 return -ENOMEM;
1801 }
1802
1803 if (cam->io == IO_READ)
1804 et61x251_empty_framequeues(cam);
1805 else if (cam->module_param.force_munmap)
1806 et61x251_requeue_outqueue(cam);
1807
1808 cam->stream = stream;
1809
1810 return 0;
1811}
1812
1813
1814static int
1815et61x251_vidioc_enum_fmt(struct et61x251_device* cam, void __user * arg)
1816{
1817 struct v4l2_fmtdesc fmtd;
1818
1819 if (copy_from_user(&fmtd, arg, sizeof(fmtd)))
1820 return -EFAULT;
1821
1822 if (fmtd.index == 0) {
1823 strcpy(fmtd.description, "bayer rgb");
1824 fmtd.pixelformat = V4L2_PIX_FMT_SBGGR8;
1825 } else if (fmtd.index == 1) {
1826 strcpy(fmtd.description, "compressed");
1827 fmtd.pixelformat = V4L2_PIX_FMT_ET61X251;
1828 fmtd.flags = V4L2_FMT_FLAG_COMPRESSED;
1829 } else
1830 return -EINVAL;
1831
1832 fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1833 memset(&fmtd.reserved, 0, sizeof(fmtd.reserved));
1834
1835 if (copy_to_user(arg, &fmtd, sizeof(fmtd)))
1836 return -EFAULT;
1837
1838 return 0;
1839}
1840
1841
1842static int
1843et61x251_vidioc_g_fmt(struct et61x251_device* cam, void __user * arg)
1844{
1845 struct v4l2_format format;
1846 struct v4l2_pix_format* pfmt = &(cam->sensor->pix_format);
1847
1848 if (copy_from_user(&format, arg, sizeof(format)))
1849 return -EFAULT;
1850
1851 if (format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1852 return -EINVAL;
1853
1854 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_ET61X251)
1855 ? 0 : (pfmt->width * pfmt->priv) / 8;
1856 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
1857 pfmt->field = V4L2_FIELD_NONE;
1858 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
1859
1860 if (copy_to_user(arg, &format, sizeof(format)))
1861 return -EFAULT;
1862
1863 return 0;
1864}
1865
1866
1867static int
1868et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
1869 void __user * arg)
1870{
1871 struct et61x251_sensor* s = cam->sensor;
1872 struct v4l2_format format;
1873 struct v4l2_pix_format* pix;
1874 struct v4l2_pix_format* pfmt = &(s->pix_format);
1875 struct v4l2_rect* bounds = &(s->cropcap.bounds);
1876 struct v4l2_rect rect;
1877 u8 scale;
1878 const enum et61x251_stream_state stream = cam->stream;
1879 const u32 nbuffers = cam->nbuffers;
1880 u32 i;
1881 int err = 0;
1882
1883 if (copy_from_user(&format, arg, sizeof(format)))
1884 return -EFAULT;
1885
1886 pix = &(format.fmt.pix);
1887
1888 if (format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1889 return -EINVAL;
1890
1891 memcpy(&rect, &(s->_rect), sizeof(rect));
1892
1893 { /* calculate the actual scaling factor */
1894 u32 a, b;
1895 a = rect.width * rect.height;
1896 b = pix->width * pix->height;
1897 scale = b ? (u8)((a / b) < 4 ? 1 : 2) : 1;
1898 }
1899
1900 rect.width = scale * pix->width;
1901 rect.height = scale * pix->height;
1902
1903 if (rect.width < 4)
1904 rect.width = 4;
1905 if (rect.height < 4)
1906 rect.height = 4;
1907 if (rect.width > bounds->left + bounds->width - rect.left)
1908 rect.width = bounds->left + bounds->width - rect.left;
1909 if (rect.height > bounds->top + bounds->height - rect.top)
1910 rect.height = bounds->top + bounds->height - rect.top;
1911
1912 rect.width &= ~3L;
1913 rect.height &= ~3L;
1914
1915 { /* adjust the scaling factor */
1916 u32 a, b;
1917 a = rect.width * rect.height;
1918 b = pix->width * pix->height;
1919 scale = b ? (u8)((a / b) < 4 ? 1 : 2) : 1;
1920 }
1921
1922 pix->width = rect.width / scale;
1923 pix->height = rect.height / scale;
1924
1925 if (pix->pixelformat != V4L2_PIX_FMT_ET61X251 &&
1926 pix->pixelformat != V4L2_PIX_FMT_SBGGR8)
1927 pix->pixelformat = pfmt->pixelformat;
1928 pix->priv = pfmt->priv; /* bpp */
1929 pix->colorspace = pfmt->colorspace;
1930 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_ET61X251)
1931 ? 0 : (pix->width * pix->priv) / 8;
1932 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
1933 pix->field = V4L2_FIELD_NONE;
1934
1935 if (cmd == VIDIOC_TRY_FMT) {
1936 if (copy_to_user(arg, &format, sizeof(format)))
1937 return -EFAULT;
1938 return 0;
1939 }
1940
1941 if (cam->module_param.force_munmap)
1942 for (i = 0; i < cam->nbuffers; i++)
1943 if (cam->frame[i].vma_use_count) {
1944 DBG(3, "VIDIOC_S_FMT failed. "
1945 "Unmap the buffers first.");
1946 return -EINVAL;
1947 }
1948
1949 if (cam->stream == STREAM_ON)
1950 if ((err = et61x251_stream_interrupt(cam)))
1951 return err;
1952
1953 if (copy_to_user(arg, &format, sizeof(format))) {
1954 cam->stream = stream;
1955 return -EFAULT;
1956 }
1957
1958 if (cam->module_param.force_munmap || cam->io == IO_READ)
1959 et61x251_release_buffers(cam);
1960
1961 err += et61x251_set_pix_format(cam, pix);
1962 err += et61x251_set_crop(cam, &rect);
1963 if (s->set_pix_format)
1964 err += s->set_pix_format(cam, pix);
1965 if (s->set_crop)
1966 err += s->set_crop(cam, &rect);
1967 err += et61x251_set_scale(cam, scale);
1968
1969 if (err) { /* atomic, no rollback in ioctl() */
1970 cam->state |= DEV_MISCONFIGURED;
1971 DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To "
1972 "use the camera, close and open /dev/video%d again.",
1973 cam->v4ldev->minor);
1974 return -EIO;
1975 }
1976
1977 memcpy(pfmt, pix, sizeof(*pix));
1978 memcpy(&(s->_rect), &rect, sizeof(rect));
1979
1980 if ((cam->module_param.force_munmap || cam->io == IO_READ) &&
1981 nbuffers != et61x251_request_buffers(cam, nbuffers, cam->io)) {
1982 cam->state |= DEV_MISCONFIGURED;
1983 DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To "
1984 "use the camera, close and open /dev/video%d again.",
1985 cam->v4ldev->minor);
1986 return -ENOMEM;
1987 }
1988
1989 if (cam->io == IO_READ)
1990 et61x251_empty_framequeues(cam);
1991 else if (cam->module_param.force_munmap)
1992 et61x251_requeue_outqueue(cam);
1993
1994 cam->stream = stream;
1995
1996 return 0;
1997}
1998
1999
2000static int
2001et61x251_vidioc_g_jpegcomp(struct et61x251_device* cam, void __user * arg)
2002{
2003 if (copy_to_user(arg, &cam->compression,
2004 sizeof(cam->compression)))
2005 return -EFAULT;
2006
2007 return 0;
2008}
2009
2010
2011static int
2012et61x251_vidioc_s_jpegcomp(struct et61x251_device* cam, void __user * arg)
2013{
2014 struct v4l2_jpegcompression jc;
2015 const enum et61x251_stream_state stream = cam->stream;
2016 int err = 0;
2017
2018 if (copy_from_user(&jc, arg, sizeof(jc)))
2019 return -EFAULT;
2020
2021 if (jc.quality != 0 && jc.quality != 1)
2022 return -EINVAL;
2023
2024 if (cam->stream == STREAM_ON)
2025 if ((err = et61x251_stream_interrupt(cam)))
2026 return err;
2027
2028 err += et61x251_set_compression(cam, &jc);
2029 if (err) { /* atomic, no rollback in ioctl() */
2030 cam->state |= DEV_MISCONFIGURED;
2031 DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware "
2032 "problems. To use the camera, close and open "
2033 "/dev/video%d again.", cam->v4ldev->minor);
2034 return -EIO;
2035 }
2036
2037 cam->compression.quality = jc.quality;
2038
2039 cam->stream = stream;
2040
2041 return 0;
2042}
2043
2044
2045static int
2046et61x251_vidioc_reqbufs(struct et61x251_device* cam, void __user * arg)
2047{
2048 struct v4l2_requestbuffers rb;
2049 u32 i;
2050 int err;
2051
2052 if (copy_from_user(&rb, arg, sizeof(rb)))
2053 return -EFAULT;
2054
2055 if (rb.type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
2056 rb.memory != V4L2_MEMORY_MMAP)
2057 return -EINVAL;
2058
2059 if (cam->io == IO_READ) {
2060 DBG(3, "Close and open the device again to choose the mmap "
2061 "I/O method");
2062 return -EINVAL;
2063 }
2064
2065 for (i = 0; i < cam->nbuffers; i++)
2066 if (cam->frame[i].vma_use_count) {
2067 DBG(3, "VIDIOC_REQBUFS failed. "
2068 "Previous buffers are still mapped.");
2069 return -EINVAL;
2070 }
2071
2072 if (cam->stream == STREAM_ON)
2073 if ((err = et61x251_stream_interrupt(cam)))
2074 return err;
2075
2076 et61x251_empty_framequeues(cam);
2077
2078 et61x251_release_buffers(cam);
2079 if (rb.count)
2080 rb.count = et61x251_request_buffers(cam, rb.count, IO_MMAP);
2081
2082 if (copy_to_user(arg, &rb, sizeof(rb))) {
2083 et61x251_release_buffers(cam);
2084 cam->io = IO_NONE;
2085 return -EFAULT;
2086 }
2087
2088 cam->io = rb.count ? IO_MMAP : IO_NONE;
2089
2090 return 0;
2091}
2092
2093
2094static int
2095et61x251_vidioc_querybuf(struct et61x251_device* cam, void __user * arg)
2096{
2097 struct v4l2_buffer b;
2098
2099 if (copy_from_user(&b, arg, sizeof(b)))
2100 return -EFAULT;
2101
2102 if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
2103 b.index >= cam->nbuffers || cam->io != IO_MMAP)
2104 return -EINVAL;
2105
2106 memcpy(&b, &cam->frame[b.index].buf, sizeof(b));
2107
2108 if (cam->frame[b.index].vma_use_count)
2109 b.flags |= V4L2_BUF_FLAG_MAPPED;
2110
2111 if (cam->frame[b.index].state == F_DONE)
2112 b.flags |= V4L2_BUF_FLAG_DONE;
2113 else if (cam->frame[b.index].state != F_UNUSED)
2114 b.flags |= V4L2_BUF_FLAG_QUEUED;
2115
2116 if (copy_to_user(arg, &b, sizeof(b)))
2117 return -EFAULT;
2118
2119 return 0;
2120}
2121
2122
2123static int
2124et61x251_vidioc_qbuf(struct et61x251_device* cam, void __user * arg)
2125{
2126 struct v4l2_buffer b;
2127 unsigned long lock_flags;
2128
2129 if (copy_from_user(&b, arg, sizeof(b)))
2130 return -EFAULT;
2131
2132 if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
2133 b.index >= cam->nbuffers || cam->io != IO_MMAP)
2134 return -EINVAL;
2135
2136 if (cam->frame[b.index].state != F_UNUSED)
2137 return -EINVAL;
2138
2139 cam->frame[b.index].state = F_QUEUED;
2140
2141 spin_lock_irqsave(&cam->queue_lock, lock_flags);
2142 list_add_tail(&cam->frame[b.index].frame, &cam->inqueue);
2143 spin_unlock_irqrestore(&cam->queue_lock, lock_flags);
2144
2145 PDBGG("Frame #%lu queued", (unsigned long)b.index);
2146
2147 return 0;
2148}
2149
2150
2151static int
2152et61x251_vidioc_dqbuf(struct et61x251_device* cam, struct file* filp,
2153 void __user * arg)
2154{
2155 struct v4l2_buffer b;
2156 struct et61x251_frame_t *f;
2157 unsigned long lock_flags;
2158 int err = 0;
2159
2160 if (copy_from_user(&b, arg, sizeof(b)))
2161 return -EFAULT;
2162
2163 if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io!= IO_MMAP)
2164 return -EINVAL;
2165
2166 if (list_empty(&cam->outqueue)) {
2167 if (cam->stream == STREAM_OFF)
2168 return -EINVAL;
2169 if (filp->f_flags & O_NONBLOCK)
2170 return -EAGAIN;
2171 err = wait_event_interruptible
2172 ( cam->wait_frame,
2173 (!list_empty(&cam->outqueue)) ||
2174 (cam->state & DEV_DISCONNECTED) ||
2175 (cam->state & DEV_MISCONFIGURED) );
2176 if (err)
2177 return err;
2178 if (cam->state & DEV_DISCONNECTED)
2179 return -ENODEV;
2180 if (cam->state & DEV_MISCONFIGURED)
2181 return -EIO;
2182 }
2183
2184 spin_lock_irqsave(&cam->queue_lock, lock_flags);
2185 f = list_entry(cam->outqueue.next, struct et61x251_frame_t, frame);
2186 list_del(cam->outqueue.next);
2187 spin_unlock_irqrestore(&cam->queue_lock, lock_flags);
2188
2189 f->state = F_UNUSED;
2190
2191 memcpy(&b, &f->buf, sizeof(b));
2192 if (f->vma_use_count)
2193 b.flags |= V4L2_BUF_FLAG_MAPPED;
2194
2195 if (copy_to_user(arg, &b, sizeof(b)))
2196 return -EFAULT;
2197
2198 PDBGG("Frame #%lu dequeued", (unsigned long)f->buf.index);
2199
2200 return 0;
2201}
2202
2203
2204static int
2205et61x251_vidioc_streamon(struct et61x251_device* cam, void __user * arg)
2206{
2207 int type;
2208
2209 if (copy_from_user(&type, arg, sizeof(type)))
2210 return -EFAULT;
2211
2212 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP)
2213 return -EINVAL;
2214
2215 if (list_empty(&cam->inqueue))
2216 return -EINVAL;
2217
2218 cam->stream = STREAM_ON;
2219
2220 DBG(3, "Stream on");
2221
2222 return 0;
2223}
2224
2225
2226static int
2227et61x251_vidioc_streamoff(struct et61x251_device* cam, void __user * arg)
2228{
2229 int type, err;
2230
2231 if (copy_from_user(&type, arg, sizeof(type)))
2232 return -EFAULT;
2233
2234 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP)
2235 return -EINVAL;
2236
2237 if (cam->stream == STREAM_ON)
2238 if ((err = et61x251_stream_interrupt(cam)))
2239 return err;
2240
2241 et61x251_empty_framequeues(cam);
2242
2243 DBG(3, "Stream off");
2244
2245 return 0;
2246}
2247
2248
2249static int
2250et61x251_vidioc_g_parm(struct et61x251_device* cam, void __user * arg)
2251{
2252 struct v4l2_streamparm sp;
2253
2254 if (copy_from_user(&sp, arg, sizeof(sp)))
2255 return -EFAULT;
2256
2257 if (sp.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
2258 return -EINVAL;
2259
2260 sp.parm.capture.extendedmode = 0;
2261 sp.parm.capture.readbuffers = cam->nreadbuffers;
2262
2263 if (copy_to_user(arg, &sp, sizeof(sp)))
2264 return -EFAULT;
2265
2266 return 0;
2267}
2268
2269
2270static int
2271et61x251_vidioc_s_parm(struct et61x251_device* cam, void __user * arg)
2272{
2273 struct v4l2_streamparm sp;
2274
2275 if (copy_from_user(&sp, arg, sizeof(sp)))
2276 return -EFAULT;
2277
2278 if (sp.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
2279 return -EINVAL;
2280
2281 sp.parm.capture.extendedmode = 0;
2282
2283 if (sp.parm.capture.readbuffers == 0)
2284 sp.parm.capture.readbuffers = cam->nreadbuffers;
2285
2286 if (sp.parm.capture.readbuffers > ET61X251_MAX_FRAMES)
2287 sp.parm.capture.readbuffers = ET61X251_MAX_FRAMES;
2288
2289 if (copy_to_user(arg, &sp, sizeof(sp)))
2290 return -EFAULT;
2291
2292 cam->nreadbuffers = sp.parm.capture.readbuffers;
2293
2294 return 0;
2295}
2296
2297
2298static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp,
2299 unsigned int cmd, void __user * arg)
2300{
2301 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
2302
2303 switch (cmd) {
2304
2305 case VIDIOC_QUERYCAP:
2306 return et61x251_vidioc_querycap(cam, arg);
2307
2308 case VIDIOC_ENUMINPUT:
2309 return et61x251_vidioc_enuminput(cam, arg);
2310
2311 case VIDIOC_G_INPUT:
2312 case VIDIOC_S_INPUT:
2313 return et61x251_vidioc_gs_input(cam, arg);
2314
2315 case VIDIOC_QUERYCTRL:
2316 return et61x251_vidioc_query_ctrl(cam, arg);
2317
2318 case VIDIOC_G_CTRL:
2319 return et61x251_vidioc_g_ctrl(cam, arg);
2320
2321 case VIDIOC_S_CTRL_OLD:
2322 case VIDIOC_S_CTRL:
2323 return et61x251_vidioc_s_ctrl(cam, arg);
2324
2325 case VIDIOC_CROPCAP_OLD:
2326 case VIDIOC_CROPCAP:
2327 return et61x251_vidioc_cropcap(cam, arg);
2328
2329 case VIDIOC_G_CROP:
2330 return et61x251_vidioc_g_crop(cam, arg);
2331
2332 case VIDIOC_S_CROP:
2333 return et61x251_vidioc_s_crop(cam, arg);
2334
2335 case VIDIOC_ENUM_FMT:
2336 return et61x251_vidioc_enum_fmt(cam, arg);
2337
2338 case VIDIOC_G_FMT:
2339 return et61x251_vidioc_g_fmt(cam, arg);
2340
2341 case VIDIOC_TRY_FMT:
2342 case VIDIOC_S_FMT:
2343 return et61x251_vidioc_try_s_fmt(cam, cmd, arg);
2344
2345 case VIDIOC_G_JPEGCOMP:
2346 return et61x251_vidioc_g_jpegcomp(cam, arg);
2347
2348 case VIDIOC_S_JPEGCOMP:
2349 return et61x251_vidioc_s_jpegcomp(cam, arg);
2350
2351 case VIDIOC_REQBUFS:
2352 return et61x251_vidioc_reqbufs(cam, arg);
2353
2354 case VIDIOC_QUERYBUF:
2355 return et61x251_vidioc_querybuf(cam, arg);
2356
2357 case VIDIOC_QBUF:
2358 return et61x251_vidioc_qbuf(cam, arg);
2359
2360 case VIDIOC_DQBUF:
2361 return et61x251_vidioc_dqbuf(cam, filp, arg);
2362
2363 case VIDIOC_STREAMON:
2364 return et61x251_vidioc_streamon(cam, arg);
2365
2366 case VIDIOC_STREAMOFF:
2367 return et61x251_vidioc_streamoff(cam, arg);
2368
2369 case VIDIOC_G_PARM:
2370 return et61x251_vidioc_g_parm(cam, arg);
2371
2372 case VIDIOC_S_PARM_OLD:
2373 case VIDIOC_S_PARM:
2374 return et61x251_vidioc_s_parm(cam, arg);
2375
2376 case VIDIOC_G_STD:
2377 case VIDIOC_S_STD:
2378 case VIDIOC_QUERYSTD:
2379 case VIDIOC_ENUMSTD:
2380 case VIDIOC_QUERYMENU:
2381 return -EINVAL;
2382
2383 default:
2384 return -EINVAL;
2385
2386 }
2387}
2388
2389
2390static int et61x251_ioctl(struct inode* inode, struct file* filp,
2391 unsigned int cmd, unsigned long arg)
2392{
2393 struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
2394 int err = 0;
2395
2396 if (down_interruptible(&cam->fileop_sem))
2397 return -ERESTARTSYS;
2398
2399 if (cam->state & DEV_DISCONNECTED) {
2400 DBG(1, "Device not present");
2401 up(&cam->fileop_sem);
2402 return -ENODEV;
2403 }
2404
2405 if (cam->state & DEV_MISCONFIGURED) {
2406 DBG(1, "The camera is misconfigured. Close and open it "
2407 "again.");
2408 up(&cam->fileop_sem);
2409 return -EIO;
2410 }
2411
2412 V4LDBG(3, "et61x251", cmd);
2413
2414 err = et61x251_ioctl_v4l2(inode, filp, cmd, (void __user *)arg);
2415
2416 up(&cam->fileop_sem);
2417
2418 return err;
2419}
2420
2421
2422static struct file_operations et61x251_fops = {
2423 .owner = THIS_MODULE,
2424 .open = et61x251_open,
2425 .release = et61x251_release,
2426 .ioctl = et61x251_ioctl,
2427 .read = et61x251_read,
2428 .poll = et61x251_poll,
2429 .mmap = et61x251_mmap,
2430 .llseek = no_llseek,
2431};
2432
2433/*****************************************************************************/
2434
2435/* It exists a single interface only. We do not need to validate anything. */
2436static int
2437et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2438{
2439 struct usb_device *udev = interface_to_usbdev(intf);
2440 struct et61x251_device* cam;
2441 static unsigned int dev_nr = 0;
2442 unsigned int i;
2443 int err = 0;
2444
2445 if (!(cam = kzalloc(sizeof(struct et61x251_device), GFP_KERNEL)))
2446 return -ENOMEM;
2447
2448 cam->usbdev = udev;
2449
2450 if (!(cam->control_buffer = kzalloc(8, GFP_KERNEL))) {
2451 DBG(1, "kmalloc() failed");
2452 err = -ENOMEM;
2453 goto fail;
2454 }
2455
2456 if (!(cam->v4ldev = video_device_alloc())) {
2457 DBG(1, "video_device_alloc() failed");
2458 err = -ENOMEM;
2459 goto fail;
2460 }
2461
2462 init_MUTEX(&cam->dev_sem);
2463
2464 DBG(2, "ET61X[12]51 PC Camera Controller detected "
2465 "(vid/pid 0x%04X/0x%04X)",id->idVendor, id->idProduct);
2466
2467 for (i = 0; et61x251_sensor_table[i]; i++) {
2468 err = et61x251_sensor_table[i](cam);
2469 if (!err)
2470 break;
2471 }
2472
2473 if (!err && cam->sensor)
2474 DBG(2, "%s image sensor detected", cam->sensor->name);
2475 else {
2476 DBG(1, "No supported image sensor detected");
2477 err = -ENODEV;
2478 goto fail;
2479 }
2480
2481 if (et61x251_init(cam)) {
2482 DBG(1, "Initialization failed. I will retry on open().");
2483 cam->state |= DEV_MISCONFIGURED;
2484 }
2485
2486 strcpy(cam->v4ldev->name, "ET61X[12]51 PC Camera");
2487 cam->v4ldev->owner = THIS_MODULE;
2488 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
2489 cam->v4ldev->hardware = 0;
2490 cam->v4ldev->fops = &et61x251_fops;
2491 cam->v4ldev->minor = video_nr[dev_nr];
2492 cam->v4ldev->release = video_device_release;
2493 video_set_drvdata(cam->v4ldev, cam);
2494
2495 down(&cam->dev_sem);
2496
2497 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
2498 video_nr[dev_nr]);
2499 if (err) {
2500 DBG(1, "V4L2 device registration failed");
2501 if (err == -ENFILE && video_nr[dev_nr] == -1)
2502 DBG(1, "Free /dev/videoX node not found");
2503 video_nr[dev_nr] = -1;
2504 dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0;
2505 up(&cam->dev_sem);
2506 goto fail;
2507 }
2508
2509 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor);
2510
2511 cam->module_param.force_munmap = force_munmap[dev_nr];
2512
2513 dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0;
2514
2515#ifdef CONFIG_VIDEO_ADV_DEBUG
2516 et61x251_create_sysfs(cam);
2517 DBG(2, "Optional device control through 'sysfs' interface ready");
2518#endif
2519
2520 usb_set_intfdata(intf, cam);
2521
2522 up(&cam->dev_sem);
2523
2524 return 0;
2525
2526fail:
2527 if (cam) {
2528 kfree(cam->control_buffer);
2529 if (cam->v4ldev)
2530 video_device_release(cam->v4ldev);
2531 kfree(cam);
2532 }
2533 return err;
2534}
2535
2536
2537static void et61x251_usb_disconnect(struct usb_interface* intf)
2538{
2539 struct et61x251_device* cam = usb_get_intfdata(intf);
2540
2541 if (!cam)
2542 return;
2543
2544 down_write(&et61x251_disconnect);
2545
2546 down(&cam->dev_sem);
2547
2548 DBG(2, "Disconnecting %s...", cam->v4ldev->name);
2549
2550 wake_up_interruptible_all(&cam->open);
2551
2552 if (cam->users) {
2553 DBG(2, "Device /dev/video%d is open! Deregistration and "
2554 "memory deallocation are deferred on close.",
2555 cam->v4ldev->minor);
2556 cam->state |= DEV_MISCONFIGURED;
2557 et61x251_stop_transfer(cam);
2558 cam->state |= DEV_DISCONNECTED;
2559 wake_up_interruptible(&cam->wait_frame);
2560 wake_up_interruptible(&cam->wait_stream);
2561 } else {
2562 cam->state |= DEV_DISCONNECTED;
2563 et61x251_release_resources(cam);
2564 }
2565
2566 up(&cam->dev_sem);
2567
2568 if (!cam->users)
2569 kfree(cam);
2570
2571 up_write(&et61x251_disconnect);
2572}
2573
2574
2575static struct usb_driver et61x251_usb_driver = {
2576 .name = "et61x251",
2577 .id_table = et61x251_id_table,
2578 .probe = et61x251_usb_probe,
2579 .disconnect = et61x251_usb_disconnect,
2580};
2581
2582/*****************************************************************************/
2583
2584static int __init et61x251_module_init(void)
2585{
2586 int err = 0;
2587
2588 KDBG(2, ET61X251_MODULE_NAME " v" ET61X251_MODULE_VERSION);
2589 KDBG(3, ET61X251_MODULE_AUTHOR);
2590
2591 if ((err = usb_register(&et61x251_usb_driver)))
2592 KDBG(1, "usb_register() failed");
2593
2594 return err;
2595}
2596
2597
2598static void __exit et61x251_module_exit(void)
2599{
2600 usb_deregister(&et61x251_usb_driver);
2601}
2602
2603
2604module_init(et61x251_module_init);
2605module_exit(et61x251_module_exit);
diff --git a/drivers/usb/media/et61x251_sensor.h b/drivers/usb/media/et61x251_sensor.h
new file mode 100644
index 000000000000..b9df91062fc0
--- /dev/null
+++ b/drivers/usb/media/et61x251_sensor.h
@@ -0,0 +1,115 @@
1/***************************************************************************
2 * API for image sensors connected to ET61X[12]51 PC Camera Controllers *
3 * *
4 * Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License 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., 675 Mass Ave, Cambridge, MA 02139, USA. *
19 ***************************************************************************/
20
21#ifndef _ET61X251_SENSOR_H_
22#define _ET61X251_SENSOR_H_
23
24#include <linux/usb.h>
25#include <linux/videodev.h>
26#include <linux/device.h>
27#include <linux/stddef.h>
28#include <linux/errno.h>
29#include <asm/types.h>
30
31struct et61x251_device;
32struct et61x251_sensor;
33
34/*****************************************************************************/
35
36extern int et61x251_probe_tas5130d1b(struct et61x251_device* cam);
37
38#define ET61X251_SENSOR_TABLE \
39/* Weak detections must go at the end of the list */ \
40static int (*et61x251_sensor_table[])(struct et61x251_device*) = { \
41 &et61x251_probe_tas5130d1b, \
42 NULL, \
43};
44
45extern void
46et61x251_attach_sensor(struct et61x251_device* cam,
47 struct et61x251_sensor* sensor);
48
49/*****************************************************************************/
50
51extern int et61x251_write_reg(struct et61x251_device*, u8 value, u16 index);
52extern int et61x251_read_reg(struct et61x251_device*, u16 index);
53extern int et61x251_i2c_write(struct et61x251_device*, u8 address, u8 value);
54extern int et61x251_i2c_read(struct et61x251_device*, u8 address);
55extern int et61x251_i2c_try_write(struct et61x251_device*,
56 struct et61x251_sensor*, u8 address,
57 u8 value);
58extern int et61x251_i2c_try_read(struct et61x251_device*,
59 struct et61x251_sensor*, u8 address);
60extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1,
61 u8 data2, u8 data3, u8 data4, u8 data5,
62 u8 data6, u8 data7, u8 data8, u8 address);
63
64/*****************************************************************************/
65
66enum et61x251_i2c_sysfs_ops {
67 ET61X251_I2C_READ = 0x01,
68 ET61X251_I2C_WRITE = 0x02,
69};
70
71enum et61x251_i2c_interface {
72 ET61X251_I2C_2WIRES,
73 ET61X251_I2C_3WIRES,
74};
75
76/* Repeat start condition when RSTA is high */
77enum et61x251_i2c_rsta {
78 ET61X251_I2C_RSTA_STOP = 0x00, /* stop then start */
79 ET61X251_I2C_RSTA_REPEAT = 0x01, /* repeat start */
80};
81
82#define ET61X251_MAX_CTRLS V4L2_CID_LASTP1-V4L2_CID_BASE+10
83
84struct et61x251_sensor {
85 char name[32];
86
87 enum et61x251_i2c_sysfs_ops sysfs_ops;
88
89 enum et61x251_i2c_interface interface;
90 u8 i2c_slave_id;
91 enum et61x251_i2c_rsta rsta;
92 struct v4l2_rect active_pixel; /* left and top define FVSX and FVSY */
93
94 struct v4l2_queryctrl qctrl[ET61X251_MAX_CTRLS];
95 struct v4l2_cropcap cropcap;
96 struct v4l2_pix_format pix_format;
97
98 int (*init)(struct et61x251_device* cam);
99 int (*get_ctrl)(struct et61x251_device* cam,
100 struct v4l2_control* ctrl);
101 int (*set_ctrl)(struct et61x251_device* cam,
102 const struct v4l2_control* ctrl);
103 int (*set_crop)(struct et61x251_device* cam,
104 const struct v4l2_rect* rect);
105 int (*set_pix_format)(struct et61x251_device* cam,
106 const struct v4l2_pix_format* pix);
107
108 const struct usb_device* usbdev;
109
110 /* Private */
111 struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS];
112 struct v4l2_rect _rect;
113};
114
115#endif /* _ET61X251_SENSOR_H_ */
diff --git a/drivers/usb/media/et61x251_tas5130d1b.c b/drivers/usb/media/et61x251_tas5130d1b.c
new file mode 100644
index 000000000000..65f1ae9cf2b3
--- /dev/null
+++ b/drivers/usb/media/et61x251_tas5130d1b.c
@@ -0,0 +1,137 @@
1/***************************************************************************
2 * Plug-in for TAS5130D1B image sensor connected to the ET61X[12]51 *
3 * PC Camera Controllers *
4 * *
5 * Copyright (C) 2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
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 as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
20 ***************************************************************************/
21
22#include "et61x251_sensor.h"
23
24
25static int tas5130d1b_init(struct et61x251_device* cam)
26{
27 int err = 0;
28
29 err += et61x251_write_reg(cam, 0x14, 0x01);
30 err += et61x251_write_reg(cam, 0x1b, 0x02);
31 err += et61x251_write_reg(cam, 0x02, 0x12);
32 err += et61x251_write_reg(cam, 0x0e, 0x60);
33 err += et61x251_write_reg(cam, 0x80, 0x61);
34 err += et61x251_write_reg(cam, 0xf0, 0x62);
35 err += et61x251_write_reg(cam, 0x03, 0x63);
36 err += et61x251_write_reg(cam, 0x14, 0x64);
37 err += et61x251_write_reg(cam, 0xf4, 0x65);
38 err += et61x251_write_reg(cam, 0x01, 0x66);
39 err += et61x251_write_reg(cam, 0x05, 0x67);
40 err += et61x251_write_reg(cam, 0x8f, 0x68);
41 err += et61x251_write_reg(cam, 0x0f, 0x8d);
42 err += et61x251_write_reg(cam, 0x08, 0x8e);
43
44 return err;
45}
46
47
48static int tas5130d1b_set_ctrl(struct et61x251_device* cam,
49 const struct v4l2_control* ctrl)
50{
51 int err = 0;
52
53 switch (ctrl->id) {
54 case V4L2_CID_GAIN:
55 err += et61x251_i2c_raw_write(cam, 2, 0x20,
56 0xf6-ctrl->value, 0, 0, 0,
57 0, 0, 0, 0);
58 break;
59 case V4L2_CID_EXPOSURE:
60 err += et61x251_i2c_raw_write(cam, 2, 0x40,
61 0x47-ctrl->value, 0, 0, 0,
62 0, 0, 0, 0);
63 break;
64 default:
65 return -EINVAL;
66 }
67
68 return err ? -EIO : 0;
69}
70
71
72static struct et61x251_sensor tas5130d1b = {
73 .name = "TAS5130D1B",
74 .interface = ET61X251_I2C_3WIRES,
75 .rsta = ET61X251_I2C_RSTA_STOP,
76 .active_pixel = {
77 .left = 106,
78 .top = 13,
79 },
80 .init = &tas5130d1b_init,
81 .qctrl = {
82 {
83 .id = V4L2_CID_GAIN,
84 .type = V4L2_CTRL_TYPE_INTEGER,
85 .name = "global gain",
86 .minimum = 0x00,
87 .maximum = 0xf6,
88 .step = 0x02,
89 .default_value = 0x0d,
90 .flags = 0,
91 },
92 {
93 .id = V4L2_CID_EXPOSURE,
94 .type = V4L2_CTRL_TYPE_INTEGER,
95 .name = "exposure",
96 .minimum = 0x00,
97 .maximum = 0x47,
98 .step = 0x01,
99 .default_value = 0x23,
100 .flags = 0,
101 },
102 },
103 .set_ctrl = &tas5130d1b_set_ctrl,
104 .cropcap = {
105 .bounds = {
106 .left = 0,
107 .top = 0,
108 .width = 640,
109 .height = 480,
110 },
111 .defrect = {
112 .left = 0,
113 .top = 0,
114 .width = 640,
115 .height = 480,
116 },
117 },
118 .pix_format = {
119 .width = 640,
120 .height = 480,
121 .pixelformat = V4L2_PIX_FMT_SBGGR8,
122 .priv = 8,
123 },
124};
125
126
127int et61x251_probe_tas5130d1b(struct et61x251_device* cam)
128{
129 /* This sensor has no identifiers, so let's attach it anyway */
130 et61x251_attach_sensor(cam, &tas5130d1b);
131
132 /* Sensor detection is based on USB pid/vid */
133 if (le16_to_cpu(tas5130d1b.usbdev->descriptor.idProduct) != 0x6251)
134 return -ENODEV;
135
136 return 0;
137}
diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
index 8af665bbe330..51e9cc06f7e3 100644
--- a/drivers/usb/media/ov511.c
+++ b/drivers/usb/media/ov511.c
@@ -204,22 +204,10 @@ MODULE_LICENSE("GPL");
204 204
205static struct usb_driver ov511_driver; 205static struct usb_driver ov511_driver;
206 206
207static struct ov51x_decomp_ops *ov511_decomp_ops;
208static struct ov51x_decomp_ops *ov511_mmx_decomp_ops;
209static struct ov51x_decomp_ops *ov518_decomp_ops;
210static struct ov51x_decomp_ops *ov518_mmx_decomp_ops;
211
212/* Number of times to retry a failed I2C transaction. Increase this if you 207/* Number of times to retry a failed I2C transaction. Increase this if you
213 * are getting "Failed to read sensor ID..." */ 208 * are getting "Failed to read sensor ID..." */
214static const int i2c_detect_tries = 5; 209static const int i2c_detect_tries = 5;
215 210
216/* MMX support is present in kernel and CPU. Checked upon decomp module load. */
217#if defined(__i386__) || defined(__x86_64__)
218#define ov51x_mmx_available (cpu_has_mmx)
219#else
220#define ov51x_mmx_available (0)
221#endif
222
223static struct usb_device_id device_table [] = { 211static struct usb_device_id device_table [] = {
224 { USB_DEVICE(VEND_OMNIVISION, PROD_OV511) }, 212 { USB_DEVICE(VEND_OMNIVISION, PROD_OV511) },
225 { USB_DEVICE(VEND_OMNIVISION, PROD_OV511PLUS) }, 213 { USB_DEVICE(VEND_OMNIVISION, PROD_OV511PLUS) },
@@ -3012,93 +3000,18 @@ yuv420raw_to_yuv420p(struct ov511_frame *frame,
3012 * 3000 *
3013 **********************************************************************/ 3001 **********************************************************************/
3014 3002
3015/* Chooses a decompression module, locks it, and sets ov->decomp_ops
3016 * accordingly. Returns -ENXIO if decompressor is not available, otherwise
3017 * returns 0 if no other error.
3018 */
3019static int 3003static int
3020request_decompressor(struct usb_ov511 *ov) 3004request_decompressor(struct usb_ov511 *ov)
3021{ 3005{
3022 if (!ov) 3006 if (ov->bclass == BCL_OV511 || ov->bclass == BCL_OV518) {
3023 return -ENODEV; 3007 err("No decompressor available");
3024
3025 if (ov->decomp_ops) {
3026 err("ERROR: Decompressor already requested!");
3027 return -EINVAL;
3028 }
3029
3030 lock_kernel();
3031
3032 /* Try to get MMX, and fall back on no-MMX if necessary */
3033 if (ov->bclass == BCL_OV511) {
3034 if (ov511_mmx_decomp_ops) {
3035 PDEBUG(3, "Using OV511 MMX decompressor");
3036 ov->decomp_ops = ov511_mmx_decomp_ops;
3037 } else if (ov511_decomp_ops) {
3038 PDEBUG(3, "Using OV511 decompressor");
3039 ov->decomp_ops = ov511_decomp_ops;
3040 } else {
3041 err("No decompressor available");
3042 }
3043 } else if (ov->bclass == BCL_OV518) {
3044 if (ov518_mmx_decomp_ops) {
3045 PDEBUG(3, "Using OV518 MMX decompressor");
3046 ov->decomp_ops = ov518_mmx_decomp_ops;
3047 } else if (ov518_decomp_ops) {
3048 PDEBUG(3, "Using OV518 decompressor");
3049 ov->decomp_ops = ov518_decomp_ops;
3050 } else {
3051 err("No decompressor available");
3052 }
3053 } else { 3008 } else {
3054 err("Unknown bridge"); 3009 err("Unknown bridge");
3055 } 3010 }
3056 3011
3057 if (!ov->decomp_ops)
3058 goto nosys;
3059
3060 if (!ov->decomp_ops->owner) {
3061 ov->decomp_ops = NULL;
3062 goto nosys;
3063 }
3064
3065 if (!try_module_get(ov->decomp_ops->owner))
3066 goto nosys;
3067
3068 unlock_kernel();
3069 return 0;
3070
3071 nosys:
3072 unlock_kernel();
3073 return -ENOSYS; 3012 return -ENOSYS;
3074} 3013}
3075 3014
3076/* Unlocks decompression module and nulls ov->decomp_ops. Safe to call even
3077 * if ov->decomp_ops is NULL.
3078 */
3079static void
3080release_decompressor(struct usb_ov511 *ov)
3081{
3082 int released = 0; /* Did we actually do anything? */
3083
3084 if (!ov)
3085 return;
3086
3087 lock_kernel();
3088
3089 if (ov->decomp_ops) {
3090 module_put(ov->decomp_ops->owner);
3091 released = 1;
3092 }
3093
3094 ov->decomp_ops = NULL;
3095
3096 unlock_kernel();
3097
3098 if (released)
3099 PDEBUG(3, "Decompressor released");
3100}
3101
3102static void 3015static void
3103decompress(struct usb_ov511 *ov, struct ov511_frame *frame, 3016decompress(struct usb_ov511 *ov, struct ov511_frame *frame,
3104 unsigned char *pIn0, unsigned char *pOut0) 3017 unsigned char *pIn0, unsigned char *pOut0)
@@ -3107,31 +3020,6 @@ decompress(struct usb_ov511 *ov, struct ov511_frame *frame,
3107 if (request_decompressor(ov)) 3020 if (request_decompressor(ov))
3108 return; 3021 return;
3109 3022
3110 PDEBUG(4, "Decompressing %d bytes", frame->bytes_recvd);
3111
3112 if (frame->format == VIDEO_PALETTE_GREY
3113 && ov->decomp_ops->decomp_400) {
3114 int ret = ov->decomp_ops->decomp_400(
3115 pIn0,
3116 pOut0,
3117 frame->compbuf,
3118 frame->rawwidth,
3119 frame->rawheight,
3120 frame->bytes_recvd);
3121 PDEBUG(4, "DEBUG: decomp_400 returned %d", ret);
3122 } else if (frame->format != VIDEO_PALETTE_GREY
3123 && ov->decomp_ops->decomp_420) {
3124 int ret = ov->decomp_ops->decomp_420(
3125 pIn0,
3126 pOut0,
3127 frame->compbuf,
3128 frame->rawwidth,
3129 frame->rawheight,
3130 frame->bytes_recvd);
3131 PDEBUG(4, "DEBUG: decomp_420 returned %d", ret);
3132 } else {
3133 err("Decompressor does not support this format");
3134 }
3135} 3023}
3136 3024
3137/********************************************************************** 3025/**********************************************************************
@@ -4087,8 +3975,6 @@ ov51x_v4l1_close(struct inode *inode, struct file *file)
4087 ov->user--; 3975 ov->user--;
4088 ov51x_stop_isoc(ov); 3976 ov51x_stop_isoc(ov);
4089 3977
4090 release_decompressor(ov);
4091
4092 if (ov->led_policy == LED_AUTO) 3978 if (ov->led_policy == LED_AUTO)
4093 ov51x_led_control(ov, 0); 3979 ov51x_led_control(ov, 0);
4094 3980
@@ -6021,82 +5907,6 @@ static struct usb_driver ov511_driver = {
6021 * 5907 *
6022 ***************************************************************************/ 5908 ***************************************************************************/
6023 5909
6024/* Returns 0 for success */
6025int
6026ov511_register_decomp_module(int ver, struct ov51x_decomp_ops *ops, int ov518,
6027 int mmx)
6028{
6029 if (ver != DECOMP_INTERFACE_VER) {
6030 err("Decompression module has incompatible");
6031 err("interface version %d", ver);
6032 err("Interface version %d is required", DECOMP_INTERFACE_VER);
6033 return -EINVAL;
6034 }
6035
6036 if (!ops)
6037 return -EFAULT;
6038
6039 if (mmx && !ov51x_mmx_available) {
6040 err("MMX not available on this system or kernel");
6041 return -EINVAL;
6042 }
6043
6044 lock_kernel();
6045
6046 if (ov518) {
6047 if (mmx) {
6048 if (ov518_mmx_decomp_ops)
6049 goto err_in_use;
6050 else
6051 ov518_mmx_decomp_ops = ops;
6052 } else {
6053 if (ov518_decomp_ops)
6054 goto err_in_use;
6055 else
6056 ov518_decomp_ops = ops;
6057 }
6058 } else {
6059 if (mmx) {
6060 if (ov511_mmx_decomp_ops)
6061 goto err_in_use;
6062 else
6063 ov511_mmx_decomp_ops = ops;
6064 } else {
6065 if (ov511_decomp_ops)
6066 goto err_in_use;
6067 else
6068 ov511_decomp_ops = ops;
6069 }
6070 }
6071
6072 unlock_kernel();
6073 return 0;
6074
6075err_in_use:
6076 unlock_kernel();
6077 return -EBUSY;
6078}
6079
6080void
6081ov511_deregister_decomp_module(int ov518, int mmx)
6082{
6083 lock_kernel();
6084
6085 if (ov518) {
6086 if (mmx)
6087 ov518_mmx_decomp_ops = NULL;
6088 else
6089 ov518_decomp_ops = NULL;
6090 } else {
6091 if (mmx)
6092 ov511_mmx_decomp_ops = NULL;
6093 else
6094 ov511_decomp_ops = NULL;
6095 }
6096
6097 unlock_kernel();
6098}
6099
6100static int __init 5910static int __init
6101usb_ov511_init(void) 5911usb_ov511_init(void)
6102{ 5912{
@@ -6123,5 +5933,3 @@ usb_ov511_exit(void)
6123module_init(usb_ov511_init); 5933module_init(usb_ov511_init);
6124module_exit(usb_ov511_exit); 5934module_exit(usb_ov511_exit);
6125 5935
6126EXPORT_SYMBOL(ov511_register_decomp_module);
6127EXPORT_SYMBOL(ov511_deregister_decomp_module);
diff --git a/drivers/usb/media/pwc/pwc-ctrl.c b/drivers/usb/media/pwc/pwc-ctrl.c
index 359c4b2df735..3ebb6e9cdf92 100644
--- a/drivers/usb/media/pwc/pwc-ctrl.c
+++ b/drivers/usb/media/pwc/pwc-ctrl.c
@@ -1152,45 +1152,6 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
1152 /* End of Add-Ons */ 1152 /* End of Add-Ons */
1153 /* ************************************************* */ 1153 /* ************************************************* */
1154 1154
1155/* Linux 2.5.something and 2.6 pass direct pointers to arguments of
1156 ioctl() calls. With 2.4, you have to do tedious copy_from_user()
1157 and copy_to_user() calls. With these macros we circumvent this,
1158 and let me maintain only one source file. The functionality is
1159 exactly the same otherwise.
1160 */
1161
1162#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
1163
1164/* define local variable for arg */
1165#define ARG_DEF(ARG_type, ARG_name)\
1166 ARG_type *ARG_name = arg;
1167/* copy arg to local variable */
1168#define ARG_IN(ARG_name) /* nothing */
1169/* argument itself (referenced) */
1170#define ARGR(ARG_name) (*ARG_name)
1171/* argument address */
1172#define ARGA(ARG_name) ARG_name
1173/* copy local variable to arg */
1174#define ARG_OUT(ARG_name) /* nothing */
1175
1176#else
1177
1178#define ARG_DEF(ARG_type, ARG_name)\
1179 ARG_type ARG_name;
1180#define ARG_IN(ARG_name)\
1181 if (copy_from_user(&ARG_name, arg, sizeof(ARG_name))) {\
1182 ret = -EFAULT;\
1183 break;\
1184 }
1185#define ARGR(ARG_name) ARG_name
1186#define ARGA(ARG_name) &ARG_name
1187#define ARG_OUT(ARG_name)\
1188 if (copy_to_user(arg, &ARG_name, sizeof(ARG_name))) {\
1189 ret = -EFAULT;\
1190 break;\
1191 }
1192
1193#endif
1194 1155
1195int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg) 1156int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1196{ 1157{
@@ -1220,243 +1181,206 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1220 1181
1221 case VIDIOCPWCSCQUAL: 1182 case VIDIOCPWCSCQUAL:
1222 { 1183 {
1223 ARG_DEF(int, qual) 1184 int *qual = arg;
1224 1185
1225 ARG_IN(qual) 1186 if (*qual < 0 || *qual > 3)
1226 if (ARGR(qual) < 0 || ARGR(qual) > 3)
1227 ret = -EINVAL; 1187 ret = -EINVAL;
1228 else 1188 else
1229 ret = pwc_try_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, ARGR(qual), pdev->vsnapshot); 1189 ret = pwc_try_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, *qual, pdev->vsnapshot);
1230 if (ret >= 0) 1190 if (ret >= 0)
1231 pdev->vcompression = ARGR(qual); 1191 pdev->vcompression = *qual;
1232 break; 1192 break;
1233 } 1193 }
1234 1194
1235 case VIDIOCPWCGCQUAL: 1195 case VIDIOCPWCGCQUAL:
1236 { 1196 {
1237 ARG_DEF(int, qual) 1197 int *qual = arg;
1238 1198 *qual = pdev->vcompression;
1239 ARGR(qual) = pdev->vcompression;
1240 ARG_OUT(qual)
1241 break; 1199 break;
1242 } 1200 }
1243 1201
1244 case VIDIOCPWCPROBE: 1202 case VIDIOCPWCPROBE:
1245 { 1203 {
1246 ARG_DEF(struct pwc_probe, probe) 1204 struct pwc_probe *probe = arg;
1247 1205 strcpy(probe->name, pdev->vdev->name);
1248 strcpy(ARGR(probe).name, pdev->vdev->name); 1206 probe->type = pdev->type;
1249 ARGR(probe).type = pdev->type;
1250 ARG_OUT(probe)
1251 break; 1207 break;
1252 } 1208 }
1253 1209
1254 case VIDIOCPWCGSERIAL: 1210 case VIDIOCPWCGSERIAL:
1255 { 1211 {
1256 ARG_DEF(struct pwc_serial, serial) 1212 struct pwc_serial *serial = arg;
1257 1213 strcpy(serial->serial, pdev->serial);
1258 strcpy(ARGR(serial).serial, pdev->serial);
1259 ARG_OUT(serial)
1260 break; 1214 break;
1261 } 1215 }
1262 1216
1263 case VIDIOCPWCSAGC: 1217 case VIDIOCPWCSAGC:
1264 { 1218 {
1265 ARG_DEF(int, agc) 1219 int *agc = arg;
1266 1220 if (pwc_set_agc(pdev, *agc < 0 ? 1 : 0, *agc))
1267 ARG_IN(agc)
1268 if (pwc_set_agc(pdev, ARGR(agc) < 0 ? 1 : 0, ARGR(agc)))
1269 ret = -EINVAL; 1221 ret = -EINVAL;
1270 break; 1222 break;
1271 } 1223 }
1272 1224
1273 case VIDIOCPWCGAGC: 1225 case VIDIOCPWCGAGC:
1274 { 1226 {
1275 ARG_DEF(int, agc) 1227 int *agc = arg;
1276 1228
1277 if (pwc_get_agc(pdev, ARGA(agc))) 1229 if (pwc_get_agc(pdev, agc))
1278 ret = -EINVAL; 1230 ret = -EINVAL;
1279 ARG_OUT(agc)
1280 break; 1231 break;
1281 } 1232 }
1282 1233
1283 case VIDIOCPWCSSHUTTER: 1234 case VIDIOCPWCSSHUTTER:
1284 { 1235 {
1285 ARG_DEF(int, shutter_speed) 1236 int *shutter_speed = arg;
1286 1237 ret = pwc_set_shutter_speed(pdev, *shutter_speed < 0 ? 1 : 0, *shutter_speed);
1287 ARG_IN(shutter_speed)
1288 ret = pwc_set_shutter_speed(pdev, ARGR(shutter_speed) < 0 ? 1 : 0, ARGR(shutter_speed));
1289 break; 1238 break;
1290 } 1239 }
1291 1240
1292 case VIDIOCPWCSAWB: 1241 case VIDIOCPWCSAWB:
1293 { 1242 {
1294 ARG_DEF(struct pwc_whitebalance, wb) 1243 struct pwc_whitebalance *wb = arg;
1295 1244
1296 ARG_IN(wb) 1245 ret = pwc_set_awb(pdev, wb->mode);
1297 ret = pwc_set_awb(pdev, ARGR(wb).mode); 1246 if (ret >= 0 && wb->mode == PWC_WB_MANUAL) {
1298 if (ret >= 0 && ARGR(wb).mode == PWC_WB_MANUAL) { 1247 pwc_set_red_gain(pdev, wb->manual_red);
1299 pwc_set_red_gain(pdev, ARGR(wb).manual_red); 1248 pwc_set_blue_gain(pdev, wb->manual_blue);
1300 pwc_set_blue_gain(pdev, ARGR(wb).manual_blue);
1301 } 1249 }
1302 break; 1250 break;
1303 } 1251 }
1304 1252
1305 case VIDIOCPWCGAWB: 1253 case VIDIOCPWCGAWB:
1306 { 1254 {
1307 ARG_DEF(struct pwc_whitebalance, wb) 1255 struct pwc_whitebalance *wb = arg;
1308 1256
1309 memset(ARGA(wb), 0, sizeof(struct pwc_whitebalance)); 1257 memset(wb, 0, sizeof(struct pwc_whitebalance));
1310 ARGR(wb).mode = pwc_get_awb(pdev); 1258 wb->mode = pwc_get_awb(pdev);
1311 if (ARGR(wb).mode < 0) 1259 if (wb->mode < 0)
1312 ret = -EINVAL; 1260 ret = -EINVAL;
1313 else { 1261 else {
1314 if (ARGR(wb).mode == PWC_WB_MANUAL) { 1262 if (wb->mode == PWC_WB_MANUAL) {
1315 ret = pwc_get_red_gain(pdev, &ARGR(wb).manual_red); 1263 ret = pwc_get_red_gain(pdev, &wb->manual_red);
1316 if (ret < 0) 1264 if (ret < 0)
1317 break; 1265 break;
1318 ret = pwc_get_blue_gain(pdev, &ARGR(wb).manual_blue); 1266 ret = pwc_get_blue_gain(pdev, &wb->manual_blue);
1319 if (ret < 0) 1267 if (ret < 0)
1320 break; 1268 break;
1321 } 1269 }
1322 if (ARGR(wb).mode == PWC_WB_AUTO) { 1270 if (wb->mode == PWC_WB_AUTO) {
1323 ret = pwc_read_red_gain(pdev, &ARGR(wb).read_red); 1271 ret = pwc_read_red_gain(pdev, &wb->read_red);
1324 if (ret < 0) 1272 if (ret < 0)
1325 break; 1273 break;
1326 ret =pwc_read_blue_gain(pdev, &ARGR(wb).read_blue); 1274 ret = pwc_read_blue_gain(pdev, &wb->read_blue);
1327 if (ret < 0) 1275 if (ret < 0)
1328 break; 1276 break;
1329 } 1277 }
1330 } 1278 }
1331 ARG_OUT(wb)
1332 break; 1279 break;
1333 } 1280 }
1334 1281
1335 case VIDIOCPWCSAWBSPEED: 1282 case VIDIOCPWCSAWBSPEED:
1336 { 1283 {
1337 ARG_DEF(struct pwc_wb_speed, wbs) 1284 struct pwc_wb_speed *wbs = arg;
1338 1285
1339 if (ARGR(wbs).control_speed > 0) { 1286 if (wbs->control_speed > 0) {
1340 ret = pwc_set_wb_speed(pdev, ARGR(wbs).control_speed); 1287 ret = pwc_set_wb_speed(pdev, wbs->control_speed);
1341 } 1288 }
1342 if (ARGR(wbs).control_delay > 0) { 1289 if (wbs->control_delay > 0) {
1343 ret = pwc_set_wb_delay(pdev, ARGR(wbs).control_delay); 1290 ret = pwc_set_wb_delay(pdev, wbs->control_delay);
1344 } 1291 }
1345 break; 1292 break;
1346 } 1293 }
1347 1294
1348 case VIDIOCPWCGAWBSPEED: 1295 case VIDIOCPWCGAWBSPEED:
1349 { 1296 {
1350 ARG_DEF(struct pwc_wb_speed, wbs) 1297 struct pwc_wb_speed *wbs = arg;
1351 1298
1352 ret = pwc_get_wb_speed(pdev, &ARGR(wbs).control_speed); 1299 ret = pwc_get_wb_speed(pdev, &wbs->control_speed);
1353 if (ret < 0) 1300 if (ret < 0)
1354 break; 1301 break;
1355 ret = pwc_get_wb_delay(pdev, &ARGR(wbs).control_delay); 1302 ret = pwc_get_wb_delay(pdev, &wbs->control_delay);
1356 if (ret < 0) 1303 if (ret < 0)
1357 break; 1304 break;
1358 ARG_OUT(wbs)
1359 break; 1305 break;
1360 } 1306 }
1361 1307
1362 case VIDIOCPWCSLED: 1308 case VIDIOCPWCSLED:
1363 { 1309 {
1364 ARG_DEF(struct pwc_leds, leds) 1310 struct pwc_leds *leds = arg;
1365 1311 ret = pwc_set_leds(pdev, leds->led_on, leds->led_off);
1366 ARG_IN(leds)
1367 ret = pwc_set_leds(pdev, ARGR(leds).led_on, ARGR(leds).led_off);
1368 break; 1312 break;
1369 } 1313 }
1370 1314
1371 1315
1372 case VIDIOCPWCGLED: 1316 case VIDIOCPWCGLED:
1373 { 1317 {
1374 ARG_DEF(struct pwc_leds, leds) 1318 struct pwc_leds *leds = arg;
1375 1319 ret = pwc_get_leds(pdev, &leds->led_on, &leds->led_off);
1376 ret = pwc_get_leds(pdev, &ARGR(leds).led_on, &ARGR(leds).led_off);
1377 ARG_OUT(leds)
1378 break; 1320 break;
1379 } 1321 }
1380 1322
1381 case VIDIOCPWCSCONTOUR: 1323 case VIDIOCPWCSCONTOUR:
1382 { 1324 {
1383 ARG_DEF(int, contour) 1325 int *contour = arg;
1384 1326 ret = pwc_set_contour(pdev, *contour);
1385 ARG_IN(contour)
1386 ret = pwc_set_contour(pdev, ARGR(contour));
1387 break; 1327 break;
1388 } 1328 }
1389 1329
1390 case VIDIOCPWCGCONTOUR: 1330 case VIDIOCPWCGCONTOUR:
1391 { 1331 {
1392 ARG_DEF(int, contour) 1332 int *contour = arg;
1393 1333 ret = pwc_get_contour(pdev, contour);
1394 ret = pwc_get_contour(pdev, ARGA(contour));
1395 ARG_OUT(contour)
1396 break; 1334 break;
1397 } 1335 }
1398 1336
1399 case VIDIOCPWCSBACKLIGHT: 1337 case VIDIOCPWCSBACKLIGHT:
1400 { 1338 {
1401 ARG_DEF(int, backlight) 1339 int *backlight = arg;
1402 1340 ret = pwc_set_backlight(pdev, *backlight);
1403 ARG_IN(backlight)
1404 ret = pwc_set_backlight(pdev, ARGR(backlight));
1405 break; 1341 break;
1406 } 1342 }
1407 1343
1408 case VIDIOCPWCGBACKLIGHT: 1344 case VIDIOCPWCGBACKLIGHT:
1409 { 1345 {
1410 ARG_DEF(int, backlight) 1346 int *backlight = arg;
1411 1347 ret = pwc_get_backlight(pdev, backlight);
1412 ret = pwc_get_backlight(pdev, ARGA(backlight));
1413 ARG_OUT(backlight)
1414 break; 1348 break;
1415 } 1349 }
1416 1350
1417 case VIDIOCPWCSFLICKER: 1351 case VIDIOCPWCSFLICKER:
1418 { 1352 {
1419 ARG_DEF(int, flicker) 1353 int *flicker = arg;
1420 1354 ret = pwc_set_flicker(pdev, *flicker);
1421 ARG_IN(flicker)
1422 ret = pwc_set_flicker(pdev, ARGR(flicker));
1423 break; 1355 break;
1424 } 1356 }
1425 1357
1426 case VIDIOCPWCGFLICKER: 1358 case VIDIOCPWCGFLICKER:
1427 { 1359 {
1428 ARG_DEF(int, flicker) 1360 int *flicker = arg;
1429 1361 ret = pwc_get_flicker(pdev, flicker);
1430 ret = pwc_get_flicker(pdev, ARGA(flicker));
1431 ARG_OUT(flicker)
1432 break; 1362 break;
1433 } 1363 }
1434 1364
1435 case VIDIOCPWCSDYNNOISE: 1365 case VIDIOCPWCSDYNNOISE:
1436 { 1366 {
1437 ARG_DEF(int, dynnoise) 1367 int *dynnoise = arg;
1438 1368 ret = pwc_set_dynamic_noise(pdev, *dynnoise);
1439 ARG_IN(dynnoise)
1440 ret = pwc_set_dynamic_noise(pdev, ARGR(dynnoise));
1441 break; 1369 break;
1442 } 1370 }
1443 1371
1444 case VIDIOCPWCGDYNNOISE: 1372 case VIDIOCPWCGDYNNOISE:
1445 { 1373 {
1446 ARG_DEF(int, dynnoise) 1374 int *dynnoise = arg;
1447 1375 ret = pwc_get_dynamic_noise(pdev, dynnoise);
1448 ret = pwc_get_dynamic_noise(pdev, ARGA(dynnoise));
1449 ARG_OUT(dynnoise);
1450 break; 1376 break;
1451 } 1377 }
1452 1378
1453 case VIDIOCPWCGREALSIZE: 1379 case VIDIOCPWCGREALSIZE:
1454 { 1380 {
1455 ARG_DEF(struct pwc_imagesize, size) 1381 struct pwc_imagesize *size = arg;
1456 1382 size->width = pdev->image.x;
1457 ARGR(size).width = pdev->image.x; 1383 size->height = pdev->image.y;
1458 ARGR(size).height = pdev->image.y;
1459 ARG_OUT(size)
1460 break; 1384 break;
1461 } 1385 }
1462 1386
@@ -1464,10 +1388,9 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1464 { 1388 {
1465 if (pdev->features & FEATURE_MOTOR_PANTILT) 1389 if (pdev->features & FEATURE_MOTOR_PANTILT)
1466 { 1390 {
1467 ARG_DEF(int, flags) 1391 int *flags = arg;
1468 1392
1469 ARG_IN(flags) 1393 ret = pwc_mpt_reset(pdev, *flags);
1470 ret = pwc_mpt_reset(pdev, ARGR(flags));
1471 if (ret >= 0) 1394 if (ret >= 0)
1472 { 1395 {
1473 pdev->pan_angle = 0; 1396 pdev->pan_angle = 0;
@@ -1485,10 +1408,8 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1485 { 1408 {
1486 if (pdev->features & FEATURE_MOTOR_PANTILT) 1409 if (pdev->features & FEATURE_MOTOR_PANTILT)
1487 { 1410 {
1488 ARG_DEF(struct pwc_mpt_range, range) 1411 struct pwc_mpt_range *range = arg;
1489 1412 *range = pdev->angle_range;
1490 ARGR(range) = pdev->angle_range;
1491 ARG_OUT(range)
1492 } 1413 }
1493 else 1414 else
1494 { 1415 {
@@ -1503,21 +1424,19 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1503 1424
1504 if (pdev->features & FEATURE_MOTOR_PANTILT) 1425 if (pdev->features & FEATURE_MOTOR_PANTILT)
1505 { 1426 {
1506 ARG_DEF(struct pwc_mpt_angles, angles) 1427 struct pwc_mpt_angles *angles = arg;
1507
1508 ARG_IN(angles)
1509 /* The camera can only set relative angles, so 1428 /* The camera can only set relative angles, so
1510 do some calculations when getting an absolute angle . 1429 do some calculations when getting an absolute angle .
1511 */ 1430 */
1512 if (ARGR(angles).absolute) 1431 if (angles->absolute)
1513 { 1432 {
1514 new_pan = ARGR(angles).pan; 1433 new_pan = angles->pan;
1515 new_tilt = ARGR(angles).tilt; 1434 new_tilt = angles->tilt;
1516 } 1435 }
1517 else 1436 else
1518 { 1437 {
1519 new_pan = pdev->pan_angle + ARGR(angles).pan; 1438 new_pan = pdev->pan_angle + angles->pan;
1520 new_tilt = pdev->tilt_angle + ARGR(angles).tilt; 1439 new_tilt = pdev->tilt_angle + angles->tilt;
1521 } 1440 }
1522 /* check absolute ranges */ 1441 /* check absolute ranges */
1523 if (new_pan < pdev->angle_range.pan_min || 1442 if (new_pan < pdev->angle_range.pan_min ||
@@ -1560,12 +1479,11 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1560 1479
1561 if (pdev->features & FEATURE_MOTOR_PANTILT) 1480 if (pdev->features & FEATURE_MOTOR_PANTILT)
1562 { 1481 {
1563 ARG_DEF(struct pwc_mpt_angles, angles) 1482 struct pwc_mpt_angles *angles = arg;
1564 1483
1565 ARGR(angles).absolute = 1; 1484 angles->absolute = 1;
1566 ARGR(angles).pan = pdev->pan_angle; 1485 angles->pan = pdev->pan_angle;
1567 ARGR(angles).tilt = pdev->tilt_angle; 1486 angles->tilt = pdev->tilt_angle;
1568 ARG_OUT(angles)
1569 } 1487 }
1570 else 1488 else
1571 { 1489 {
@@ -1578,10 +1496,8 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1578 { 1496 {
1579 if (pdev->features & FEATURE_MOTOR_PANTILT) 1497 if (pdev->features & FEATURE_MOTOR_PANTILT)
1580 { 1498 {
1581 ARG_DEF(struct pwc_mpt_status, status) 1499 struct pwc_mpt_status *status = arg;
1582 1500 ret = pwc_mpt_get_status(pdev, status);
1583 ret = pwc_mpt_get_status(pdev, ARGA(status));
1584 ARG_OUT(status)
1585 } 1501 }
1586 else 1502 else
1587 { 1503 {
@@ -1592,24 +1508,22 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1592 1508
1593 case VIDIOCPWCGVIDCMD: 1509 case VIDIOCPWCGVIDCMD:
1594 { 1510 {
1595 ARG_DEF(struct pwc_video_command, cmd); 1511 struct pwc_video_command *cmd = arg;
1596 1512
1597 ARGR(cmd).type = pdev->type; 1513 cmd->type = pdev->type;
1598 ARGR(cmd).release = pdev->release; 1514 cmd->release = pdev->release;
1599 ARGR(cmd).command_len = pdev->cmd_len; 1515 cmd->command_len = pdev->cmd_len;
1600 memcpy(&ARGR(cmd).command_buf, pdev->cmd_buf, pdev->cmd_len); 1516 memcpy(&cmd->command_buf, pdev->cmd_buf, pdev->cmd_len);
1601 ARGR(cmd).bandlength = pdev->vbandlength; 1517 cmd->bandlength = pdev->vbandlength;
1602 ARGR(cmd).frame_size = pdev->frame_size; 1518 cmd->frame_size = pdev->frame_size;
1603 ARG_OUT(cmd)
1604 break; 1519 break;
1605 } 1520 }
1606 /* 1521 /*
1607 case VIDIOCPWCGVIDTABLE: 1522 case VIDIOCPWCGVIDTABLE:
1608 { 1523 {
1609 ARG_DEF(struct pwc_table_init_buffer, table); 1524 struct pwc_table_init_buffer *table = arg;
1610 ARGR(table).len = pdev->cmd_len; 1525 table->len = pdev->cmd_len;
1611 memcpy(&ARGR(table).buffer, pdev->decompress_data, pdev->decompressor->table_size); 1526 memcpy(&table->buffer, pdev->decompress_data, pdev->decompressor->table_size);
1612 ARG_OUT(table)
1613 break; 1527 break;
1614 } 1528 }
1615 */ 1529 */
diff --git a/drivers/usb/media/sn9c102.h b/drivers/usb/media/sn9c102.h
index e5cea0e2eb57..17d60c1eea7e 100644
--- a/drivers/usb/media/sn9c102.h
+++ b/drivers/usb/media/sn9c102.h
@@ -1,7 +1,7 @@
1/*************************************************************************** 1/***************************************************************************
2 * V4L2 driver for SN9C10x PC Camera Controllers * 2 * V4L2 driver for SN9C10x PC Camera Controllers *
3 * * 3 * *
4 * Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> * 4 * Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
@@ -23,7 +23,8 @@
23 23
24#include <linux/version.h> 24#include <linux/version.h>
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/videodev.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h>
27#include <linux/device.h> 28#include <linux/device.h>
28#include <linux/list.h> 29#include <linux/list.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
@@ -52,13 +53,6 @@
52 53
53/*****************************************************************************/ 54/*****************************************************************************/
54 55
55#define SN9C102_MODULE_NAME "V4L2 driver for SN9C10x PC Camera Controllers"
56#define SN9C102_MODULE_AUTHOR "(C) 2004-2005 Luca Risolia"
57#define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
58#define SN9C102_MODULE_LICENSE "GPL"
59#define SN9C102_MODULE_VERSION "1:1.24a"
60#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 24)
61
62enum sn9c102_bridge { 56enum sn9c102_bridge {
63 BRIDGE_SN9C101 = 0x01, 57 BRIDGE_SN9C101 = 0x01,
64 BRIDGE_SN9C102 = 0x02, 58 BRIDGE_SN9C102 = 0x02,
@@ -102,12 +96,13 @@ enum sn9c102_stream_state {
102 STREAM_ON, 96 STREAM_ON,
103}; 97};
104 98
99typedef char sn9c103_sof_header_t[18];
105typedef char sn9c102_sof_header_t[12]; 100typedef char sn9c102_sof_header_t[12];
106typedef char sn9c102_eof_header_t[4]; 101typedef char sn9c102_eof_header_t[4];
107 102
108struct sn9c102_sysfs_attr { 103struct sn9c102_sysfs_attr {
109 u8 reg, i2c_reg; 104 u8 reg, i2c_reg;
110 sn9c102_sof_header_t frame_header; 105 sn9c103_sof_header_t frame_header;
111}; 106};
112 107
113struct sn9c102_module_param { 108struct sn9c102_module_param {
@@ -118,8 +113,6 @@ static DECLARE_MUTEX(sn9c102_sysfs_lock);
118static DECLARE_RWSEM(sn9c102_disconnect); 113static DECLARE_RWSEM(sn9c102_disconnect);
119 114
120struct sn9c102_device { 115struct sn9c102_device {
121 struct device dev;
122
123 struct video_device* v4ldev; 116 struct video_device* v4ldev;
124 117
125 enum sn9c102_bridge bridge; 118 enum sn9c102_bridge bridge;
@@ -140,8 +133,8 @@ struct sn9c102_device {
140 struct v4l2_jpegcompression compression; 133 struct v4l2_jpegcompression compression;
141 134
142 struct sn9c102_sysfs_attr sysfs; 135 struct sn9c102_sysfs_attr sysfs;
143 sn9c102_sof_header_t sof_header; 136 sn9c103_sof_header_t sof_header;
144 u16 reg[32]; 137 u16 reg[63];
145 138
146 struct sn9c102_module_param module_param; 139 struct sn9c102_module_param module_param;
147 140
@@ -160,7 +153,6 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
160 struct sn9c102_sensor* sensor) 153 struct sn9c102_sensor* sensor)
161{ 154{
162 cam->sensor = sensor; 155 cam->sensor = sensor;
163 cam->sensor->dev = &cam->dev;
164 cam->sensor->usbdev = cam->usbdev; 156 cam->sensor->usbdev = cam->usbdev;
165} 157}
166 158
@@ -170,19 +162,24 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
170#undef KDBG 162#undef KDBG
171#ifdef SN9C102_DEBUG 163#ifdef SN9C102_DEBUG
172# define DBG(level, fmt, args...) \ 164# define DBG(level, fmt, args...) \
173{ \ 165do { \
174 if (debug >= (level)) { \ 166 if (debug >= (level)) { \
175 if ((level) == 1) \ 167 if ((level) == 1) \
176 dev_err(&cam->dev, fmt "\n", ## args); \ 168 dev_err(&cam->usbdev->dev, fmt "\n", ## args); \
177 else if ((level) == 2) \ 169 else if ((level) == 2) \
178 dev_info(&cam->dev, fmt "\n", ## args); \ 170 dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
179 else if ((level) >= 3) \ 171 else if ((level) >= 3) \
180 dev_info(&cam->dev, "[%s:%d] " fmt "\n", \ 172 dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
181 __FUNCTION__, __LINE__ , ## args); \ 173 __FUNCTION__, __LINE__ , ## args); \
182 } \ 174 } \
183} 175} while (0)
176# define V4LDBG(level, name, cmd) \
177do { \
178 if (debug >= (level)) \
179 v4l_print_ioctl(name, cmd); \
180} while (0)
184# define KDBG(level, fmt, args...) \ 181# define KDBG(level, fmt, args...) \
185{ \ 182do { \
186 if (debug >= (level)) { \ 183 if (debug >= (level)) { \
187 if ((level) == 1 || (level) == 2) \ 184 if ((level) == 1 || (level) == 2) \
188 pr_info("sn9c102: " fmt "\n", ## args); \ 185 pr_info("sn9c102: " fmt "\n", ## args); \
@@ -190,17 +187,18 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
190 pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \ 187 pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \
191 __LINE__ , ## args); \ 188 __LINE__ , ## args); \
192 } \ 189 } \
193} 190} while (0)
194#else 191#else
195# define KDBG(level, fmt, args...) do {;} while(0); 192# define DBG(level, fmt, args...) do {;} while(0)
196# define DBG(level, fmt, args...) do {;} while(0); 193# define V4LDBG(level, name, cmd) do {;} while(0)
194# define KDBG(level, fmt, args...) do {;} while(0)
197#endif 195#endif
198 196
199#undef PDBG 197#undef PDBG
200#define PDBG(fmt, args...) \ 198#define PDBG(fmt, args...) \
201dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args); 199dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args)
202 200
203#undef PDBGG 201#undef PDBGG
204#define PDBGG(fmt, args...) do {;} while(0); /* placeholder */ 202#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
205 203
206#endif /* _SN9C102_H_ */ 204#endif /* _SN9C102_H_ */
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c
index 8d1a1c357d5a..c81397e4714b 100644
--- a/drivers/usb/media/sn9c102_core.c
+++ b/drivers/usb/media/sn9c102_core.c
@@ -1,7 +1,7 @@
1/*************************************************************************** 1/***************************************************************************
2 * V4L2 driver for SN9C10x PC Camera Controllers * 2 * V4L2 driver for SN9C10x PC Camera Controllers *
3 * * 3 * *
4 * Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> * 4 * Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
@@ -45,6 +45,15 @@
45 45
46/*****************************************************************************/ 46/*****************************************************************************/
47 47
48#define SN9C102_MODULE_NAME "V4L2 driver for SN9C10x PC Camera Controllers"
49#define SN9C102_MODULE_AUTHOR "(C) 2004-2006 Luca Risolia"
50#define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
51#define SN9C102_MODULE_LICENSE "GPL"
52#define SN9C102_MODULE_VERSION "1:1.26"
53#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 26)
54
55/*****************************************************************************/
56
48MODULE_DEVICE_TABLE(usb, sn9c102_id_table); 57MODULE_DEVICE_TABLE(usb, sn9c102_id_table);
49 58
50MODULE_AUTHOR(SN9C102_MODULE_AUTHOR " " SN9C102_AUTHOR_EMAIL); 59MODULE_AUTHOR(SN9C102_MODULE_AUTHOR " " SN9C102_AUTHOR_EMAIL);
@@ -70,10 +79,10 @@ static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] =
70 SN9C102_FORCE_MUNMAP}; 79 SN9C102_FORCE_MUNMAP};
71module_param_array(force_munmap, bool, NULL, 0444); 80module_param_array(force_munmap, bool, NULL, 0444);
72MODULE_PARM_DESC(force_munmap, 81MODULE_PARM_DESC(force_munmap,
73 "\n<0|1[,...]> Force the application to unmap previously " 82 "\n<0|1[,...]> Force the application to unmap previously"
74 "\nmapped buffer memory before calling any VIDIOC_S_CROP or " 83 "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
75 "\nVIDIOC_S_FMT ioctl's. Not all the applications support " 84 "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
76 "\nthis feature. This parameter is specific for each " 85 "\nthis feature. This parameter is specific for each"
77 "\ndetected camera." 86 "\ndetected camera."
78 "\n 0 = do not force memory unmapping" 87 "\n 0 = do not force memory unmapping"
79 "\n 1 = force memory unmapping (save memory)" 88 "\n 1 = force memory unmapping (save memory)"
@@ -102,6 +111,9 @@ static sn9c102_sof_header_t sn9c102_sof_header[] = {
102 {0xff, 0xff, 0x00, 0xc4, 0xc4, 0x96, 0x01}, 111 {0xff, 0xff, 0x00, 0xc4, 0xc4, 0x96, 0x01},
103}; 112};
104 113
114static sn9c103_sof_header_t sn9c103_sof_header[] = {
115 {0xff, 0xff, 0x00, 0xc4, 0xc4, 0x96, 0x20},
116};
105 117
106static sn9c102_eof_header_t sn9c102_eof_header[] = { 118static sn9c102_eof_header_t sn9c102_eof_header[] = {
107 {0x00, 0x00, 0x00, 0x00}, 119 {0x00, 0x00, 0x00, 0x00},
@@ -112,50 +124,6 @@ static sn9c102_eof_header_t sn9c102_eof_header[] = {
112 124
113/*****************************************************************************/ 125/*****************************************************************************/
114 126
115static void* rvmalloc(size_t size)
116{
117 void* mem;
118 unsigned long adr;
119
120 size = PAGE_ALIGN(size);
121
122 mem = vmalloc_32((unsigned long)size);
123 if (!mem)
124 return NULL;
125
126 memset(mem, 0, size);
127
128 adr = (unsigned long)mem;
129 while (size > 0) {
130 SetPageReserved(vmalloc_to_page((void *)adr));
131 adr += PAGE_SIZE;
132 size -= PAGE_SIZE;
133 }
134
135 return mem;
136}
137
138
139static void rvfree(void* mem, size_t size)
140{
141 unsigned long adr;
142
143 if (!mem)
144 return;
145
146 size = PAGE_ALIGN(size);
147
148 adr = (unsigned long)mem;
149 while (size > 0) {
150 ClearPageReserved(vmalloc_to_page((void *)adr));
151 adr += PAGE_SIZE;
152 size -= PAGE_SIZE;
153 }
154
155 vfree(mem);
156}
157
158
159static u32 127static u32
160sn9c102_request_buffers(struct sn9c102_device* cam, u32 count, 128sn9c102_request_buffers(struct sn9c102_device* cam, u32 count,
161 enum sn9c102_io_method io) 129 enum sn9c102_io_method io)
@@ -174,7 +142,7 @@ sn9c102_request_buffers(struct sn9c102_device* cam, u32 count,
174 142
175 cam->nbuffers = count; 143 cam->nbuffers = count;
176 while (cam->nbuffers > 0) { 144 while (cam->nbuffers > 0) {
177 if ((buff = rvmalloc(cam->nbuffers * PAGE_ALIGN(imagesize)))) 145 if ((buff = vmalloc_32(cam->nbuffers * PAGE_ALIGN(imagesize))))
178 break; 146 break;
179 cam->nbuffers--; 147 cam->nbuffers--;
180 } 148 }
@@ -198,10 +166,10 @@ sn9c102_request_buffers(struct sn9c102_device* cam, u32 count,
198static void sn9c102_release_buffers(struct sn9c102_device* cam) 166static void sn9c102_release_buffers(struct sn9c102_device* cam)
199{ 167{
200 if (cam->nbuffers) { 168 if (cam->nbuffers) {
201 rvfree(cam->frame[0].bufmem, 169 vfree(cam->frame[0].bufmem);
202 cam->nbuffers * PAGE_ALIGN(cam->frame[0].buf.length));
203 cam->nbuffers = 0; 170 cam->nbuffers = 0;
204 } 171 }
172 cam->frame_current = NULL;
205} 173}
206 174
207 175
@@ -219,6 +187,19 @@ static void sn9c102_empty_framequeues(struct sn9c102_device* cam)
219} 187}
220 188
221 189
190static void sn9c102_requeue_outqueue(struct sn9c102_device* cam)
191{
192 struct sn9c102_frame_t *i;
193
194 list_for_each_entry(i, &cam->outqueue, frame) {
195 i->state = F_QUEUED;
196 list_add(&i->frame, &cam->inqueue);
197 }
198
199 INIT_LIST_HEAD(&cam->outqueue);
200}
201
202
222static void sn9c102_queue_unusedframes(struct sn9c102_device* cam) 203static void sn9c102_queue_unusedframes(struct sn9c102_device* cam)
223{ 204{
224 unsigned long lock_flags; 205 unsigned long lock_flags;
@@ -235,19 +216,46 @@ static void sn9c102_queue_unusedframes(struct sn9c102_device* cam)
235 216
236/*****************************************************************************/ 217/*****************************************************************************/
237 218
219int sn9c102_write_regs(struct sn9c102_device* cam, u8* buff, u16 index)
220{
221 struct usb_device* udev = cam->usbdev;
222 int i, res;
223
224 if (index + sizeof(buff) >= ARRAY_SIZE(cam->reg))
225 return -1;
226
227 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
228 index, 0, buff, sizeof(buff),
229 SN9C102_CTRL_TIMEOUT*sizeof(buff));
230 if (res < 0) {
231 DBG(3, "Failed to write registers (index 0x%02X, error %d)",
232 index, res);
233 return -1;
234 }
235
236 for (i = 0; i < sizeof(buff); i++)
237 cam->reg[index+i] = buff[i];
238
239 return 0;
240}
241
242
238int sn9c102_write_reg(struct sn9c102_device* cam, u8 value, u16 index) 243int sn9c102_write_reg(struct sn9c102_device* cam, u8 value, u16 index)
239{ 244{
240 struct usb_device* udev = cam->usbdev; 245 struct usb_device* udev = cam->usbdev;
241 u8* buff = cam->control_buffer; 246 u8* buff = cam->control_buffer;
242 int res; 247 int res;
243 248
249 if (index >= ARRAY_SIZE(cam->reg))
250 return -1;
251
244 *buff = value; 252 *buff = value;
245 253
246 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, 254 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
247 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT); 255 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
248 if (res < 0) { 256 if (res < 0) {
249 DBG(3, "Failed to write a register (value 0x%02X, index " 257 DBG(3, "Failed to write a register (value 0x%02X, index "
250 "0x%02X, error %d)", value, index, res) 258 "0x%02X, error %d)", value, index, res);
251 return -1; 259 return -1;
252 } 260 }
253 261
@@ -268,7 +276,7 @@ static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index)
268 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT); 276 index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
269 if (res < 0) 277 if (res < 0)
270 DBG(3, "Failed to read a register (index 0x%02X, error %d)", 278 DBG(3, "Failed to read a register (index 0x%02X, error %d)",
271 index, res) 279 index, res);
272 280
273 return (res >= 0) ? (int)(*buff) : -1; 281 return (res >= 0) ? (int)(*buff) : -1;
274} 282}
@@ -276,8 +284,8 @@ static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index)
276 284
277int sn9c102_pread_reg(struct sn9c102_device* cam, u16 index) 285int sn9c102_pread_reg(struct sn9c102_device* cam, u16 index)
278{ 286{
279 if (index > 0x1f) 287 if (index >= ARRAY_SIZE(cam->reg))
280 return -EINVAL; 288 return -1;
281 289
282 return cam->reg[index]; 290 return cam->reg[index];
283} 291}
@@ -367,10 +375,10 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
367 err += sn9c102_i2c_detect_read_error(cam, sensor); 375 err += sn9c102_i2c_detect_read_error(cam, sensor);
368 376
369 PDBGG("I2C read: address 0x%02X, first read byte: 0x%02X", data1, 377 PDBGG("I2C read: address 0x%02X, first read byte: 0x%02X", data1,
370 data[4]) 378 data[4]);
371 379
372 if (err) { 380 if (err) {
373 DBG(3, "I2C read failed for %s image sensor", sensor->name) 381 DBG(3, "I2C read failed for %s image sensor", sensor->name);
374 return -1; 382 return -1;
375 } 383 }
376 384
@@ -410,11 +418,11 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
410 err += sn9c102_i2c_detect_write_error(cam, sensor); 418 err += sn9c102_i2c_detect_write_error(cam, sensor);
411 419
412 if (err) 420 if (err)
413 DBG(3, "I2C write failed for %s image sensor", sensor->name) 421 DBG(3, "I2C write failed for %s image sensor", sensor->name);
414 422
415 PDBGG("I2C raw write: %u bytes, data0 = 0x%02X, data1 = 0x%02X, " 423 PDBGG("I2C raw write: %u bytes, data0 = 0x%02X, data1 = 0x%02X, "
416 "data2 = 0x%02X, data3 = 0x%02X, data4 = 0x%02X, data5 = 0x%02X", 424 "data2 = 0x%02X, data3 = 0x%02X, data4 = 0x%02X, data5 = 0x%02X",
417 n, data0, data1, data2, data3, data4, data5) 425 n, data0, data1, data2, data3, data4, data5);
418 426
419 return err ? -1 : 0; 427 return err ? -1 : 0;
420} 428}
@@ -461,13 +469,27 @@ int sn9c102_i2c_write(struct sn9c102_device* cam, u8 address, u8 value)
461static void* 469static void*
462sn9c102_find_sof_header(struct sn9c102_device* cam, void* mem, size_t len) 470sn9c102_find_sof_header(struct sn9c102_device* cam, void* mem, size_t len)
463{ 471{
464 size_t soflen = sizeof(sn9c102_sof_header_t), i; 472 size_t soflen = 0, i;
465 u8 j, n = sizeof(sn9c102_sof_header) / soflen; 473 u8 j, n = 0;
466 474
467 for (i = 0; (len >= soflen) && (i <= len - soflen); i++) 475 switch (cam->bridge) {
476 case BRIDGE_SN9C101:
477 case BRIDGE_SN9C102:
478 soflen = sizeof(sn9c102_sof_header_t);
479 n = sizeof(sn9c102_sof_header) / soflen;
480 break;
481 case BRIDGE_SN9C103:
482 soflen = sizeof(sn9c103_sof_header_t);
483 n = sizeof(sn9c103_sof_header) / soflen;
484 }
485
486 for (i = 0; (len >= soflen) && (i <= len - soflen); i++)
468 for (j = 0; j < n; j++) 487 for (j = 0; j < n; j++)
469 /* It's enough to compare 7 bytes */ 488 /* The invariable part of the header is 6 bytes long */
470 if (!memcmp(mem + i, sn9c102_sof_header[j], 7)) { 489 if ((cam->bridge != BRIDGE_SN9C103 &&
490 !memcmp(mem + i, sn9c102_sof_header[j], 6)) ||
491 (cam->bridge == BRIDGE_SN9C103 &&
492 !memcmp(mem + i, sn9c103_sof_header[j], 6))) {
471 memcpy(cam->sof_header, mem + i, soflen); 493 memcpy(cam->sof_header, mem + i, soflen);
472 /* Skip the header */ 494 /* Skip the header */
473 return mem + i + soflen; 495 return mem + i + soflen;
@@ -499,8 +521,7 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs)
499{ 521{
500 struct sn9c102_device* cam = urb->context; 522 struct sn9c102_device* cam = urb->context;
501 struct sn9c102_frame_t** f; 523 struct sn9c102_frame_t** f;
502 size_t imagesize; 524 size_t imagesize, soflen;
503 unsigned long lock_flags;
504 u8 i; 525 u8 i;
505 int err = 0; 526 int err = 0;
506 527
@@ -513,7 +534,7 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs)
513 cam->stream = STREAM_OFF; 534 cam->stream = STREAM_OFF;
514 if ((*f)) 535 if ((*f))
515 (*f)->state = F_QUEUED; 536 (*f)->state = F_QUEUED;
516 DBG(3, "Stream interrupted") 537 DBG(3, "Stream interrupted");
517 wake_up_interruptible(&cam->wait_stream); 538 wake_up_interruptible(&cam->wait_stream);
518 } 539 }
519 540
@@ -536,6 +557,10 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs)
536 cam->sensor->pix_format.height * 557 cam->sensor->pix_format.height *
537 cam->sensor->pix_format.priv) / 8; 558 cam->sensor->pix_format.priv) / 8;
538 559
560 soflen = (cam->bridge) == BRIDGE_SN9C103 ?
561 sizeof(sn9c103_sof_header_t) :
562 sizeof(sn9c102_sof_header_t);
563
539 for (i = 0; i < urb->number_of_packets; i++) { 564 for (i = 0; i < urb->number_of_packets; i++) {
540 unsigned int img, len, status; 565 unsigned int img, len, status;
541 void *pos, *sof, *eof; 566 void *pos, *sof, *eof;
@@ -545,19 +570,12 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs)
545 pos = urb->iso_frame_desc[i].offset + urb->transfer_buffer; 570 pos = urb->iso_frame_desc[i].offset + urb->transfer_buffer;
546 571
547 if (status) { 572 if (status) {
548 DBG(3, "Error in isochronous frame") 573 DBG(3, "Error in isochronous frame");
549 (*f)->state = F_ERROR; 574 (*f)->state = F_ERROR;
550 continue; 575 continue;
551 } 576 }
552 577
553 PDBGG("Isochrnous frame: length %u, #%u i", len, i) 578 PDBGG("Isochrnous frame: length %u, #%u i", len, i);
554
555 /*
556 NOTE: It is probably correct to assume that SOF and EOF
557 headers do not occur between two consecutive packets,
558 but who knows..Whatever is the truth, this assumption
559 doesn't introduce bugs.
560 */
561 579
562redo: 580redo:
563 sof = sn9c102_find_sof_header(cam, pos, len); 581 sof = sn9c102_find_sof_header(cam, pos, len);
@@ -575,10 +593,10 @@ end_of_frame:
575 imagesize; 593 imagesize;
576 img = imagesize - (*f)->buf.bytesused; 594 img = imagesize - (*f)->buf.bytesused;
577 DBG(3, "Expected EOF not found: " 595 DBG(3, "Expected EOF not found: "
578 "video frame cut") 596 "video frame cut");
579 if (eof) 597 if (eof)
580 DBG(3, "Exceeded limit: +%u " 598 DBG(3, "Exceeded limit: +%u "
581 "bytes", (unsigned)(b)) 599 "bytes", (unsigned)(b));
582 } 600 }
583 601
584 memcpy((*f)->bufmem + (*f)->buf.bytesused, pos, 602 memcpy((*f)->bufmem + (*f)->buf.bytesused, pos,
@@ -595,8 +613,7 @@ end_of_frame:
595 u32 b = (*f)->buf.bytesused; 613 u32 b = (*f)->buf.bytesused;
596 (*f)->state = F_DONE; 614 (*f)->state = F_DONE;
597 (*f)->buf.sequence= ++cam->frame_count; 615 (*f)->buf.sequence= ++cam->frame_count;
598 spin_lock_irqsave(&cam->queue_lock, 616 spin_lock(&cam->queue_lock);
599 lock_flags);
600 list_move_tail(&(*f)->frame, 617 list_move_tail(&(*f)->frame,
601 &cam->outqueue); 618 &cam->outqueue);
602 if (!list_empty(&cam->inqueue)) 619 if (!list_empty(&cam->inqueue))
@@ -606,13 +623,11 @@ end_of_frame:
606 frame ); 623 frame );
607 else 624 else
608 (*f) = NULL; 625 (*f) = NULL;
609 spin_unlock_irqrestore(&cam->queue_lock 626 spin_unlock(&cam->queue_lock);
610 , lock_flags);
611 memcpy(cam->sysfs.frame_header, 627 memcpy(cam->sysfs.frame_header,
612 cam->sof_header, 628 cam->sof_header, soflen);
613 sizeof(sn9c102_sof_header_t)); 629 DBG(3, "Video frame captured: %lu "
614 DBG(3, "Video frame captured: " 630 "bytes", (unsigned long)(b));
615 "%lu bytes", (unsigned long)(b))
616 631
617 if (!(*f)) 632 if (!(*f))
618 goto resubmit_urb; 633 goto resubmit_urb;
@@ -621,18 +636,19 @@ end_of_frame:
621 (*f)->state = F_ERROR; 636 (*f)->state = F_ERROR;
622 DBG(3, "Not expected EOF after %lu " 637 DBG(3, "Not expected EOF after %lu "
623 "bytes of image data", 638 "bytes of image data",
624 (unsigned long)((*f)->buf.bytesused)) 639 (unsigned long)
640 ((*f)->buf.bytesused));
625 } 641 }
626 642
627 if (sof) /* (1) */ 643 if (sof) /* (1) */
628 goto start_of_frame; 644 goto start_of_frame;
629 645
630 } else if (eof) { 646 } else if (eof) {
631 DBG(3, "EOF without SOF") 647 DBG(3, "EOF without SOF");
632 continue; 648 continue;
633 649
634 } else { 650 } else {
635 PDBGG("Ignoring pointless isochronous frame") 651 PDBGG("Ignoring pointless isochronous frame");
636 continue; 652 continue;
637 } 653 }
638 654
@@ -642,7 +658,7 @@ start_of_frame:
642 (*f)->buf.bytesused = 0; 658 (*f)->buf.bytesused = 0;
643 len -= (sof - pos); 659 len -= (sof - pos);
644 pos = sof; 660 pos = sof;
645 DBG(3, "SOF detected: new video frame") 661 DBG(3, "SOF detected: new video frame");
646 if (len) 662 if (len)
647 goto redo; 663 goto redo;
648 664
@@ -653,12 +669,13 @@ start_of_frame:
653 else { 669 else {
654 if (cam->sensor->pix_format.pixelformat == 670 if (cam->sensor->pix_format.pixelformat ==
655 V4L2_PIX_FMT_SN9C10X) { 671 V4L2_PIX_FMT_SN9C10X) {
656 eof = sof-sizeof(sn9c102_sof_header_t); 672 eof = sof - soflen;
657 goto end_of_frame; 673 goto end_of_frame;
658 } else { 674 } else {
659 DBG(3, "SOF before expected EOF after " 675 DBG(3, "SOF before expected EOF after "
660 "%lu bytes of image data", 676 "%lu bytes of image data",
661 (unsigned long)((*f)->buf.bytesused)) 677 (unsigned long)
678 ((*f)->buf.bytesused));
662 goto start_of_frame; 679 goto start_of_frame;
663 } 680 }
664 } 681 }
@@ -670,7 +687,7 @@ resubmit_urb:
670 err = usb_submit_urb(urb, GFP_ATOMIC); 687 err = usb_submit_urb(urb, GFP_ATOMIC);
671 if (err < 0 && err != -EPERM) { 688 if (err < 0 && err != -EPERM) {
672 cam->state |= DEV_MISCONFIGURED; 689 cam->state |= DEV_MISCONFIGURED;
673 DBG(1, "usb_submit_urb() failed") 690 DBG(1, "usb_submit_urb() failed");
674 } 691 }
675 692
676 wake_up_interruptible(&cam->wait_frame); 693 wake_up_interruptible(&cam->wait_frame);
@@ -681,18 +698,22 @@ static int sn9c102_start_transfer(struct sn9c102_device* cam)
681{ 698{
682 struct usb_device *udev = cam->usbdev; 699 struct usb_device *udev = cam->usbdev;
683 struct urb* urb; 700 struct urb* urb;
684 const unsigned int wMaxPacketSize[] = {0, 128, 256, 384, 512, 701 const unsigned int sn9c102_wMaxPacketSize[] = {0, 128, 256, 384, 512,
685 680, 800, 900, 1023}; 702 680, 800, 900, 1023};
686 const unsigned int psz = wMaxPacketSize[SN9C102_ALTERNATE_SETTING]; 703 const unsigned int sn9c103_wMaxPacketSize[] = {0, 128, 256, 384, 512,
704 680, 800, 900, 1003};
705 const unsigned int psz = (cam->bridge == BRIDGE_SN9C103) ?
706 sn9c103_wMaxPacketSize[SN9C102_ALTERNATE_SETTING] :
707 sn9c102_wMaxPacketSize[SN9C102_ALTERNATE_SETTING];
687 s8 i, j; 708 s8 i, j;
688 int err = 0; 709 int err = 0;
689 710
690 for (i = 0; i < SN9C102_URBS; i++) { 711 for (i = 0; i < SN9C102_URBS; i++) {
691 cam->transfer_buffer[i] = kmalloc(SN9C102_ISO_PACKETS * psz, 712 cam->transfer_buffer[i] = kzalloc(SN9C102_ISO_PACKETS * psz,
692 GFP_KERNEL); 713 GFP_KERNEL);
693 if (!cam->transfer_buffer[i]) { 714 if (!cam->transfer_buffer[i]) {
694 err = -ENOMEM; 715 err = -ENOMEM;
695 DBG(1, "Not enough memory") 716 DBG(1, "Not enough memory");
696 goto free_buffers; 717 goto free_buffers;
697 } 718 }
698 } 719 }
@@ -702,7 +723,7 @@ static int sn9c102_start_transfer(struct sn9c102_device* cam)
702 cam->urb[i] = urb; 723 cam->urb[i] = urb;
703 if (!urb) { 724 if (!urb) {
704 err = -ENOMEM; 725 err = -ENOMEM;
705 DBG(1, "usb_alloc_urb() failed") 726 DBG(1, "usb_alloc_urb() failed");
706 goto free_urbs; 727 goto free_urbs;
707 } 728 }
708 urb->dev = udev; 729 urb->dev = udev;
@@ -725,14 +746,14 @@ static int sn9c102_start_transfer(struct sn9c102_device* cam)
725 err = sn9c102_write_reg(cam, cam->reg[0x01] | 0x04, 0x01); 746 err = sn9c102_write_reg(cam, cam->reg[0x01] | 0x04, 0x01);
726 if (err) { 747 if (err) {
727 err = -EIO; 748 err = -EIO;
728 DBG(1, "I/O hardware error") 749 DBG(1, "I/O hardware error");
729 goto free_urbs; 750 goto free_urbs;
730 } 751 }
731 } 752 }
732 753
733 err = usb_set_interface(udev, 0, SN9C102_ALTERNATE_SETTING); 754 err = usb_set_interface(udev, 0, SN9C102_ALTERNATE_SETTING);
734 if (err) { 755 if (err) {
735 DBG(1, "usb_set_interface() failed") 756 DBG(1, "usb_set_interface() failed");
736 goto free_urbs; 757 goto free_urbs;
737 } 758 }
738 759
@@ -743,7 +764,7 @@ static int sn9c102_start_transfer(struct sn9c102_device* cam)
743 if (err) { 764 if (err) {
744 for (j = i-1; j >= 0; j--) 765 for (j = i-1; j >= 0; j--)
745 usb_kill_urb(cam->urb[j]); 766 usb_kill_urb(cam->urb[j]);
746 DBG(1, "usb_submit_urb() failed, error %d", err) 767 DBG(1, "usb_submit_urb() failed, error %d", err);
747 goto free_urbs; 768 goto free_urbs;
748 } 769 }
749 } 770 }
@@ -779,7 +800,7 @@ static int sn9c102_stop_transfer(struct sn9c102_device* cam)
779 800
780 err = usb_set_interface(udev, 0, 0); /* 0 Mb/s */ 801 err = usb_set_interface(udev, 0, 0); /* 0 Mb/s */
781 if (err) 802 if (err)
782 DBG(3, "usb_set_interface() failed") 803 DBG(3, "usb_set_interface() failed");
783 804
784 return err; 805 return err;
785} 806}
@@ -799,7 +820,7 @@ static int sn9c102_stream_interrupt(struct sn9c102_device* cam)
799 else if (err) { 820 else if (err) {
800 cam->state |= DEV_MISCONFIGURED; 821 cam->state |= DEV_MISCONFIGURED;
801 DBG(1, "The camera is misconfigured. To use it, close and " 822 DBG(1, "The camera is misconfigured. To use it, close and "
802 "open /dev/video%d again.", cam->v4ldev->minor) 823 "open /dev/video%d again.", cam->v4ldev->minor);
803 return err; 824 return err;
804 } 825 }
805 826
@@ -808,6 +829,7 @@ static int sn9c102_stream_interrupt(struct sn9c102_device* cam)
808 829
809/*****************************************************************************/ 830/*****************************************************************************/
810 831
832#ifdef CONFIG_VIDEO_ADV_DEBUG
811static u8 sn9c102_strtou8(const char* buff, size_t len, ssize_t* count) 833static u8 sn9c102_strtou8(const char* buff, size_t len, ssize_t* count)
812{ 834{
813 char str[5]; 835 char str[5];
@@ -885,8 +907,8 @@ sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len)
885 907
886 cam->sysfs.reg = index; 908 cam->sysfs.reg = index;
887 909
888 DBG(2, "Moved SN9C10X register index to 0x%02X", cam->sysfs.reg) 910 DBG(2, "Moved SN9C10X register index to 0x%02X", cam->sysfs.reg);
889 DBG(3, "Written bytes: %zd", count) 911 DBG(3, "Written bytes: %zd", count);
890 912
891 up(&sn9c102_sysfs_lock); 913 up(&sn9c102_sysfs_lock);
892 914
@@ -916,7 +938,7 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf)
916 938
917 count = sprintf(buf, "%d\n", val); 939 count = sprintf(buf, "%d\n", val);
918 940
919 DBG(3, "Read bytes: %zd", count) 941 DBG(3, "Read bytes: %zd", count);
920 942
921 up(&sn9c102_sysfs_lock); 943 up(&sn9c102_sysfs_lock);
922 944
@@ -954,8 +976,8 @@ sn9c102_store_val(struct class_device* cd, const char* buf, size_t len)
954 } 976 }
955 977
956 DBG(2, "Written SN9C10X reg. 0x%02X, val. 0x%02X", 978 DBG(2, "Written SN9C10X reg. 0x%02X, val. 0x%02X",
957 cam->sysfs.reg, value) 979 cam->sysfs.reg, value);
958 DBG(3, "Written bytes: %zd", count) 980 DBG(3, "Written bytes: %zd", count);
959 981
960 up(&sn9c102_sysfs_lock); 982 up(&sn9c102_sysfs_lock);
961 983
@@ -979,7 +1001,7 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf)
979 1001
980 count = sprintf(buf, "%u\n", cam->sysfs.i2c_reg); 1002 count = sprintf(buf, "%u\n", cam->sysfs.i2c_reg);
981 1003
982 DBG(3, "Read bytes: %zd", count) 1004 DBG(3, "Read bytes: %zd", count);
983 1005
984 up(&sn9c102_sysfs_lock); 1006 up(&sn9c102_sysfs_lock);
985 1007
@@ -1011,8 +1033,8 @@ sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len)
1011 1033
1012 cam->sysfs.i2c_reg = index; 1034 cam->sysfs.i2c_reg = index;
1013 1035
1014 DBG(2, "Moved sensor register index to 0x%02X", cam->sysfs.i2c_reg) 1036 DBG(2, "Moved sensor register index to 0x%02X", cam->sysfs.i2c_reg);
1015 DBG(3, "Written bytes: %zd", count) 1037 DBG(3, "Written bytes: %zd", count);
1016 1038
1017 up(&sn9c102_sysfs_lock); 1039 up(&sn9c102_sysfs_lock);
1018 1040
@@ -1047,7 +1069,7 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf)
1047 1069
1048 count = sprintf(buf, "%d\n", val); 1070 count = sprintf(buf, "%d\n", val);
1049 1071
1050 DBG(3, "Read bytes: %zd", count) 1072 DBG(3, "Read bytes: %zd", count);
1051 1073
1052 up(&sn9c102_sysfs_lock); 1074 up(&sn9c102_sysfs_lock);
1053 1075
@@ -1090,8 +1112,8 @@ sn9c102_store_i2c_val(struct class_device* cd, const char* buf, size_t len)
1090 } 1112 }
1091 1113
1092 DBG(2, "Written sensor reg. 0x%02X, val. 0x%02X", 1114 DBG(2, "Written sensor reg. 0x%02X, val. 0x%02X",
1093 cam->sysfs.i2c_reg, value) 1115 cam->sysfs.i2c_reg, value);
1094 DBG(3, "Written bytes: %zd", count) 1116 DBG(3, "Written bytes: %zd", count);
1095 1117
1096 up(&sn9c102_sysfs_lock); 1118 up(&sn9c102_sysfs_lock);
1097 1119
@@ -1193,7 +1215,7 @@ static ssize_t sn9c102_show_frame_header(struct class_device* cd, char* buf)
1193 count = sizeof(cam->sysfs.frame_header); 1215 count = sizeof(cam->sysfs.frame_header);
1194 memcpy(buf, cam->sysfs.frame_header, count); 1216 memcpy(buf, cam->sysfs.frame_header, count);
1195 1217
1196 DBG(3, "Frame header, read bytes: %zd", count) 1218 DBG(3, "Frame header, read bytes: %zd", count);
1197 1219
1198 return count; 1220 return count;
1199} 1221}
@@ -1227,11 +1249,12 @@ static void sn9c102_create_sysfs(struct sn9c102_device* cam)
1227 video_device_create_file(v4ldev, &class_device_attr_blue); 1249 video_device_create_file(v4ldev, &class_device_attr_blue);
1228 video_device_create_file(v4ldev, &class_device_attr_red); 1250 video_device_create_file(v4ldev, &class_device_attr_red);
1229 } 1251 }
1230 if (cam->sensor->sysfs_ops) { 1252 if (cam->sensor && cam->sensor->sysfs_ops) {
1231 video_device_create_file(v4ldev, &class_device_attr_i2c_reg); 1253 video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
1232 video_device_create_file(v4ldev, &class_device_attr_i2c_val); 1254 video_device_create_file(v4ldev, &class_device_attr_i2c_val);
1233 } 1255 }
1234} 1256}
1257#endif /* CONFIG_VIDEO_ADV_DEBUG */
1235 1258
1236/*****************************************************************************/ 1259/*****************************************************************************/
1237 1260
@@ -1281,7 +1304,7 @@ static int sn9c102_set_scale(struct sn9c102_device* cam, u8 scale)
1281 if (err) 1304 if (err)
1282 return -EIO; 1305 return -EIO;
1283 1306
1284 PDBGG("Scaling factor: %u", scale) 1307 PDBGG("Scaling factor: %u", scale);
1285 1308
1286 return 0; 1309 return 0;
1287} 1310}
@@ -1304,7 +1327,7 @@ static int sn9c102_set_crop(struct sn9c102_device* cam, struct v4l2_rect* rect)
1304 return -EIO; 1327 return -EIO;
1305 1328
1306 PDBGG("h_start, v_start, h_size, v_size, ho_size, vo_size " 1329 PDBGG("h_start, v_start, h_size, v_size, ho_size, vo_size "
1307 "%u %u %u %u", h_start, v_start, h_size, v_size) 1330 "%u %u %u %u", h_start, v_start, h_size, v_size);
1308 1331
1309 return 0; 1332 return 0;
1310} 1333}
@@ -1336,7 +1359,7 @@ static int sn9c102_init(struct sn9c102_device* cam)
1336 if (s->init) { 1359 if (s->init) {
1337 err = s->init(cam); 1360 err = s->init(cam);
1338 if (err) { 1361 if (err) {
1339 DBG(3, "Sensor initialization failed") 1362 DBG(3, "Sensor initialization failed");
1340 return err; 1363 return err;
1341 } 1364 }
1342 } 1365 }
@@ -1353,13 +1376,13 @@ static int sn9c102_init(struct sn9c102_device* cam)
1353 1376
1354 if (s->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X) 1377 if (s->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X)
1355 DBG(3, "Compressed video format is active, quality %d", 1378 DBG(3, "Compressed video format is active, quality %d",
1356 cam->compression.quality) 1379 cam->compression.quality);
1357 else 1380 else
1358 DBG(3, "Uncompressed video format is active") 1381 DBG(3, "Uncompressed video format is active");
1359 1382
1360 if (s->set_crop) 1383 if (s->set_crop)
1361 if ((err = s->set_crop(cam, rect))) { 1384 if ((err = s->set_crop(cam, rect))) {
1362 DBG(3, "set_crop() failed") 1385 DBG(3, "set_crop() failed");
1363 return err; 1386 return err;
1364 } 1387 }
1365 1388
@@ -1372,11 +1395,11 @@ static int sn9c102_init(struct sn9c102_device* cam)
1372 err = s->set_ctrl(cam, &ctrl); 1395 err = s->set_ctrl(cam, &ctrl);
1373 if (err) { 1396 if (err) {
1374 DBG(3, "Set %s control failed", 1397 DBG(3, "Set %s control failed",
1375 s->qctrl[i].name) 1398 s->qctrl[i].name);
1376 return err; 1399 return err;
1377 } 1400 }
1378 DBG(3, "Image sensor supports '%s' control", 1401 DBG(3, "Image sensor supports '%s' control",
1379 s->qctrl[i].name) 1402 s->qctrl[i].name);
1380 } 1403 }
1381 } 1404 }
1382 1405
@@ -1392,7 +1415,7 @@ static int sn9c102_init(struct sn9c102_device* cam)
1392 cam->state |= DEV_INITIALIZED; 1415 cam->state |= DEV_INITIALIZED;
1393 } 1416 }
1394 1417
1395 DBG(2, "Initialization succeeded") 1418 DBG(2, "Initialization succeeded");
1396 return 0; 1419 return 0;
1397} 1420}
1398 1421
@@ -1401,7 +1424,7 @@ static void sn9c102_release_resources(struct sn9c102_device* cam)
1401{ 1424{
1402 down(&sn9c102_sysfs_lock); 1425 down(&sn9c102_sysfs_lock);
1403 1426
1404 DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->minor) 1427 DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->minor);
1405 video_set_drvdata(cam->v4ldev, NULL); 1428 video_set_drvdata(cam->v4ldev, NULL);
1406 video_unregister_device(cam->v4ldev); 1429 video_unregister_device(cam->v4ldev);
1407 1430
@@ -1432,7 +1455,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp)
1432 } 1455 }
1433 1456
1434 if (cam->users) { 1457 if (cam->users) {
1435 DBG(2, "Device /dev/video%d is busy...", cam->v4ldev->minor) 1458 DBG(2, "Device /dev/video%d is busy...", cam->v4ldev->minor);
1436 if ((filp->f_flags & O_NONBLOCK) || 1459 if ((filp->f_flags & O_NONBLOCK) ||
1437 (filp->f_flags & O_NDELAY)) { 1460 (filp->f_flags & O_NDELAY)) {
1438 err = -EWOULDBLOCK; 1461 err = -EWOULDBLOCK;
@@ -1458,7 +1481,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp)
1458 err = sn9c102_init(cam); 1481 err = sn9c102_init(cam);
1459 if (err) { 1482 if (err) {
1460 DBG(1, "Initialization failed again. " 1483 DBG(1, "Initialization failed again. "
1461 "I will retry on next open().") 1484 "I will retry on next open().");
1462 goto out; 1485 goto out;
1463 } 1486 }
1464 cam->state &= ~DEV_MISCONFIGURED; 1487 cam->state &= ~DEV_MISCONFIGURED;
@@ -1475,7 +1498,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp)
1475 cam->frame_count = 0; 1498 cam->frame_count = 0;
1476 sn9c102_empty_framequeues(cam); 1499 sn9c102_empty_framequeues(cam);
1477 1500
1478 DBG(3, "Video device /dev/video%d is open", cam->v4ldev->minor) 1501 DBG(3, "Video device /dev/video%d is open", cam->v4ldev->minor);
1479 1502
1480out: 1503out:
1481 up(&cam->dev_sem); 1504 up(&cam->dev_sem);
@@ -1504,7 +1527,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp)
1504 cam->users--; 1527 cam->users--;
1505 wake_up_interruptible_nr(&cam->open, 1); 1528 wake_up_interruptible_nr(&cam->open, 1);
1506 1529
1507 DBG(3, "Video device /dev/video%d closed", cam->v4ldev->minor) 1530 DBG(3, "Video device /dev/video%d closed", cam->v4ldev->minor);
1508 1531
1509 up(&cam->dev_sem); 1532 up(&cam->dev_sem);
1510 1533
@@ -1524,32 +1547,38 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
1524 return -ERESTARTSYS; 1547 return -ERESTARTSYS;
1525 1548
1526 if (cam->state & DEV_DISCONNECTED) { 1549 if (cam->state & DEV_DISCONNECTED) {
1527 DBG(1, "Device not present") 1550 DBG(1, "Device not present");
1528 up(&cam->fileop_sem); 1551 up(&cam->fileop_sem);
1529 return -ENODEV; 1552 return -ENODEV;
1530 } 1553 }
1531 1554
1532 if (cam->state & DEV_MISCONFIGURED) { 1555 if (cam->state & DEV_MISCONFIGURED) {
1533 DBG(1, "The camera is misconfigured. Close and open it again.") 1556 DBG(1, "The camera is misconfigured. Close and open it "
1557 "again.");
1534 up(&cam->fileop_sem); 1558 up(&cam->fileop_sem);
1535 return -EIO; 1559 return -EIO;
1536 } 1560 }
1537 1561
1538 if (cam->io == IO_MMAP) { 1562 if (cam->io == IO_MMAP) {
1539 DBG(3, "Close and open the device again to choose " 1563 DBG(3, "Close and open the device again to choose "
1540 "the read method") 1564 "the read method");
1541 up(&cam->fileop_sem); 1565 up(&cam->fileop_sem);
1542 return -EINVAL; 1566 return -EINVAL;
1543 } 1567 }
1544 1568
1545 if (cam->io == IO_NONE) { 1569 if (cam->io == IO_NONE) {
1546 if (!sn9c102_request_buffers(cam,cam->nreadbuffers, IO_READ)) { 1570 if (!sn9c102_request_buffers(cam,cam->nreadbuffers, IO_READ)) {
1547 DBG(1, "read() failed, not enough memory") 1571 DBG(1, "read() failed, not enough memory");
1548 up(&cam->fileop_sem); 1572 up(&cam->fileop_sem);
1549 return -ENOMEM; 1573 return -ENOMEM;
1550 } 1574 }
1551 cam->io = IO_READ; 1575 cam->io = IO_READ;
1552 cam->stream = STREAM_ON; 1576 cam->stream = STREAM_ON;
1577 }
1578
1579 if (list_empty(&cam->inqueue)) {
1580 if (!list_empty(&cam->outqueue))
1581 sn9c102_empty_framequeues(cam);
1553 sn9c102_queue_unusedframes(cam); 1582 sn9c102_queue_unusedframes(cam);
1554 } 1583 }
1555 1584
@@ -1584,6 +1613,16 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
1584 1613
1585 f = list_entry(cam->outqueue.prev, struct sn9c102_frame_t, frame); 1614 f = list_entry(cam->outqueue.prev, struct sn9c102_frame_t, frame);
1586 1615
1616 if (count > f->buf.bytesused)
1617 count = f->buf.bytesused;
1618
1619 if (copy_to_user(buf, f->bufmem, count)) {
1620 err = -EFAULT;
1621 goto exit;
1622 }
1623 *f_pos += count;
1624
1625exit:
1587 spin_lock_irqsave(&cam->queue_lock, lock_flags); 1626 spin_lock_irqsave(&cam->queue_lock, lock_flags);
1588 list_for_each_entry(i, &cam->outqueue, frame) 1627 list_for_each_entry(i, &cam->outqueue, frame)
1589 i->state = F_UNUSED; 1628 i->state = F_UNUSED;
@@ -1592,16 +1631,8 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
1592 1631
1593 sn9c102_queue_unusedframes(cam); 1632 sn9c102_queue_unusedframes(cam);
1594 1633
1595 if (count > f->buf.bytesused) 1634 PDBGG("Frame #%lu, bytes read: %zu",
1596 count = f->buf.bytesused; 1635 (unsigned long)f->buf.index, count);
1597
1598 if (copy_to_user(buf, f->bufmem, count)) {
1599 up(&cam->fileop_sem);
1600 return -EFAULT;
1601 }
1602 *f_pos += count;
1603
1604 PDBGG("Frame #%lu, bytes read: %zu", (unsigned long)f->buf.index,count)
1605 1636
1606 up(&cam->fileop_sem); 1637 up(&cam->fileop_sem);
1607 1638
@@ -1612,33 +1643,42 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
1612static unsigned int sn9c102_poll(struct file *filp, poll_table *wait) 1643static unsigned int sn9c102_poll(struct file *filp, poll_table *wait)
1613{ 1644{
1614 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 1645 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
1646 struct sn9c102_frame_t* f;
1647 unsigned long lock_flags;
1615 unsigned int mask = 0; 1648 unsigned int mask = 0;
1616 1649
1617 if (down_interruptible(&cam->fileop_sem)) 1650 if (down_interruptible(&cam->fileop_sem))
1618 return POLLERR; 1651 return POLLERR;
1619 1652
1620 if (cam->state & DEV_DISCONNECTED) { 1653 if (cam->state & DEV_DISCONNECTED) {
1621 DBG(1, "Device not present") 1654 DBG(1, "Device not present");
1622 goto error; 1655 goto error;
1623 } 1656 }
1624 1657
1625 if (cam->state & DEV_MISCONFIGURED) { 1658 if (cam->state & DEV_MISCONFIGURED) {
1626 DBG(1, "The camera is misconfigured. Close and open it again.") 1659 DBG(1, "The camera is misconfigured. Close and open it "
1660 "again.");
1627 goto error; 1661 goto error;
1628 } 1662 }
1629 1663
1630 if (cam->io == IO_NONE) { 1664 if (cam->io == IO_NONE) {
1631 if (!sn9c102_request_buffers(cam, cam->nreadbuffers, 1665 if (!sn9c102_request_buffers(cam, cam->nreadbuffers,
1632 IO_READ)) { 1666 IO_READ)) {
1633 DBG(1, "poll() failed, not enough memory") 1667 DBG(1, "poll() failed, not enough memory");
1634 goto error; 1668 goto error;
1635 } 1669 }
1636 cam->io = IO_READ; 1670 cam->io = IO_READ;
1637 cam->stream = STREAM_ON; 1671 cam->stream = STREAM_ON;
1638 } 1672 }
1639 1673
1640 if (cam->io == IO_READ) 1674 if (cam->io == IO_READ) {
1675 spin_lock_irqsave(&cam->queue_lock, lock_flags);
1676 list_for_each_entry(f, &cam->outqueue, frame)
1677 f->state = F_UNUSED;
1678 INIT_LIST_HEAD(&cam->outqueue);
1679 spin_unlock_irqrestore(&cam->queue_lock, lock_flags);
1641 sn9c102_queue_unusedframes(cam); 1680 sn9c102_queue_unusedframes(cam);
1681 }
1642 1682
1643 poll_wait(filp, &cam->wait_frame, wait); 1683 poll_wait(filp, &cam->wait_frame, wait);
1644 1684
@@ -1680,22 +1720,22 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma)
1680{ 1720{
1681 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 1721 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
1682 unsigned long size = vma->vm_end - vma->vm_start, 1722 unsigned long size = vma->vm_end - vma->vm_start,
1683 start = vma->vm_start, 1723 start = vma->vm_start;
1684 pos, 1724 void *pos;
1685 page;
1686 u32 i; 1725 u32 i;
1687 1726
1688 if (down_interruptible(&cam->fileop_sem)) 1727 if (down_interruptible(&cam->fileop_sem))
1689 return -ERESTARTSYS; 1728 return -ERESTARTSYS;
1690 1729
1691 if (cam->state & DEV_DISCONNECTED) { 1730 if (cam->state & DEV_DISCONNECTED) {
1692 DBG(1, "Device not present") 1731 DBG(1, "Device not present");
1693 up(&cam->fileop_sem); 1732 up(&cam->fileop_sem);
1694 return -ENODEV; 1733 return -ENODEV;
1695 } 1734 }
1696 1735
1697 if (cam->state & DEV_MISCONFIGURED) { 1736 if (cam->state & DEV_MISCONFIGURED) {
1698 DBG(1, "The camera is misconfigured. Close and open it again.") 1737 DBG(1, "The camera is misconfigured. Close and open it "
1738 "again.");
1699 up(&cam->fileop_sem); 1739 up(&cam->fileop_sem);
1700 return -EIO; 1740 return -EIO;
1701 } 1741 }
@@ -1715,15 +1755,12 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma)
1715 return -EINVAL; 1755 return -EINVAL;
1716 } 1756 }
1717 1757
1718 /* VM_IO is eventually going to replace PageReserved altogether */
1719 vma->vm_flags |= VM_IO; 1758 vma->vm_flags |= VM_IO;
1720 vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */ 1759 vma->vm_flags |= VM_RESERVED;
1721 1760
1722 pos = (unsigned long)cam->frame[i].bufmem; 1761 pos = cam->frame[i].bufmem;
1723 while (size > 0) { /* size is page-aligned */ 1762 while (size > 0) { /* size is page-aligned */
1724 page = vmalloc_to_pfn((void *)pos); 1763 if (vm_insert_page(vma, start, vmalloc_to_page(pos))) {
1725 if (remap_pfn_range(vma, start, page, PAGE_SIZE,
1726 vma->vm_page_prot)) {
1727 up(&cam->fileop_sem); 1764 up(&cam->fileop_sem);
1728 return -EAGAIN; 1765 return -EAGAIN;
1729 } 1766 }
@@ -1742,738 +1779,861 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma)
1742 return 0; 1779 return 0;
1743} 1780}
1744 1781
1782/*****************************************************************************/
1745 1783
1746static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, 1784static int
1747 unsigned int cmd, void __user * arg) 1785sn9c102_vidioc_querycap(struct sn9c102_device* cam, void __user * arg)
1748{ 1786{
1749 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); 1787 struct v4l2_capability cap = {
1788 .driver = "sn9c102",
1789 .version = SN9C102_MODULE_VERSION_CODE,
1790 .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1791 V4L2_CAP_STREAMING,
1792 };
1793
1794 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
1795 if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
1796 strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
1797 sizeof(cap.bus_info));
1798
1799 if (copy_to_user(arg, &cap, sizeof(cap)))
1800 return -EFAULT;
1750 1801
1751 switch (cmd) { 1802 return 0;
1803}
1752 1804
1753 case VIDIOC_QUERYCAP:
1754 {
1755 struct v4l2_capability cap = {
1756 .driver = "sn9c102",
1757 .version = SN9C102_MODULE_VERSION_CODE,
1758 .capabilities = V4L2_CAP_VIDEO_CAPTURE |
1759 V4L2_CAP_READWRITE |
1760 V4L2_CAP_STREAMING,
1761 };
1762
1763 strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
1764 if (usb_make_path(cam->usbdev, cap.bus_info,
1765 sizeof(cap.bus_info)) < 0)
1766 strlcpy(cap.bus_info, cam->dev.bus_id,
1767 sizeof(cap.bus_info));
1768
1769 if (copy_to_user(arg, &cap, sizeof(cap)))
1770 return -EFAULT;
1771 1805
1772 return 0; 1806static int
1773 } 1807sn9c102_vidioc_enuminput(struct sn9c102_device* cam, void __user * arg)
1808{
1809 struct v4l2_input i;
1774 1810
1775 case VIDIOC_ENUMINPUT: 1811 if (copy_from_user(&i, arg, sizeof(i)))
1776 { 1812 return -EFAULT;
1777 struct v4l2_input i;
1778 1813
1779 if (copy_from_user(&i, arg, sizeof(i))) 1814 if (i.index)
1780 return -EFAULT; 1815 return -EINVAL;
1781 1816
1782 if (i.index) 1817 memset(&i, 0, sizeof(i));
1783 return -EINVAL; 1818 strcpy(i.name, "Camera");
1784 1819
1785 memset(&i, 0, sizeof(i)); 1820 if (copy_to_user(arg, &i, sizeof(i)))
1786 strcpy(i.name, "USB"); 1821 return -EFAULT;
1787 1822
1788 if (copy_to_user(arg, &i, sizeof(i))) 1823 return 0;
1789 return -EFAULT; 1824}
1790 1825
1791 return 0;
1792 }
1793 1826
1794 case VIDIOC_G_INPUT: 1827static int
1795 case VIDIOC_S_INPUT: 1828sn9c102_vidioc_gs_input(struct sn9c102_device* cam, void __user * arg)
1796 { 1829{
1797 int index; 1830 int index;
1798 1831
1799 if (copy_from_user(&index, arg, sizeof(index))) 1832 if (copy_from_user(&index, arg, sizeof(index)))
1800 return -EFAULT; 1833 return -EFAULT;
1801 1834
1802 if (index != 0) 1835 if (index != 0)
1803 return -EINVAL; 1836 return -EINVAL;
1804 1837
1805 return 0; 1838 return 0;
1806 } 1839}
1807 1840
1808 case VIDIOC_QUERYCTRL:
1809 {
1810 struct sn9c102_sensor* s = cam->sensor;
1811 struct v4l2_queryctrl qc;
1812 u8 i;
1813 1841
1814 if (copy_from_user(&qc, arg, sizeof(qc))) 1842static int
1815 return -EFAULT; 1843sn9c102_vidioc_query_ctrl(struct sn9c102_device* cam, void __user * arg)
1844{
1845 struct sn9c102_sensor* s = cam->sensor;
1846 struct v4l2_queryctrl qc;
1847 u8 i;
1816 1848
1849 if (copy_from_user(&qc, arg, sizeof(qc)))
1850 return -EFAULT;
1851
1852 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1853 if (qc.id && qc.id == s->qctrl[i].id) {
1854 memcpy(&qc, &(s->qctrl[i]), sizeof(qc));
1855 if (copy_to_user(arg, &qc, sizeof(qc)))
1856 return -EFAULT;
1857 return 0;
1858 }
1859
1860 return -EINVAL;
1861}
1862
1863
1864static int
1865sn9c102_vidioc_g_ctrl(struct sn9c102_device* cam, void __user * arg)
1866{
1867 struct sn9c102_sensor* s = cam->sensor;
1868 struct v4l2_control ctrl;
1869 int err = 0;
1870 u8 i;
1871
1872 if (!s->get_ctrl && !s->set_ctrl)
1873 return -EINVAL;
1874
1875 if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
1876 return -EFAULT;
1877
1878 if (!s->get_ctrl) {
1817 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) 1879 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1818 if (qc.id && qc.id == s->qctrl[i].id) { 1880 if (ctrl.id && ctrl.id == s->qctrl[i].id) {
1819 memcpy(&qc, &(s->qctrl[i]), sizeof(qc)); 1881 ctrl.value = s->_qctrl[i].default_value;
1820 if (copy_to_user(arg, &qc, sizeof(qc))) 1882 goto exit;
1821 return -EFAULT;
1822 return 0;
1823 } 1883 }
1824
1825 return -EINVAL; 1884 return -EINVAL;
1826 } 1885 } else
1886 err = s->get_ctrl(cam, &ctrl);
1827 1887
1828 case VIDIOC_G_CTRL: 1888exit:
1829 { 1889 if (copy_to_user(arg, &ctrl, sizeof(ctrl)))
1830 struct sn9c102_sensor* s = cam->sensor; 1890 return -EFAULT;
1831 struct v4l2_control ctrl;
1832 int err = 0;
1833 1891
1834 if (!s->get_ctrl) 1892 return err;
1835 return -EINVAL; 1893}
1836 1894
1837 if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
1838 return -EFAULT;
1839 1895
1840 err = s->get_ctrl(cam, &ctrl); 1896static int
1897sn9c102_vidioc_s_ctrl(struct sn9c102_device* cam, void __user * arg)
1898{
1899 struct sn9c102_sensor* s = cam->sensor;
1900 struct v4l2_control ctrl;
1901 u8 i;
1902 int err = 0;
1841 1903
1842 if (copy_to_user(arg, &ctrl, sizeof(ctrl))) 1904 if (!s->set_ctrl)
1843 return -EFAULT; 1905 return -EINVAL;
1906
1907 if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
1908 return -EFAULT;
1844 1909
1910 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1911 if (ctrl.id == s->qctrl[i].id) {
1912 if (ctrl.value < s->qctrl[i].minimum ||
1913 ctrl.value > s->qctrl[i].maximum)
1914 return -ERANGE;
1915 ctrl.value -= ctrl.value % s->qctrl[i].step;
1916 break;
1917 }
1918
1919 if ((err = s->set_ctrl(cam, &ctrl)))
1845 return err; 1920 return err;
1846 }
1847 1921
1848 case VIDIOC_S_CTRL_OLD: 1922 s->_qctrl[i].default_value = ctrl.value;
1849 case VIDIOC_S_CTRL:
1850 {
1851 struct sn9c102_sensor* s = cam->sensor;
1852 struct v4l2_control ctrl;
1853 u8 i;
1854 int err = 0;
1855 1923
1856 if (!s->set_ctrl) 1924 PDBGG("VIDIOC_S_CTRL: id %lu, value %lu",
1857 return -EINVAL; 1925 (unsigned long)ctrl.id, (unsigned long)ctrl.value);
1858 1926
1859 if (copy_from_user(&ctrl, arg, sizeof(ctrl))) 1927 return 0;
1860 return -EFAULT; 1928}
1861 1929
1862 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) 1930
1863 if (ctrl.id == s->qctrl[i].id) { 1931static int
1864 if (ctrl.value < s->qctrl[i].minimum || 1932sn9c102_vidioc_cropcap(struct sn9c102_device* cam, void __user * arg)
1865 ctrl.value > s->qctrl[i].maximum) 1933{
1866 return -ERANGE; 1934 struct v4l2_cropcap* cc = &(cam->sensor->cropcap);
1867 ctrl.value -= ctrl.value % s->qctrl[i].step; 1935
1868 break; 1936 cc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1937 cc->pixelaspect.numerator = 1;
1938 cc->pixelaspect.denominator = 1;
1939
1940 if (copy_to_user(arg, cc, sizeof(*cc)))
1941 return -EFAULT;
1942
1943 return 0;
1944}
1945
1946
1947static int
1948sn9c102_vidioc_g_crop(struct sn9c102_device* cam, void __user * arg)
1949{
1950 struct sn9c102_sensor* s = cam->sensor;
1951 struct v4l2_crop crop = {
1952 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
1953 };
1954
1955 memcpy(&(crop.c), &(s->_rect), sizeof(struct v4l2_rect));
1956
1957 if (copy_to_user(arg, &crop, sizeof(crop)))
1958 return -EFAULT;
1959
1960 return 0;
1961}
1962
1963
1964static int
1965sn9c102_vidioc_s_crop(struct sn9c102_device* cam, void __user * arg)
1966{
1967 struct sn9c102_sensor* s = cam->sensor;
1968 struct v4l2_crop crop;
1969 struct v4l2_rect* rect;
1970 struct v4l2_rect* bounds = &(s->cropcap.bounds);
1971 struct v4l2_pix_format* pix_format = &(s->pix_format);
1972 u8 scale;
1973 const enum sn9c102_stream_state stream = cam->stream;
1974 const u32 nbuffers = cam->nbuffers;
1975 u32 i;
1976 int err = 0;
1977
1978 if (copy_from_user(&crop, arg, sizeof(crop)))
1979 return -EFAULT;
1980
1981 rect = &(crop.c);
1982
1983 if (crop.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1984 return -EINVAL;
1985
1986 if (cam->module_param.force_munmap)
1987 for (i = 0; i < cam->nbuffers; i++)
1988 if (cam->frame[i].vma_use_count) {
1989 DBG(3, "VIDIOC_S_CROP failed. "
1990 "Unmap the buffers first.");
1991 return -EINVAL;
1869 } 1992 }
1870 1993
1871 if ((err = s->set_ctrl(cam, &ctrl))) 1994 /* Preserve R,G or B origin */
1995 rect->left = (s->_rect.left & 1L) ? rect->left | 1L : rect->left & ~1L;
1996 rect->top = (s->_rect.top & 1L) ? rect->top | 1L : rect->top & ~1L;
1997
1998 if (rect->width < 16)
1999 rect->width = 16;
2000 if (rect->height < 16)
2001 rect->height = 16;
2002 if (rect->width > bounds->width)
2003 rect->width = bounds->width;
2004 if (rect->height > bounds->height)
2005 rect->height = bounds->height;
2006 if (rect->left < bounds->left)
2007 rect->left = bounds->left;
2008 if (rect->top < bounds->top)
2009 rect->top = bounds->top;
2010 if (rect->left + rect->width > bounds->left + bounds->width)
2011 rect->left = bounds->left+bounds->width - rect->width;
2012 if (rect->top + rect->height > bounds->top + bounds->height)
2013 rect->top = bounds->top+bounds->height - rect->height;
2014
2015 rect->width &= ~15L;
2016 rect->height &= ~15L;
2017
2018 if (SN9C102_PRESERVE_IMGSCALE) {
2019 /* Calculate the actual scaling factor */
2020 u32 a, b;
2021 a = rect->width * rect->height;
2022 b = pix_format->width * pix_format->height;
2023 scale = b ? (u8)((a / b) < 4 ? 1 : ((a / b) < 16 ? 2 : 4)) : 1;
2024 } else
2025 scale = 1;
2026
2027 if (cam->stream == STREAM_ON)
2028 if ((err = sn9c102_stream_interrupt(cam)))
1872 return err; 2029 return err;
1873 2030
1874 s->_qctrl[i].default_value = ctrl.value; 2031 if (copy_to_user(arg, &crop, sizeof(crop))) {
2032 cam->stream = stream;
2033 return -EFAULT;
2034 }
2035
2036 if (cam->module_param.force_munmap || cam->io == IO_READ)
2037 sn9c102_release_buffers(cam);
1875 2038
1876 PDBGG("VIDIOC_S_CTRL: id %lu, value %lu", 2039 err = sn9c102_set_crop(cam, rect);
1877 (unsigned long)ctrl.id, (unsigned long)ctrl.value) 2040 if (s->set_crop)
2041 err += s->set_crop(cam, rect);
2042 err += sn9c102_set_scale(cam, scale);
1878 2043
1879 return 0; 2044 if (err) { /* atomic, no rollback in ioctl() */
2045 cam->state |= DEV_MISCONFIGURED;
2046 DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To "
2047 "use the camera, close and open /dev/video%d again.",
2048 cam->v4ldev->minor);
2049 return -EIO;
1880 } 2050 }
1881 2051
1882 case VIDIOC_CROPCAP: 2052 s->pix_format.width = rect->width/scale;
1883 { 2053 s->pix_format.height = rect->height/scale;
1884 struct v4l2_cropcap* cc = &(cam->sensor->cropcap); 2054 memcpy(&(s->_rect), rect, sizeof(*rect));
1885 2055
1886 cc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 2056 if ((cam->module_param.force_munmap || cam->io == IO_READ) &&
1887 cc->pixelaspect.numerator = 1; 2057 nbuffers != sn9c102_request_buffers(cam, nbuffers, cam->io)) {
1888 cc->pixelaspect.denominator = 1; 2058 cam->state |= DEV_MISCONFIGURED;
2059 DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To "
2060 "use the camera, close and open /dev/video%d again.",
2061 cam->v4ldev->minor);
2062 return -ENOMEM;
2063 }
1889 2064
1890 if (copy_to_user(arg, cc, sizeof(*cc))) 2065 if (cam->io == IO_READ)
1891 return -EFAULT; 2066 sn9c102_empty_framequeues(cam);
2067 else if (cam->module_param.force_munmap)
2068 sn9c102_requeue_outqueue(cam);
1892 2069
1893 return 0; 2070 cam->stream = stream;
1894 }
1895 2071
1896 case VIDIOC_G_CROP: 2072 return 0;
1897 { 2073}
1898 struct sn9c102_sensor* s = cam->sensor;
1899 struct v4l2_crop crop = {
1900 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
1901 };
1902 2074
1903 memcpy(&(crop.c), &(s->_rect), sizeof(struct v4l2_rect));
1904 2075
1905 if (copy_to_user(arg, &crop, sizeof(crop))) 2076static int
1906 return -EFAULT; 2077sn9c102_vidioc_enum_fmt(struct sn9c102_device* cam, void __user * arg)
2078{
2079 struct v4l2_fmtdesc fmtd;
1907 2080
1908 return 0; 2081 if (copy_from_user(&fmtd, arg, sizeof(fmtd)))
1909 } 2082 return -EFAULT;
1910 2083
1911 case VIDIOC_S_CROP: 2084 if (fmtd.index == 0) {
1912 { 2085 strcpy(fmtd.description, "bayer rgb");
1913 struct sn9c102_sensor* s = cam->sensor; 2086 fmtd.pixelformat = V4L2_PIX_FMT_SBGGR8;
1914 struct v4l2_crop crop; 2087 } else if (fmtd.index == 1) {
1915 struct v4l2_rect* rect; 2088 strcpy(fmtd.description, "compressed");
1916 struct v4l2_rect* bounds = &(s->cropcap.bounds); 2089 fmtd.pixelformat = V4L2_PIX_FMT_SN9C10X;
1917 struct v4l2_pix_format* pix_format = &(s->pix_format); 2090 fmtd.flags = V4L2_FMT_FLAG_COMPRESSED;
1918 u8 scale; 2091 } else
1919 const enum sn9c102_stream_state stream = cam->stream; 2092 return -EINVAL;
1920 const u32 nbuffers = cam->nbuffers;
1921 u32 i;
1922 int err = 0;
1923
1924 if (copy_from_user(&crop, arg, sizeof(crop)))
1925 return -EFAULT;
1926 2093
1927 rect = &(crop.c); 2094 fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
2095 memset(&fmtd.reserved, 0, sizeof(fmtd.reserved));
1928 2096
1929 if (crop.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 2097 if (copy_to_user(arg, &fmtd, sizeof(fmtd)))
1930 return -EINVAL; 2098 return -EFAULT;
1931 2099
1932 if (cam->module_param.force_munmap) 2100 return 0;
1933 for (i = 0; i < cam->nbuffers; i++) 2101}
1934 if (cam->frame[i].vma_use_count) {
1935 DBG(3, "VIDIOC_S_CROP failed. "
1936 "Unmap the buffers first.")
1937 return -EINVAL;
1938 }
1939 2102
1940 /* Preserve R,G or B origin */
1941 rect->left = (s->_rect.left & 1L) ?
1942 rect->left | 1L : rect->left & ~1L;
1943 rect->top = (s->_rect.top & 1L) ?
1944 rect->top | 1L : rect->top & ~1L;
1945
1946 if (rect->width < 16)
1947 rect->width = 16;
1948 if (rect->height < 16)
1949 rect->height = 16;
1950 if (rect->width > bounds->width)
1951 rect->width = bounds->width;
1952 if (rect->height > bounds->height)
1953 rect->height = bounds->height;
1954 if (rect->left < bounds->left)
1955 rect->left = bounds->left;
1956 if (rect->top < bounds->top)
1957 rect->top = bounds->top;
1958 if (rect->left + rect->width > bounds->left + bounds->width)
1959 rect->left = bounds->left+bounds->width - rect->width;
1960 if (rect->top + rect->height > bounds->top + bounds->height)
1961 rect->top = bounds->top+bounds->height - rect->height;
1962
1963 rect->width &= ~15L;
1964 rect->height &= ~15L;
1965
1966 if (SN9C102_PRESERVE_IMGSCALE) {
1967 /* Calculate the actual scaling factor */
1968 u32 a, b;
1969 a = rect->width * rect->height;
1970 b = pix_format->width * pix_format->height;
1971 scale = b ? (u8)((a / b) < 4 ? 1 :
1972 ((a / b) < 16 ? 2 : 4)) : 1;
1973 } else
1974 scale = 1;
1975
1976 if (cam->stream == STREAM_ON)
1977 if ((err = sn9c102_stream_interrupt(cam)))
1978 return err;
1979
1980 if (copy_to_user(arg, &crop, sizeof(crop))) {
1981 cam->stream = stream;
1982 return -EFAULT;
1983 }
1984 2103
1985 if (cam->module_param.force_munmap || cam->io == IO_READ) 2104static int
1986 sn9c102_release_buffers(cam); 2105sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg)
2106{
2107 struct v4l2_format format;
2108 struct v4l2_pix_format* pfmt = &(cam->sensor->pix_format);
1987 2109
1988 err = sn9c102_set_crop(cam, rect); 2110 if (copy_from_user(&format, arg, sizeof(format)))
1989 if (s->set_crop) 2111 return -EFAULT;
1990 err += s->set_crop(cam, rect);
1991 err += sn9c102_set_scale(cam, scale);
1992 2112
1993 if (err) { /* atomic, no rollback in ioctl() */ 2113 if (format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1994 cam->state |= DEV_MISCONFIGURED; 2114 return -EINVAL;
1995 DBG(1, "VIDIOC_S_CROP failed because of hardware "
1996 "problems. To use the camera, close and open "
1997 "/dev/video%d again.", cam->v4ldev->minor)
1998 return -EIO;
1999 }
2000 2115
2001 s->pix_format.width = rect->width/scale; 2116 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_SN9C10X)
2002 s->pix_format.height = rect->height/scale; 2117 ? 0 : (pfmt->width * pfmt->priv) / 8;
2003 memcpy(&(s->_rect), rect, sizeof(*rect)); 2118 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
2004 2119 pfmt->field = V4L2_FIELD_NONE;
2005 if ((cam->module_param.force_munmap || cam->io == IO_READ) && 2120 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
2006 nbuffers != sn9c102_request_buffers(cam, nbuffers,
2007 cam->io)) {
2008 cam->state |= DEV_MISCONFIGURED;
2009 DBG(1, "VIDIOC_S_CROP failed because of not enough "
2010 "memory. To use the camera, close and open "
2011 "/dev/video%d again.", cam->v4ldev->minor)
2012 return -ENOMEM;
2013 }
2014 2121
2015 cam->stream = stream; 2122 if (copy_to_user(arg, &format, sizeof(format)))
2123 return -EFAULT;
2016 2124
2017 return 0; 2125 return 0;
2018 } 2126}
2019 2127
2020 case VIDIOC_ENUM_FMT:
2021 {
2022 struct v4l2_fmtdesc fmtd;
2023 2128
2024 if (copy_from_user(&fmtd, arg, sizeof(fmtd))) 2129static int
2025 return -EFAULT; 2130sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
2131 void __user * arg)
2132{
2133 struct sn9c102_sensor* s = cam->sensor;
2134 struct v4l2_format format;
2135 struct v4l2_pix_format* pix;
2136 struct v4l2_pix_format* pfmt = &(s->pix_format);
2137 struct v4l2_rect* bounds = &(s->cropcap.bounds);
2138 struct v4l2_rect rect;
2139 u8 scale;
2140 const enum sn9c102_stream_state stream = cam->stream;
2141 const u32 nbuffers = cam->nbuffers;
2142 u32 i;
2143 int err = 0;
2026 2144
2027 if (fmtd.index == 0) { 2145 if (copy_from_user(&format, arg, sizeof(format)))
2028 strcpy(fmtd.description, "bayer rgb"); 2146 return -EFAULT;
2029 fmtd.pixelformat = V4L2_PIX_FMT_SBGGR8;
2030 } else if (fmtd.index == 1) {
2031 strcpy(fmtd.description, "compressed");
2032 fmtd.pixelformat = V4L2_PIX_FMT_SN9C10X;
2033 fmtd.flags = V4L2_FMT_FLAG_COMPRESSED;
2034 } else
2035 return -EINVAL;
2036 2147
2037 fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 2148 pix = &(format.fmt.pix);
2038 memset(&fmtd.reserved, 0, sizeof(fmtd.reserved));
2039 2149
2040 if (copy_to_user(arg, &fmtd, sizeof(fmtd))) 2150 if (format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
2041 return -EFAULT; 2151 return -EINVAL;
2042 2152
2043 return 0; 2153 memcpy(&rect, &(s->_rect), sizeof(rect));
2154
2155 { /* calculate the actual scaling factor */
2156 u32 a, b;
2157 a = rect.width * rect.height;
2158 b = pix->width * pix->height;
2159 scale = b ? (u8)((a / b) < 4 ? 1 : ((a / b) < 16 ? 2 : 4)) : 1;
2044 } 2160 }
2045 2161
2046 case VIDIOC_G_FMT: 2162 rect.width = scale * pix->width;
2047 { 2163 rect.height = scale * pix->height;
2048 struct v4l2_format format;
2049 struct v4l2_pix_format* pfmt = &(cam->sensor->pix_format);
2050 2164
2051 if (copy_from_user(&format, arg, sizeof(format))) 2165 if (rect.width < 16)
2052 return -EFAULT; 2166 rect.width = 16;
2167 if (rect.height < 16)
2168 rect.height = 16;
2169 if (rect.width > bounds->left + bounds->width - rect.left)
2170 rect.width = bounds->left + bounds->width - rect.left;
2171 if (rect.height > bounds->top + bounds->height - rect.top)
2172 rect.height = bounds->top + bounds->height - rect.top;
2053 2173
2054 if (format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 2174 rect.width &= ~15L;
2055 return -EINVAL; 2175 rect.height &= ~15L;
2176
2177 { /* adjust the scaling factor */
2178 u32 a, b;
2179 a = rect.width * rect.height;
2180 b = pix->width * pix->height;
2181 scale = b ? (u8)((a / b) < 4 ? 1 : ((a / b) < 16 ? 2 : 4)) : 1;
2182 }
2056 2183
2057 pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_SN9C10X) 2184 pix->width = rect.width / scale;
2058 ? 0 : (pfmt->width * pfmt->priv) / 8; 2185 pix->height = rect.height / scale;
2059 pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
2060 pfmt->field = V4L2_FIELD_NONE;
2061 memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
2062 2186
2187 if (pix->pixelformat != V4L2_PIX_FMT_SN9C10X &&
2188 pix->pixelformat != V4L2_PIX_FMT_SBGGR8)
2189 pix->pixelformat = pfmt->pixelformat;
2190 pix->priv = pfmt->priv; /* bpp */
2191 pix->colorspace = pfmt->colorspace;
2192 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_SN9C10X)
2193 ? 0 : (pix->width * pix->priv) / 8;
2194 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
2195 pix->field = V4L2_FIELD_NONE;
2196
2197 if (cmd == VIDIOC_TRY_FMT) {
2063 if (copy_to_user(arg, &format, sizeof(format))) 2198 if (copy_to_user(arg, &format, sizeof(format)))
2064 return -EFAULT; 2199 return -EFAULT;
2065
2066 return 0; 2200 return 0;
2067 } 2201 }
2068 2202
2069 case VIDIOC_TRY_FMT: 2203 if (cam->module_param.force_munmap)
2070 case VIDIOC_S_FMT: 2204 for (i = 0; i < cam->nbuffers; i++)
2071 { 2205 if (cam->frame[i].vma_use_count) {
2072 struct sn9c102_sensor* s = cam->sensor; 2206 DBG(3, "VIDIOC_S_FMT failed. Unmap the "
2073 struct v4l2_format format; 2207 "buffers first.");
2074 struct v4l2_pix_format* pix; 2208 return -EINVAL;
2075 struct v4l2_pix_format* pfmt = &(s->pix_format); 2209 }
2076 struct v4l2_rect* bounds = &(s->cropcap.bounds);
2077 struct v4l2_rect rect;
2078 u8 scale;
2079 const enum sn9c102_stream_state stream = cam->stream;
2080 const u32 nbuffers = cam->nbuffers;
2081 u32 i;
2082 int err = 0;
2083
2084 if (copy_from_user(&format, arg, sizeof(format)))
2085 return -EFAULT;
2086 2210
2087 pix = &(format.fmt.pix); 2211 if (cam->stream == STREAM_ON)
2212 if ((err = sn9c102_stream_interrupt(cam)))
2213 return err;
2088 2214
2089 if (format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 2215 if (copy_to_user(arg, &format, sizeof(format))) {
2090 return -EINVAL; 2216 cam->stream = stream;
2217 return -EFAULT;
2218 }
2091 2219
2092 memcpy(&rect, &(s->_rect), sizeof(rect)); 2220 if (cam->module_param.force_munmap || cam->io == IO_READ)
2221 sn9c102_release_buffers(cam);
2093 2222
2094 { /* calculate the actual scaling factor */ 2223 err += sn9c102_set_pix_format(cam, pix);
2095 u32 a, b; 2224 err += sn9c102_set_crop(cam, &rect);
2096 a = rect.width * rect.height; 2225 if (s->set_pix_format)
2097 b = pix->width * pix->height; 2226 err += s->set_pix_format(cam, pix);
2098 scale = b ? (u8)((a / b) < 4 ? 1 : 2227 if (s->set_crop)
2099 ((a / b) < 16 ? 2 : 4)) : 1; 2228 err += s->set_crop(cam, &rect);
2100 } 2229 err += sn9c102_set_scale(cam, scale);
2101 2230
2102 rect.width = scale * pix->width; 2231 if (err) { /* atomic, no rollback in ioctl() */
2103 rect.height = scale * pix->height; 2232 cam->state |= DEV_MISCONFIGURED;
2104 2233 DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To "
2105 if (rect.width < 16) 2234 "use the camera, close and open /dev/video%d again.",
2106 rect.width = 16; 2235 cam->v4ldev->minor);
2107 if (rect.height < 16) 2236 return -EIO;
2108 rect.height = 16; 2237 }
2109 if (rect.width > bounds->left + bounds->width - rect.left)
2110 rect.width = bounds->left + bounds->width - rect.left;
2111 if (rect.height > bounds->top + bounds->height - rect.top)
2112 rect.height = bounds->top + bounds->height - rect.top;
2113
2114 rect.width &= ~15L;
2115 rect.height &= ~15L;
2116
2117 { /* adjust the scaling factor */
2118 u32 a, b;
2119 a = rect.width * rect.height;
2120 b = pix->width * pix->height;
2121 scale = b ? (u8)((a / b) < 4 ? 1 :
2122 ((a / b) < 16 ? 2 : 4)) : 1;
2123 }
2124 2238
2125 pix->width = rect.width / scale; 2239 memcpy(pfmt, pix, sizeof(*pix));
2126 pix->height = rect.height / scale; 2240 memcpy(&(s->_rect), &rect, sizeof(rect));
2127
2128 if (pix->pixelformat != V4L2_PIX_FMT_SN9C10X &&
2129 pix->pixelformat != V4L2_PIX_FMT_SBGGR8)
2130 pix->pixelformat = pfmt->pixelformat;
2131 pix->priv = pfmt->priv; /* bpp */
2132 pix->colorspace = pfmt->colorspace;
2133 pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_SN9C10X)
2134 ? 0 : (pix->width * pix->priv) / 8;
2135 pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
2136 pix->field = V4L2_FIELD_NONE;
2137
2138 if (cmd == VIDIOC_TRY_FMT) {
2139 if (copy_to_user(arg, &format, sizeof(format)))
2140 return -EFAULT;
2141 return 0;
2142 }
2143 2241
2144 if (cam->module_param.force_munmap) 2242 if ((cam->module_param.force_munmap || cam->io == IO_READ) &&
2145 for (i = 0; i < cam->nbuffers; i++) 2243 nbuffers != sn9c102_request_buffers(cam, nbuffers, cam->io)) {
2146 if (cam->frame[i].vma_use_count) { 2244 cam->state |= DEV_MISCONFIGURED;
2147 DBG(3, "VIDIOC_S_FMT failed. " 2245 DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To "
2148 "Unmap the buffers first.") 2246 "use the camera, close and open /dev/video%d again.",
2149 return -EINVAL; 2247 cam->v4ldev->minor);
2150 } 2248 return -ENOMEM;
2249 }
2151 2250
2152 if (cam->stream == STREAM_ON) 2251 if (cam->io == IO_READ)
2153 if ((err = sn9c102_stream_interrupt(cam))) 2252 sn9c102_empty_framequeues(cam);
2154 return err; 2253 else if (cam->module_param.force_munmap)
2254 sn9c102_requeue_outqueue(cam);
2155 2255
2156 if (copy_to_user(arg, &format, sizeof(format))) { 2256 cam->stream = stream;
2157 cam->stream = stream;
2158 return -EFAULT;
2159 }
2160 2257
2161 if (cam->module_param.force_munmap || cam->io == IO_READ) 2258 return 0;
2162 sn9c102_release_buffers(cam); 2259}
2163
2164 err += sn9c102_set_pix_format(cam, pix);
2165 err += sn9c102_set_crop(cam, &rect);
2166 if (s->set_pix_format)
2167 err += s->set_pix_format(cam, pix);
2168 if (s->set_crop)
2169 err += s->set_crop(cam, &rect);
2170 err += sn9c102_set_scale(cam, scale);
2171
2172 if (err) { /* atomic, no rollback in ioctl() */
2173 cam->state |= DEV_MISCONFIGURED;
2174 DBG(1, "VIDIOC_S_FMT failed because of hardware "
2175 "problems. To use the camera, close and open "
2176 "/dev/video%d again.", cam->v4ldev->minor)
2177 return -EIO;
2178 }
2179 2260
2180 memcpy(pfmt, pix, sizeof(*pix));
2181 memcpy(&(s->_rect), &rect, sizeof(rect));
2182 2261
2183 if ((cam->module_param.force_munmap || cam->io == IO_READ) && 2262static int
2184 nbuffers != sn9c102_request_buffers(cam, nbuffers, 2263sn9c102_vidioc_g_jpegcomp(struct sn9c102_device* cam, void __user * arg)
2185 cam->io)) { 2264{
2186 cam->state |= DEV_MISCONFIGURED; 2265 if (copy_to_user(arg, &cam->compression,
2187 DBG(1, "VIDIOC_S_FMT failed because of not enough " 2266 sizeof(cam->compression)))
2188 "memory. To use the camera, close and open " 2267 return -EFAULT;
2189 "/dev/video%d again.", cam->v4ldev->minor)
2190 return -ENOMEM;
2191 }
2192 2268
2193 cam->stream = stream; 2269 return 0;
2270}
2194 2271
2195 return 0;
2196 }
2197 2272
2198 case VIDIOC_G_JPEGCOMP: 2273static int
2199 { 2274sn9c102_vidioc_s_jpegcomp(struct sn9c102_device* cam, void __user * arg)
2200 if (copy_to_user(arg, &cam->compression, 2275{
2201 sizeof(cam->compression))) 2276 struct v4l2_jpegcompression jc;
2202 return -EFAULT; 2277 const enum sn9c102_stream_state stream = cam->stream;
2278 int err = 0;
2203 2279
2204 return 0; 2280 if (copy_from_user(&jc, arg, sizeof(jc)))
2205 } 2281 return -EFAULT;
2206 2282
2207 case VIDIOC_S_JPEGCOMP: 2283 if (jc.quality != 0 && jc.quality != 1)
2208 { 2284 return -EINVAL;
2209 struct v4l2_jpegcompression jc;
2210 const enum sn9c102_stream_state stream = cam->stream;
2211 int err = 0;
2212 2285
2213 if (copy_from_user(&jc, arg, sizeof(jc))) 2286 if (cam->stream == STREAM_ON)
2214 return -EFAULT; 2287 if ((err = sn9c102_stream_interrupt(cam)))
2288 return err;
2215 2289
2216 if (jc.quality != 0 && jc.quality != 1) 2290 err += sn9c102_set_compression(cam, &jc);
2217 return -EINVAL; 2291 if (err) { /* atomic, no rollback in ioctl() */
2292 cam->state |= DEV_MISCONFIGURED;
2293 DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware "
2294 "problems. To use the camera, close and open "
2295 "/dev/video%d again.", cam->v4ldev->minor);
2296 return -EIO;
2297 }
2218 2298
2219 if (cam->stream == STREAM_ON) 2299 cam->compression.quality = jc.quality;
2220 if ((err = sn9c102_stream_interrupt(cam)))
2221 return err;
2222 2300
2223 err += sn9c102_set_compression(cam, &jc); 2301 cam->stream = stream;
2224 if (err) { /* atomic, no rollback in ioctl() */
2225 cam->state |= DEV_MISCONFIGURED;
2226 DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware "
2227 "problems. To use the camera, close and open "
2228 "/dev/video%d again.", cam->v4ldev->minor)
2229 return -EIO;
2230 }
2231 2302
2232 cam->compression.quality = jc.quality; 2303 return 0;
2304}
2233 2305
2234 cam->stream = stream;
2235 2306
2236 return 0; 2307static int
2237 } 2308sn9c102_vidioc_reqbufs(struct sn9c102_device* cam, void __user * arg)
2309{
2310 struct v4l2_requestbuffers rb;
2311 u32 i;
2312 int err;
2238 2313
2239 case VIDIOC_REQBUFS: 2314 if (copy_from_user(&rb, arg, sizeof(rb)))
2240 { 2315 return -EFAULT;
2241 struct v4l2_requestbuffers rb;
2242 u32 i;
2243 int err;
2244 2316
2245 if (copy_from_user(&rb, arg, sizeof(rb))) 2317 if (rb.type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
2246 return -EFAULT; 2318 rb.memory != V4L2_MEMORY_MMAP)
2319 return -EINVAL;
2247 2320
2248 if (rb.type != V4L2_BUF_TYPE_VIDEO_CAPTURE || 2321 if (cam->io == IO_READ) {
2249 rb.memory != V4L2_MEMORY_MMAP) 2322 DBG(3, "Close and open the device again to choose the mmap "
2250 return -EINVAL; 2323 "I/O method");
2324 return -EINVAL;
2325 }
2251 2326
2252 if (cam->io == IO_READ) { 2327 for (i = 0; i < cam->nbuffers; i++)
2253 DBG(3, "Close and open the device again to choose " 2328 if (cam->frame[i].vma_use_count) {
2254 "the mmap I/O method") 2329 DBG(3, "VIDIOC_REQBUFS failed. Previous buffers are "
2330 "still mapped.");
2255 return -EINVAL; 2331 return -EINVAL;
2256 } 2332 }
2257 2333
2258 for (i = 0; i < cam->nbuffers; i++) 2334 if (cam->stream == STREAM_ON)
2259 if (cam->frame[i].vma_use_count) { 2335 if ((err = sn9c102_stream_interrupt(cam)))
2260 DBG(3, "VIDIOC_REQBUFS failed. " 2336 return err;
2261 "Previous buffers are still mapped.")
2262 return -EINVAL;
2263 }
2264 2337
2265 if (cam->stream == STREAM_ON) 2338 sn9c102_empty_framequeues(cam);
2266 if ((err = sn9c102_stream_interrupt(cam)))
2267 return err;
2268 2339
2269 sn9c102_empty_framequeues(cam); 2340 sn9c102_release_buffers(cam);
2341 if (rb.count)
2342 rb.count = sn9c102_request_buffers(cam, rb.count, IO_MMAP);
2270 2343
2344 if (copy_to_user(arg, &rb, sizeof(rb))) {
2271 sn9c102_release_buffers(cam); 2345 sn9c102_release_buffers(cam);
2272 if (rb.count) 2346 cam->io = IO_NONE;
2273 rb.count = sn9c102_request_buffers(cam, rb.count, 2347 return -EFAULT;
2274 IO_MMAP); 2348 }
2275 2349
2276 if (copy_to_user(arg, &rb, sizeof(rb))) { 2350 cam->io = rb.count ? IO_MMAP : IO_NONE;
2277 sn9c102_release_buffers(cam);
2278 cam->io = IO_NONE;
2279 return -EFAULT;
2280 }
2281 2351
2282 cam->io = rb.count ? IO_MMAP : IO_NONE; 2352 return 0;
2353}
2283 2354
2284 return 0;
2285 }
2286 2355
2287 case VIDIOC_QUERYBUF: 2356static int
2288 { 2357sn9c102_vidioc_querybuf(struct sn9c102_device* cam, void __user * arg)
2289 struct v4l2_buffer b; 2358{
2359 struct v4l2_buffer b;
2290 2360
2291 if (copy_from_user(&b, arg, sizeof(b))) 2361 if (copy_from_user(&b, arg, sizeof(b)))
2292 return -EFAULT; 2362 return -EFAULT;
2293 2363
2294 if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE || 2364 if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
2295 b.index >= cam->nbuffers || cam->io != IO_MMAP) 2365 b.index >= cam->nbuffers || cam->io != IO_MMAP)
2296 return -EINVAL; 2366 return -EINVAL;
2297 2367
2298 memcpy(&b, &cam->frame[b.index].buf, sizeof(b)); 2368 memcpy(&b, &cam->frame[b.index].buf, sizeof(b));
2299 2369
2300 if (cam->frame[b.index].vma_use_count) 2370 if (cam->frame[b.index].vma_use_count)
2301 b.flags |= V4L2_BUF_FLAG_MAPPED; 2371 b.flags |= V4L2_BUF_FLAG_MAPPED;
2302 2372
2303 if (cam->frame[b.index].state == F_DONE) 2373 if (cam->frame[b.index].state == F_DONE)
2304 b.flags |= V4L2_BUF_FLAG_DONE; 2374 b.flags |= V4L2_BUF_FLAG_DONE;
2305 else if (cam->frame[b.index].state != F_UNUSED) 2375 else if (cam->frame[b.index].state != F_UNUSED)
2306 b.flags |= V4L2_BUF_FLAG_QUEUED; 2376 b.flags |= V4L2_BUF_FLAG_QUEUED;
2307 2377
2308 if (copy_to_user(arg, &b, sizeof(b))) 2378 if (copy_to_user(arg, &b, sizeof(b)))
2309 return -EFAULT; 2379 return -EFAULT;
2310 2380
2311 return 0; 2381 return 0;
2312 } 2382}
2313 2383
2314 case VIDIOC_QBUF:
2315 {
2316 struct v4l2_buffer b;
2317 unsigned long lock_flags;
2318 2384
2319 if (copy_from_user(&b, arg, sizeof(b))) 2385static int
2320 return -EFAULT; 2386sn9c102_vidioc_qbuf(struct sn9c102_device* cam, void __user * arg)
2387{
2388 struct v4l2_buffer b;
2389 unsigned long lock_flags;
2321 2390
2322 if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE || 2391 if (copy_from_user(&b, arg, sizeof(b)))
2323 b.index >= cam->nbuffers || cam->io != IO_MMAP) 2392 return -EFAULT;
2324 return -EINVAL;
2325 2393
2326 if (cam->frame[b.index].state != F_UNUSED) 2394 if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
2327 return -EINVAL; 2395 b.index >= cam->nbuffers || cam->io != IO_MMAP)
2396 return -EINVAL;
2328 2397
2329 cam->frame[b.index].state = F_QUEUED; 2398 if (cam->frame[b.index].state != F_UNUSED)
2399 return -EINVAL;
2330 2400
2331 spin_lock_irqsave(&cam->queue_lock, lock_flags); 2401 cam->frame[b.index].state = F_QUEUED;
2332 list_add_tail(&cam->frame[b.index].frame, &cam->inqueue);
2333 spin_unlock_irqrestore(&cam->queue_lock, lock_flags);
2334 2402
2335 PDBGG("Frame #%lu queued", (unsigned long)b.index) 2403 spin_lock_irqsave(&cam->queue_lock, lock_flags);
2404 list_add_tail(&cam->frame[b.index].frame, &cam->inqueue);
2405 spin_unlock_irqrestore(&cam->queue_lock, lock_flags);
2336 2406
2337 return 0; 2407 PDBGG("Frame #%lu queued", (unsigned long)b.index);
2338 }
2339 2408
2340 case VIDIOC_DQBUF: 2409 return 0;
2341 { 2410}
2342 struct v4l2_buffer b;
2343 struct sn9c102_frame_t *f;
2344 unsigned long lock_flags;
2345 int err = 0;
2346 2411
2347 if (copy_from_user(&b, arg, sizeof(b)))
2348 return -EFAULT;
2349 2412
2350 if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io!= IO_MMAP) 2413static int
2414sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp,
2415 void __user * arg)
2416{
2417 struct v4l2_buffer b;
2418 struct sn9c102_frame_t *f;
2419 unsigned long lock_flags;
2420 int err = 0;
2421
2422 if (copy_from_user(&b, arg, sizeof(b)))
2423 return -EFAULT;
2424
2425 if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP)
2426 return -EINVAL;
2427
2428 if (list_empty(&cam->outqueue)) {
2429 if (cam->stream == STREAM_OFF)
2351 return -EINVAL; 2430 return -EINVAL;
2431 if (filp->f_flags & O_NONBLOCK)
2432 return -EAGAIN;
2433 err = wait_event_interruptible
2434 ( cam->wait_frame,
2435 (!list_empty(&cam->outqueue)) ||
2436 (cam->state & DEV_DISCONNECTED) ||
2437 (cam->state & DEV_MISCONFIGURED) );
2438 if (err)
2439 return err;
2440 if (cam->state & DEV_DISCONNECTED)
2441 return -ENODEV;
2442 if (cam->state & DEV_MISCONFIGURED)
2443 return -EIO;
2444 }
2352 2445
2353 if (list_empty(&cam->outqueue)) { 2446 spin_lock_irqsave(&cam->queue_lock, lock_flags);
2354 if (cam->stream == STREAM_OFF) 2447 f = list_entry(cam->outqueue.next, struct sn9c102_frame_t, frame);
2355 return -EINVAL; 2448 list_del(cam->outqueue.next);
2356 if (filp->f_flags & O_NONBLOCK) 2449 spin_unlock_irqrestore(&cam->queue_lock, lock_flags);
2357 return -EAGAIN;
2358 err = wait_event_interruptible
2359 ( cam->wait_frame,
2360 (!list_empty(&cam->outqueue)) ||
2361 (cam->state & DEV_DISCONNECTED) ||
2362 (cam->state & DEV_MISCONFIGURED) );
2363 if (err)
2364 return err;
2365 if (cam->state & DEV_DISCONNECTED)
2366 return -ENODEV;
2367 if (cam->state & DEV_MISCONFIGURED)
2368 return -EIO;
2369 }
2370 2450
2371 spin_lock_irqsave(&cam->queue_lock, lock_flags); 2451 f->state = F_UNUSED;
2372 f = list_entry(cam->outqueue.next, struct sn9c102_frame_t,
2373 frame);
2374 list_del(cam->outqueue.next);
2375 spin_unlock_irqrestore(&cam->queue_lock, lock_flags);
2376 2452
2377 f->state = F_UNUSED; 2453 memcpy(&b, &f->buf, sizeof(b));
2454 if (f->vma_use_count)
2455 b.flags |= V4L2_BUF_FLAG_MAPPED;
2378 2456
2379 memcpy(&b, &f->buf, sizeof(b)); 2457 if (copy_to_user(arg, &b, sizeof(b)))
2380 if (f->vma_use_count) 2458 return -EFAULT;
2381 b.flags |= V4L2_BUF_FLAG_MAPPED;
2382 2459
2383 if (copy_to_user(arg, &b, sizeof(b))) 2460 PDBGG("Frame #%lu dequeued", (unsigned long)f->buf.index);
2384 return -EFAULT;
2385 2461
2386 PDBGG("Frame #%lu dequeued", (unsigned long)f->buf.index) 2462 return 0;
2463}
2387 2464
2388 return 0;
2389 }
2390 2465
2391 case VIDIOC_STREAMON: 2466static int
2392 { 2467sn9c102_vidioc_streamon(struct sn9c102_device* cam, void __user * arg)
2393 int type; 2468{
2469 int type;
2394 2470
2395 if (copy_from_user(&type, arg, sizeof(type))) 2471 if (copy_from_user(&type, arg, sizeof(type)))
2396 return -EFAULT; 2472 return -EFAULT;
2397 2473
2398 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP) 2474 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP)
2399 return -EINVAL; 2475 return -EINVAL;
2400 2476
2401 if (list_empty(&cam->inqueue)) 2477 if (list_empty(&cam->inqueue))
2402 return -EINVAL; 2478 return -EINVAL;
2403 2479
2404 cam->stream = STREAM_ON; 2480 cam->stream = STREAM_ON;
2405 2481
2406 DBG(3, "Stream on") 2482 DBG(3, "Stream on");
2407 2483
2408 return 0; 2484 return 0;
2409 } 2485}
2410 2486
2411 case VIDIOC_STREAMOFF:
2412 {
2413 int type, err;
2414 2487
2415 if (copy_from_user(&type, arg, sizeof(type))) 2488static int
2416 return -EFAULT; 2489sn9c102_vidioc_streamoff(struct sn9c102_device* cam, void __user * arg)
2490{
2491 int type, err;
2417 2492
2418 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP) 2493 if (copy_from_user(&type, arg, sizeof(type)))
2419 return -EINVAL; 2494 return -EFAULT;
2420 2495
2421 if (cam->stream == STREAM_ON) 2496 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP)
2422 if ((err = sn9c102_stream_interrupt(cam))) 2497 return -EINVAL;
2423 return err;
2424 2498
2425 sn9c102_empty_framequeues(cam); 2499 if (cam->stream == STREAM_ON)
2500 if ((err = sn9c102_stream_interrupt(cam)))
2501 return err;
2426 2502
2427 DBG(3, "Stream off") 2503 sn9c102_empty_framequeues(cam);
2428 2504
2429 return 0; 2505 DBG(3, "Stream off");
2430 }
2431 2506
2432 case VIDIOC_G_PARM: 2507 return 0;
2433 { 2508}
2434 struct v4l2_streamparm sp;
2435 2509
2436 if (copy_from_user(&sp, arg, sizeof(sp)))
2437 return -EFAULT;
2438 2510
2439 if (sp.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 2511static int
2440 return -EINVAL; 2512sn9c102_vidioc_g_parm(struct sn9c102_device* cam, void __user * arg)
2513{
2514 struct v4l2_streamparm sp;
2515
2516 if (copy_from_user(&sp, arg, sizeof(sp)))
2517 return -EFAULT;
2518
2519 if (sp.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
2520 return -EINVAL;
2521
2522 sp.parm.capture.extendedmode = 0;
2523 sp.parm.capture.readbuffers = cam->nreadbuffers;
2524
2525 if (copy_to_user(arg, &sp, sizeof(sp)))
2526 return -EFAULT;
2527
2528 return 0;
2529}
2530
2531
2532static int
2533sn9c102_vidioc_s_parm(struct sn9c102_device* cam, void __user * arg)
2534{
2535 struct v4l2_streamparm sp;
2536
2537 if (copy_from_user(&sp, arg, sizeof(sp)))
2538 return -EFAULT;
2539
2540 if (sp.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
2541 return -EINVAL;
2542
2543 sp.parm.capture.extendedmode = 0;
2441 2544
2442 sp.parm.capture.extendedmode = 0; 2545 if (sp.parm.capture.readbuffers == 0)
2443 sp.parm.capture.readbuffers = cam->nreadbuffers; 2546 sp.parm.capture.readbuffers = cam->nreadbuffers;
2444 2547
2445 if (copy_to_user(arg, &sp, sizeof(sp))) 2548 if (sp.parm.capture.readbuffers > SN9C102_MAX_FRAMES)
2446 return -EFAULT; 2549 sp.parm.capture.readbuffers = SN9C102_MAX_FRAMES;
2447 2550
2448 return 0; 2551 if (copy_to_user(arg, &sp, sizeof(sp)))
2449 } 2552 return -EFAULT;
2450 2553
2451 case VIDIOC_S_PARM_OLD: 2554 cam->nreadbuffers = sp.parm.capture.readbuffers;
2452 case VIDIOC_S_PARM:
2453 {
2454 struct v4l2_streamparm sp;
2455 2555
2456 if (copy_from_user(&sp, arg, sizeof(sp))) 2556 return 0;
2457 return -EFAULT; 2557}
2458 2558
2459 if (sp.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
2460 return -EINVAL;
2461 2559
2462 sp.parm.capture.extendedmode = 0; 2560static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
2561 unsigned int cmd, void __user * arg)
2562{
2563 struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
2564
2565 switch (cmd) {
2566
2567 case VIDIOC_QUERYCAP:
2568 return sn9c102_vidioc_querycap(cam, arg);
2463 2569
2464 if (sp.parm.capture.readbuffers == 0) 2570 case VIDIOC_ENUMINPUT:
2465 sp.parm.capture.readbuffers = cam->nreadbuffers; 2571 return sn9c102_vidioc_enuminput(cam, arg);
2466 2572
2467 if (sp.parm.capture.readbuffers > SN9C102_MAX_FRAMES) 2573 case VIDIOC_G_INPUT:
2468 sp.parm.capture.readbuffers = SN9C102_MAX_FRAMES; 2574 case VIDIOC_S_INPUT:
2575 return sn9c102_vidioc_gs_input(cam, arg);
2469 2576
2470 if (copy_to_user(arg, &sp, sizeof(sp))) 2577 case VIDIOC_QUERYCTRL:
2471 return -EFAULT; 2578 return sn9c102_vidioc_query_ctrl(cam, arg);
2472 2579
2473 cam->nreadbuffers = sp.parm.capture.readbuffers; 2580 case VIDIOC_G_CTRL:
2581 return sn9c102_vidioc_g_ctrl(cam, arg);
2474 2582
2475 return 0; 2583 case VIDIOC_S_CTRL_OLD:
2476 } 2584 case VIDIOC_S_CTRL:
2585 return sn9c102_vidioc_s_ctrl(cam, arg);
2586
2587 case VIDIOC_CROPCAP_OLD:
2588 case VIDIOC_CROPCAP:
2589 return sn9c102_vidioc_cropcap(cam, arg);
2590
2591 case VIDIOC_G_CROP:
2592 return sn9c102_vidioc_g_crop(cam, arg);
2593
2594 case VIDIOC_S_CROP:
2595 return sn9c102_vidioc_s_crop(cam, arg);
2596
2597 case VIDIOC_ENUM_FMT:
2598 return sn9c102_vidioc_enum_fmt(cam, arg);
2599
2600 case VIDIOC_G_FMT:
2601 return sn9c102_vidioc_g_fmt(cam, arg);
2602
2603 case VIDIOC_TRY_FMT:
2604 case VIDIOC_S_FMT:
2605 return sn9c102_vidioc_try_s_fmt(cam, cmd, arg);
2606
2607 case VIDIOC_G_JPEGCOMP:
2608 return sn9c102_vidioc_g_jpegcomp(cam, arg);
2609
2610 case VIDIOC_S_JPEGCOMP:
2611 return sn9c102_vidioc_s_jpegcomp(cam, arg);
2612
2613 case VIDIOC_REQBUFS:
2614 return sn9c102_vidioc_reqbufs(cam, arg);
2615
2616 case VIDIOC_QUERYBUF:
2617 return sn9c102_vidioc_querybuf(cam, arg);
2618
2619 case VIDIOC_QBUF:
2620 return sn9c102_vidioc_qbuf(cam, arg);
2621
2622 case VIDIOC_DQBUF:
2623 return sn9c102_vidioc_dqbuf(cam, filp, arg);
2624
2625 case VIDIOC_STREAMON:
2626 return sn9c102_vidioc_streamon(cam, arg);
2627
2628 case VIDIOC_STREAMOFF:
2629 return sn9c102_vidioc_streamoff(cam, arg);
2630
2631 case VIDIOC_G_PARM:
2632 return sn9c102_vidioc_g_parm(cam, arg);
2633
2634 case VIDIOC_S_PARM_OLD:
2635 case VIDIOC_S_PARM:
2636 return sn9c102_vidioc_s_parm(cam, arg);
2477 2637
2478 case VIDIOC_G_STD: 2638 case VIDIOC_G_STD:
2479 case VIDIOC_S_STD: 2639 case VIDIOC_S_STD:
@@ -2499,17 +2659,20 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp,
2499 return -ERESTARTSYS; 2659 return -ERESTARTSYS;
2500 2660
2501 if (cam->state & DEV_DISCONNECTED) { 2661 if (cam->state & DEV_DISCONNECTED) {
2502 DBG(1, "Device not present") 2662 DBG(1, "Device not present");
2503 up(&cam->fileop_sem); 2663 up(&cam->fileop_sem);
2504 return -ENODEV; 2664 return -ENODEV;
2505 } 2665 }
2506 2666
2507 if (cam->state & DEV_MISCONFIGURED) { 2667 if (cam->state & DEV_MISCONFIGURED) {
2508 DBG(1, "The camera is misconfigured. Close and open it again.") 2668 DBG(1, "The camera is misconfigured. Close and open it "
2669 "again.");
2509 up(&cam->fileop_sem); 2670 up(&cam->fileop_sem);
2510 return -EIO; 2671 return -EIO;
2511 } 2672 }
2512 2673
2674 V4LDBG(3, "sn9c102", cmd);
2675
2513 err = sn9c102_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); 2676 err = sn9c102_ioctl_v4l2(inode, filp, cmd, (void __user *)arg);
2514 2677
2515 up(&cam->fileop_sem); 2678 up(&cam->fileop_sem);
@@ -2517,9 +2680,10 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp,
2517 return err; 2680 return err;
2518} 2681}
2519 2682
2683/*****************************************************************************/
2520 2684
2521static struct file_operations sn9c102_fops = { 2685static struct file_operations sn9c102_fops = {
2522 .owner = THIS_MODULE, 2686 .owner = THIS_MODULE,
2523 .open = sn9c102_open, 2687 .open = sn9c102_open,
2524 .release = sn9c102_release, 2688 .release = sn9c102_release,
2525 .ioctl = sn9c102_ioctl, 2689 .ioctl = sn9c102_ioctl,
@@ -2538,36 +2702,22 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2538 struct usb_device *udev = interface_to_usbdev(intf); 2702 struct usb_device *udev = interface_to_usbdev(intf);
2539 struct sn9c102_device* cam; 2703 struct sn9c102_device* cam;
2540 static unsigned int dev_nr = 0; 2704 static unsigned int dev_nr = 0;
2541 unsigned int i, n; 2705 unsigned int i;
2542 int err = 0, r; 2706 int err = 0, r;
2543 2707
2544 n = ARRAY_SIZE(sn9c102_id_table); 2708 if (!(cam = kzalloc(sizeof(struct sn9c102_device), GFP_KERNEL)))
2545 for (i = 0; i < n-1; i++)
2546 if (le16_to_cpu(udev->descriptor.idVendor) ==
2547 sn9c102_id_table[i].idVendor &&
2548 le16_to_cpu(udev->descriptor.idProduct) ==
2549 sn9c102_id_table[i].idProduct)
2550 break;
2551 if (i == n-1)
2552 return -ENODEV;
2553
2554 if (!(cam = kmalloc(sizeof(struct sn9c102_device), GFP_KERNEL)))
2555 return -ENOMEM; 2709 return -ENOMEM;
2556 memset(cam, 0, sizeof(*cam));
2557 2710
2558 cam->usbdev = udev; 2711 cam->usbdev = udev;
2559 2712
2560 memcpy(&cam->dev, &udev->dev, sizeof(struct device)); 2713 if (!(cam->control_buffer = kzalloc(8, GFP_KERNEL))) {
2561 2714 DBG(1, "kmalloc() failed");
2562 if (!(cam->control_buffer = kmalloc(8, GFP_KERNEL))) {
2563 DBG(1, "kmalloc() failed")
2564 err = -ENOMEM; 2715 err = -ENOMEM;
2565 goto fail; 2716 goto fail;
2566 } 2717 }
2567 memset(cam->control_buffer, 0, 8);
2568 2718
2569 if (!(cam->v4ldev = video_device_alloc())) { 2719 if (!(cam->v4ldev = video_device_alloc())) {
2570 DBG(1, "video_device_alloc() failed") 2720 DBG(1, "video_device_alloc() failed");
2571 err = -ENOMEM; 2721 err = -ENOMEM;
2572 goto fail; 2722 goto fail;
2573 } 2723 }
@@ -2577,25 +2727,22 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2577 r = sn9c102_read_reg(cam, 0x00); 2727 r = sn9c102_read_reg(cam, 0x00);
2578 if (r < 0 || r != 0x10) { 2728 if (r < 0 || r != 0x10) {
2579 DBG(1, "Sorry, this is not a SN9C10x based camera " 2729 DBG(1, "Sorry, this is not a SN9C10x based camera "
2580 "(vid/pid 0x%04X/0x%04X)", 2730 "(vid/pid 0x%04X/0x%04X)", id->idVendor, id->idProduct);
2581 sn9c102_id_table[i].idVendor,sn9c102_id_table[i].idProduct)
2582 err = -ENODEV; 2731 err = -ENODEV;
2583 goto fail; 2732 goto fail;
2584 } 2733 }
2585 2734
2586 cam->bridge = (sn9c102_id_table[i].idProduct & 0xffc0) == 0x6080 ? 2735 cam->bridge = (id->idProduct & 0xffc0) == 0x6080 ?
2587 BRIDGE_SN9C103 : BRIDGE_SN9C102; 2736 BRIDGE_SN9C103 : BRIDGE_SN9C102;
2588 switch (cam->bridge) { 2737 switch (cam->bridge) {
2589 case BRIDGE_SN9C101: 2738 case BRIDGE_SN9C101:
2590 case BRIDGE_SN9C102: 2739 case BRIDGE_SN9C102:
2591 DBG(2, "SN9C10[12] PC Camera Controller detected " 2740 DBG(2, "SN9C10[12] PC Camera Controller detected "
2592 "(vid/pid 0x%04X/0x%04X)", sn9c102_id_table[i].idVendor, 2741 "(vid/pid 0x%04X/0x%04X)", id->idVendor, id->idProduct);
2593 sn9c102_id_table[i].idProduct)
2594 break; 2742 break;
2595 case BRIDGE_SN9C103: 2743 case BRIDGE_SN9C103:
2596 DBG(2, "SN9C103 PC Camera Controller detected " 2744 DBG(2, "SN9C103 PC Camera Controller detected "
2597 "(vid/pid 0x%04X/0x%04X)", sn9c102_id_table[i].idVendor, 2745 "(vid/pid 0x%04X/0x%04X)", id->idVendor, id->idProduct);
2598 sn9c102_id_table[i].idProduct)
2599 break; 2746 break;
2600 } 2747 }
2601 2748
@@ -2606,24 +2753,24 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2606 } 2753 }
2607 2754
2608 if (!err && cam->sensor) { 2755 if (!err && cam->sensor) {
2609 DBG(2, "%s image sensor detected", cam->sensor->name) 2756 DBG(2, "%s image sensor detected", cam->sensor->name);
2610 DBG(3, "Support for %s maintained by %s", 2757 DBG(3, "Support for %s maintained by %s",
2611 cam->sensor->name, cam->sensor->maintainer) 2758 cam->sensor->name, cam->sensor->maintainer);
2612 } else { 2759 } else {
2613 DBG(1, "No supported image sensor detected") 2760 DBG(1, "No supported image sensor detected");
2614 err = -ENODEV; 2761 err = -ENODEV;
2615 goto fail; 2762 goto fail;
2616 } 2763 }
2617 2764
2618 if (sn9c102_init(cam)) { 2765 if (sn9c102_init(cam)) {
2619 DBG(1, "Initialization failed. I will retry on open().") 2766 DBG(1, "Initialization failed. I will retry on open().");
2620 cam->state |= DEV_MISCONFIGURED; 2767 cam->state |= DEV_MISCONFIGURED;
2621 } 2768 }
2622 2769
2623 strcpy(cam->v4ldev->name, "SN9C10x PC Camera"); 2770 strcpy(cam->v4ldev->name, "SN9C10x PC Camera");
2624 cam->v4ldev->owner = THIS_MODULE; 2771 cam->v4ldev->owner = THIS_MODULE;
2625 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; 2772 cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
2626 cam->v4ldev->hardware = VID_HARDWARE_SN9C102; 2773 cam->v4ldev->hardware = 0;
2627 cam->v4ldev->fops = &sn9c102_fops; 2774 cam->v4ldev->fops = &sn9c102_fops;
2628 cam->v4ldev->minor = video_nr[dev_nr]; 2775 cam->v4ldev->minor = video_nr[dev_nr];
2629 cam->v4ldev->release = video_device_release; 2776 cam->v4ldev->release = video_device_release;
@@ -2634,23 +2781,25 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2634 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 2781 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
2635 video_nr[dev_nr]); 2782 video_nr[dev_nr]);
2636 if (err) { 2783 if (err) {
2637 DBG(1, "V4L2 device registration failed") 2784 DBG(1, "V4L2 device registration failed");
2638 if (err == -ENFILE && video_nr[dev_nr] == -1) 2785 if (err == -ENFILE && video_nr[dev_nr] == -1)
2639 DBG(1, "Free /dev/videoX node not found") 2786 DBG(1, "Free /dev/videoX node not found");
2640 video_nr[dev_nr] = -1; 2787 video_nr[dev_nr] = -1;
2641 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; 2788 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;
2642 up(&cam->dev_sem); 2789 up(&cam->dev_sem);
2643 goto fail; 2790 goto fail;
2644 } 2791 }
2645 2792
2646 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor) 2793 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor);
2647 2794
2648 cam->module_param.force_munmap = force_munmap[dev_nr]; 2795 cam->module_param.force_munmap = force_munmap[dev_nr];
2649 2796
2650 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; 2797 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;
2651 2798
2799#ifdef CONFIG_VIDEO_ADV_DEBUG
2652 sn9c102_create_sysfs(cam); 2800 sn9c102_create_sysfs(cam);
2653 DBG(2, "Optional device control through 'sysfs' interface ready") 2801 DBG(2, "Optional device control through 'sysfs' interface ready");
2802#endif
2654 2803
2655 usb_set_intfdata(intf, cam); 2804 usb_set_intfdata(intf, cam);
2656 2805
@@ -2680,14 +2829,14 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf)
2680 2829
2681 down(&cam->dev_sem); 2830 down(&cam->dev_sem);
2682 2831
2683 DBG(2, "Disconnecting %s...", cam->v4ldev->name) 2832 DBG(2, "Disconnecting %s...", cam->v4ldev->name);
2684 2833
2685 wake_up_interruptible_all(&cam->open); 2834 wake_up_interruptible_all(&cam->open);
2686 2835
2687 if (cam->users) { 2836 if (cam->users) {
2688 DBG(2, "Device /dev/video%d is open! Deregistration and " 2837 DBG(2, "Device /dev/video%d is open! Deregistration and "
2689 "memory deallocation are deferred on close.", 2838 "memory deallocation are deferred on close.",
2690 cam->v4ldev->minor) 2839 cam->v4ldev->minor);
2691 cam->state |= DEV_MISCONFIGURED; 2840 cam->state |= DEV_MISCONFIGURED;
2692 sn9c102_stop_transfer(cam); 2841 sn9c102_stop_transfer(cam);
2693 cam->state |= DEV_DISCONNECTED; 2842 cam->state |= DEV_DISCONNECTED;
@@ -2720,11 +2869,11 @@ static int __init sn9c102_module_init(void)
2720{ 2869{
2721 int err = 0; 2870 int err = 0;
2722 2871
2723 KDBG(2, SN9C102_MODULE_NAME " v" SN9C102_MODULE_VERSION) 2872 KDBG(2, SN9C102_MODULE_NAME " v" SN9C102_MODULE_VERSION);
2724 KDBG(3, SN9C102_MODULE_AUTHOR) 2873 KDBG(3, SN9C102_MODULE_AUTHOR);
2725 2874
2726 if ((err = usb_register(&sn9c102_usb_driver))) 2875 if ((err = usb_register(&sn9c102_usb_driver)))
2727 KDBG(1, "usb_register() failed") 2876 KDBG(1, "usb_register() failed");
2728 2877
2729 return err; 2878 return err;
2730} 2879}
diff --git a/drivers/usb/media/sn9c102_hv7131d.c b/drivers/usb/media/sn9c102_hv7131d.c
index 18070d5333cf..46c12ec3ca62 100644
--- a/drivers/usb/media/sn9c102_hv7131d.c
+++ b/drivers/usb/media/sn9c102_hv7131d.c
@@ -2,7 +2,7 @@
2 * Plug-in for HV7131D image sensor connected to the SN9C10x PC Camera * 2 * Plug-in for HV7131D image sensor connected to the SN9C10x PC Camera *
3 * Controllers * 3 * Controllers *
4 * * 4 * *
5 * Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 * Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
diff --git a/drivers/usb/media/sn9c102_mi0343.c b/drivers/usb/media/sn9c102_mi0343.c
index 86676abf3547..d9aa7a61095d 100644
--- a/drivers/usb/media/sn9c102_mi0343.c
+++ b/drivers/usb/media/sn9c102_mi0343.c
@@ -2,7 +2,7 @@
2 * Plug-in for MI-0343 image sensor connected to the SN9C10x PC Camera * 2 * Plug-in for MI-0343 image sensor connected to the SN9C10x PC Camera *
3 * Controllers * 3 * Controllers *
4 * * 4 * *
5 * Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 * Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
diff --git a/drivers/usb/media/sn9c102_ov7630.c b/drivers/usb/media/sn9c102_ov7630.c
index d27c5aedeaf8..4a36519b5af4 100644
--- a/drivers/usb/media/sn9c102_ov7630.c
+++ b/drivers/usb/media/sn9c102_ov7630.c
@@ -2,7 +2,7 @@
2 * Plug-in for OV7630 image sensor connected to the SN9C10x PC Camera * 2 * Plug-in for OV7630 image sensor connected to the SN9C10x PC Camera *
3 * Controllers * 3 * Controllers *
4 * * 4 * *
5 * Copyright (C) 2005 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 * Copyright (C) 2005-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
@@ -375,8 +375,10 @@ int sn9c102_probe_ov7630(struct sn9c102_device* cam)
375 375
376 sn9c102_attach_sensor(cam, &ov7630); 376 sn9c102_attach_sensor(cam, &ov7630);
377 377
378 if (le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x608f && 378 if (le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x602c &&
379 le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x602c) 379 le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x602d &&
380 le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x608f &&
381 le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x60b0)
380 return -ENODEV; 382 return -ENODEV;
381 383
382 err += sn9c102_write_reg(cam, 0x01, 0x01); 384 err += sn9c102_write_reg(cam, 0x01, 0x01);
diff --git a/drivers/usb/media/sn9c102_pas106b.c b/drivers/usb/media/sn9c102_pas106b.c
index 48e3ec39d4e2..b1dee78abe04 100644
--- a/drivers/usb/media/sn9c102_pas106b.c
+++ b/drivers/usb/media/sn9c102_pas106b.c
@@ -2,7 +2,7 @@
2 * Plug-in for PAS106B image sensor connected to the SN9C10x PC Camera * 2 * Plug-in for PAS106B image sensor connected to the SN9C10x PC Camera *
3 * Controllers * 3 * Controllers *
4 * * 4 * *
5 * Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 * Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
diff --git a/drivers/usb/media/sn9c102_sensor.h b/drivers/usb/media/sn9c102_sensor.h
index a45166c3488c..7d953b24f2f2 100644
--- a/drivers/usb/media/sn9c102_sensor.h
+++ b/drivers/usb/media/sn9c102_sensor.h
@@ -1,7 +1,7 @@
1/*************************************************************************** 1/***************************************************************************
2 * API for image sensors connected to the SN9C10x PC Camera Controllers * 2 * API for image sensors connected to the SN9C10x PC Camera Controllers *
3 * * 3 * *
4 * Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> * 4 * Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
@@ -92,7 +92,18 @@ extern void
92sn9c102_attach_sensor(struct sn9c102_device* cam, 92sn9c102_attach_sensor(struct sn9c102_device* cam,
93 struct sn9c102_sensor* sensor); 93 struct sn9c102_sensor* sensor);
94 94
95/* Each SN9C10X camera has proper PID/VID identifiers. Add them here in case.*/ 95/*
96 Each SN9C10x camera has proper PID/VID identifiers.
97 SN9C103 supports multiple interfaces, but we only handle the video class
98 interface.
99*/
100#define SN9C102_USB_DEVICE(vend, prod, intclass) \
101 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
102 USB_DEVICE_ID_MATCH_INT_CLASS, \
103 .idVendor = (vend), \
104 .idProduct = (prod), \
105 .bInterfaceClass = (intclass)
106
96#define SN9C102_ID_TABLE \ 107#define SN9C102_ID_TABLE \
97static const struct usb_device_id sn9c102_id_table[] = { \ 108static const struct usb_device_id sn9c102_id_table[] = { \
98 { USB_DEVICE(0x0c45, 0x6001), }, /* TAS5110C1B */ \ 109 { USB_DEVICE(0x0c45, 0x6001), }, /* TAS5110C1B */ \
@@ -107,33 +118,34 @@ static const struct usb_device_id sn9c102_id_table[] = { \
107 { USB_DEVICE(0x0c45, 0x602b), }, /* MI-0343 */ \ 118 { USB_DEVICE(0x0c45, 0x602b), }, /* MI-0343 */ \
108 { USB_DEVICE(0x0c45, 0x602c), }, /* OV7630 */ \ 119 { USB_DEVICE(0x0c45, 0x602c), }, /* OV7630 */ \
109 { USB_DEVICE(0x0c45, 0x602d), }, \ 120 { USB_DEVICE(0x0c45, 0x602d), }, \
121 { USB_DEVICE(0x0c45, 0x602e), }, /* OV7630 */ \
110 { USB_DEVICE(0x0c45, 0x6030), }, /* MI03x */ \ 122 { USB_DEVICE(0x0c45, 0x6030), }, /* MI03x */ \
111 { USB_DEVICE(0x0c45, 0x6080), }, \ 123 { SN9C102_USB_DEVICE(0x0c45, 0x6080, 0xff), }, \
112 { USB_DEVICE(0x0c45, 0x6082), }, /* MI0343 and MI0360 */ \ 124 { SN9C102_USB_DEVICE(0x0c45, 0x6082, 0xff), }, /* MI0343 & MI0360 */ \
113 { USB_DEVICE(0x0c45, 0x6083), }, /* HV7131[D|E1] */ \ 125 { SN9C102_USB_DEVICE(0x0c45, 0x6083, 0xff), }, /* HV7131[D|E1] */ \
114 { USB_DEVICE(0x0c45, 0x6088), }, \ 126 { SN9C102_USB_DEVICE(0x0c45, 0x6088, 0xff), }, \
115 { USB_DEVICE(0x0c45, 0x608a), }, \ 127 { SN9C102_USB_DEVICE(0x0c45, 0x608a, 0xff), }, \
116 { USB_DEVICE(0x0c45, 0x608b), }, \ 128 { SN9C102_USB_DEVICE(0x0c45, 0x608b, 0xff), }, \
117 { USB_DEVICE(0x0c45, 0x608c), }, /* HV7131x */ \ 129 { SN9C102_USB_DEVICE(0x0c45, 0x608c, 0xff), }, /* HV7131x */ \
118 { USB_DEVICE(0x0c45, 0x608e), }, /* CIS-VF10 */ \ 130 { SN9C102_USB_DEVICE(0x0c45, 0x608e, 0xff), }, /* CIS-VF10 */ \
119 { USB_DEVICE(0x0c45, 0x608f), }, /* OV7630 */ \ 131 { SN9C102_USB_DEVICE(0x0c45, 0x608f, 0xff), }, /* OV7630 */ \
120 { USB_DEVICE(0x0c45, 0x60a0), }, \ 132 { SN9C102_USB_DEVICE(0x0c45, 0x60a0, 0xff), }, \
121 { USB_DEVICE(0x0c45, 0x60a2), }, \ 133 { SN9C102_USB_DEVICE(0x0c45, 0x60a2, 0xff), }, \
122 { USB_DEVICE(0x0c45, 0x60a3), }, \ 134 { SN9C102_USB_DEVICE(0x0c45, 0x60a3, 0xff), }, \
123 { USB_DEVICE(0x0c45, 0x60a8), }, /* PAS106B */ \ 135 { SN9C102_USB_DEVICE(0x0c45, 0x60a8, 0xff), }, /* PAS106B */ \
124 { USB_DEVICE(0x0c45, 0x60aa), }, /* TAS5130D1B */ \ 136 { SN9C102_USB_DEVICE(0x0c45, 0x60aa, 0xff), }, /* TAS5130D1B */ \
125 { USB_DEVICE(0x0c45, 0x60ab), }, /* TAS5110C1B */ \ 137 { SN9C102_USB_DEVICE(0x0c45, 0x60ab, 0xff), }, /* TAS5110C1B */ \
126 { USB_DEVICE(0x0c45, 0x60ac), }, \ 138 { SN9C102_USB_DEVICE(0x0c45, 0x60ac, 0xff), }, \
127 { USB_DEVICE(0x0c45, 0x60ae), }, \ 139 { SN9C102_USB_DEVICE(0x0c45, 0x60ae, 0xff), }, \
128 { USB_DEVICE(0x0c45, 0x60af), }, /* PAS202BCB */ \ 140 { SN9C102_USB_DEVICE(0x0c45, 0x60af, 0xff), }, /* PAS202BCB */ \
129 { USB_DEVICE(0x0c45, 0x60b0), }, \ 141 { SN9C102_USB_DEVICE(0x0c45, 0x60b0, 0xff), }, /* OV7630 (?) */ \
130 { USB_DEVICE(0x0c45, 0x60b2), }, \ 142 { SN9C102_USB_DEVICE(0x0c45, 0x60b2, 0xff), }, \
131 { USB_DEVICE(0x0c45, 0x60b3), }, \ 143 { SN9C102_USB_DEVICE(0x0c45, 0x60b3, 0xff), }, \
132 { USB_DEVICE(0x0c45, 0x60b8), }, \ 144 { SN9C102_USB_DEVICE(0x0c45, 0x60b8, 0xff), }, \
133 { USB_DEVICE(0x0c45, 0x60ba), }, \ 145 { SN9C102_USB_DEVICE(0x0c45, 0x60ba, 0xff), }, \
134 { USB_DEVICE(0x0c45, 0x60bb), }, \ 146 { SN9C102_USB_DEVICE(0x0c45, 0x60bb, 0xff), }, \
135 { USB_DEVICE(0x0c45, 0x60bc), }, \ 147 { SN9C102_USB_DEVICE(0x0c45, 0x60bc, 0xff), }, \
136 { USB_DEVICE(0x0c45, 0x60be), }, \ 148 { SN9C102_USB_DEVICE(0x0c45, 0x60be, 0xff), }, \
137 { } \ 149 { } \
138}; 150};
139 151
@@ -177,16 +189,18 @@ extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value);
177extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address); 189extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address);
178 190
179/* I/O on registers in the bridge. Could be used by the sensor methods too */ 191/* I/O on registers in the bridge. Could be used by the sensor methods too */
192extern int sn9c102_write_regs(struct sn9c102_device*, u8* buff, u16 index);
180extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); 193extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index);
181extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index); 194extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index);
182 195
183/* 196/*
184 NOTE: there are no exported debugging functions. To uniform the output you 197 NOTE: there are no exported debugging functions. To uniform the output you
185 must use the dev_info()/dev_warn()/dev_err() macros defined in device.h, 198 must use the dev_info()/dev_warn()/dev_err() macros defined in device.h,
186 already included here, the argument being the struct device 'dev' of the 199 already included here, the argument being the struct device '&usbdev->dev'
187 sensor structure. Do NOT use these macros before the sensor is attached or 200 of the sensor structure. Do NOT use these macros before the sensor is
188 the kernel will crash! However, you should not need to notify the user about 201 attached or the kernel will crash! However, you should not need to notify
189 common errors or other messages, since this is done by the master module. 202 the user about common errors or other messages, since this is done by the
203 master module.
190*/ 204*/
191 205
192/*****************************************************************************/ 206/*****************************************************************************/
@@ -345,13 +359,6 @@ struct sn9c102_sensor {
345 error code without rolling back. 359 error code without rolling back.
346 */ 360 */
347 361
348 const struct device* dev;
349 /*
350 This is the argument for dev_err(), dev_info() and dev_warn(). It
351 is used for debugging purposes. You must not access the struct
352 before the sensor is attached.
353 */
354
355 const struct usb_device* usbdev; 362 const struct usb_device* usbdev;
356 /* 363 /*
357 Points to the usb_device struct after the sensor is attached. 364 Points to the usb_device struct after the sensor is attached.
diff --git a/drivers/usb/media/sn9c102_tas5110c1b.c b/drivers/usb/media/sn9c102_tas5110c1b.c
index 8775999b5aff..32ddf236cafe 100644
--- a/drivers/usb/media/sn9c102_tas5110c1b.c
+++ b/drivers/usb/media/sn9c102_tas5110c1b.c
@@ -2,7 +2,7 @@
2 * Plug-in for TAS5110C1B image sensor connected to the SN9C10x PC Camera * 2 * Plug-in for TAS5110C1B image sensor connected to the SN9C10x PC Camera *
3 * Controllers * 3 * Controllers *
4 * * 4 * *
5 * Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 * Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
diff --git a/drivers/usb/media/sn9c102_tas5130d1b.c b/drivers/usb/media/sn9c102_tas5130d1b.c
index 927eafdd8c73..a0728f0ae00c 100644
--- a/drivers/usb/media/sn9c102_tas5130d1b.c
+++ b/drivers/usb/media/sn9c102_tas5130d1b.c
@@ -2,7 +2,7 @@
2 * Plug-in for TAS5130D1B image sensor connected to the SN9C10x PC Camera * 2 * Plug-in for TAS5130D1B image sensor connected to the SN9C10x PC Camera *
3 * Controllers * 3 * Controllers *
4 * * 4 * *
5 * Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> * 5 * Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c
index bff9434c8e55..9937fc64c8bf 100644
--- a/drivers/usb/media/w9968cf.c
+++ b/drivers/usb/media/w9968cf.c
@@ -62,7 +62,6 @@ MODULE_LICENSE(W9968CF_MODULE_LICENSE);
62MODULE_SUPPORTED_DEVICE("Video"); 62MODULE_SUPPORTED_DEVICE("Video");
63 63
64static int ovmod_load = W9968CF_OVMOD_LOAD; 64static int ovmod_load = W9968CF_OVMOD_LOAD;
65static int vppmod_load = W9968CF_VPPMOD_LOAD;
66static unsigned short simcams = W9968CF_SIMCAMS; 65static unsigned short simcams = W9968CF_SIMCAMS;
67static short video_nr[]={[0 ... W9968CF_MAX_DEVICES-1] = -1}; /*-1=first free*/ 66static short video_nr[]={[0 ... W9968CF_MAX_DEVICES-1] = -1}; /*-1=first free*/
68static unsigned int packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1] = 67static unsigned int packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1] =
@@ -107,7 +106,6 @@ static unsigned int param_nv[24]; /* number of values per parameter */
107 106
108#ifdef CONFIG_KMOD 107#ifdef CONFIG_KMOD
109module_param(ovmod_load, bool, 0644); 108module_param(ovmod_load, bool, 0644);
110module_param(vppmod_load, bool, 0444);
111#endif 109#endif
112module_param(simcams, ushort, 0644); 110module_param(simcams, ushort, 0644);
113module_param_array(video_nr, short, &param_nv[0], 0444); 111module_param_array(video_nr, short, &param_nv[0], 0444);
@@ -150,18 +148,6 @@ MODULE_PARM_DESC(ovmod_load,
150 "\ninto memory." 148 "\ninto memory."
151 "\nDefault value is "__MODULE_STRING(W9968CF_OVMOD_LOAD)"." 149 "\nDefault value is "__MODULE_STRING(W9968CF_OVMOD_LOAD)"."
152 "\n"); 150 "\n");
153MODULE_PARM_DESC(vppmod_load,
154 "\n<0|1> Automatic 'w9968cf-vpp' module loading."
155 "\n0 disabled, 1 enabled."
156 "\nIf enabled, every time an application attempts to open a"
157 "\ncamera, 'insmod' searches for the video post-processing"
158 "\nmodule in the system and loads it automatically (if"
159 "\npresent). The optional 'w9968cf-vpp' module adds extra"
160 "\n image manipulation functions to the 'w9968cf' module,like"
161 "\nsoftware up-scaling,colour conversions and video decoding"
162 "\nfor very high frame rates."
163 "\nDefault value is "__MODULE_STRING(W9968CF_VPPMOD_LOAD)"."
164 "\n");
165#endif 151#endif
166MODULE_PARM_DESC(simcams, 152MODULE_PARM_DESC(simcams,
167 "\n<n> Number of cameras allowed to stream simultaneously." 153 "\n<n> Number of cameras allowed to stream simultaneously."
@@ -492,10 +478,6 @@ static void w9968cf_push_frame(struct w9968cf_device*, u8 f_num);
492static void w9968cf_pop_frame(struct w9968cf_device*,struct w9968cf_frame_t**); 478static void w9968cf_pop_frame(struct w9968cf_device*,struct w9968cf_frame_t**);
493static void w9968cf_release_resources(struct w9968cf_device*); 479static void w9968cf_release_resources(struct w9968cf_device*);
494 480
495/* Intermodule communication */
496static int w9968cf_vppmod_detect(struct w9968cf_device*);
497static void w9968cf_vppmod_release(struct w9968cf_device*);
498
499 481
500 482
501/**************************************************************************** 483/****************************************************************************
@@ -2737,9 +2719,7 @@ static int w9968cf_open(struct inode* inode, struct file* filp)
2737 cam->streaming = 0; 2719 cam->streaming = 0;
2738 cam->misconfigured = 0; 2720 cam->misconfigured = 0;
2739 2721
2740 if (!w9968cf_vpp) 2722 w9968cf_adjust_configuration(cam);
2741 if ((err = w9968cf_vppmod_detect(cam)))
2742 goto out;
2743 2723
2744 if ((err = w9968cf_allocate_memory(cam))) 2724 if ((err = w9968cf_allocate_memory(cam)))
2745 goto deallocate_memory; 2725 goto deallocate_memory;
@@ -2766,7 +2746,6 @@ static int w9968cf_open(struct inode* inode, struct file* filp)
2766 2746
2767deallocate_memory: 2747deallocate_memory:
2768 w9968cf_deallocate_memory(cam); 2748 w9968cf_deallocate_memory(cam);
2769out:
2770 DBG(2, "Failed to open the video device") 2749 DBG(2, "Failed to open the video device")
2771 up(&cam->dev_sem); 2750 up(&cam->dev_sem);
2772 up_read(&w9968cf_disconnect); 2751 up_read(&w9968cf_disconnect);
@@ -2784,8 +2763,6 @@ static int w9968cf_release(struct inode* inode, struct file* filp)
2784 2763
2785 w9968cf_stop_transfer(cam); 2764 w9968cf_stop_transfer(cam);
2786 2765
2787 w9968cf_vppmod_release(cam);
2788
2789 if (cam->disconnected) { 2766 if (cam->disconnected) {
2790 w9968cf_release_resources(cam); 2767 w9968cf_release_resources(cam);
2791 up(&cam->dev_sem); 2768 up(&cam->dev_sem);
@@ -3681,106 +3658,6 @@ static struct usb_driver w9968cf_usb_driver = {
3681 * Module init, exit and intermodule communication * 3658 * Module init, exit and intermodule communication *
3682 ****************************************************************************/ 3659 ****************************************************************************/
3683 3660
3684static int w9968cf_vppmod_detect(struct w9968cf_device* cam)
3685{
3686 if (!w9968cf_vpp)
3687 if (vppmod_load)
3688 request_module("w9968cf-vpp");
3689
3690 down(&w9968cf_vppmod_lock);
3691
3692 if (!w9968cf_vpp) {
3693 DBG(4, "Video post-processing module not detected")
3694 w9968cf_adjust_configuration(cam);
3695 goto out;
3696 }
3697
3698 if (!try_module_get(w9968cf_vpp->owner)) {
3699 DBG(1, "Couldn't increment the reference count of "
3700 "the video post-processing module")
3701 up(&w9968cf_vppmod_lock);
3702 return -ENOSYS;
3703 }
3704
3705 w9968cf_vpp->busy++;
3706
3707 DBG(5, "Video post-processing module detected")
3708
3709out:
3710 up(&w9968cf_vppmod_lock);
3711 return 0;
3712}
3713
3714
3715static void w9968cf_vppmod_release(struct w9968cf_device* cam)
3716{
3717 down(&w9968cf_vppmod_lock);
3718
3719 if (w9968cf_vpp && w9968cf_vpp->busy) {
3720 module_put(w9968cf_vpp->owner);
3721 w9968cf_vpp->busy--;
3722 wake_up(&w9968cf_vppmod_wait);
3723 DBG(5, "Video post-processing module released")
3724 }
3725
3726 up(&w9968cf_vppmod_lock);
3727}
3728
3729
3730int w9968cf_vppmod_register(struct w9968cf_vpp_t* vpp)
3731{
3732 down(&w9968cf_vppmod_lock);
3733
3734 if (w9968cf_vpp) {
3735 KDBG(1, "Video post-processing module already registered")
3736 up(&w9968cf_vppmod_lock);
3737 return -EINVAL;
3738 }
3739
3740 w9968cf_vpp = vpp;
3741 w9968cf_vpp->busy = 0;
3742
3743 KDBG(2, "Video post-processing module registered")
3744 up(&w9968cf_vppmod_lock);
3745 return 0;
3746}
3747
3748
3749int w9968cf_vppmod_deregister(struct w9968cf_vpp_t* vpp)
3750{
3751 down(&w9968cf_vppmod_lock);
3752
3753 if (!w9968cf_vpp) {
3754 up(&w9968cf_vppmod_lock);
3755 return -EINVAL;
3756 }
3757
3758 if (w9968cf_vpp != vpp) {
3759 KDBG(1, "Only the owner can unregister the video "
3760 "post-processing module")
3761 up(&w9968cf_vppmod_lock);
3762 return -EINVAL;
3763 }
3764
3765 if (w9968cf_vpp->busy) {
3766 KDBG(2, "Video post-processing module busy. Wait for it to be "
3767 "released...")
3768 up(&w9968cf_vppmod_lock);
3769 wait_event(w9968cf_vppmod_wait, !w9968cf_vpp->busy);
3770 w9968cf_vpp = NULL;
3771 goto out;
3772 }
3773
3774 w9968cf_vpp = NULL;
3775
3776 up(&w9968cf_vppmod_lock);
3777
3778out:
3779 KDBG(2, "Video post-processing module unregistered")
3780 return 0;
3781}
3782
3783
3784static int __init w9968cf_module_init(void) 3661static int __init w9968cf_module_init(void)
3785{ 3662{
3786 int err; 3663 int err;
@@ -3810,6 +3687,3 @@ static void __exit w9968cf_module_exit(void)
3810module_init(w9968cf_module_init); 3687module_init(w9968cf_module_init);
3811module_exit(w9968cf_module_exit); 3688module_exit(w9968cf_module_exit);
3812 3689
3813
3814EXPORT_SYMBOL(w9968cf_vppmod_register);
3815EXPORT_SYMBOL(w9968cf_vppmod_deregister);
diff --git a/drivers/usb/media/w9968cf.h b/drivers/usb/media/w9968cf.h
index 8acbfe205bc7..47a6ff794171 100644
--- a/drivers/usb/media/w9968cf.h
+++ b/drivers/usb/media/w9968cf.h
@@ -195,7 +195,6 @@ enum w9968cf_vpp_flag {
195}; 195};
196 196
197static struct w9968cf_vpp_t* w9968cf_vpp; 197static struct w9968cf_vpp_t* w9968cf_vpp;
198static DECLARE_MUTEX(w9968cf_vppmod_lock);
199static DECLARE_WAIT_QUEUE_HEAD(w9968cf_vppmod_wait); 198static DECLARE_WAIT_QUEUE_HEAD(w9968cf_vppmod_wait);
200 199
201static LIST_HEAD(w9968cf_dev_list); /* head of V4L registered cameras list */ 200static LIST_HEAD(w9968cf_dev_list); /* head of V4L registered cameras list */
diff --git a/drivers/usb/media/w9968cf_vpp.h b/drivers/usb/media/w9968cf_vpp.h
index 3f5317dc4c29..f3b91b782671 100644
--- a/drivers/usb/media/w9968cf_vpp.h
+++ b/drivers/usb/media/w9968cf_vpp.h
@@ -37,7 +37,4 @@ struct w9968cf_vpp_t {
37 u8 busy; /* read-only flag: module is/is not in use */ 37 u8 busy; /* read-only flag: module is/is not in use */
38}; 38};
39 39
40extern int w9968cf_vppmod_register(struct w9968cf_vpp_t*);
41extern int w9968cf_vppmod_deregister(struct w9968cf_vpp_t*);
42
43#endif /* _W9968CF_VPP_H_ */ 40#endif /* _W9968CF_VPP_H_ */
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 449b2501acf3..ad2f4cccd388 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -2093,6 +2093,8 @@ static void auerswald_disconnect (struct usb_interface *intf)
2093static struct usb_device_id auerswald_ids [] = { 2093static struct usb_device_id auerswald_ids [] = {
2094 { USB_DEVICE (ID_AUERSWALD, 0x00C0) }, /* COMpact 2104 USB */ 2094 { USB_DEVICE (ID_AUERSWALD, 0x00C0) }, /* COMpact 2104 USB */
2095 { USB_DEVICE (ID_AUERSWALD, 0x00DB) }, /* COMpact 4410/2206 USB */ 2095 { USB_DEVICE (ID_AUERSWALD, 0x00DB) }, /* COMpact 4410/2206 USB */
2096 { USB_DEVICE (ID_AUERSWALD, 0x00DC) }, /* COMpact 4406 DSL */
2097 { USB_DEVICE (ID_AUERSWALD, 0x00DD) }, /* COMpact 2204 USB */
2096 { USB_DEVICE (ID_AUERSWALD, 0x00F1) }, /* Comfort 2000 System Telephone */ 2098 { USB_DEVICE (ID_AUERSWALD, 0x00F1) }, /* Comfort 2000 System Telephone */
2097 { USB_DEVICE (ID_AUERSWALD, 0x00F2) }, /* Comfort 1200 System Telephone */ 2099 { USB_DEVICE (ID_AUERSWALD, 0x00F2) }, /* Comfort 1200 System Telephone */
2098 { } /* Terminating entry */ 2100 { } /* Terminating entry */
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 981d8a5fbfd9..331d4ae949ed 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -593,7 +593,7 @@ static struct file_operations ld_usb_fops = {
593 593
594/* 594/*
595 * usb class driver info in order to get a minor number from the usb core, 595 * usb class driver info in order to get a minor number from the usb core,
596 * and to have the device registered with devfs and the driver core 596 * and to have the device registered with the driver core
597 */ 597 */
598static struct usb_class_driver ld_usb_class = { 598static struct usb_class_driver ld_usb_class = {
599 .name = "ldusb%d", 599 .name = "ldusb%d",
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index 541181695040..3094970615cb 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -916,6 +916,10 @@ static const struct usb_device_id products [] = {
916 // Linksys USB200M Rev 2 916 // Linksys USB200M Rev 2
917 USB_DEVICE (0x13b1, 0x0018), 917 USB_DEVICE (0x13b1, 0x0018),
918 .driver_info = (unsigned long) &ax88772_info, 918 .driver_info = (unsigned long) &ax88772_info,
919}, {
920 // 0Q0 cable ethernet
921 USB_DEVICE (0x1557, 0x7720),
922 .driver_info = (unsigned long) &ax88772_info,
919}, 923},
920 { }, // END 924 { }, // END
921}; 925};
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index da46b351e188..dc7a069503e0 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -32,7 +32,7 @@
32/* 32/*
33 * Version Information 33 * Version Information
34 */ 34 */
35#define DRIVER_VERSION "v0.05" 35#define DRIVER_VERSION "v0.06"
36#define DRIVER_DESC "Silicon Labs CP2101/CP2102 RS232 serial adaptor driver" 36#define DRIVER_DESC "Silicon Labs CP2101/CP2102 RS232 serial adaptor driver"
37 37
38/* 38/*
@@ -55,11 +55,15 @@ static int debug;
55 55
56static struct usb_device_id id_table [] = { 56static struct usb_device_id id_table [] = {
57 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ 57 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */
58 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
59 { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */
60 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */
61 { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ 58 { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */
62 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ 59 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */
60 { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */
61 { USB_DEVICE(0x10C4, 0x807A) }, /* Crumb128 board */
62 { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */
63 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */
64 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */
65 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
66 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
63 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ 67 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
64 { } /* Terminating Entry */ 68 { } /* Terminating Entry */
65}; 69};
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 10bc1bf23b35..f2b4ca8692d8 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -476,10 +476,16 @@ static struct usb_device_id id_table_combined [] = {
476 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, 476 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
477 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, 477 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
478 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, 478 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
479 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) },
479 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) }, 480 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) },
481 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HRC_PID) },
480 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) }, 482 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) },
481 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) }, 483 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) },
482 { USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) }, 484 { USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) },
485 { USB_DEVICE(FTDI_VID, FTDI_TTUSB_PID) },
486 { USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_777_PID) },
487 { USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_8900F_PID) },
488 { USB_DEVICE(FTDI_VID, FTDI_PCDJ_DAC2_PID) },
483 { }, /* Optional parameter entry */ 489 { }, /* Optional parameter entry */
484 { } /* Terminating entry */ 490 { } /* Terminating entry */
485}; 491};
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 00d45f8600de..ca40f16370f1 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -31,9 +31,14 @@
31#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */ 31#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */
32#define FTDI_NF_RIC_PID 0x0001 /* Product Id */ 32#define FTDI_NF_RIC_PID 0x0001 /* Product Id */
33 33
34
34/* www.irtrans.de device */ 35/* www.irtrans.de device */
35#define FTDI_IRTRANS_PID 0xFC60 /* Product Id */ 36#define FTDI_IRTRANS_PID 0xFC60 /* Product Id */
36 37
38
39/* www.thoughttechnology.com/ TT-USB provide with procomp use ftdi_sio */
40#define FTDI_TTUSB_PID 0xFF20 /* Product Id */
41
37/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */ 42/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */
38/* they use the ftdi chipset for the USB interface and the vendor id is the same */ 43/* they use the ftdi chipset for the USB interface and the vendor id is the same */
39#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ 44#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
@@ -51,6 +56,12 @@
51#define FTDI_VNHCPCUSB_D_PID 0xfe38 /* Product Id */ 56#define FTDI_VNHCPCUSB_D_PID 0xfe38 /* Product Id */
52 57
53/* 58/*
59 * PCDJ use ftdi based dj-controllers. The following PID is for their DAC-2 device
60 * http://www.pcdjhardware.com/DAC2.asp (PID sent by Wouter Paesen)
61 * (the VID is the standard ftdi vid (FTDI_VID) */
62#define FTDI_PCDJ_DAC2_PID 0xFA88
63
64/*
54 * The following are the values for the Matrix Orbital LCD displays, 65 * The following are the values for the Matrix Orbital LCD displays,
55 * which are the FT232BM ( similar to the 8U232AM ) 66 * which are the FT232BM ( similar to the 8U232AM )
56 */ 67 */
@@ -215,8 +226,10 @@
215 * Definitions for ATIK Instruments astronomical USB based cameras 226 * Definitions for ATIK Instruments astronomical USB based cameras
216 * Check it at http://www.atik-instruments.com/ 227 * Check it at http://www.atik-instruments.com/
217 */ 228 */
218#define FTDI_ATIK_ATK16_PID 0xDF30 /* ATIK ATK-16 Camera */ 229#define FTDI_ATIK_ATK16_PID 0xDF30 /* ATIK ATK-16 Grayscale Camera */
219#define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Camera */ 230#define FTDI_ATIK_ATK16C_PID 0xDF32 /* ATIK ATK-16C Colour Camera */
231#define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Grayscale Camera */
232#define FTDI_ATIK_ATK16HRC_PID 0xDF33 /* ATIK ATK-16HRC Colour Camera */
220 233
221/* 234/*
222 * Protego product ids 235 * Protego product ids
@@ -365,6 +378,12 @@
365#define POSIFLEX_VID 0x0d3a /* Vendor ID */ 378#define POSIFLEX_VID 0x0d3a /* Vendor ID */
366#define POSIFLEX_PP7000_PID 0x0300 /* PP-7000II thermal printer */ 379#define POSIFLEX_PP7000_PID 0x0300 /* PP-7000II thermal printer */
367 380
381/*
382 * Westrex International devices submitted by Cory Lee
383 */
384#define FTDI_WESTREX_MODEL_777_PID 0xDC00 /* Model 777 */
385#define FTDI_WESTREX_MODEL_8900F_PID 0xDC01 /* Model 8900F */
386
368/* Commands */ 387/* Commands */
369#define FTDI_SIO_RESET 0 /* Reset the port */ 388#define FTDI_SIO_RESET 0 /* Reset the port */
370#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 389#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 0eb883f44ada..e8e575e037c1 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -73,7 +73,9 @@ static struct usb_device_id id_table [] = {
73 { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, 73 { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) },
74 { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X75) }, 74 { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X75) },
75 { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) }, 75 { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) },
76 { USB_DEVICE( NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID ) }, 76 { USB_DEVICE(NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID ) },
77 { USB_DEVICE(CA_42_CA42_VENDOR_ID, CA_42_CA42_PRODUCT_ID ) },
78 { USB_DEVICE(SAGEM_VENDOR_ID, SAGEM_PRODUCT_ID) },
77 { } /* Terminating entry */ 79 { } /* Terminating entry */
78}; 80};
79 81
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 21d434d81813..1807087a76e3 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -64,3 +64,10 @@
64/* Nokia CA-42 Cable */ 64/* Nokia CA-42 Cable */
65#define NOKIA_CA42_VENDOR_ID 0x078b 65#define NOKIA_CA42_VENDOR_ID 0x078b
66#define NOKIA_CA42_PRODUCT_ID 0x1234 66#define NOKIA_CA42_PRODUCT_ID 0x1234
67
68/* CA-42 CLONE Cable www.ca-42.com chipset: Prolific Technology Inc */
69#define CA_42_CA42_VENDOR_ID 0x10b5
70#define CA_42_CA42_PRODUCT_ID 0xac70
71
72#define SAGEM_VENDOR_ID 0x079b
73#define SAGEM_PRODUCT_ID 0x0027
diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c
index 5b06f9240d05..ab173b30076e 100644
--- a/drivers/usb/storage/initializers.c
+++ b/drivers/usb/storage/initializers.c
@@ -45,6 +45,12 @@
45#include "debug.h" 45#include "debug.h"
46#include "transport.h" 46#include "transport.h"
47 47
48#define RIO_MSC 0x08
49#define RIOP_INIT "RIOP\x00\x01\x08"
50#define RIOP_INIT_LEN 7
51#define RIO_SEND_LEN 40
52#define RIO_RECV_LEN 0x200
53
48/* This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target 54/* This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target
49 * mode */ 55 * mode */
50int usb_stor_euscsi_init(struct us_data *us) 56int usb_stor_euscsi_init(struct us_data *us)
@@ -91,3 +97,70 @@ int usb_stor_ucr61s2b_init(struct us_data *us)
91 97
92 return (res ? -1 : 0); 98 return (res ? -1 : 0);
93} 99}
100
101/* Place the Rio Karma into mass storage mode.
102 *
103 * The initialization begins by sending 40 bytes starting
104 * RIOP\x00\x01\x08\x00, which the device will ack with a 512-byte
105 * packet with the high four bits set and everything else null.
106 *
107 * Next, we send RIOP\x80\x00\x08\x00. Each time, a 512 byte response
108 * must be read, but we must loop until byte 5 in the response is 0x08,
109 * indicating success. */
110int rio_karma_init(struct us_data *us)
111{
112 int result, partial;
113 char *recv;
114 unsigned long timeout;
115
116 // us->iobuf is big enough to hold cmd but not receive
117 if (!(recv = kmalloc(RIO_RECV_LEN, GFP_KERNEL)))
118 goto die_nomem;
119
120 US_DEBUGP("Initializing Karma...\n");
121
122 memset(us->iobuf, 0, RIO_SEND_LEN);
123 memcpy(us->iobuf, RIOP_INIT, RIOP_INIT_LEN);
124
125 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
126 us->iobuf, RIO_SEND_LEN, &partial);
127 if (result != USB_STOR_XFER_GOOD)
128 goto die;
129
130 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
131 recv, RIO_RECV_LEN, &partial);
132 if (result != USB_STOR_XFER_GOOD)
133 goto die;
134
135 us->iobuf[4] = 0x80;
136 us->iobuf[5] = 0;
137 timeout = jiffies + msecs_to_jiffies(3000);
138 for (;;) {
139 US_DEBUGP("Sending init command\n");
140 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
141 us->iobuf, RIO_SEND_LEN, &partial);
142 if (result != USB_STOR_XFER_GOOD)
143 goto die;
144
145 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
146 recv, RIO_RECV_LEN, &partial);
147 if (result != USB_STOR_XFER_GOOD)
148 goto die;
149
150 if (recv[5] == RIO_MSC)
151 break;
152 if (time_after(jiffies, timeout))
153 goto die;
154 msleep(10);
155 }
156 US_DEBUGP("Karma initialized.\n");
157 kfree(recv);
158 return 0;
159
160die:
161 kfree(recv);
162die_nomem:
163 US_DEBUGP("Could not initialize karma.\n");
164 return USB_STOR_TRANSPORT_FAILED;
165}
166
diff --git a/drivers/usb/storage/initializers.h b/drivers/usb/storage/initializers.h
index 4c1b2bd2e2e4..f9907a5cf129 100644
--- a/drivers/usb/storage/initializers.h
+++ b/drivers/usb/storage/initializers.h
@@ -48,3 +48,4 @@ int usb_stor_euscsi_init(struct us_data *us);
48/* This function is required to activate all four slots on the UCR-61S2B 48/* This function is required to activate all four slots on the UCR-61S2B
49 * flash reader */ 49 * flash reader */
50int usb_stor_ucr61s2b_init(struct us_data *us); 50int usb_stor_ucr61s2b_init(struct us_data *us);
51int rio_karma_init(struct us_data *us);
diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c
index b28151d1b609..b1ec4a718547 100644
--- a/drivers/usb/storage/libusual.c
+++ b/drivers/usb/storage/libusual.c
@@ -116,7 +116,7 @@ EXPORT_SYMBOL_GPL(usb_usual_check_type);
116static int usu_probe(struct usb_interface *intf, 116static int usu_probe(struct usb_interface *intf,
117 const struct usb_device_id *id) 117 const struct usb_device_id *id)
118{ 118{
119 int type; 119 unsigned long type;
120 int rc; 120 int rc;
121 unsigned long flags; 121 unsigned long flags;
122 122
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index dc301e567cfc..ee958f986eb8 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -145,6 +145,11 @@ UNUSUAL_DEV( 0x0451, 0x5416, 0x0100, 0x0100,
145 US_SC_DEVICE, US_PR_BULK, NULL, 145 US_SC_DEVICE, US_PR_BULK, NULL,
146 US_FL_NEED_OVERRIDE ), 146 US_FL_NEED_OVERRIDE ),
147 147
148UNUSUAL_DEV( 0x045a, 0x5210, 0x0101, 0x0101,
149 "Rio",
150 "Rio Karma",
151 US_SC_SCSI, US_PR_BULK, rio_karma_init, 0),
152
148/* Patch submitted by Philipp Friedrich <philipp@void.at> */ 153/* Patch submitted by Philipp Friedrich <philipp@void.at> */
149UNUSUAL_DEV( 0x0482, 0x0100, 0x0100, 0x0100, 154UNUSUAL_DEV( 0x0482, 0x0100, 0x0100, 0x0100,
150 "Kyocera", 155 "Kyocera",
@@ -424,11 +429,11 @@ UNUSUAL_DEV( 0x054c, 0x0010, 0x0106, 0x0450,
424 US_FL_SINGLE_LUN | US_FL_NOT_LOCKABLE | US_FL_NO_WP_DETECT ), 429 US_FL_SINGLE_LUN | US_FL_NOT_LOCKABLE | US_FL_NO_WP_DETECT ),
425 430
426/* This entry is needed because the device reports Sub=ff */ 431/* This entry is needed because the device reports Sub=ff */
427UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0500, 432UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0600,
428 "Sony", 433 "Sony",
429 "DSC-T1", 434 "DSC-T1/T5",
430 US_SC_8070, US_PR_DEVICE, NULL, 435 US_SC_8070, US_PR_DEVICE, NULL,
431 US_FL_SINGLE_LUN ), 436 US_FL_SINGLE_LUN ),
432 437
433 438
434/* Reported by wim@geeks.nl */ 439/* Reported by wim@geeks.nl */
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 5d02f16b7d0e..4de9fb56ebfc 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -234,7 +234,7 @@ static struct file_operations skel_fops = {
234 234
235/* 235/*
236 * usb class driver info in order to get a minor number from the usb core, 236 * usb class driver info in order to get a minor number from the usb core,
237 * and to have the device registered with devfs and the driver core 237 * and to have the device registered with the driver core
238 */ 238 */
239static struct usb_class_driver skel_class = { 239static struct usb_class_driver skel_class = {
240 .name = "skel%d", 240 .name = "skel%d",
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index b2187175d03f..6761b68c35e9 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -116,9 +116,10 @@ clcdfb_set_bitfields(struct clcd_fb *fb, struct fb_var_screeninfo *var)
116 int ret = 0; 116 int ret = 0;
117 117
118 memset(&var->transp, 0, sizeof(var->transp)); 118 memset(&var->transp, 0, sizeof(var->transp));
119 memset(&var->red, 0, sizeof(var->red)); 119
120 memset(&var->green, 0, sizeof(var->green)); 120 var->red.msb_right = 0;
121 memset(&var->blue, 0, sizeof(var->blue)); 121 var->green.msb_right = 0;
122 var->blue.msb_right = 0;
122 123
123 switch (var->bits_per_pixel) { 124 switch (var->bits_per_pixel) {
124 case 1: 125 case 1:
@@ -133,34 +134,20 @@ clcdfb_set_bitfields(struct clcd_fb *fb, struct fb_var_screeninfo *var)
133 var->blue.offset = 0; 134 var->blue.offset = 0;
134 break; 135 break;
135 case 16: 136 case 16:
136 var->red.length = 5; 137 var->red.length = 5;
137 var->green.length = 6; 138 var->blue.length = 5;
138 var->blue.length = 5; 139 /*
139 if (fb->panel->cntl & CNTL_BGR) { 140 * Green length can be 5 or 6 depending whether
140 var->red.offset = 11; 141 * we're operating in RGB555 or RGB565 mode.
141 var->green.offset = 5; 142 */
142 var->blue.offset = 0; 143 if (var->green.length != 5 && var->green.length != 6)
143 } else { 144 var->green.length = 6;
144 var->red.offset = 0;
145 var->green.offset = 5;
146 var->blue.offset = 11;
147 }
148 break; 145 break;
149 case 32: 146 case 32:
150 if (fb->panel->cntl & CNTL_LCDTFT) { 147 if (fb->panel->cntl & CNTL_LCDTFT) {
151 var->red.length = 8; 148 var->red.length = 8;
152 var->green.length = 8; 149 var->green.length = 8;
153 var->blue.length = 8; 150 var->blue.length = 8;
154
155 if (fb->panel->cntl & CNTL_BGR) {
156 var->red.offset = 16;
157 var->green.offset = 8;
158 var->blue.offset = 0;
159 } else {
160 var->red.offset = 0;
161 var->green.offset = 8;
162 var->blue.offset = 16;
163 }
164 break; 151 break;
165 } 152 }
166 default: 153 default:
@@ -168,6 +155,23 @@ clcdfb_set_bitfields(struct clcd_fb *fb, struct fb_var_screeninfo *var)
168 break; 155 break;
169 } 156 }
170 157
158 /*
159 * >= 16bpp displays have separate colour component bitfields
160 * encoded in the pixel data. Calculate their position from
161 * the bitfield length defined above.
162 */
163 if (ret == 0 && var->bits_per_pixel >= 16) {
164 if (fb->panel->cntl & CNTL_BGR) {
165 var->blue.offset = 0;
166 var->green.offset = var->blue.offset + var->blue.length;
167 var->red.offset = var->green.offset + var->green.length;
168 } else {
169 var->red.offset = 0;
170 var->green.offset = var->red.offset + var->red.length;
171 var->blue.offset = var->green.offset + var->green.length;
172 }
173 }
174
171 return ret; 175 return ret;
172} 176}
173 177
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 996d543d6609..9d996f2c10d5 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -50,3 +50,11 @@ config BACKLIGHT_CORGI
50 If you have a Sharp Zaurus SL-C7xx, say y to enable the 50 If you have a Sharp Zaurus SL-C7xx, say y to enable the
51 backlight driver. 51 backlight driver.
52 52
53config BACKLIGHT_HP680
54 tristate "HP Jornada 680 Backlight Driver"
55 depends on BACKLIGHT_DEVICE && SH_HP6XX
56 default y
57 help
58 If you have a HP Jornada 680, say y to enable the
59 backlight driver.
60
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 4af321fae390..744210c38e74 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -3,4 +3,5 @@
3obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o 3obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o
4obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o 4obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
5obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o 5obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o
6obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
6obj-$(CONFIG_SHARP_LOCOMO) += locomolcd.o 7obj-$(CONFIG_SHARP_LOCOMO) += locomolcd.o
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
new file mode 100644
index 000000000000..95da4c9ed1f1
--- /dev/null
+++ b/drivers/video/backlight/hp680_bl.c
@@ -0,0 +1,189 @@
1/*
2 * Backlight Driver for HP Jornada 680
3 *
4 * Copyright (c) 2005 Andriy Skulysh
5 *
6 * Based on Sharp's Corgi Backlight Driver
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/device.h>
17#include <linux/spinlock.h>
18#include <linux/fb.h>
19#include <linux/backlight.h>
20
21#include <asm/cpu/dac.h>
22#include <asm/hp6xx/hp6xx.h>
23#include <asm/hd64461/hd64461.h>
24
25#define HP680_MAX_INTENSITY 255
26#define HP680_DEFAULT_INTENSITY 10
27
28static int hp680bl_powermode = FB_BLANK_UNBLANK;
29static int current_intensity = 0;
30static spinlock_t bl_lock = SPIN_LOCK_UNLOCKED;
31
32static void hp680bl_send_intensity(int intensity)
33{
34 unsigned long flags;
35
36 if (hp680bl_powermode != FB_BLANK_UNBLANK)
37 intensity = 0;
38
39 spin_lock_irqsave(&bl_lock, flags);
40 sh_dac_output(255-(u8)intensity, DAC_LCD_BRIGHTNESS);
41 spin_unlock_irqrestore(&bl_lock, flags);
42}
43
44static void hp680bl_blank(int blank)
45{
46 u16 v;
47
48 switch(blank) {
49
50 case FB_BLANK_NORMAL:
51 case FB_BLANK_VSYNC_SUSPEND:
52 case FB_BLANK_HSYNC_SUSPEND:
53 case FB_BLANK_POWERDOWN:
54 if (hp680bl_powermode == FB_BLANK_UNBLANK) {
55 hp680bl_send_intensity(0);
56 hp680bl_powermode = blank;
57 sh_dac_disable(DAC_LCD_BRIGHTNESS);
58 v = inw(HD64461_GPBDR);
59 v |= HD64461_GPBDR_LCDOFF;
60 outw(v, HD64461_GPBDR);
61 }
62 break;
63 case FB_BLANK_UNBLANK:
64 if (hp680bl_powermode != FB_BLANK_UNBLANK) {
65 sh_dac_enable(DAC_LCD_BRIGHTNESS);
66 v = inw(HD64461_GPBDR);
67 v &= ~HD64461_GPBDR_LCDOFF;
68 outw(v, HD64461_GPBDR);
69 hp680bl_powermode = blank;
70 hp680bl_send_intensity(current_intensity);
71 }
72 break;
73 }
74}
75
76#ifdef CONFIG_PM
77static int hp680bl_suspend(struct device *dev, pm_message_t state, u32 level)
78{
79 if (level == SUSPEND_POWER_DOWN)
80 hp680bl_blank(FB_BLANK_POWERDOWN);
81 return 0;
82}
83
84static int hp680bl_resume(struct device *dev, u32 level)
85{
86 if (level == RESUME_POWER_ON)
87 hp680bl_blank(FB_BLANK_UNBLANK);
88 return 0;
89}
90#else
91#define hp680bl_suspend NULL
92#define hp680bl_resume NULL
93#endif
94
95
96static int hp680bl_set_power(struct backlight_device *bd, int state)
97{
98 hp680bl_blank(state);
99 return 0;
100}
101
102static int hp680bl_get_power(struct backlight_device *bd)
103{
104 return hp680bl_powermode;
105}
106
107static int hp680bl_set_intensity(struct backlight_device *bd, int intensity)
108{
109 if (intensity > HP680_MAX_INTENSITY)
110 intensity = HP680_MAX_INTENSITY;
111 hp680bl_send_intensity(intensity);
112 current_intensity = intensity;
113 return 0;
114}
115
116static int hp680bl_get_intensity(struct backlight_device *bd)
117{
118 return current_intensity;
119}
120
121static struct backlight_properties hp680bl_data = {
122 .owner = THIS_MODULE,
123 .get_power = hp680bl_get_power,
124 .set_power = hp680bl_set_power,
125 .max_brightness = HP680_MAX_INTENSITY,
126 .get_brightness = hp680bl_get_intensity,
127 .set_brightness = hp680bl_set_intensity,
128};
129
130static struct backlight_device *hp680_backlight_device;
131
132static int __init hp680bl_probe(struct device *dev)
133{
134 hp680_backlight_device = backlight_device_register ("hp680-bl",
135 NULL, &hp680bl_data);
136 if (IS_ERR (hp680_backlight_device))
137 return PTR_ERR (hp680_backlight_device);
138
139 hp680bl_set_intensity(NULL, HP680_DEFAULT_INTENSITY);
140
141 return 0;
142}
143
144static int hp680bl_remove(struct device *dev)
145{
146 backlight_device_unregister(hp680_backlight_device);
147
148 return 0;
149}
150
151static struct device_driver hp680bl_driver = {
152 .name = "hp680-bl",
153 .bus = &platform_bus_type,
154 .probe = hp680bl_probe,
155 .remove = hp680bl_remove,
156 .suspend = hp680bl_suspend,
157 .resume = hp680bl_resume,
158};
159
160static struct platform_device hp680bl_device = {
161 .name = "hp680-bl",
162 .id = -1,
163};
164
165static int __init hp680bl_init(void)
166{
167 int ret;
168
169 ret=driver_register(&hp680bl_driver);
170 if (!ret) {
171 ret = platform_device_register(&hp680bl_device);
172 if (ret)
173 driver_unregister(&hp680bl_driver);
174 }
175 return ret;
176}
177
178static void __exit hp680bl_exit(void)
179{
180 platform_device_unregister(&hp680bl_device);
181 driver_unregister(&hp680bl_driver);
182}
183
184module_init(hp680bl_init);
185module_exit(hp680bl_exit);
186
187MODULE_AUTHOR("Andriy Skulysh <askulysh@image.kiev.ua>");
188MODULE_DESCRIPTION("HP Jornada 680 Backlight Driver");
189MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c
index a7bcd17112c0..0339f5640a78 100644
--- a/drivers/video/console/sticore.c
+++ b/drivers/video/console/sticore.c
@@ -30,10 +30,11 @@
30 30
31#define STI_DRIVERVERSION "Version 0.9a" 31#define STI_DRIVERVERSION "Version 0.9a"
32 32
33struct sti_struct *default_sti; 33struct sti_struct *default_sti __read_mostly;
34 34
35static int num_sti_roms; /* # of STI ROMS found */ 35/* number of STI ROMS found and their ptrs to each struct */
36static struct sti_struct *sti_roms[MAX_STI_ROMS]; /* ptr to each sti_struct */ 36static int num_sti_roms __read_mostly;
37static struct sti_struct *sti_roms[MAX_STI_ROMS] __read_mostly;
37 38
38 39
39/* The colour indices used by STI are 40/* The colour indices used by STI are
@@ -266,7 +267,7 @@ sti_rom_copy(unsigned long base, unsigned long count, void *dest)
266 267
267 268
268 269
269static char default_sti_path[21]; 270static char default_sti_path[21] __read_mostly;
270 271
271#ifndef MODULE 272#ifndef MODULE
272static int __init sti_setup(char *str) 273static int __init sti_setup(char *str)
@@ -414,10 +415,10 @@ sti_init_glob_cfg(struct sti_struct *sti,
414 if (!sti->sti_mem_request) 415 if (!sti->sti_mem_request)
415 sti->sti_mem_request = 256; /* STI default */ 416 sti->sti_mem_request = 256; /* STI default */
416 417
417 glob_cfg = kmalloc(sizeof(*sti->glob_cfg), GFP_KERNEL); 418 glob_cfg = kzalloc(sizeof(*sti->glob_cfg), GFP_KERNEL);
418 glob_cfg_ext = kmalloc(sizeof(*glob_cfg_ext), GFP_KERNEL); 419 glob_cfg_ext = kzalloc(sizeof(*glob_cfg_ext), GFP_KERNEL);
419 save_addr = kmalloc(save_addr_size, GFP_KERNEL); 420 save_addr = kzalloc(save_addr_size, GFP_KERNEL);
420 sti_mem_addr = kmalloc(sti->sti_mem_request, GFP_KERNEL); 421 sti_mem_addr = kzalloc(sti->sti_mem_request, GFP_KERNEL);
421 422
422 if (!(glob_cfg && glob_cfg_ext && save_addr && sti_mem_addr)) { 423 if (!(glob_cfg && glob_cfg_ext && save_addr && sti_mem_addr)) {
423 kfree(glob_cfg); 424 kfree(glob_cfg);
@@ -427,11 +428,6 @@ sti_init_glob_cfg(struct sti_struct *sti,
427 return -ENOMEM; 428 return -ENOMEM;
428 } 429 }
429 430
430 memset(glob_cfg, 0, sizeof(*glob_cfg));
431 memset(glob_cfg_ext, 0, sizeof(*glob_cfg_ext));
432 memset(save_addr, 0, save_addr_size);
433 memset(sti_mem_addr, 0, sti->sti_mem_request);
434
435 glob_cfg->ext_ptr = STI_PTR(glob_cfg_ext); 431 glob_cfg->ext_ptr = STI_PTR(glob_cfg_ext);
436 glob_cfg->save_addr = STI_PTR(save_addr); 432 glob_cfg->save_addr = STI_PTR(save_addr);
437 for (i=0; i<8; i++) { 433 for (i=0; i<8; i++) {
@@ -502,9 +498,9 @@ sti_init_glob_cfg(struct sti_struct *sti,
502 498
503#ifdef CONFIG_FB 499#ifdef CONFIG_FB
504struct sti_cooked_font * __init 500struct sti_cooked_font * __init
505sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name ) 501sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
506{ 502{
507 struct font_desc *fbfont; 503 const struct font_desc *fbfont;
508 unsigned int size, bpc; 504 unsigned int size, bpc;
509 void *dest; 505 void *dest;
510 struct sti_rom_font *nf; 506 struct sti_rom_font *nf;
@@ -525,10 +521,9 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name )
525 size = bpc * 256; 521 size = bpc * 256;
526 size += sizeof(struct sti_rom_font); 522 size += sizeof(struct sti_rom_font);
527 523
528 nf = kmalloc(size, GFP_KERNEL); 524 nf = kzalloc(size, GFP_KERNEL);
529 if (!nf) 525 if (!nf)
530 return NULL; 526 return NULL;
531 memset(nf, 0, size);
532 527
533 nf->first_char = 0; 528 nf->first_char = 0;
534 nf->last_char = 255; 529 nf->last_char = 255;
@@ -544,7 +539,7 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name )
544 dest += sizeof(struct sti_rom_font); 539 dest += sizeof(struct sti_rom_font);
545 memcpy(dest, fbfont->data, bpc*256); 540 memcpy(dest, fbfont->data, bpc*256);
546 541
547 cooked_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL); 542 cooked_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL);
548 if (!cooked_font) { 543 if (!cooked_font) {
549 kfree(nf); 544 kfree(nf);
550 return NULL; 545 return NULL;
@@ -559,7 +554,7 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name )
559} 554}
560#else 555#else
561struct sti_cooked_font * __init 556struct sti_cooked_font * __init
562sti_select_fbfont(struct sti_cooked_rom *cooked_rom, char *fbfont_name) 557sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
563{ 558{
564 return NULL; 559 return NULL;
565} 560}
@@ -617,7 +612,7 @@ sti_cook_fonts(struct sti_cooked_rom *cooked_rom,
617 struct sti_rom_font *raw_font, *font_start; 612 struct sti_rom_font *raw_font, *font_start;
618 struct sti_cooked_font *cooked_font; 613 struct sti_cooked_font *cooked_font;
619 614
620 cooked_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL); 615 cooked_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL);
621 if (!cooked_font) 616 if (!cooked_font)
622 return 0; 617 return 0;
623 618
@@ -631,7 +626,7 @@ sti_cook_fonts(struct sti_cooked_rom *cooked_rom,
631 while (raw_font->next_font) { 626 while (raw_font->next_font) {
632 raw_font = ((void *)font_start) + (raw_font->next_font); 627 raw_font = ((void *)font_start) + (raw_font->next_font);
633 628
634 cooked_font->next_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL); 629 cooked_font->next_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL);
635 if (!cooked_font->next_font) 630 if (!cooked_font->next_font)
636 return 1; 631 return 1;
637 632
@@ -668,10 +663,9 @@ sti_bmode_font_raw(struct sti_cooked_font *f)
668 unsigned char *n, *p, *q; 663 unsigned char *n, *p, *q;
669 int size = f->raw->bytes_per_char*256+sizeof(struct sti_rom_font); 664 int size = f->raw->bytes_per_char*256+sizeof(struct sti_rom_font);
670 665
671 n = kmalloc (4*size, GFP_KERNEL); 666 n = kzalloc (4*size, GFP_KERNEL);
672 if (!n) 667 if (!n)
673 return NULL; 668 return NULL;
674 memset (n, 0, 4*size);
675 p = n + 3; 669 p = n + 3;
676 q = (unsigned char *)f->raw; 670 q = (unsigned char *)f->raw;
677 while (size--) { 671 while (size--) {
@@ -816,13 +810,12 @@ sti_try_rom_generic(unsigned long address, unsigned long hpa, struct pci_dev *pd
816 return NULL; 810 return NULL;
817 } 811 }
818 812
819 sti = kmalloc(sizeof(*sti), GFP_KERNEL); 813 sti = kzalloc(sizeof(*sti), GFP_KERNEL);
820 if (!sti) { 814 if (!sti) {
821 printk(KERN_ERR "Not enough memory !\n"); 815 printk(KERN_ERR "Not enough memory !\n");
822 return NULL; 816 return NULL;
823 } 817 }
824 818
825 memset(sti, 0, sizeof(*sti));
826 spin_lock_init(&sti->lock); 819 spin_lock_init(&sti->lock);
827 820
828test_rom: 821test_rom:
@@ -1035,7 +1028,7 @@ static struct parisc_driver pa_sti_driver = {
1035 * sti_init_roms() - detects all STI ROMs and stores them in sti_roms[] 1028 * sti_init_roms() - detects all STI ROMs and stores them in sti_roms[]
1036 */ 1029 */
1037 1030
1038static int sticore_initialized; 1031static int sticore_initialized __read_mostly;
1039 1032
1040static void __init sti_init_roms(void) 1033static void __init sti_init_roms(void)
1041{ 1034{
diff --git a/drivers/video/cyblafb.c b/drivers/video/cyblafb.c
index 2b972461a030..0ae0a97b0fed 100644
--- a/drivers/video/cyblafb.c
+++ b/drivers/video/cyblafb.c
@@ -1665,7 +1665,6 @@ static int __devinit cyblafb_init(void)
1665 } 1665 }
1666#endif 1666#endif
1667 output("CyblaFB version %s initializing\n", VERSION); 1667 output("CyblaFB version %s initializing\n", VERSION);
1668 return pci_module_init(&cyblafb_pci_driver);
1669 return pci_register_driver(&cyblafb_pci_driver); 1668 return pci_register_driver(&cyblafb_pci_driver);
1670} 1669}
1671 1670
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c
index bd410e06db73..e3c8b5f1ca76 100644
--- a/drivers/video/i810/i810-i2c.c
+++ b/drivers/video/i810/i810-i2c.c
@@ -191,11 +191,11 @@ int i810_probe_i2c_connector(struct fb_info *info, u8 **out_edid, int conn)
191 u8 *edid = NULL; 191 u8 *edid = NULL;
192 int i; 192 int i;
193 193
194 DPRINTK("i810-i2c: Probe DDC%i Bus\n", conn); 194 DPRINTK("i810-i2c: Probe DDC%i Bus\n", conn+1);
195 if (conn < 4) { 195 if (conn < par->ddc_num) {
196 for (i = 0; i < 3; i++) { 196 for (i = 0; i < 3; i++) {
197 /* Do the real work */ 197 /* Do the real work */
198 edid = i810_do_probe_i2c_edid(&par->chan[conn-1]); 198 edid = i810_do_probe_i2c_edid(&par->chan[conn]);
199 if (edid) 199 if (edid)
200 break; 200 break;
201 } 201 }
diff --git a/drivers/video/i810/i810.h b/drivers/video/i810/i810.h
index 6c187d5fe951..579195c2bea3 100644
--- a/drivers/video/i810/i810.h
+++ b/drivers/video/i810/i810.h
@@ -280,6 +280,7 @@ struct i810fb_par {
280 u32 blit_bpp; 280 u32 blit_bpp;
281 u32 ovract; 281 u32 ovract;
282 u32 cur_state; 282 u32 cur_state;
283 u32 ddc_num;
283 int mtrr_reg; 284 int mtrr_reg;
284 u16 bltcntl; 285 u16 bltcntl;
285 u8 interlace; 286 u8 interlace;
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 266d0ab92663..d8467c03b49f 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -149,6 +149,7 @@ static int vyres __devinitdata;
149static int sync __devinitdata; 149static int sync __devinitdata;
150static int extvga __devinitdata; 150static int extvga __devinitdata;
151static int dcolor __devinitdata; 151static int dcolor __devinitdata;
152static int ddc3 __devinitdata = 2;
152 153
153/*------------------------------------------------------------*/ 154/*------------------------------------------------------------*/
154 155
@@ -1763,6 +1764,8 @@ static void __devinit i810_init_defaults(struct i810fb_par *par,
1763 if (sync) 1764 if (sync)
1764 par->dev_flags |= ALWAYS_SYNC; 1765 par->dev_flags |= ALWAYS_SYNC;
1765 1766
1767 par->ddc_num = ddc3;
1768
1766 if (bpp < 8) 1769 if (bpp < 8)
1767 bpp = 8; 1770 bpp = 8;
1768 1771
@@ -1885,7 +1888,7 @@ static void __devinit i810fb_find_init_mode(struct fb_info *info)
1885 int found = 0; 1888 int found = 0;
1886#ifdef CONFIG_FB_I810_I2C 1889#ifdef CONFIG_FB_I810_I2C
1887 int i; 1890 int i;
1888 int err; 1891 int err = 1;
1889 struct i810fb_par *par = info->par; 1892 struct i810fb_par *par = info->par;
1890#endif 1893#endif
1891 1894
@@ -1895,8 +1898,8 @@ static void __devinit i810fb_find_init_mode(struct fb_info *info)
1895#ifdef CONFIG_FB_I810_I2C 1898#ifdef CONFIG_FB_I810_I2C
1896 i810_create_i2c_busses(par); 1899 i810_create_i2c_busses(par);
1897 1900
1898 for (i = 0; i < 4; i++) { 1901 for (i = 0; i < par->ddc_num + 1; i++) {
1899 err = i810_probe_i2c_connector(info, &par->edid, i+1); 1902 err = i810_probe_i2c_connector(info, &par->edid, i);
1900 if (!err) 1903 if (!err)
1901 break; 1904 break;
1902 } 1905 }
@@ -1983,6 +1986,8 @@ static int __devinit i810fb_setup(char *options)
1983 vsync2 = simple_strtoul(this_opt+7, NULL, 0); 1986 vsync2 = simple_strtoul(this_opt+7, NULL, 0);
1984 else if (!strncmp(this_opt, "dcolor", 6)) 1987 else if (!strncmp(this_opt, "dcolor", 6))
1985 dcolor = 1; 1988 dcolor = 1;
1989 else if (!strncmp(this_opt, "ddc3", 4))
1990 ddc3 = 3;
1986 else 1991 else
1987 mode_option = this_opt; 1992 mode_option = this_opt;
1988 } 1993 }
@@ -2190,6 +2195,8 @@ MODULE_PARM_DESC(sync, "wait for accel engine to finish drawing"
2190module_param(dcolor, bool, 0); 2195module_param(dcolor, bool, 0);
2191MODULE_PARM_DESC(dcolor, "use DirectColor visuals" 2196MODULE_PARM_DESC(dcolor, "use DirectColor visuals"
2192 " (default = 0 = TrueColor)"); 2197 " (default = 0 = TrueColor)");
2198module_param(ddc3, bool, 0);
2199MODULE_PARM_DESC(ddc3, "Probe DDC bus 3 (default = 0 = no)");
2193module_param(mode_option, charp, 0); 2200module_param(mode_option, charp, 0);
2194MODULE_PARM_DESC(mode_option, "Specify initial video mode"); 2201MODULE_PARM_DESC(mode_option, "Specify initial video mode");
2195 2202
diff --git a/fs/9p/conv.c b/fs/9p/conv.c
index 32a9f99154e2..bf1f10067960 100644
--- a/fs/9p/conv.c
+++ b/fs/9p/conv.c
@@ -116,13 +116,19 @@ static void buf_put_int64(struct cbuf *buf, u64 val)
116 } 116 }
117} 117}
118 118
119static void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) 119static char *buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)
120{ 120{
121 char *ret;
122
123 ret = NULL;
121 if (buf_check_size(buf, slen + 2)) { 124 if (buf_check_size(buf, slen + 2)) {
122 buf_put_int16(buf, slen); 125 buf_put_int16(buf, slen);
126 ret = buf->p;
123 memcpy(buf->p, s, slen); 127 memcpy(buf->p, s, slen);
124 buf->p += slen; 128 buf->p += slen;
125 } 129 }
130
131 return ret;
126} 132}
127 133
128static inline void buf_put_string(struct cbuf *buf, const char *s) 134static inline void buf_put_string(struct cbuf *buf, const char *s)
@@ -430,15 +436,19 @@ static inline void v9fs_put_int64(struct cbuf *bufp, u64 val, u64 * p)
430static void 436static void
431v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str) 437v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str)
432{ 438{
433 if (data) { 439 int len;
434 str->len = strlen(data); 440 char *s;
435 str->str = bufp->p; 441
436 } else { 442 if (data)
437 str->len = 0; 443 len = strlen(data);
438 str->str = NULL; 444 else
439 } 445 len = 0;
440 446
441 buf_put_stringn(bufp, data, str->len); 447 s = buf_put_stringn(bufp, data, len);
448 if (str) {
449 str->len = len;
450 str->str = s;
451 }
442} 452}
443 453
444static int 454static int
diff --git a/fs/9p/mux.c b/fs/9p/mux.c
index 945cb368d451..ea1134eb47c8 100644
--- a/fs/9p/mux.c
+++ b/fs/9p/mux.c
@@ -471,10 +471,13 @@ static void v9fs_write_work(void *a)
471 } 471 }
472 472
473 spin_lock(&m->lock); 473 spin_lock(&m->lock);
474 req = 474again:
475 list_entry(m->unsent_req_list.next, struct v9fs_req, 475 req = list_entry(m->unsent_req_list.next, struct v9fs_req,
476 req_list); 476 req_list);
477 list_move_tail(&req->req_list, &m->req_list); 477 list_move_tail(&req->req_list, &m->req_list);
478 if (req->err == ERREQFLUSH)
479 goto again;
480
478 m->wbuf = req->tcall->sdata; 481 m->wbuf = req->tcall->sdata;
479 m->wsize = req->tcall->size; 482 m->wsize = req->tcall->size;
480 m->wpos = 0; 483 m->wpos = 0;
@@ -525,7 +528,7 @@ static void process_request(struct v9fs_mux_data *m, struct v9fs_req *req)
525 struct v9fs_str *ename; 528 struct v9fs_str *ename;
526 529
527 tag = req->tag; 530 tag = req->tag;
528 if (req->rcall->id == RERROR && !req->err) { 531 if (!req->err && req->rcall->id == RERROR) {
529 ecode = req->rcall->params.rerror.errno; 532 ecode = req->rcall->params.rerror.errno;
530 ename = &req->rcall->params.rerror.error; 533 ename = &req->rcall->params.rerror.error;
531 534
@@ -551,7 +554,10 @@ static void process_request(struct v9fs_mux_data *m, struct v9fs_req *req)
551 req->err = -EIO; 554 req->err = -EIO;
552 } 555 }
553 556
554 if (req->cb && req->err != ERREQFLUSH) { 557 if (req->err == ERREQFLUSH)
558 return;
559
560 if (req->cb) {
555 dprintk(DEBUG_MUX, "calling callback tcall %p rcall %p\n", 561 dprintk(DEBUG_MUX, "calling callback tcall %p rcall %p\n",
556 req->tcall, req->rcall); 562 req->tcall, req->rcall);
557 563
@@ -812,6 +818,7 @@ v9fs_mux_rpc_cb(void *a, struct v9fs_fcall *tc, struct v9fs_fcall *rc, int err)
812 struct v9fs_mux_rpc *r; 818 struct v9fs_mux_rpc *r;
813 819
814 if (err == ERREQFLUSH) { 820 if (err == ERREQFLUSH) {
821 kfree(rc);
815 dprintk(DEBUG_MUX, "err req flush\n"); 822 dprintk(DEBUG_MUX, "err req flush\n");
816 return; 823 return;
817 } 824 }
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 91f552454c76..63e5b0398e8b 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -886,8 +886,8 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
886 } 886 }
887 887
888 /* copy extension buffer into buffer */ 888 /* copy extension buffer into buffer */
889 if (fcall->params.rstat.stat.extension.len < buflen) 889 if (fcall->params.rstat.stat.extension.len+1 < buflen)
890 buflen = fcall->params.rstat.stat.extension.len; 890 buflen = fcall->params.rstat.stat.extension.len + 1;
891 891
892 memcpy(buffer, fcall->params.rstat.stat.extension.str, buflen - 1); 892 memcpy(buffer, fcall->params.rstat.stat.extension.str, buflen - 1);
893 buffer[buflen-1] = 0; 893 buffer[buflen-1] = 0;
@@ -951,7 +951,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
951 if (!link) 951 if (!link)
952 link = ERR_PTR(-ENOMEM); 952 link = ERR_PTR(-ENOMEM);
953 else { 953 else {
954 len = v9fs_readlink(dentry, link, strlen(link)); 954 len = v9fs_readlink(dentry, link, PATH_MAX);
955 955
956 if (len < 0) { 956 if (len < 0) {
957 __putname(link); 957 __putname(link);
diff --git a/fs/Kconfig b/fs/Kconfig
index ef78e3a42d32..e9749b0eecd8 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -883,8 +883,6 @@ config CONFIGFS_FS
883 Both sysfs and configfs can and should exist together on the 883 Both sysfs and configfs can and should exist together on the
884 same system. One is not a replacement for the other. 884 same system. One is not a replacement for the other.
885 885
886 If unsure, say N.
887
888endmenu 886endmenu
889 887
890menu "Miscellaneous filesystems" 888menu "Miscellaneous filesystems"
@@ -1327,7 +1325,7 @@ config UFS_FS
1327 1325
1328config UFS_FS_WRITE 1326config UFS_FS_WRITE
1329 bool "UFS file system write support (DANGEROUS)" 1327 bool "UFS file system write support (DANGEROUS)"
1330 depends on UFS_FS && EXPERIMENTAL 1328 depends on UFS_FS && EXPERIMENTAL && BROKEN
1331 help 1329 help
1332 Say Y here if you want to try writing to UFS partitions. This is 1330 Say Y here if you want to try writing to UFS partitions. This is
1333 experimental, so you should back up your UFS partitions beforehand. 1331 experimental, so you should back up your UFS partitions beforehand.
diff --git a/fs/bio.c b/fs/bio.c
index bbc442b8c867..1f3bb501c262 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -411,6 +411,7 @@ static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page
411 411
412/** 412/**
413 * bio_add_pc_page - attempt to add page to bio 413 * bio_add_pc_page - attempt to add page to bio
414 * @q: the target queue
414 * @bio: destination bio 415 * @bio: destination bio
415 * @page: page to add 416 * @page: page to add
416 * @len: vec entry length 417 * @len: vec entry length
diff --git a/fs/buffer.c b/fs/buffer.c
index 3dc712f29d2d..62cfd17dc5fe 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1022,6 +1022,7 @@ try_again:
1022 1022
1023 bh->b_state = 0; 1023 bh->b_state = 0;
1024 atomic_set(&bh->b_count, 0); 1024 atomic_set(&bh->b_count, 0);
1025 bh->b_private = NULL;
1025 bh->b_size = size; 1026 bh->b_size = size;
1026 1027
1027 /* Link the buffer to its page */ 1028 /* Link the buffer to its page */
@@ -2866,22 +2867,22 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
2866 else if (test_set_buffer_locked(bh)) 2867 else if (test_set_buffer_locked(bh))
2867 continue; 2868 continue;
2868 2869
2869 get_bh(bh);
2870 if (rw == WRITE || rw == SWRITE) { 2870 if (rw == WRITE || rw == SWRITE) {
2871 if (test_clear_buffer_dirty(bh)) { 2871 if (test_clear_buffer_dirty(bh)) {
2872 bh->b_end_io = end_buffer_write_sync; 2872 bh->b_end_io = end_buffer_write_sync;
2873 get_bh(bh);
2873 submit_bh(WRITE, bh); 2874 submit_bh(WRITE, bh);
2874 continue; 2875 continue;
2875 } 2876 }
2876 } else { 2877 } else {
2877 if (!buffer_uptodate(bh)) { 2878 if (!buffer_uptodate(bh)) {
2878 bh->b_end_io = end_buffer_read_sync; 2879 bh->b_end_io = end_buffer_read_sync;
2880 get_bh(bh);
2879 submit_bh(rw, bh); 2881 submit_bh(rw, bh);
2880 continue; 2882 continue;
2881 } 2883 }
2882 } 2884 }
2883 unlock_buffer(bh); 2885 unlock_buffer(bh);
2884 put_bh(bh);
2885 } 2886 }
2886} 2887}
2887 2888
@@ -3050,6 +3051,66 @@ asmlinkage long sys_bdflush(int func, long data)
3050} 3051}
3051 3052
3052/* 3053/*
3054 * Migration function for pages with buffers. This function can only be used
3055 * if the underlying filesystem guarantees that no other references to "page"
3056 * exist.
3057 */
3058#ifdef CONFIG_MIGRATION
3059int buffer_migrate_page(struct page *newpage, struct page *page)
3060{
3061 struct address_space *mapping = page->mapping;
3062 struct buffer_head *bh, *head;
3063
3064 if (!mapping)
3065 return -EAGAIN;
3066
3067 if (!page_has_buffers(page))
3068 return migrate_page(newpage, page);
3069
3070 head = page_buffers(page);
3071
3072 if (migrate_page_remove_references(newpage, page, 3))
3073 return -EAGAIN;
3074
3075 bh = head;
3076 do {
3077 get_bh(bh);
3078 lock_buffer(bh);
3079 bh = bh->b_this_page;
3080
3081 } while (bh != head);
3082
3083 ClearPagePrivate(page);
3084 set_page_private(newpage, page_private(page));
3085 set_page_private(page, 0);
3086 put_page(page);
3087 get_page(newpage);
3088
3089 bh = head;
3090 do {
3091 set_bh_page(bh, newpage, bh_offset(bh));
3092 bh = bh->b_this_page;
3093
3094 } while (bh != head);
3095
3096 SetPagePrivate(newpage);
3097
3098 migrate_page_copy(newpage, page);
3099
3100 bh = head;
3101 do {
3102 unlock_buffer(bh);
3103 put_bh(bh);
3104 bh = bh->b_this_page;
3105
3106 } while (bh != head);
3107
3108 return 0;
3109}
3110EXPORT_SYMBOL(buffer_migrate_page);
3111#endif
3112
3113/*
3053 * Buffer-head allocation 3114 * Buffer-head allocation
3054 */ 3115 */
3055static kmem_cache_t *bh_cachep; 3116static kmem_cache_t *bh_cachep;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 88f60aa52058..e488603fb1e7 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1785,7 +1785,16 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1785 } else if(volume_info.wsize) 1785 } else if(volume_info.wsize)
1786 cifs_sb->wsize = volume_info.wsize; 1786 cifs_sb->wsize = volume_info.wsize;
1787 else 1787 else
1788 cifs_sb->wsize = CIFSMaxBufSize; /* default */ 1788 cifs_sb->wsize =
1789 min_t(const int, PAGEVEC_SIZE * PAGE_CACHE_SIZE,
1790 127*1024);
1791 /* old default of CIFSMaxBufSize was too small now
1792 that SMB Write2 can send multiple pages in kvec.
1793 RFC1001 does not describe what happens when frame
1794 bigger than 128K is sent so use that as max in
1795 conjunction with 52K kvec constraint on arch with 4K
1796 page size */
1797
1789 if(cifs_sb->rsize < PAGE_CACHE_SIZE) { 1798 if(cifs_sb->rsize < PAGE_CACHE_SIZE) {
1790 cifs_sb->rsize = PAGE_CACHE_SIZE; 1799 cifs_sb->rsize = PAGE_CACHE_SIZE;
1791 /* Windows ME does this */ 1800 /* Windows ME does this */
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 77c990f0cb98..d17c97d07c80 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1190,7 +1190,6 @@ retry:
1190 /* BB what if continued retry is 1190 /* BB what if continued retry is
1191 requested via mount flags? */ 1191 requested via mount flags? */
1192 set_bit(AS_EIO, &mapping->flags); 1192 set_bit(AS_EIO, &mapping->flags);
1193 SetPageError(page);
1194 } else { 1193 } else {
1195 cifs_stats_bytes_written(cifs_sb->tcon, 1194 cifs_stats_bytes_written(cifs_sb->tcon,
1196 bytes_written); 1195 bytes_written);
@@ -1198,6 +1197,13 @@ retry:
1198 } 1197 }
1199 for (i = 0; i < n_iov; i++) { 1198 for (i = 0; i < n_iov; i++) {
1200 page = pvec.pages[first + i]; 1199 page = pvec.pages[first + i];
1200 /* Should we also set page error on
1201 success rc but too little data written? */
1202 /* BB investigate retry logic on temporary
1203 server crash cases and how recovery works
1204 when page marked as error */
1205 if(rc)
1206 SetPageError(page);
1201 kunmap(page); 1207 kunmap(page);
1202 unlock_page(page); 1208 unlock_page(page);
1203 page_cache_release(page); 1209 page_cache_release(page);
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 7b98792150ea..b12cb8a7da7c 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -498,7 +498,6 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
498 else 498 else
499 *pRespBufType = CIFS_SMALL_BUFFER; 499 *pRespBufType = CIFS_SMALL_BUFFER;
500 iov[0].iov_len = receive_len + 4; 500 iov[0].iov_len = receive_len + 4;
501 iov[1].iov_len = 0;
502 501
503 dump_smb(midQ->resp_buf, 80); 502 dump_smb(midQ->resp_buf, 80);
504 /* convert the length into a more usable form */ 503 /* convert the length into a more usable form */
diff --git a/fs/compat.c b/fs/compat.c
index ff0bafcff720..70c5af4cc270 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -73,17 +73,17 @@ asmlinkage long compat_sys_utime(char __user *filename, struct compat_utimbuf __
73 return do_utimes(AT_FDCWD, filename, t ? tv : NULL); 73 return do_utimes(AT_FDCWD, filename, t ? tv : NULL);
74} 74}
75 75
76asmlinkage long compat_sys_futimesat(int dfd, char __user *filename, struct compat_timeval __user *t) 76asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, struct compat_timeval __user *t)
77{ 77{
78 struct timeval tv[2]; 78 struct timeval tv[2];
79 79
80 if (t) { 80 if (t) {
81 if (get_user(tv[0].tv_sec, &t[0].tv_sec) || 81 if (get_user(tv[0].tv_sec, &t[0].tv_sec) ||
82 get_user(tv[0].tv_usec, &t[0].tv_usec) || 82 get_user(tv[0].tv_usec, &t[0].tv_usec) ||
83 get_user(tv[1].tv_sec, &t[1].tv_sec) || 83 get_user(tv[1].tv_sec, &t[1].tv_sec) ||
84 get_user(tv[1].tv_usec, &t[1].tv_usec)) 84 get_user(tv[1].tv_usec, &t[1].tv_usec))
85 return -EFAULT; 85 return -EFAULT;
86 } 86 }
87 return do_utimes(dfd, filename, t ? tv : NULL); 87 return do_utimes(dfd, filename, t ? tv : NULL);
88} 88}
89 89
@@ -114,7 +114,7 @@ asmlinkage long compat_sys_newlstat(char __user * filename,
114 return error; 114 return error;
115} 115}
116 116
117asmlinkage long compat_sys_newfstatat(int dfd, char __user *filename, 117asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename,
118 struct compat_stat __user *statbuf, int flag) 118 struct compat_stat __user *statbuf, int flag)
119{ 119{
120 struct kstat stat; 120 struct kstat stat;
@@ -1326,7 +1326,7 @@ compat_sys_open(const char __user *filename, int flags, int mode)
1326 * O_LARGEFILE flag. 1326 * O_LARGEFILE flag.
1327 */ 1327 */
1328asmlinkage long 1328asmlinkage long
1329compat_sys_openat(int dfd, const char __user *filename, int flags, int mode) 1329compat_sys_openat(unsigned int dfd, const char __user *filename, int flags, int mode)
1330{ 1330{
1331 return do_sys_open(dfd, filename, flags, mode); 1331 return do_sys_open(dfd, filename, flags, mode);
1332} 1332}
@@ -1781,7 +1781,7 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
1781{ 1781{
1782 compat_sigset_t ss32; 1782 compat_sigset_t ss32;
1783 sigset_t ksigmask, sigsaved; 1783 sigset_t ksigmask, sigsaved;
1784 long timeout = MAX_SCHEDULE_TIMEOUT; 1784 s64 timeout = MAX_SCHEDULE_TIMEOUT;
1785 struct compat_timespec ts; 1785 struct compat_timespec ts;
1786 int ret; 1786 int ret;
1787 1787
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
index 8899d9c5f6bf..f70e46951b37 100644
--- a/fs/configfs/configfs_internal.h
+++ b/fs/configfs/configfs_internal.h
@@ -36,6 +36,7 @@ struct configfs_dirent {
36 int s_type; 36 int s_type;
37 umode_t s_mode; 37 umode_t s_mode;
38 struct dentry * s_dentry; 38 struct dentry * s_dentry;
39 struct iattr * s_iattr;
39}; 40};
40 41
41#define CONFIGFS_ROOT 0x0001 42#define CONFIGFS_ROOT 0x0001
@@ -48,10 +49,11 @@ struct configfs_dirent {
48#define CONFIGFS_NOT_PINNED (CONFIGFS_ITEM_ATTR) 49#define CONFIGFS_NOT_PINNED (CONFIGFS_ITEM_ATTR)
49 50
50extern struct vfsmount * configfs_mount; 51extern struct vfsmount * configfs_mount;
52extern kmem_cache_t *configfs_dir_cachep;
51 53
52extern int configfs_is_root(struct config_item *item); 54extern int configfs_is_root(struct config_item *item);
53 55
54extern struct inode * configfs_new_inode(mode_t mode); 56extern struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent *);
55extern int configfs_create(struct dentry *, int mode, int (*init)(struct inode *)); 57extern int configfs_create(struct dentry *, int mode, int (*init)(struct inode *));
56 58
57extern int configfs_create_file(struct config_item *, const struct configfs_attribute *); 59extern int configfs_create_file(struct config_item *, const struct configfs_attribute *);
@@ -63,6 +65,7 @@ extern void configfs_hash_and_remove(struct dentry * dir, const char * name);
63 65
64extern const unsigned char * configfs_get_name(struct configfs_dirent *sd); 66extern const unsigned char * configfs_get_name(struct configfs_dirent *sd);
65extern void configfs_drop_dentry(struct configfs_dirent *sd, struct dentry *parent); 67extern void configfs_drop_dentry(struct configfs_dirent *sd, struct dentry *parent);
68extern int configfs_setattr(struct dentry *dentry, struct iattr *iattr);
66 69
67extern int configfs_pin_fs(void); 70extern int configfs_pin_fs(void);
68extern void configfs_release_fs(void); 71extern void configfs_release_fs(void);
@@ -120,8 +123,10 @@ static inline struct config_item *configfs_get_config_item(struct dentry *dentry
120 123
121static inline void release_configfs_dirent(struct configfs_dirent * sd) 124static inline void release_configfs_dirent(struct configfs_dirent * sd)
122{ 125{
123 if (!(sd->s_type & CONFIGFS_ROOT)) 126 if (!(sd->s_type & CONFIGFS_ROOT)) {
124 kfree(sd); 127 kfree(sd->s_iattr);
128 kmem_cache_free(configfs_dir_cachep, sd);
129 }
125} 130}
126 131
127static inline struct configfs_dirent * configfs_get(struct configfs_dirent * sd) 132static inline struct configfs_dirent * configfs_get(struct configfs_dirent * sd)
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index b668ec61527e..ca60e3abef45 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -72,7 +72,7 @@ static struct configfs_dirent *configfs_new_dirent(struct configfs_dirent * pare
72{ 72{
73 struct configfs_dirent * sd; 73 struct configfs_dirent * sd;
74 74
75 sd = kmalloc(sizeof(*sd), GFP_KERNEL); 75 sd = kmem_cache_alloc(configfs_dir_cachep, GFP_KERNEL);
76 if (!sd) 76 if (!sd)
77 return NULL; 77 return NULL;
78 78
@@ -136,13 +136,19 @@ static int create_dir(struct config_item * k, struct dentry * p,
136 int error; 136 int error;
137 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; 137 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
138 138
139 error = configfs_create(d, mode, init_dir); 139 error = configfs_make_dirent(p->d_fsdata, d, k, mode,
140 CONFIGFS_DIR);
140 if (!error) { 141 if (!error) {
141 error = configfs_make_dirent(p->d_fsdata, d, k, mode, 142 error = configfs_create(d, mode, init_dir);
142 CONFIGFS_DIR);
143 if (!error) { 143 if (!error) {
144 p->d_inode->i_nlink++; 144 p->d_inode->i_nlink++;
145 (d)->d_op = &configfs_dentry_ops; 145 (d)->d_op = &configfs_dentry_ops;
146 } else {
147 struct configfs_dirent *sd = d->d_fsdata;
148 if (sd) {
149 list_del_init(&sd->s_sibling);
150 configfs_put(sd);
151 }
146 } 152 }
147 } 153 }
148 return error; 154 return error;
@@ -182,12 +188,19 @@ int configfs_create_link(struct configfs_symlink *sl,
182 int err = 0; 188 int err = 0;
183 umode_t mode = S_IFLNK | S_IRWXUGO; 189 umode_t mode = S_IFLNK | S_IRWXUGO;
184 190
185 err = configfs_create(dentry, mode, init_symlink); 191 err = configfs_make_dirent(parent->d_fsdata, dentry, sl, mode,
192 CONFIGFS_ITEM_LINK);
186 if (!err) { 193 if (!err) {
187 err = configfs_make_dirent(parent->d_fsdata, dentry, sl, 194 err = configfs_create(dentry, mode, init_symlink);
188 mode, CONFIGFS_ITEM_LINK);
189 if (!err) 195 if (!err)
190 dentry->d_op = &configfs_dentry_ops; 196 dentry->d_op = &configfs_dentry_ops;
197 else {
198 struct configfs_dirent *sd = dentry->d_fsdata;
199 if (sd) {
200 list_del_init(&sd->s_sibling);
201 configfs_put(sd);
202 }
203 }
191 } 204 }
192 return err; 205 return err;
193} 206}
@@ -241,13 +254,15 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
241 struct configfs_attribute * attr = sd->s_element; 254 struct configfs_attribute * attr = sd->s_element;
242 int error; 255 int error;
243 256
257 dentry->d_fsdata = configfs_get(sd);
258 sd->s_dentry = dentry;
244 error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG, init_file); 259 error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG, init_file);
245 if (error) 260 if (error) {
261 configfs_put(sd);
246 return error; 262 return error;
263 }
247 264
248 dentry->d_op = &configfs_dentry_ops; 265 dentry->d_op = &configfs_dentry_ops;
249 dentry->d_fsdata = configfs_get(sd);
250 sd->s_dentry = dentry;
251 d_rehash(dentry); 266 d_rehash(dentry);
252 267
253 return 0; 268 return 0;
@@ -839,6 +854,7 @@ struct inode_operations configfs_dir_inode_operations = {
839 .symlink = configfs_symlink, 854 .symlink = configfs_symlink,
840 .unlink = configfs_unlink, 855 .unlink = configfs_unlink,
841 .lookup = configfs_lookup, 856 .lookup = configfs_lookup,
857 .setattr = configfs_setattr,
842}; 858};
843 859
844#if 0 860#if 0
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index c26cd61f13af..3921920d8716 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -26,7 +26,6 @@
26 26
27#include <linux/fs.h> 27#include <linux/fs.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/dnotify.h>
30#include <linux/slab.h> 29#include <linux/slab.h>
31#include <asm/uaccess.h> 30#include <asm/uaccess.h>
32#include <asm/semaphore.h> 31#include <asm/semaphore.h>
@@ -150,7 +149,7 @@ out:
150/** 149/**
151 * fill_write_buffer - copy buffer from userspace. 150 * fill_write_buffer - copy buffer from userspace.
152 * @buffer: data buffer for file. 151 * @buffer: data buffer for file.
153 * @userbuf: data from user. 152 * @buf: data from user.
154 * @count: number of bytes in @userbuf. 153 * @count: number of bytes in @userbuf.
155 * 154 *
156 * Allocate @buffer->page if it hasn't been already, then 155 * Allocate @buffer->page if it hasn't been already, then
@@ -177,8 +176,9 @@ fill_write_buffer(struct configfs_buffer * buffer, const char __user * buf, size
177 176
178/** 177/**
179 * flush_write_buffer - push buffer to config_item. 178 * flush_write_buffer - push buffer to config_item.
180 * @file: file pointer. 179 * @dentry: dentry to the attribute
181 * @buffer: data buffer for file. 180 * @buffer: data buffer for file.
181 * @count: number of bytes
182 * 182 *
183 * Get the correct pointers for the config_item and the attribute we're 183 * Get the correct pointers for the config_item and the attribute we're
184 * dealing with, then call the store() method for the attribute, 184 * dealing with, then call the store() method for the attribute,
@@ -217,15 +217,16 @@ static ssize_t
217configfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 217configfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
218{ 218{
219 struct configfs_buffer * buffer = file->private_data; 219 struct configfs_buffer * buffer = file->private_data;
220 ssize_t len;
220 221
221 down(&buffer->sem); 222 down(&buffer->sem);
222 count = fill_write_buffer(buffer,buf,count); 223 len = fill_write_buffer(buffer, buf, count);
223 if (count > 0) 224 if (len > 0)
224 count = flush_write_buffer(file->f_dentry,buffer,count); 225 len = flush_write_buffer(file->f_dentry, buffer, count);
225 if (count > 0) 226 if (len > 0)
226 *ppos += count; 227 *ppos += len;
227 up(&buffer->sem); 228 up(&buffer->sem);
228 return count; 229 return len;
229} 230}
230 231
231static int check_perm(struct inode * inode, struct file * file) 232static int check_perm(struct inode * inode, struct file * file)
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index 6577c588de9d..c153bd9534cb 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -31,6 +31,7 @@
31#include <linux/pagemap.h> 31#include <linux/pagemap.h>
32#include <linux/namei.h> 32#include <linux/namei.h>
33#include <linux/backing-dev.h> 33#include <linux/backing-dev.h>
34#include <linux/capability.h>
34 35
35#include <linux/configfs.h> 36#include <linux/configfs.h>
36#include "configfs_internal.h" 37#include "configfs_internal.h"
@@ -48,18 +49,107 @@ static struct backing_dev_info configfs_backing_dev_info = {
48 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, 49 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK,
49}; 50};
50 51
51struct inode * configfs_new_inode(mode_t mode) 52static struct inode_operations configfs_inode_operations ={
53 .setattr = configfs_setattr,
54};
55
56int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
57{
58 struct inode * inode = dentry->d_inode;
59 struct configfs_dirent * sd = dentry->d_fsdata;
60 struct iattr * sd_iattr;
61 unsigned int ia_valid = iattr->ia_valid;
62 int error;
63
64 if (!sd)
65 return -EINVAL;
66
67 sd_iattr = sd->s_iattr;
68
69 error = inode_change_ok(inode, iattr);
70 if (error)
71 return error;
72
73 error = inode_setattr(inode, iattr);
74 if (error)
75 return error;
76
77 if (!sd_iattr) {
78 /* setting attributes for the first time, allocate now */
79 sd_iattr = kmalloc(sizeof(struct iattr), GFP_KERNEL);
80 if (!sd_iattr)
81 return -ENOMEM;
82 /* assign default attributes */
83 memset(sd_iattr, 0, sizeof(struct iattr));
84 sd_iattr->ia_mode = sd->s_mode;
85 sd_iattr->ia_uid = 0;
86 sd_iattr->ia_gid = 0;
87 sd_iattr->ia_atime = sd_iattr->ia_mtime = sd_iattr->ia_ctime = CURRENT_TIME;
88 sd->s_iattr = sd_iattr;
89 }
90
91 /* attributes were changed atleast once in past */
92
93 if (ia_valid & ATTR_UID)
94 sd_iattr->ia_uid = iattr->ia_uid;
95 if (ia_valid & ATTR_GID)
96 sd_iattr->ia_gid = iattr->ia_gid;
97 if (ia_valid & ATTR_ATIME)
98 sd_iattr->ia_atime = timespec_trunc(iattr->ia_atime,
99 inode->i_sb->s_time_gran);
100 if (ia_valid & ATTR_MTIME)
101 sd_iattr->ia_mtime = timespec_trunc(iattr->ia_mtime,
102 inode->i_sb->s_time_gran);
103 if (ia_valid & ATTR_CTIME)
104 sd_iattr->ia_ctime = timespec_trunc(iattr->ia_ctime,
105 inode->i_sb->s_time_gran);
106 if (ia_valid & ATTR_MODE) {
107 umode_t mode = iattr->ia_mode;
108
109 if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
110 mode &= ~S_ISGID;
111 sd_iattr->ia_mode = sd->s_mode = mode;
112 }
113
114 return error;
115}
116
117static inline void set_default_inode_attr(struct inode * inode, mode_t mode)
118{
119 inode->i_mode = mode;
120 inode->i_uid = 0;
121 inode->i_gid = 0;
122 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
123}
124
125static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
126{
127 inode->i_mode = iattr->ia_mode;
128 inode->i_uid = iattr->ia_uid;
129 inode->i_gid = iattr->ia_gid;
130 inode->i_atime = iattr->ia_atime;
131 inode->i_mtime = iattr->ia_mtime;
132 inode->i_ctime = iattr->ia_ctime;
133}
134
135struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd)
52{ 136{
53 struct inode * inode = new_inode(configfs_sb); 137 struct inode * inode = new_inode(configfs_sb);
54 if (inode) { 138 if (inode) {
55 inode->i_mode = mode;
56 inode->i_uid = 0;
57 inode->i_gid = 0;
58 inode->i_blksize = PAGE_CACHE_SIZE; 139 inode->i_blksize = PAGE_CACHE_SIZE;
59 inode->i_blocks = 0; 140 inode->i_blocks = 0;
60 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
61 inode->i_mapping->a_ops = &configfs_aops; 141 inode->i_mapping->a_ops = &configfs_aops;
62 inode->i_mapping->backing_dev_info = &configfs_backing_dev_info; 142 inode->i_mapping->backing_dev_info = &configfs_backing_dev_info;
143 inode->i_op = &configfs_inode_operations;
144
145 if (sd->s_iattr) {
146 /* sysfs_dirent has non-default attributes
147 * get them for the new inode from persistent copy
148 * in sysfs_dirent
149 */
150 set_inode_attr(inode, sd->s_iattr);
151 } else
152 set_default_inode_attr(inode, mode);
63 } 153 }
64 return inode; 154 return inode;
65} 155}
@@ -70,7 +160,8 @@ int configfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *
70 struct inode * inode = NULL; 160 struct inode * inode = NULL;
71 if (dentry) { 161 if (dentry) {
72 if (!dentry->d_inode) { 162 if (!dentry->d_inode) {
73 if ((inode = configfs_new_inode(mode))) { 163 struct configfs_dirent *sd = dentry->d_fsdata;
164 if ((inode = configfs_new_inode(mode, sd))) {
74 if (dentry->d_parent && dentry->d_parent->d_inode) { 165 if (dentry->d_parent && dentry->d_parent->d_inode) {
75 struct inode *p_inode = dentry->d_parent->d_inode; 166 struct inode *p_inode = dentry->d_parent->d_inode;
76 p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME; 167 p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME;
@@ -103,10 +194,9 @@ int configfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *
103 */ 194 */
104const unsigned char * configfs_get_name(struct configfs_dirent *sd) 195const unsigned char * configfs_get_name(struct configfs_dirent *sd)
105{ 196{
106 struct attribute * attr; 197 struct configfs_attribute *attr;
107 198
108 if (!sd || !sd->s_element) 199 BUG_ON(!sd || !sd->s_element);
109 BUG();
110 200
111 /* These always have a dentry, so use that */ 201 /* These always have a dentry, so use that */
112 if (sd->s_type & (CONFIGFS_DIR | CONFIGFS_ITEM_LINK)) 202 if (sd->s_type & (CONFIGFS_DIR | CONFIGFS_ITEM_LINK))
@@ -114,7 +204,7 @@ const unsigned char * configfs_get_name(struct configfs_dirent *sd)
114 204
115 if (sd->s_type & CONFIGFS_ITEM_ATTR) { 205 if (sd->s_type & CONFIGFS_ITEM_ATTR) {
116 attr = sd->s_element; 206 attr = sd->s_element;
117 return attr->name; 207 return attr->ca_name;
118 } 208 }
119 return NULL; 209 return NULL;
120} 210}
@@ -130,13 +220,17 @@ void configfs_drop_dentry(struct configfs_dirent * sd, struct dentry * parent)
130 220
131 if (dentry) { 221 if (dentry) {
132 spin_lock(&dcache_lock); 222 spin_lock(&dcache_lock);
223 spin_lock(&dentry->d_lock);
133 if (!(d_unhashed(dentry) && dentry->d_inode)) { 224 if (!(d_unhashed(dentry) && dentry->d_inode)) {
134 dget_locked(dentry); 225 dget_locked(dentry);
135 __d_drop(dentry); 226 __d_drop(dentry);
227 spin_unlock(&dentry->d_lock);
136 spin_unlock(&dcache_lock); 228 spin_unlock(&dcache_lock);
137 simple_unlink(parent->d_inode, dentry); 229 simple_unlink(parent->d_inode, dentry);
138 } else 230 } else {
231 spin_unlock(&dentry->d_lock);
139 spin_unlock(&dcache_lock); 232 spin_unlock(&dcache_lock);
233 }
140 } 234 }
141} 235}
142 236
@@ -145,6 +239,10 @@ void configfs_hash_and_remove(struct dentry * dir, const char * name)
145 struct configfs_dirent * sd; 239 struct configfs_dirent * sd;
146 struct configfs_dirent * parent_sd = dir->d_fsdata; 240 struct configfs_dirent * parent_sd = dir->d_fsdata;
147 241
242 if (dir->d_inode == NULL)
243 /* no inode means this hasn't been made visible yet */
244 return;
245
148 mutex_lock(&dir->d_inode->i_mutex); 246 mutex_lock(&dir->d_inode->i_mutex);
149 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { 247 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
150 if (!sd->s_element) 248 if (!sd->s_element)
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index 1a2f6f6a4d91..f920d30478e5 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -38,6 +38,7 @@
38 38
39struct vfsmount * configfs_mount = NULL; 39struct vfsmount * configfs_mount = NULL;
40struct super_block * configfs_sb = NULL; 40struct super_block * configfs_sb = NULL;
41kmem_cache_t *configfs_dir_cachep;
41static int configfs_mnt_count = 0; 42static int configfs_mnt_count = 0;
42 43
43static struct super_operations configfs_ops = { 44static struct super_operations configfs_ops = {
@@ -62,6 +63,7 @@ static struct configfs_dirent configfs_root = {
62 .s_children = LIST_HEAD_INIT(configfs_root.s_children), 63 .s_children = LIST_HEAD_INIT(configfs_root.s_children),
63 .s_element = &configfs_root_group.cg_item, 64 .s_element = &configfs_root_group.cg_item,
64 .s_type = CONFIGFS_ROOT, 65 .s_type = CONFIGFS_ROOT,
66 .s_iattr = NULL,
65}; 67};
66 68
67static int configfs_fill_super(struct super_block *sb, void *data, int silent) 69static int configfs_fill_super(struct super_block *sb, void *data, int silent)
@@ -73,9 +75,11 @@ static int configfs_fill_super(struct super_block *sb, void *data, int silent)
73 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; 75 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
74 sb->s_magic = CONFIGFS_MAGIC; 76 sb->s_magic = CONFIGFS_MAGIC;
75 sb->s_op = &configfs_ops; 77 sb->s_op = &configfs_ops;
78 sb->s_time_gran = 1;
76 configfs_sb = sb; 79 configfs_sb = sb;
77 80
78 inode = configfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); 81 inode = configfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
82 &configfs_root);
79 if (inode) { 83 if (inode) {
80 inode->i_op = &configfs_dir_inode_operations; 84 inode->i_op = &configfs_dir_inode_operations;
81 inode->i_fop = &configfs_dir_operations; 85 inode->i_fop = &configfs_dir_operations;
@@ -128,19 +132,31 @@ static decl_subsys(config, NULL, NULL);
128 132
129static int __init configfs_init(void) 133static int __init configfs_init(void)
130{ 134{
131 int err; 135 int err = -ENOMEM;
136
137 configfs_dir_cachep = kmem_cache_create("configfs_dir_cache",
138 sizeof(struct configfs_dirent),
139 0, 0, NULL, NULL);
140 if (!configfs_dir_cachep)
141 goto out;
132 142
133 kset_set_kset_s(&config_subsys, kernel_subsys); 143 kset_set_kset_s(&config_subsys, kernel_subsys);
134 err = subsystem_register(&config_subsys); 144 err = subsystem_register(&config_subsys);
135 if (err) 145 if (err) {
136 return err; 146 kmem_cache_destroy(configfs_dir_cachep);
147 configfs_dir_cachep = NULL;
148 goto out;
149 }
137 150
138 err = register_filesystem(&configfs_fs_type); 151 err = register_filesystem(&configfs_fs_type);
139 if (err) { 152 if (err) {
140 printk(KERN_ERR "configfs: Unable to register filesystem!\n"); 153 printk(KERN_ERR "configfs: Unable to register filesystem!\n");
141 subsystem_unregister(&config_subsys); 154 subsystem_unregister(&config_subsys);
155 kmem_cache_destroy(configfs_dir_cachep);
156 configfs_dir_cachep = NULL;
142 } 157 }
143 158
159out:
144 return err; 160 return err;
145} 161}
146 162
@@ -148,11 +164,13 @@ static void __exit configfs_exit(void)
148{ 164{
149 unregister_filesystem(&configfs_fs_type); 165 unregister_filesystem(&configfs_fs_type);
150 subsystem_unregister(&config_subsys); 166 subsystem_unregister(&config_subsys);
167 kmem_cache_destroy(configfs_dir_cachep);
168 configfs_dir_cachep = NULL;
151} 169}
152 170
153MODULE_AUTHOR("Oracle"); 171MODULE_AUTHOR("Oracle");
154MODULE_LICENSE("GPL"); 172MODULE_LICENSE("GPL");
155MODULE_VERSION("0.0.1"); 173MODULE_VERSION("0.0.2");
156MODULE_DESCRIPTION("Simple RAM filesystem for user driven kernel subsystem configuration."); 174MODULE_DESCRIPTION("Simple RAM filesystem for user driven kernel subsystem configuration.");
157 175
158module_init(configfs_init); 176module_init(configfs_init);
diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c
index 50f5840521a9..e5512e295cf2 100644
--- a/fs/configfs/symlink.c
+++ b/fs/configfs/symlink.c
@@ -162,8 +162,7 @@ int configfs_unlink(struct inode *dir, struct dentry *dentry)
162 if (!(sd->s_type & CONFIGFS_ITEM_LINK)) 162 if (!(sd->s_type & CONFIGFS_ITEM_LINK))
163 goto out; 163 goto out;
164 164
165 if (dentry->d_parent == configfs_sb->s_root) 165 BUG_ON(dentry->d_parent == configfs_sb->s_root);
166 BUG();
167 166
168 sl = sd->s_element; 167 sl = sd->s_element;
169 168
@@ -277,5 +276,6 @@ struct inode_operations configfs_symlink_inode_operations = {
277 .follow_link = configfs_follow_link, 276 .follow_link = configfs_follow_link,
278 .readlink = generic_readlink, 277 .readlink = generic_readlink,
279 .put_link = configfs_put_link, 278 .put_link = configfs_put_link,
279 .setattr = configfs_setattr,
280}; 280};
281 281
diff --git a/fs/dcache.c b/fs/dcache.c
index 86bdb93789c6..a173bba32666 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -743,7 +743,9 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
743 dentry->d_op = NULL; 743 dentry->d_op = NULL;
744 dentry->d_fsdata = NULL; 744 dentry->d_fsdata = NULL;
745 dentry->d_mounted = 0; 745 dentry->d_mounted = 0;
746#ifdef CONFIG_PROFILING
746 dentry->d_cookie = NULL; 747 dentry->d_cookie = NULL;
748#endif
747 INIT_HLIST_NODE(&dentry->d_hash); 749 INIT_HLIST_NODE(&dentry->d_hash);
748 INIT_LIST_HEAD(&dentry->d_lru); 750 INIT_LIST_HEAD(&dentry->d_lru);
749 INIT_LIST_HEAD(&dentry->d_subdirs); 751 INIT_LIST_HEAD(&dentry->d_subdirs);
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 30dbbd1df511..848044af7e16 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -857,6 +857,7 @@ do_holes:
857 /* Handle holes */ 857 /* Handle holes */
858 if (!buffer_mapped(map_bh)) { 858 if (!buffer_mapped(map_bh)) {
859 char *kaddr; 859 char *kaddr;
860 loff_t i_size_aligned;
860 861
861 /* AKPM: eargh, -ENOTBLK is a hack */ 862 /* AKPM: eargh, -ENOTBLK is a hack */
862 if (dio->rw == WRITE) { 863 if (dio->rw == WRITE) {
@@ -864,8 +865,14 @@ do_holes:
864 return -ENOTBLK; 865 return -ENOTBLK;
865 } 866 }
866 867
868 /*
869 * Be sure to account for a partial block as the
870 * last block in the file
871 */
872 i_size_aligned = ALIGN(i_size_read(dio->inode),
873 1 << blkbits);
867 if (dio->block_in_file >= 874 if (dio->block_in_file >=
868 i_size_read(dio->inode)>>blkbits) { 875 i_size_aligned >> blkbits) {
869 /* We hit eof */ 876 /* We hit eof */
870 page_cache_release(page); 877 page_cache_release(page);
871 goto out; 878 goto out;
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 35acc43b897f..da52b4a5db64 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -220,7 +220,7 @@ ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
220 struct ext2_inode_info *ei = EXT2_I(inode); 220 struct ext2_inode_info *ei = EXT2_I(inode);
221 int name_index; 221 int name_index;
222 void *value = NULL; 222 void *value = NULL;
223 size_t size; 223 size_t size = 0;
224 int error; 224 int error;
225 225
226 if (S_ISLNK(inode->i_mode)) 226 if (S_ISLNK(inode->i_mode))
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index 74714af4ae69..e52765219e16 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -605,7 +605,7 @@ got:
605 insert_inode_hash(inode); 605 insert_inode_hash(inode);
606 606
607 if (DQUOT_ALLOC_INODE(inode)) { 607 if (DQUOT_ALLOC_INODE(inode)) {
608 err = -ENOSPC; 608 err = -EDQUOT;
609 goto fail_drop; 609 goto fail_drop;
610 } 610 }
611 611
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index e7d3f0522d01..a717837f272e 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -706,6 +706,7 @@ struct address_space_operations ext2_aops = {
706 .bmap = ext2_bmap, 706 .bmap = ext2_bmap,
707 .direct_IO = ext2_direct_IO, 707 .direct_IO = ext2_direct_IO,
708 .writepages = ext2_writepages, 708 .writepages = ext2_writepages,
709 .migratepage = buffer_migrate_page,
709}; 710};
710 711
711struct address_space_operations ext2_aops_xip = { 712struct address_space_operations ext2_aops_xip = {
@@ -723,6 +724,7 @@ struct address_space_operations ext2_nobh_aops = {
723 .bmap = ext2_bmap, 724 .bmap = ext2_bmap,
724 .direct_IO = ext2_direct_IO, 725 .direct_IO = ext2_direct_IO,
725 .writepages = ext2_writepages, 726 .writepages = ext2_writepages,
727 .migratepage = buffer_migrate_page,
726}; 728};
727 729
728/* 730/*
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 8d6819846fc9..cb6f9bd658de 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -221,6 +221,11 @@ static int ext2_show_options(struct seq_file *seq, struct vfsmount *vfs)
221 seq_puts(seq, ",grpquota"); 221 seq_puts(seq, ",grpquota");
222#endif 222#endif
223 223
224#if defined(CONFIG_EXT2_FS_XIP)
225 if (sbi->s_mount_opt & EXT2_MOUNT_XIP)
226 seq_puts(seq, ",xip");
227#endif
228
224 return 0; 229 return 0;
225} 230}
226 231
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index 47a9da2dfb4f..0d21d558b87a 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -226,7 +226,7 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type,
226 struct ext3_inode_info *ei = EXT3_I(inode); 226 struct ext3_inode_info *ei = EXT3_I(inode);
227 int name_index; 227 int name_index;
228 void *value = NULL; 228 void *value = NULL;
229 size_t size; 229 size_t size = 0;
230 int error; 230 int error;
231 231
232 if (S_ISLNK(inode->i_mode)) 232 if (S_ISLNK(inode->i_mode))
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 8824e84f8a56..3fc4238e9703 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1559,6 +1559,7 @@ static struct address_space_operations ext3_ordered_aops = {
1559 .invalidatepage = ext3_invalidatepage, 1559 .invalidatepage = ext3_invalidatepage,
1560 .releasepage = ext3_releasepage, 1560 .releasepage = ext3_releasepage,
1561 .direct_IO = ext3_direct_IO, 1561 .direct_IO = ext3_direct_IO,
1562 .migratepage = buffer_migrate_page,
1562}; 1563};
1563 1564
1564static struct address_space_operations ext3_writeback_aops = { 1565static struct address_space_operations ext3_writeback_aops = {
@@ -1572,6 +1573,7 @@ static struct address_space_operations ext3_writeback_aops = {
1572 .invalidatepage = ext3_invalidatepage, 1573 .invalidatepage = ext3_invalidatepage,
1573 .releasepage = ext3_releasepage, 1574 .releasepage = ext3_releasepage,
1574 .direct_IO = ext3_direct_IO, 1575 .direct_IO = ext3_direct_IO,
1576 .migratepage = buffer_migrate_page,
1575}; 1577};
1576 1578
1577static struct address_space_operations ext3_journalled_aops = { 1579static struct address_space_operations ext3_journalled_aops = {
diff --git a/fs/fat/file.c b/fs/fat/file.c
index e99c5a73b39e..88aa1ae13f9f 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -210,10 +210,30 @@ static int fat_free(struct inode *inode, int skip)
210 if (MSDOS_I(inode)->i_start == 0) 210 if (MSDOS_I(inode)->i_start == 0)
211 return 0; 211 return 0;
212 212
213 /* 213 fat_cache_inval_inode(inode);
214 * Write a new EOF, and get the remaining cluster chain for freeing. 214
215 */
216 wait = IS_DIRSYNC(inode); 215 wait = IS_DIRSYNC(inode);
216 i_start = free_start = MSDOS_I(inode)->i_start;
217 i_logstart = MSDOS_I(inode)->i_logstart;
218
219 /* First, we write the new file size. */
220 if (!skip) {
221 MSDOS_I(inode)->i_start = 0;
222 MSDOS_I(inode)->i_logstart = 0;
223 }
224 MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
225 inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
226 if (wait) {
227 err = fat_sync_inode(inode);
228 if (err) {
229 MSDOS_I(inode)->i_start = i_start;
230 MSDOS_I(inode)->i_logstart = i_logstart;
231 return err;
232 }
233 } else
234 mark_inode_dirty(inode);
235
236 /* Write a new EOF, and get the remaining cluster chain for freeing. */
217 if (skip) { 237 if (skip) {
218 struct fat_entry fatent; 238 struct fat_entry fatent;
219 int ret, fclus, dclus; 239 int ret, fclus, dclus;
@@ -244,35 +264,11 @@ static int fat_free(struct inode *inode, int skip)
244 return ret; 264 return ret;
245 265
246 free_start = ret; 266 free_start = ret;
247 i_start = i_logstart = 0;
248 fat_cache_inval_inode(inode);
249 } else {
250 fat_cache_inval_inode(inode);
251
252 i_start = free_start = MSDOS_I(inode)->i_start;
253 i_logstart = MSDOS_I(inode)->i_logstart;
254 MSDOS_I(inode)->i_start = 0;
255 MSDOS_I(inode)->i_logstart = 0;
256 } 267 }
257 MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
258 inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
259 if (wait) {
260 err = fat_sync_inode(inode);
261 if (err)
262 goto error;
263 } else
264 mark_inode_dirty(inode);
265 inode->i_blocks = skip << (MSDOS_SB(sb)->cluster_bits - 9); 268 inode->i_blocks = skip << (MSDOS_SB(sb)->cluster_bits - 9);
266 269
267 /* Freeing the remained cluster chain */ 270 /* Freeing the remained cluster chain */
268 return fat_free_clusters(inode, free_start); 271 return fat_free_clusters(inode, free_start);
269
270error:
271 if (i_start) {
272 MSDOS_I(inode)->i_start = i_start;
273 MSDOS_I(inode)->i_logstart = i_logstart;
274 }
275 return err;
276} 272}
277 273
278void fat_truncate(struct inode *inode) 274void fat_truncate(struct inode *inode)
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 32fb0a3f1da4..944652e9dde1 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -196,19 +196,9 @@ EXPORT_SYMBOL_GPL(fat_date_unix2dos);
196 196
197int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs) 197int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs)
198{ 198{
199 int i, e, err = 0; 199 int i, err = 0;
200 200
201 for (i = 0; i < nr_bhs; i++) { 201 ll_rw_block(SWRITE, nr_bhs, bhs);
202 lock_buffer(bhs[i]);
203 if (test_clear_buffer_dirty(bhs[i])) {
204 get_bh(bhs[i]);
205 bhs[i]->b_end_io = end_buffer_write_sync;
206 e = submit_bh(WRITE, bhs[i]);
207 if (!err && e)
208 err = e;
209 } else
210 unlock_buffer(bhs[i]);
211 }
212 for (i = 0; i < nr_bhs; i++) { 202 for (i = 0; i < nr_bhs; i++) {
213 wait_on_buffer(bhs[i]); 203 wait_on_buffer(bhs[i]);
214 if (buffer_eopnotsupp(bhs[i])) { 204 if (buffer_eopnotsupp(bhs[i])) {
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 5f96786d1c73..dc4a7007f4e7 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -208,8 +208,11 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
208 struct inode * inode = filp->f_dentry->d_inode; 208 struct inode * inode = filp->f_dentry->d_inode;
209 int error = 0; 209 int error = 0;
210 210
211 /* O_APPEND cannot be cleared if the file is marked as append-only */ 211 /*
212 if (!(arg & O_APPEND) && IS_APPEND(inode)) 212 * O_APPEND cannot be cleared if the file is marked as append-only
213 * and the file is open for write.
214 */
215 if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
213 return -EPERM; 216 return -EPERM;
214 217
215 /* O_NOATIME can only be set by the owner or superuser */ 218 /* O_NOATIME can only be set by the owner or superuser */
diff --git a/fs/file.c b/fs/file.c
index fd066b261c75..cea7cbea11d0 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -379,7 +379,6 @@ static void __devinit fdtable_defer_list_init(int cpu)
379void __init files_defer_init(void) 379void __init files_defer_init(void)
380{ 380{
381 int i; 381 int i;
382 /* Really early - can't use for_each_cpu */ 382 for_each_cpu(i)
383 for (i = 0; i < NR_CPUS; i++)
384 fdtable_defer_list_init(i); 383 fdtable_defer_list_init(i);
385} 384}
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 4526da8907c6..f556a0d5c0d3 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -120,9 +120,9 @@ struct fuse_req *fuse_get_request(struct fuse_conn *fc)
120 return do_get_request(fc); 120 return do_get_request(fc);
121} 121}
122 122
123/* Must be called with fuse_lock held */
123static void fuse_putback_request(struct fuse_conn *fc, struct fuse_req *req) 124static void fuse_putback_request(struct fuse_conn *fc, struct fuse_req *req)
124{ 125{
125 spin_lock(&fuse_lock);
126 if (req->preallocated) { 126 if (req->preallocated) {
127 atomic_dec(&fc->num_waiting); 127 atomic_dec(&fc->num_waiting);
128 list_add(&req->list, &fc->unused_list); 128 list_add(&req->list, &fc->unused_list);
@@ -134,11 +134,19 @@ static void fuse_putback_request(struct fuse_conn *fc, struct fuse_req *req)
134 fc->outstanding_debt--; 134 fc->outstanding_debt--;
135 else 135 else
136 up(&fc->outstanding_sem); 136 up(&fc->outstanding_sem);
137 spin_unlock(&fuse_lock);
138} 137}
139 138
140void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req) 139void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req)
141{ 140{
141 if (atomic_dec_and_test(&req->count)) {
142 spin_lock(&fuse_lock);
143 fuse_putback_request(fc, req);
144 spin_unlock(&fuse_lock);
145 }
146}
147
148static void fuse_put_request_locked(struct fuse_conn *fc, struct fuse_req *req)
149{
142 if (atomic_dec_and_test(&req->count)) 150 if (atomic_dec_and_test(&req->count))
143 fuse_putback_request(fc, req); 151 fuse_putback_request(fc, req);
144} 152}
@@ -163,26 +171,36 @@ void fuse_release_background(struct fuse_req *req)
163 * still waiting), the 'end' callback is called if given, else the 171 * still waiting), the 'end' callback is called if given, else the
164 * reference to the request is released 172 * reference to the request is released
165 * 173 *
174 * Releasing extra reference for foreground requests must be done
175 * within the same locked region as setting state to finished. This
176 * is because fuse_reset_request() may be called after request is
177 * finished and it must be the sole possessor. If request is
178 * interrupted and put in the background, it will return with an error
179 * and hence never be reset and reused.
180 *
166 * Called with fuse_lock, unlocks it 181 * Called with fuse_lock, unlocks it
167 */ 182 */
168static void request_end(struct fuse_conn *fc, struct fuse_req *req) 183static void request_end(struct fuse_conn *fc, struct fuse_req *req)
169{ 184{
170 void (*end) (struct fuse_conn *, struct fuse_req *) = req->end;
171 req->end = NULL;
172 list_del(&req->list); 185 list_del(&req->list);
173 req->state = FUSE_REQ_FINISHED; 186 req->state = FUSE_REQ_FINISHED;
174 spin_unlock(&fuse_lock); 187 if (!req->background) {
175 if (req->background) { 188 wake_up(&req->waitq);
189 fuse_put_request_locked(fc, req);
190 spin_unlock(&fuse_lock);
191 } else {
192 void (*end) (struct fuse_conn *, struct fuse_req *) = req->end;
193 req->end = NULL;
194 spin_unlock(&fuse_lock);
176 down_read(&fc->sbput_sem); 195 down_read(&fc->sbput_sem);
177 if (fc->mounted) 196 if (fc->mounted)
178 fuse_release_background(req); 197 fuse_release_background(req);
179 up_read(&fc->sbput_sem); 198 up_read(&fc->sbput_sem);
199 if (end)
200 end(fc, req);
201 else
202 fuse_put_request(fc, req);
180 } 203 }
181 wake_up(&req->waitq);
182 if (end)
183 end(fc, req);
184 else
185 fuse_put_request(fc, req);
186} 204}
187 205
188/* 206/*
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index a7ef5e716f3c..296351615b00 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -335,9 +335,14 @@ static void fuse_send_readpages(struct fuse_req *req, struct file *file,
335 loff_t pos = page_offset(req->pages[0]); 335 loff_t pos = page_offset(req->pages[0]);
336 size_t count = req->num_pages << PAGE_CACHE_SHIFT; 336 size_t count = req->num_pages << PAGE_CACHE_SHIFT;
337 req->out.page_zeroing = 1; 337 req->out.page_zeroing = 1;
338 req->end = fuse_readpages_end;
339 fuse_read_fill(req, file, inode, pos, count, FUSE_READ); 338 fuse_read_fill(req, file, inode, pos, count, FUSE_READ);
340 request_send_background(fc, req); 339 if (fc->async_read) {
340 req->end = fuse_readpages_end;
341 request_send_background(fc, req);
342 } else {
343 request_send(fc, req);
344 fuse_readpages_end(fc, req);
345 }
341} 346}
342 347
343struct fuse_readpages_data { 348struct fuse_readpages_data {
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 46cf933aa3bf..4a83adfec968 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -272,6 +272,9 @@ struct fuse_conn {
272 reply, before any other request, and never cleared */ 272 reply, before any other request, and never cleared */
273 unsigned conn_error : 1; 273 unsigned conn_error : 1;
274 274
275 /** Do readpages asynchronously? Only set in INIT */
276 unsigned async_read : 1;
277
275 /* 278 /*
276 * The following bitfields are only for optimization purposes 279 * The following bitfields are only for optimization purposes
277 * and hence races in setting them will not cause malfunction 280 * and hence races in setting them will not cause malfunction
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index c755a0440a66..879e6fba9480 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -473,6 +473,16 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
473 if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION) 473 if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION)
474 fc->conn_error = 1; 474 fc->conn_error = 1;
475 else { 475 else {
476 unsigned long ra_pages;
477
478 if (arg->minor >= 6) {
479 ra_pages = arg->max_readahead / PAGE_CACHE_SIZE;
480 if (arg->flags & FUSE_ASYNC_READ)
481 fc->async_read = 1;
482 } else
483 ra_pages = fc->max_read / PAGE_CACHE_SIZE;
484
485 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages);
476 fc->minor = arg->minor; 486 fc->minor = arg->minor;
477 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; 487 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
478 } 488 }
@@ -496,6 +506,8 @@ static void fuse_send_init(struct fuse_conn *fc)
496 506
497 arg->major = FUSE_KERNEL_VERSION; 507 arg->major = FUSE_KERNEL_VERSION;
498 arg->minor = FUSE_KERNEL_MINOR_VERSION; 508 arg->minor = FUSE_KERNEL_MINOR_VERSION;
509 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
510 arg->flags |= FUSE_ASYNC_READ;
499 req->in.h.opcode = FUSE_INIT; 511 req->in.h.opcode = FUSE_INIT;
500 req->in.numargs = 1; 512 req->in.numargs = 1;
501 req->in.args[0].size = sizeof(*arg); 513 req->in.args[0].size = sizeof(*arg);
@@ -552,8 +564,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
552 fc->user_id = d.user_id; 564 fc->user_id = d.user_id;
553 fc->group_id = d.group_id; 565 fc->group_id = d.group_id;
554 fc->max_read = d.max_read; 566 fc->max_read = d.max_read;
555 if (fc->max_read / PAGE_CACHE_SIZE < fc->bdi.ra_pages)
556 fc->bdi.ra_pages = fc->max_read / PAGE_CACHE_SIZE;
557 567
558 /* Used by get_root_inode() */ 568 /* Used by get_root_inode() */
559 sb->s_fs_info = fc; 569 sb->s_fs_info = fc;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index f568102da1e8..b35195289945 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -72,8 +72,8 @@ huge_pages_needed(struct address_space *mapping, struct vm_area_struct *vma)
72 unsigned long start = vma->vm_start; 72 unsigned long start = vma->vm_start;
73 unsigned long end = vma->vm_end; 73 unsigned long end = vma->vm_end;
74 unsigned long hugepages = (end - start) >> HPAGE_SHIFT; 74 unsigned long hugepages = (end - start) >> HPAGE_SHIFT;
75 pgoff_t next = vma->vm_pgoff; 75 pgoff_t next = vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT);
76 pgoff_t endpg = next + ((end - start) >> PAGE_SHIFT); 76 pgoff_t endpg = next + hugepages;
77 77
78 pagevec_init(&pvec, 0); 78 pagevec_init(&pvec, 0);
79 while (next < endpg) { 79 while (next < endpg) {
diff --git a/fs/inode.c b/fs/inode.c
index 108138d4e909..d0be6159eb7f 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1179,7 +1179,7 @@ EXPORT_SYMBOL(bmap);
1179/** 1179/**
1180 * touch_atime - update the access time 1180 * touch_atime - update the access time
1181 * @mnt: mount the inode is accessed on 1181 * @mnt: mount the inode is accessed on
1182 * @inode: inode accessed 1182 * @dentry: dentry accessed
1183 * 1183 *
1184 * Update the accessed time on an inode and mark it for writeback. 1184 * Update the accessed time on an inode and mark it for writeback.
1185 * This function automatically handles read only file systems and media, 1185 * This function automatically handles read only file systems and media,
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 429f4b263cf1..ca917973c2c0 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -1308,6 +1308,7 @@ int journal_stop(handle_t *handle)
1308 transaction_t *transaction = handle->h_transaction; 1308 transaction_t *transaction = handle->h_transaction;
1309 journal_t *journal = transaction->t_journal; 1309 journal_t *journal = transaction->t_journal;
1310 int old_handle_count, err; 1310 int old_handle_count, err;
1311 pid_t pid;
1311 1312
1312 J_ASSERT(transaction->t_updates > 0); 1313 J_ASSERT(transaction->t_updates > 0);
1313 J_ASSERT(journal_current_handle() == handle); 1314 J_ASSERT(journal_current_handle() == handle);
@@ -1333,8 +1334,15 @@ int journal_stop(handle_t *handle)
1333 * It doesn't cost much - we're about to run a commit and sleep 1334 * It doesn't cost much - we're about to run a commit and sleep
1334 * on IO anyway. Speeds up many-threaded, many-dir operations 1335 * on IO anyway. Speeds up many-threaded, many-dir operations
1335 * by 30x or more... 1336 * by 30x or more...
1337 *
1338 * But don't do this if this process was the most recent one to
1339 * perform a synchronous write. We do this to detect the case where a
1340 * single process is doing a stream of sync writes. No point in waiting
1341 * for joiners in that case.
1336 */ 1342 */
1337 if (handle->h_sync) { 1343 pid = current->pid;
1344 if (handle->h_sync && journal->j_last_sync_writer != pid) {
1345 journal->j_last_sync_writer = pid;
1338 do { 1346 do {
1339 old_handle_count = transaction->t_handle_count; 1347 old_handle_count = transaction->t_handle_count;
1340 schedule_timeout_uninterruptible(1); 1348 schedule_timeout_uninterruptible(1);
diff --git a/fs/jffs/intrep.c b/fs/jffs/intrep.c
index b2e95421d932..ce7b54b0b2b7 100644
--- a/fs/jffs/intrep.c
+++ b/fs/jffs/intrep.c
@@ -1965,7 +1965,7 @@ retry:
1965 iovec_cnt++; 1965 iovec_cnt++;
1966 1966
1967 if (JFFS_GET_PAD_BYTES(raw_inode->nsize)) { 1967 if (JFFS_GET_PAD_BYTES(raw_inode->nsize)) {
1968 static char allff[3]={255,255,255}; 1968 static unsigned char allff[3]={255,255,255};
1969 /* Add some extra padding if necessary */ 1969 /* Add some extra padding if necessary */
1970 node_iovec[iovec_cnt].iov_base = allff; 1970 node_iovec[iovec_cnt].iov_base = allff;
1971 node_iovec[iovec_cnt].iov_len = 1971 node_iovec[iovec_cnt].iov_len =
diff --git a/fs/libfs.c b/fs/libfs.c
index 63c020e6589e..71fd08fa4103 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -388,6 +388,7 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files
388 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 388 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
389 inode->i_op = &simple_dir_inode_operations; 389 inode->i_op = &simple_dir_inode_operations;
390 inode->i_fop = &simple_dir_operations; 390 inode->i_fop = &simple_dir_operations;
391 inode->i_nlink = 2;
391 root = d_alloc_root(inode); 392 root = d_alloc_root(inode);
392 if (!root) { 393 if (!root) {
393 iput(inode); 394 iput(inode);
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 145524039577..220058d8616d 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -22,12 +22,14 @@
22#define NLMDBG_FACILITY NLMDBG_CLIENT 22#define NLMDBG_FACILITY NLMDBG_CLIENT
23#define NLMCLNT_GRACE_WAIT (5*HZ) 23#define NLMCLNT_GRACE_WAIT (5*HZ)
24#define NLMCLNT_POLL_TIMEOUT (30*HZ) 24#define NLMCLNT_POLL_TIMEOUT (30*HZ)
25#define NLMCLNT_MAX_RETRIES 3
25 26
26static int nlmclnt_test(struct nlm_rqst *, struct file_lock *); 27static int nlmclnt_test(struct nlm_rqst *, struct file_lock *);
27static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *); 28static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *);
28static int nlmclnt_unlock(struct nlm_rqst *, struct file_lock *); 29static int nlmclnt_unlock(struct nlm_rqst *, struct file_lock *);
29static int nlm_stat_to_errno(u32 stat); 30static int nlm_stat_to_errno(u32 stat);
30static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host); 31static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host);
32static int nlmclnt_cancel(struct nlm_host *, int , struct file_lock *);
31 33
32static const struct rpc_call_ops nlmclnt_unlock_ops; 34static const struct rpc_call_ops nlmclnt_unlock_ops;
33static const struct rpc_call_ops nlmclnt_cancel_ops; 35static const struct rpc_call_ops nlmclnt_cancel_ops;
@@ -598,7 +600,7 @@ out_unblock:
598 nlmclnt_finish_block(req); 600 nlmclnt_finish_block(req);
599 /* Cancel the blocked request if it is still pending */ 601 /* Cancel the blocked request if it is still pending */
600 if (resp->status == NLM_LCK_BLOCKED) 602 if (resp->status == NLM_LCK_BLOCKED)
601 nlmclnt_cancel(host, fl); 603 nlmclnt_cancel(host, req->a_args.block, fl);
602out: 604out:
603 nlmclnt_release_lockargs(req); 605 nlmclnt_release_lockargs(req);
604 return status; 606 return status;
@@ -728,8 +730,7 @@ static const struct rpc_call_ops nlmclnt_unlock_ops = {
728 * We always use an async RPC call for this in order not to hang a 730 * We always use an async RPC call for this in order not to hang a
729 * process that has been Ctrl-C'ed. 731 * process that has been Ctrl-C'ed.
730 */ 732 */
731int 733static int nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *fl)
732nlmclnt_cancel(struct nlm_host *host, struct file_lock *fl)
733{ 734{
734 struct nlm_rqst *req; 735 struct nlm_rqst *req;
735 unsigned long flags; 736 unsigned long flags;
@@ -750,6 +751,7 @@ nlmclnt_cancel(struct nlm_host *host, struct file_lock *fl)
750 req->a_flags = RPC_TASK_ASYNC; 751 req->a_flags = RPC_TASK_ASYNC;
751 752
752 nlmclnt_setlockargs(req, fl); 753 nlmclnt_setlockargs(req, fl);
754 req->a_args.block = block;
753 755
754 status = nlmclnt_async_call(req, NLMPROC_CANCEL, &nlmclnt_cancel_ops); 756 status = nlmclnt_async_call(req, NLMPROC_CANCEL, &nlmclnt_cancel_ops);
755 if (status < 0) { 757 if (status < 0) {
@@ -801,6 +803,9 @@ die:
801 return; 803 return;
802 804
803retry_cancel: 805retry_cancel:
806 /* Don't ever retry more than 3 times */
807 if (req->a_retries++ >= NLMCLNT_MAX_RETRIES)
808 goto die;
804 nlm_rebind_host(req->a_host); 809 nlm_rebind_host(req->a_host);
805 rpc_restart_call(task); 810 rpc_restart_call(task);
806 rpc_delay(task, 30 * HZ); 811 rpc_delay(task, 30 * HZ);
diff --git a/fs/namei.c b/fs/namei.c
index 4acdac043b6b..faf61c35308c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -790,7 +790,7 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
790 790
791 inode = nd->dentry->d_inode; 791 inode = nd->dentry->d_inode;
792 if (nd->depth) 792 if (nd->depth)
793 lookup_flags = LOOKUP_FOLLOW; 793 lookup_flags = LOOKUP_FOLLOW | (nd->flags & LOOKUP_CONTINUE);
794 794
795 /* At this point we know we have a real path component. */ 795 /* At this point we know we have a real path component. */
796 for(;;) { 796 for(;;) {
@@ -885,7 +885,8 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
885last_with_slashes: 885last_with_slashes:
886 lookup_flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; 886 lookup_flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
887last_component: 887last_component:
888 nd->flags &= ~LOOKUP_CONTINUE; 888 /* Clear LOOKUP_CONTINUE iff it was previously unset */
889 nd->flags &= lookup_flags | ~LOOKUP_CONTINUE;
889 if (lookup_flags & LOOKUP_PARENT) 890 if (lookup_flags & LOOKUP_PARENT)
890 goto lookup_parent; 891 goto lookup_parent;
891 if (this.name[0] == '.') switch (this.len) { 892 if (this.name[0] == '.') switch (this.len) {
@@ -1069,6 +1070,8 @@ static int fastcall do_path_lookup(int dfd, const char *name,
1069 unsigned int flags, struct nameidata *nd) 1070 unsigned int flags, struct nameidata *nd)
1070{ 1071{
1071 int retval = 0; 1072 int retval = 0;
1073 int fput_needed;
1074 struct file *file;
1072 1075
1073 nd->last_type = LAST_ROOT; /* if there are only slashes... */ 1076 nd->last_type = LAST_ROOT; /* if there are only slashes... */
1074 nd->flags = flags; 1077 nd->flags = flags;
@@ -1090,29 +1093,22 @@ static int fastcall do_path_lookup(int dfd, const char *name,
1090 nd->mnt = mntget(current->fs->pwdmnt); 1093 nd->mnt = mntget(current->fs->pwdmnt);
1091 nd->dentry = dget(current->fs->pwd); 1094 nd->dentry = dget(current->fs->pwd);
1092 } else { 1095 } else {
1093 struct file *file;
1094 int fput_needed;
1095 struct dentry *dentry; 1096 struct dentry *dentry;
1096 1097
1097 file = fget_light(dfd, &fput_needed); 1098 file = fget_light(dfd, &fput_needed);
1098 if (!file) { 1099 retval = -EBADF;
1099 retval = -EBADF; 1100 if (!file)
1100 goto out_fail; 1101 goto unlock_fail;
1101 }
1102 1102
1103 dentry = file->f_dentry; 1103 dentry = file->f_dentry;
1104 1104
1105 if (!S_ISDIR(dentry->d_inode->i_mode)) { 1105 retval = -ENOTDIR;
1106 retval = -ENOTDIR; 1106 if (!S_ISDIR(dentry->d_inode->i_mode))
1107 fput_light(file, fput_needed); 1107 goto fput_unlock_fail;
1108 goto out_fail;
1109 }
1110 1108
1111 retval = file_permission(file, MAY_EXEC); 1109 retval = file_permission(file, MAY_EXEC);
1112 if (retval) { 1110 if (retval)
1113 fput_light(file, fput_needed); 1111 goto fput_unlock_fail;
1114 goto out_fail;
1115 }
1116 1112
1117 nd->mnt = mntget(file->f_vfsmnt); 1113 nd->mnt = mntget(file->f_vfsmnt);
1118 nd->dentry = dget(dentry); 1114 nd->dentry = dget(dentry);
@@ -1126,7 +1122,12 @@ out:
1126 if (unlikely(current->audit_context 1122 if (unlikely(current->audit_context
1127 && nd && nd->dentry && nd->dentry->d_inode)) 1123 && nd && nd->dentry && nd->dentry->d_inode))
1128 audit_inode(name, nd->dentry->d_inode, flags); 1124 audit_inode(name, nd->dentry->d_inode, flags);
1129out_fail: 1125 return retval;
1126
1127fput_unlock_fail:
1128 fput_light(file, fput_needed);
1129unlock_fail:
1130 read_unlock(&current->fs->lock);
1130 return retval; 1131 return retval;
1131} 1132}
1132 1133
@@ -1161,6 +1162,7 @@ static int __path_lookup_intent_open(int dfd, const char *name,
1161 1162
1162/** 1163/**
1163 * path_lookup_open - lookup a file path with open intent 1164 * path_lookup_open - lookup a file path with open intent
1165 * @dfd: the directory to use as base, or AT_FDCWD
1164 * @name: pointer to file name 1166 * @name: pointer to file name
1165 * @lookup_flags: lookup intent flags 1167 * @lookup_flags: lookup intent flags
1166 * @nd: pointer to nameidata 1168 * @nd: pointer to nameidata
@@ -1175,6 +1177,7 @@ int path_lookup_open(int dfd, const char *name, unsigned int lookup_flags,
1175 1177
1176/** 1178/**
1177 * path_lookup_create - lookup a file path with open + create intent 1179 * path_lookup_create - lookup a file path with open + create intent
1180 * @dfd: the directory to use as base, or AT_FDCWD
1178 * @name: pointer to file name 1181 * @name: pointer to file name
1179 * @lookup_flags: lookup intent flags 1182 * @lookup_flags: lookup intent flags
1180 * @nd: pointer to nameidata 1183 * @nd: pointer to nameidata
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 10ae377e68ff..04ab2fc360e7 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -481,7 +481,7 @@ retry:
481 if (wdata->verf.committed != NFS_FILE_SYNC) { 481 if (wdata->verf.committed != NFS_FILE_SYNC) {
482 need_commit = 1; 482 need_commit = 1;
483 if (memcmp(&first_verf.verifier, &wdata->verf.verifier, 483 if (memcmp(&first_verf.verifier, &wdata->verf.verifier,
484 sizeof(first_verf.verifier))); 484 sizeof(first_verf.verifier)))
485 goto sync_retry; 485 goto sync_retry;
486 } 486 }
487 487
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 89ed04696865..1d163b616915 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -64,6 +64,32 @@ struct nfsd_list {
64}; 64};
65static struct list_head nfsd_list = LIST_HEAD_INIT(nfsd_list); 65static struct list_head nfsd_list = LIST_HEAD_INIT(nfsd_list);
66 66
67#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
68static struct svc_stat nfsd_acl_svcstats;
69static struct svc_version * nfsd_acl_version[] = {
70 [2] = &nfsd_acl_version2,
71 [3] = &nfsd_acl_version3,
72};
73
74#define NFSD_ACL_MINVERS 2
75#define NFSD_ACL_NRVERS (sizeof(nfsd_acl_version)/sizeof(nfsd_acl_version[0]))
76static struct svc_version *nfsd_acl_versions[NFSD_ACL_NRVERS];
77
78static struct svc_program nfsd_acl_program = {
79 .pg_prog = NFS_ACL_PROGRAM,
80 .pg_nvers = NFSD_ACL_NRVERS,
81 .pg_vers = nfsd_acl_versions,
82 .pg_name = "nfsd",
83 .pg_class = "nfsd",
84 .pg_stats = &nfsd_acl_svcstats,
85 .pg_authenticate = &svc_set_client,
86};
87
88static struct svc_stat nfsd_acl_svcstats = {
89 .program = &nfsd_acl_program,
90};
91#endif /* defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) */
92
67static struct svc_version * nfsd_version[] = { 93static struct svc_version * nfsd_version[] = {
68 [2] = &nfsd_version2, 94 [2] = &nfsd_version2,
69#if defined(CONFIG_NFSD_V3) 95#if defined(CONFIG_NFSD_V3)
@@ -79,6 +105,9 @@ static struct svc_version * nfsd_version[] = {
79static struct svc_version *nfsd_versions[NFSD_NRVERS]; 105static struct svc_version *nfsd_versions[NFSD_NRVERS];
80 106
81struct svc_program nfsd_program = { 107struct svc_program nfsd_program = {
108#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
109 .pg_next = &nfsd_acl_program,
110#endif
82 .pg_prog = NFS_PROGRAM, /* program number */ 111 .pg_prog = NFS_PROGRAM, /* program number */
83 .pg_nvers = NFSD_NRVERS, /* nr of entries in nfsd_version */ 112 .pg_nvers = NFSD_NRVERS, /* nr of entries in nfsd_version */
84 .pg_vers = nfsd_versions, /* version table */ 113 .pg_vers = nfsd_versions, /* version table */
@@ -147,6 +176,26 @@ nfsd_svc(unsigned short port, int nrservs)
147 nfsd_program.pg_vers[i] = nfsd_version[i]; 176 nfsd_program.pg_vers[i] = nfsd_version[i];
148 } 177 }
149 178
179
180#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
181 found_one = 0;
182
183 for (i = NFSD_ACL_MINVERS; i < NFSD_ACL_NRVERS; i++) {
184 if (NFSCTL_VERISSET(nfsd_versbits, i)) {
185 nfsd_acl_program.pg_vers[i] =
186 nfsd_acl_version[i];
187 found_one = 1;
188 } else
189 nfsd_acl_program.pg_vers[i] = NULL;
190 }
191
192 if (!found_one) {
193 for (i = NFSD_ACL_MINVERS; i < NFSD_ACL_NRVERS; i++)
194 nfsd_acl_program.pg_vers[i] =
195 nfsd_acl_version[i];
196 }
197#endif
198
150 atomic_set(&nfsd_busy, 0); 199 atomic_set(&nfsd_busy, 0);
151 error = -ENOMEM; 200 error = -ENOMEM;
152 nfsd_serv = svc_create(&nfsd_program, NFSD_BUFSIZE); 201 nfsd_serv = svc_create(&nfsd_program, NFSD_BUFSIZE);
@@ -411,30 +460,3 @@ nfsd_dispatch(struct svc_rqst *rqstp, u32 *statp)
411 nfsd_cache_update(rqstp, proc->pc_cachetype, statp + 1); 460 nfsd_cache_update(rqstp, proc->pc_cachetype, statp + 1);
412 return 1; 461 return 1;
413} 462}
414
415#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
416static struct svc_stat nfsd_acl_svcstats;
417static struct svc_version * nfsd_acl_version[] = {
418 [2] = &nfsd_acl_version2,
419 [3] = &nfsd_acl_version3,
420};
421
422#define NFSD_ACL_NRVERS (sizeof(nfsd_acl_version)/sizeof(nfsd_acl_version[0]))
423static struct svc_program nfsd_acl_program = {
424 .pg_prog = NFS_ACL_PROGRAM,
425 .pg_nvers = NFSD_ACL_NRVERS,
426 .pg_vers = nfsd_acl_version,
427 .pg_name = "nfsd",
428 .pg_class = "nfsd",
429 .pg_stats = &nfsd_acl_svcstats,
430 .pg_authenticate = &svc_set_client,
431};
432
433static struct svc_stat nfsd_acl_svcstats = {
434 .program = &nfsd_acl_program,
435};
436
437#define nfsd_acl_program_p &nfsd_acl_program
438#else
439#define nfsd_acl_program_p NULL
440#endif /* defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) */
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
index d424041b38e9..bae3d7548bea 100644
--- a/fs/ocfs2/buffer_head_io.c
+++ b/fs/ocfs2/buffer_head_io.c
@@ -58,7 +58,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh,
58 goto out; 58 goto out;
59 } 59 }
60 60
61 down(&OCFS2_I(inode)->ip_io_sem); 61 mutex_lock(&OCFS2_I(inode)->ip_io_mutex);
62 62
63 lock_buffer(bh); 63 lock_buffer(bh);
64 set_buffer_uptodate(bh); 64 set_buffer_uptodate(bh);
@@ -82,7 +82,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh,
82 brelse(bh); 82 brelse(bh);
83 } 83 }
84 84
85 up(&OCFS2_I(inode)->ip_io_sem); 85 mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
86out: 86out:
87 mlog_exit(ret); 87 mlog_exit(ret);
88 return ret; 88 return ret;
@@ -125,13 +125,13 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
125 flags &= ~OCFS2_BH_CACHED; 125 flags &= ~OCFS2_BH_CACHED;
126 126
127 if (inode) 127 if (inode)
128 down(&OCFS2_I(inode)->ip_io_sem); 128 mutex_lock(&OCFS2_I(inode)->ip_io_mutex);
129 for (i = 0 ; i < nr ; i++) { 129 for (i = 0 ; i < nr ; i++) {
130 if (bhs[i] == NULL) { 130 if (bhs[i] == NULL) {
131 bhs[i] = sb_getblk(sb, block++); 131 bhs[i] = sb_getblk(sb, block++);
132 if (bhs[i] == NULL) { 132 if (bhs[i] == NULL) {
133 if (inode) 133 if (inode)
134 up(&OCFS2_I(inode)->ip_io_sem); 134 mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
135 status = -EIO; 135 status = -EIO;
136 mlog_errno(status); 136 mlog_errno(status);
137 goto bail; 137 goto bail;
@@ -220,7 +220,7 @@ int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr,
220 ocfs2_set_buffer_uptodate(inode, bh); 220 ocfs2_set_buffer_uptodate(inode, bh);
221 } 221 }
222 if (inode) 222 if (inode)
223 up(&OCFS2_I(inode)->ip_io_sem); 223 mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
224 224
225 mlog(ML_BH_IO, "block=(%"MLFu64"), nr=(%d), cached=%s\n", block, nr, 225 mlog(ML_BH_IO, "block=(%"MLFu64"), nr=(%d), cached=%s\n", block, nr,
226 (!(flags & OCFS2_BH_CACHED) || ignore_cache) ? "no" : "yes"); 226 (!(flags & OCFS2_BH_CACHED) || ignore_cache) ? "no" : "yes");
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 7307ba528913..d08971d29b63 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -917,8 +917,9 @@ static int o2hb_thread(void *data)
917 elapsed_msec = o2hb_elapsed_msecs(&before_hb, &after_hb); 917 elapsed_msec = o2hb_elapsed_msecs(&before_hb, &after_hb);
918 918
919 mlog(0, "start = %lu.%lu, end = %lu.%lu, msec = %u\n", 919 mlog(0, "start = %lu.%lu, end = %lu.%lu, msec = %u\n",
920 before_hb.tv_sec, before_hb.tv_usec, 920 before_hb.tv_sec, (unsigned long) before_hb.tv_usec,
921 after_hb.tv_sec, after_hb.tv_usec, elapsed_msec); 921 after_hb.tv_sec, (unsigned long) after_hb.tv_usec,
922 elapsed_msec);
922 923
923 if (elapsed_msec < reg->hr_timeout_ms) { 924 if (elapsed_msec < reg->hr_timeout_ms) {
924 /* the kthread api has blocked signals for us so no 925 /* the kthread api has blocked signals for us so no
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 35d92c01a972..d22d4cf08db1 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -1285,14 +1285,16 @@ static void o2net_idle_timer(unsigned long data)
1285 mlog(ML_NOTICE, "here are some times that might help debug the " 1285 mlog(ML_NOTICE, "here are some times that might help debug the "
1286 "situation: (tmr %ld.%ld now %ld.%ld dr %ld.%ld adv " 1286 "situation: (tmr %ld.%ld now %ld.%ld dr %ld.%ld adv "
1287 "%ld.%ld:%ld.%ld func (%08x:%u) %ld.%ld:%ld.%ld)\n", 1287 "%ld.%ld:%ld.%ld func (%08x:%u) %ld.%ld:%ld.%ld)\n",
1288 sc->sc_tv_timer.tv_sec, sc->sc_tv_timer.tv_usec, 1288 sc->sc_tv_timer.tv_sec, (long) sc->sc_tv_timer.tv_usec,
1289 now.tv_sec, now.tv_usec, 1289 now.tv_sec, (long) now.tv_usec,
1290 sc->sc_tv_data_ready.tv_sec, sc->sc_tv_data_ready.tv_usec, 1290 sc->sc_tv_data_ready.tv_sec, (long) sc->sc_tv_data_ready.tv_usec,
1291 sc->sc_tv_advance_start.tv_sec, sc->sc_tv_advance_start.tv_usec, 1291 sc->sc_tv_advance_start.tv_sec,
1292 sc->sc_tv_advance_stop.tv_sec, sc->sc_tv_advance_stop.tv_usec, 1292 (long) sc->sc_tv_advance_start.tv_usec,
1293 sc->sc_tv_advance_stop.tv_sec,
1294 (long) sc->sc_tv_advance_stop.tv_usec,
1293 sc->sc_msg_key, sc->sc_msg_type, 1295 sc->sc_msg_key, sc->sc_msg_type,
1294 sc->sc_tv_func_start.tv_sec, sc->sc_tv_func_start.tv_usec, 1296 sc->sc_tv_func_start.tv_sec, (long) sc->sc_tv_func_start.tv_usec,
1295 sc->sc_tv_func_stop.tv_sec, sc->sc_tv_func_stop.tv_usec); 1297 sc->sc_tv_func_stop.tv_sec, (long) sc->sc_tv_func_stop.tv_usec);
1296 1298
1297 o2net_sc_queue_work(sc, &sc->sc_shutdown_work); 1299 o2net_sc_queue_work(sc, &sc->sc_shutdown_work);
1298} 1300}
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
index 3fecba0a6023..42eb53b5293b 100644
--- a/fs/ocfs2/dlm/dlmcommon.h
+++ b/fs/ocfs2/dlm/dlmcommon.h
@@ -657,6 +657,7 @@ void dlm_complete_thread(struct dlm_ctxt *dlm);
657int dlm_launch_recovery_thread(struct dlm_ctxt *dlm); 657int dlm_launch_recovery_thread(struct dlm_ctxt *dlm);
658void dlm_complete_recovery_thread(struct dlm_ctxt *dlm); 658void dlm_complete_recovery_thread(struct dlm_ctxt *dlm);
659void dlm_wait_for_recovery(struct dlm_ctxt *dlm); 659void dlm_wait_for_recovery(struct dlm_ctxt *dlm);
660int dlm_is_node_dead(struct dlm_ctxt *dlm, u8 node);
660 661
661void dlm_put(struct dlm_ctxt *dlm); 662void dlm_put(struct dlm_ctxt *dlm);
662struct dlm_ctxt *dlm_grab(struct dlm_ctxt *dlm); 663struct dlm_ctxt *dlm_grab(struct dlm_ctxt *dlm);
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index da3c22045f89..6ee30837389c 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -573,8 +573,11 @@ static int dlm_query_join_handler(struct o2net_msg *msg, u32 len, void *data)
573 spin_lock(&dlm_domain_lock); 573 spin_lock(&dlm_domain_lock);
574 dlm = __dlm_lookup_domain_full(query->domain, query->name_len); 574 dlm = __dlm_lookup_domain_full(query->domain, query->name_len);
575 /* Once the dlm ctxt is marked as leaving then we don't want 575 /* Once the dlm ctxt is marked as leaving then we don't want
576 * to be put in someone's domain map. */ 576 * to be put in someone's domain map.
577 * Also, explicitly disallow joining at certain troublesome
578 * times (ie. during recovery). */
577 if (dlm && dlm->dlm_state != DLM_CTXT_LEAVING) { 579 if (dlm && dlm->dlm_state != DLM_CTXT_LEAVING) {
580 int bit = query->node_idx;
578 spin_lock(&dlm->spinlock); 581 spin_lock(&dlm->spinlock);
579 582
580 if (dlm->dlm_state == DLM_CTXT_NEW && 583 if (dlm->dlm_state == DLM_CTXT_NEW &&
@@ -586,6 +589,19 @@ static int dlm_query_join_handler(struct o2net_msg *msg, u32 len, void *data)
586 } else if (dlm->joining_node != DLM_LOCK_RES_OWNER_UNKNOWN) { 589 } else if (dlm->joining_node != DLM_LOCK_RES_OWNER_UNKNOWN) {
587 /* Disallow parallel joins. */ 590 /* Disallow parallel joins. */
588 response = JOIN_DISALLOW; 591 response = JOIN_DISALLOW;
592 } else if (dlm->reco.state & DLM_RECO_STATE_ACTIVE) {
593 mlog(ML_NOTICE, "node %u trying to join, but recovery "
594 "is ongoing.\n", bit);
595 response = JOIN_DISALLOW;
596 } else if (test_bit(bit, dlm->recovery_map)) {
597 mlog(ML_NOTICE, "node %u trying to join, but it "
598 "still needs recovery.\n", bit);
599 response = JOIN_DISALLOW;
600 } else if (test_bit(bit, dlm->domain_map)) {
601 mlog(ML_NOTICE, "node %u trying to join, but it "
602 "is still in the domain! needs recovery?\n",
603 bit);
604 response = JOIN_DISALLOW;
589 } else { 605 } else {
590 /* Alright we're fully a part of this domain 606 /* Alright we're fully a part of this domain
591 * so we keep some state as to who's joining 607 * so we keep some state as to who's joining
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 27e984f7e4cd..a3194fe173d9 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -1050,17 +1050,10 @@ static int dlm_restart_lock_mastery(struct dlm_ctxt *dlm,
1050 node = dlm_bitmap_diff_iter_next(&bdi, &sc); 1050 node = dlm_bitmap_diff_iter_next(&bdi, &sc);
1051 while (node >= 0) { 1051 while (node >= 0) {
1052 if (sc == NODE_UP) { 1052 if (sc == NODE_UP) {
1053 /* a node came up. easy. might not even need 1053 /* a node came up. clear any old vote from
1054 * to talk to it if its node number is higher 1054 * the response map and set it in the vote map
1055 * or if we are already blocked. */ 1055 * then restart the mastery. */
1056 mlog(0, "node up! %d\n", node); 1056 mlog(ML_NOTICE, "node %d up while restarting\n", node);
1057 if (blocked)
1058 goto next;
1059
1060 if (node > dlm->node_num) {
1061 mlog(0, "node > this node. skipping.\n");
1062 goto next;
1063 }
1064 1057
1065 /* redo the master request, but only for the new node */ 1058 /* redo the master request, but only for the new node */
1066 mlog(0, "sending request to new node\n"); 1059 mlog(0, "sending request to new node\n");
@@ -2005,6 +1998,15 @@ fail:
2005 break; 1998 break;
2006 1999
2007 mlog(0, "timed out during migration\n"); 2000 mlog(0, "timed out during migration\n");
2001 /* avoid hang during shutdown when migrating lockres
2002 * to a node which also goes down */
2003 if (dlm_is_node_dead(dlm, target)) {
2004 mlog(0, "%s:%.*s: expected migration target %u "
2005 "is no longer up. restarting.\n",
2006 dlm->name, res->lockname.len,
2007 res->lockname.name, target);
2008 ret = -ERESTARTSYS;
2009 }
2008 } 2010 }
2009 if (ret == -ERESTARTSYS) { 2011 if (ret == -ERESTARTSYS) {
2010 /* migration failed, detach and clean up mle */ 2012 /* migration failed, detach and clean up mle */
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 0c8eb1093f00..186e9a76aa58 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -39,6 +39,7 @@
39#include <linux/inet.h> 39#include <linux/inet.h>
40#include <linux/timer.h> 40#include <linux/timer.h>
41#include <linux/kthread.h> 41#include <linux/kthread.h>
42#include <linux/delay.h>
42 43
43 44
44#include "cluster/heartbeat.h" 45#include "cluster/heartbeat.h"
@@ -256,6 +257,27 @@ static int dlm_recovery_thread(void *data)
256 return 0; 257 return 0;
257} 258}
258 259
260/* returns true when the recovery master has contacted us */
261static int dlm_reco_master_ready(struct dlm_ctxt *dlm)
262{
263 int ready;
264 spin_lock(&dlm->spinlock);
265 ready = (dlm->reco.new_master != O2NM_INVALID_NODE_NUM);
266 spin_unlock(&dlm->spinlock);
267 return ready;
268}
269
270/* returns true if node is no longer in the domain
271 * could be dead or just not joined */
272int dlm_is_node_dead(struct dlm_ctxt *dlm, u8 node)
273{
274 int dead;
275 spin_lock(&dlm->spinlock);
276 dead = test_bit(node, dlm->domain_map);
277 spin_unlock(&dlm->spinlock);
278 return dead;
279}
280
259/* callers of the top-level api calls (dlmlock/dlmunlock) should 281/* callers of the top-level api calls (dlmlock/dlmunlock) should
260 * block on the dlm->reco.event when recovery is in progress. 282 * block on the dlm->reco.event when recovery is in progress.
261 * the dlm recovery thread will set this state when it begins 283 * the dlm recovery thread will set this state when it begins
@@ -297,6 +319,7 @@ static void dlm_end_recovery(struct dlm_ctxt *dlm)
297static int dlm_do_recovery(struct dlm_ctxt *dlm) 319static int dlm_do_recovery(struct dlm_ctxt *dlm)
298{ 320{
299 int status = 0; 321 int status = 0;
322 int ret;
300 323
301 spin_lock(&dlm->spinlock); 324 spin_lock(&dlm->spinlock);
302 325
@@ -343,10 +366,13 @@ static int dlm_do_recovery(struct dlm_ctxt *dlm)
343 goto master_here; 366 goto master_here;
344 367
345 if (dlm->reco.new_master == O2NM_INVALID_NODE_NUM) { 368 if (dlm->reco.new_master == O2NM_INVALID_NODE_NUM) {
346 /* choose a new master */ 369 /* choose a new master, returns 0 if this node
347 if (!dlm_pick_recovery_master(dlm)) { 370 * is the master, -EEXIST if it's another node.
371 * this does not return until a new master is chosen
372 * or recovery completes entirely. */
373 ret = dlm_pick_recovery_master(dlm);
374 if (!ret) {
348 /* already notified everyone. go. */ 375 /* already notified everyone. go. */
349 dlm->reco.new_master = dlm->node_num;
350 goto master_here; 376 goto master_here;
351 } 377 }
352 mlog(0, "another node will master this recovery session.\n"); 378 mlog(0, "another node will master this recovery session.\n");
@@ -371,8 +397,13 @@ master_here:
371 if (status < 0) { 397 if (status < 0) {
372 mlog(ML_ERROR, "error %d remastering locks for node %u, " 398 mlog(ML_ERROR, "error %d remastering locks for node %u, "
373 "retrying.\n", status, dlm->reco.dead_node); 399 "retrying.\n", status, dlm->reco.dead_node);
400 /* yield a bit to allow any final network messages
401 * to get handled on remaining nodes */
402 msleep(100);
374 } else { 403 } else {
375 /* success! see if any other nodes need recovery */ 404 /* success! see if any other nodes need recovery */
405 mlog(0, "DONE mastering recovery of %s:%u here(this=%u)!\n",
406 dlm->name, dlm->reco.dead_node, dlm->node_num);
376 dlm_reset_recovery(dlm); 407 dlm_reset_recovery(dlm);
377 } 408 }
378 dlm_end_recovery(dlm); 409 dlm_end_recovery(dlm);
@@ -477,7 +508,7 @@ static int dlm_remaster_locks(struct dlm_ctxt *dlm, u8 dead_node)
477 BUG(); 508 BUG();
478 break; 509 break;
479 case DLM_RECO_NODE_DATA_DEAD: 510 case DLM_RECO_NODE_DATA_DEAD:
480 mlog(0, "node %u died after " 511 mlog(ML_NOTICE, "node %u died after "
481 "requesting recovery info for " 512 "requesting recovery info for "
482 "node %u\n", ndata->node_num, 513 "node %u\n", ndata->node_num,
483 dead_node); 514 dead_node);
@@ -485,6 +516,19 @@ static int dlm_remaster_locks(struct dlm_ctxt *dlm, u8 dead_node)
485 // start all over 516 // start all over
486 destroy = 1; 517 destroy = 1;
487 status = -EAGAIN; 518 status = -EAGAIN;
519 /* instead of spinning like crazy here,
520 * wait for the domain map to catch up
521 * with the network state. otherwise this
522 * can be hit hundreds of times before
523 * the node is really seen as dead. */
524 wait_event_timeout(dlm->dlm_reco_thread_wq,
525 dlm_is_node_dead(dlm,
526 ndata->node_num),
527 msecs_to_jiffies(1000));
528 mlog(0, "waited 1 sec for %u, "
529 "dead? %s\n", ndata->node_num,
530 dlm_is_node_dead(dlm, ndata->node_num) ?
531 "yes" : "no");
488 goto leave; 532 goto leave;
489 case DLM_RECO_NODE_DATA_RECEIVING: 533 case DLM_RECO_NODE_DATA_RECEIVING:
490 case DLM_RECO_NODE_DATA_REQUESTED: 534 case DLM_RECO_NODE_DATA_REQUESTED:
@@ -678,11 +722,27 @@ static void dlm_request_all_locks_worker(struct dlm_work_item *item, void *data)
678 dlm = item->dlm; 722 dlm = item->dlm;
679 dead_node = item->u.ral.dead_node; 723 dead_node = item->u.ral.dead_node;
680 reco_master = item->u.ral.reco_master; 724 reco_master = item->u.ral.reco_master;
725 mres = (struct dlm_migratable_lockres *)data;
726
727 if (dead_node != dlm->reco.dead_node ||
728 reco_master != dlm->reco.new_master) {
729 /* show extra debug info if the recovery state is messed */
730 mlog(ML_ERROR, "%s: bad reco state: reco(dead=%u, master=%u), "
731 "request(dead=%u, master=%u)\n",
732 dlm->name, dlm->reco.dead_node, dlm->reco.new_master,
733 dead_node, reco_master);
734 mlog(ML_ERROR, "%s: name=%.*s master=%u locks=%u/%u flags=%u "
735 "entry[0]={c=%"MLFu64",l=%u,f=%u,t=%d,ct=%d,hb=%d,n=%u}\n",
736 dlm->name, mres->lockname_len, mres->lockname, mres->master,
737 mres->num_locks, mres->total_locks, mres->flags,
738 mres->ml[0].cookie, mres->ml[0].list, mres->ml[0].flags,
739 mres->ml[0].type, mres->ml[0].convert_type,
740 mres->ml[0].highest_blocked, mres->ml[0].node);
741 BUG();
742 }
681 BUG_ON(dead_node != dlm->reco.dead_node); 743 BUG_ON(dead_node != dlm->reco.dead_node);
682 BUG_ON(reco_master != dlm->reco.new_master); 744 BUG_ON(reco_master != dlm->reco.new_master);
683 745
684 mres = (struct dlm_migratable_lockres *)data;
685
686 /* lock resources should have already been moved to the 746 /* lock resources should have already been moved to the
687 * dlm->reco.resources list. now move items from that list 747 * dlm->reco.resources list. now move items from that list
688 * to a temp list if the dead owner matches. note that the 748 * to a temp list if the dead owner matches. note that the
@@ -757,15 +817,18 @@ int dlm_reco_data_done_handler(struct o2net_msg *msg, u32 len, void *data)
757 continue; 817 continue;
758 818
759 switch (ndata->state) { 819 switch (ndata->state) {
820 /* should have moved beyond INIT but not to FINALIZE yet */
760 case DLM_RECO_NODE_DATA_INIT: 821 case DLM_RECO_NODE_DATA_INIT:
761 case DLM_RECO_NODE_DATA_DEAD: 822 case DLM_RECO_NODE_DATA_DEAD:
762 case DLM_RECO_NODE_DATA_DONE:
763 case DLM_RECO_NODE_DATA_FINALIZE_SENT: 823 case DLM_RECO_NODE_DATA_FINALIZE_SENT:
764 mlog(ML_ERROR, "bad ndata state for node %u:" 824 mlog(ML_ERROR, "bad ndata state for node %u:"
765 " state=%d\n", ndata->node_num, 825 " state=%d\n", ndata->node_num,
766 ndata->state); 826 ndata->state);
767 BUG(); 827 BUG();
768 break; 828 break;
829 /* these states are possible at this point, anywhere along
830 * the line of recovery */
831 case DLM_RECO_NODE_DATA_DONE:
769 case DLM_RECO_NODE_DATA_RECEIVING: 832 case DLM_RECO_NODE_DATA_RECEIVING:
770 case DLM_RECO_NODE_DATA_REQUESTED: 833 case DLM_RECO_NODE_DATA_REQUESTED:
771 case DLM_RECO_NODE_DATA_REQUESTING: 834 case DLM_RECO_NODE_DATA_REQUESTING:
@@ -799,13 +862,31 @@ static void dlm_move_reco_locks_to_list(struct dlm_ctxt *dlm,
799{ 862{
800 struct dlm_lock_resource *res; 863 struct dlm_lock_resource *res;
801 struct list_head *iter, *iter2; 864 struct list_head *iter, *iter2;
865 struct dlm_lock *lock;
802 866
803 spin_lock(&dlm->spinlock); 867 spin_lock(&dlm->spinlock);
804 list_for_each_safe(iter, iter2, &dlm->reco.resources) { 868 list_for_each_safe(iter, iter2, &dlm->reco.resources) {
805 res = list_entry (iter, struct dlm_lock_resource, recovering); 869 res = list_entry (iter, struct dlm_lock_resource, recovering);
870 /* always prune any $RECOVERY entries for dead nodes,
871 * otherwise hangs can occur during later recovery */
806 if (dlm_is_recovery_lock(res->lockname.name, 872 if (dlm_is_recovery_lock(res->lockname.name,
807 res->lockname.len)) 873 res->lockname.len)) {
874 spin_lock(&res->spinlock);
875 list_for_each_entry(lock, &res->granted, list) {
876 if (lock->ml.node == dead_node) {
877 mlog(0, "AHA! there was "
878 "a $RECOVERY lock for dead "
879 "node %u (%s)!\n",
880 dead_node, dlm->name);
881 list_del_init(&lock->list);
882 dlm_lock_put(lock);
883 break;
884 }
885 }
886 spin_unlock(&res->spinlock);
808 continue; 887 continue;
888 }
889
809 if (res->owner == dead_node) { 890 if (res->owner == dead_node) {
810 mlog(0, "found lockres owned by dead node while " 891 mlog(0, "found lockres owned by dead node while "
811 "doing recovery for node %u. sending it.\n", 892 "doing recovery for node %u. sending it.\n",
@@ -1179,7 +1260,7 @@ static void dlm_mig_lockres_worker(struct dlm_work_item *item, void *data)
1179again: 1260again:
1180 ret = dlm_lockres_master_requery(dlm, res, &real_master); 1261 ret = dlm_lockres_master_requery(dlm, res, &real_master);
1181 if (ret < 0) { 1262 if (ret < 0) {
1182 mlog(0, "dlm_lockres_master_requery failure: %d\n", 1263 mlog(0, "dlm_lockres_master_requery ret=%d\n",
1183 ret); 1264 ret);
1184 goto again; 1265 goto again;
1185 } 1266 }
@@ -1757,6 +1838,7 @@ static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node)
1757 struct dlm_lock_resource *res; 1838 struct dlm_lock_resource *res;
1758 int i; 1839 int i;
1759 struct list_head *bucket; 1840 struct list_head *bucket;
1841 struct dlm_lock *lock;
1760 1842
1761 1843
1762 /* purge any stale mles */ 1844 /* purge any stale mles */
@@ -1780,10 +1862,25 @@ static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node)
1780 bucket = &(dlm->resources[i]); 1862 bucket = &(dlm->resources[i]);
1781 list_for_each(iter, bucket) { 1863 list_for_each(iter, bucket) {
1782 res = list_entry (iter, struct dlm_lock_resource, list); 1864 res = list_entry (iter, struct dlm_lock_resource, list);
1865 /* always prune any $RECOVERY entries for dead nodes,
1866 * otherwise hangs can occur during later recovery */
1783 if (dlm_is_recovery_lock(res->lockname.name, 1867 if (dlm_is_recovery_lock(res->lockname.name,
1784 res->lockname.len)) 1868 res->lockname.len)) {
1869 spin_lock(&res->spinlock);
1870 list_for_each_entry(lock, &res->granted, list) {
1871 if (lock->ml.node == dead_node) {
1872 mlog(0, "AHA! there was "
1873 "a $RECOVERY lock for dead "
1874 "node %u (%s)!\n",
1875 dead_node, dlm->name);
1876 list_del_init(&lock->list);
1877 dlm_lock_put(lock);
1878 break;
1879 }
1880 }
1881 spin_unlock(&res->spinlock);
1785 continue; 1882 continue;
1786 1883 }
1787 spin_lock(&res->spinlock); 1884 spin_lock(&res->spinlock);
1788 /* zero the lvb if necessary */ 1885 /* zero the lvb if necessary */
1789 dlm_revalidate_lvb(dlm, res, dead_node); 1886 dlm_revalidate_lvb(dlm, res, dead_node);
@@ -1869,12 +1966,9 @@ void dlm_hb_node_up_cb(struct o2nm_node *node, int idx, void *data)
1869 return; 1966 return;
1870 1967
1871 spin_lock(&dlm->spinlock); 1968 spin_lock(&dlm->spinlock);
1872
1873 set_bit(idx, dlm->live_nodes_map); 1969 set_bit(idx, dlm->live_nodes_map);
1874 1970 /* do NOT notify mle attached to the heartbeat events.
1875 /* notify any mles attached to the heartbeat events */ 1971 * new nodes are not interesting in mastery until joined. */
1876 dlm_hb_event_notify_attached(dlm, idx, 1);
1877
1878 spin_unlock(&dlm->spinlock); 1972 spin_unlock(&dlm->spinlock);
1879 1973
1880 dlm_put(dlm); 1974 dlm_put(dlm);
@@ -1897,7 +1991,18 @@ static void dlm_reco_unlock_ast(void *astdata, enum dlm_status st)
1897 mlog(0, "unlockast for recovery lock fired!\n"); 1991 mlog(0, "unlockast for recovery lock fired!\n");
1898} 1992}
1899 1993
1900 1994/*
1995 * dlm_pick_recovery_master will continually attempt to use
1996 * dlmlock() on the special "$RECOVERY" lockres with the
1997 * LKM_NOQUEUE flag to get an EX. every thread that enters
1998 * this function on each node racing to become the recovery
1999 * master will not stop attempting this until either:
2000 * a) this node gets the EX (and becomes the recovery master),
2001 * or b) dlm->reco.new_master gets set to some nodenum
2002 * != O2NM_INVALID_NODE_NUM (another node will do the reco).
2003 * so each time a recovery master is needed, the entire cluster
2004 * will sync at this point. if the new master dies, that will
2005 * be detected in dlm_do_recovery */
1901static int dlm_pick_recovery_master(struct dlm_ctxt *dlm) 2006static int dlm_pick_recovery_master(struct dlm_ctxt *dlm)
1902{ 2007{
1903 enum dlm_status ret; 2008 enum dlm_status ret;
@@ -1906,23 +2011,45 @@ static int dlm_pick_recovery_master(struct dlm_ctxt *dlm)
1906 2011
1907 mlog(0, "starting recovery of %s at %lu, dead=%u, this=%u\n", 2012 mlog(0, "starting recovery of %s at %lu, dead=%u, this=%u\n",
1908 dlm->name, jiffies, dlm->reco.dead_node, dlm->node_num); 2013 dlm->name, jiffies, dlm->reco.dead_node, dlm->node_num);
1909retry: 2014again:
1910 memset(&lksb, 0, sizeof(lksb)); 2015 memset(&lksb, 0, sizeof(lksb));
1911 2016
1912 ret = dlmlock(dlm, LKM_EXMODE, &lksb, LKM_NOQUEUE|LKM_RECOVERY, 2017 ret = dlmlock(dlm, LKM_EXMODE, &lksb, LKM_NOQUEUE|LKM_RECOVERY,
1913 DLM_RECOVERY_LOCK_NAME, dlm_reco_ast, dlm, dlm_reco_bast); 2018 DLM_RECOVERY_LOCK_NAME, dlm_reco_ast, dlm, dlm_reco_bast);
1914 2019
2020 mlog(0, "%s: dlmlock($RECOVERY) returned %d, lksb=%d\n",
2021 dlm->name, ret, lksb.status);
2022
1915 if (ret == DLM_NORMAL) { 2023 if (ret == DLM_NORMAL) {
1916 mlog(0, "dlm=%s dlmlock says I got it (this=%u)\n", 2024 mlog(0, "dlm=%s dlmlock says I got it (this=%u)\n",
1917 dlm->name, dlm->node_num); 2025 dlm->name, dlm->node_num);
1918 /* I am master, send message to all nodes saying 2026
1919 * that I am beginning a recovery session */ 2027 /* got the EX lock. check to see if another node
1920 status = dlm_send_begin_reco_message(dlm, 2028 * just became the reco master */
1921 dlm->reco.dead_node); 2029 if (dlm_reco_master_ready(dlm)) {
2030 mlog(0, "%s: got reco EX lock, but %u will "
2031 "do the recovery\n", dlm->name,
2032 dlm->reco.new_master);
2033 status = -EEXIST;
2034 } else {
2035 status = dlm_send_begin_reco_message(dlm,
2036 dlm->reco.dead_node);
2037 /* this always succeeds */
2038 BUG_ON(status);
2039
2040 /* set the new_master to this node */
2041 spin_lock(&dlm->spinlock);
2042 dlm->reco.new_master = dlm->node_num;
2043 spin_unlock(&dlm->spinlock);
2044 }
1922 2045
1923 /* recovery lock is a special case. ast will not get fired, 2046 /* recovery lock is a special case. ast will not get fired,
1924 * so just go ahead and unlock it. */ 2047 * so just go ahead and unlock it. */
1925 ret = dlmunlock(dlm, &lksb, 0, dlm_reco_unlock_ast, dlm); 2048 ret = dlmunlock(dlm, &lksb, 0, dlm_reco_unlock_ast, dlm);
2049 if (ret == DLM_DENIED) {
2050 mlog(0, "got DLM_DENIED, trying LKM_CANCEL\n");
2051 ret = dlmunlock(dlm, &lksb, LKM_CANCEL, dlm_reco_unlock_ast, dlm);
2052 }
1926 if (ret != DLM_NORMAL) { 2053 if (ret != DLM_NORMAL) {
1927 /* this would really suck. this could only happen 2054 /* this would really suck. this could only happen
1928 * if there was a network error during the unlock 2055 * if there was a network error during the unlock
@@ -1930,20 +2057,42 @@ retry:
1930 * is actually "done" and the lock structure is 2057 * is actually "done" and the lock structure is
1931 * even freed. we can continue, but only 2058 * even freed. we can continue, but only
1932 * because this specific lock name is special. */ 2059 * because this specific lock name is special. */
1933 mlog(0, "dlmunlock returned %d\n", ret); 2060 mlog(ML_ERROR, "dlmunlock returned %d\n", ret);
1934 }
1935
1936 if (status < 0) {
1937 mlog(0, "failed to send recovery message. "
1938 "must retry with new node map.\n");
1939 goto retry;
1940 } 2061 }
1941 } else if (ret == DLM_NOTQUEUED) { 2062 } else if (ret == DLM_NOTQUEUED) {
1942 mlog(0, "dlm=%s dlmlock says another node got it (this=%u)\n", 2063 mlog(0, "dlm=%s dlmlock says another node got it (this=%u)\n",
1943 dlm->name, dlm->node_num); 2064 dlm->name, dlm->node_num);
1944 /* another node is master. wait on 2065 /* another node is master. wait on
1945 * reco.new_master != O2NM_INVALID_NODE_NUM */ 2066 * reco.new_master != O2NM_INVALID_NODE_NUM
2067 * for at most one second */
2068 wait_event_timeout(dlm->dlm_reco_thread_wq,
2069 dlm_reco_master_ready(dlm),
2070 msecs_to_jiffies(1000));
2071 if (!dlm_reco_master_ready(dlm)) {
2072 mlog(0, "%s: reco master taking awhile\n",
2073 dlm->name);
2074 goto again;
2075 }
2076 /* another node has informed this one that it is reco master */
2077 mlog(0, "%s: reco master %u is ready to recover %u\n",
2078 dlm->name, dlm->reco.new_master, dlm->reco.dead_node);
1946 status = -EEXIST; 2079 status = -EEXIST;
2080 } else {
2081 struct dlm_lock_resource *res;
2082
2083 /* dlmlock returned something other than NOTQUEUED or NORMAL */
2084 mlog(ML_ERROR, "%s: got %s from dlmlock($RECOVERY), "
2085 "lksb.status=%s\n", dlm->name, dlm_errname(ret),
2086 dlm_errname(lksb.status));
2087 res = dlm_lookup_lockres(dlm, DLM_RECOVERY_LOCK_NAME,
2088 DLM_RECOVERY_LOCK_NAME_LEN);
2089 if (res) {
2090 dlm_print_one_lock_resource(res);
2091 dlm_lockres_put(res);
2092 } else {
2093 mlog(ML_ERROR, "recovery lock not found\n");
2094 }
2095 BUG();
1947 } 2096 }
1948 2097
1949 return status; 2098 return status;
@@ -1982,7 +2131,7 @@ static int dlm_send_begin_reco_message(struct dlm_ctxt *dlm, u8 dead_node)
1982 mlog(0, "not sending begin reco to self\n"); 2131 mlog(0, "not sending begin reco to self\n");
1983 continue; 2132 continue;
1984 } 2133 }
1985 2134retry:
1986 ret = -EINVAL; 2135 ret = -EINVAL;
1987 mlog(0, "attempting to send begin reco msg to %d\n", 2136 mlog(0, "attempting to send begin reco msg to %d\n",
1988 nodenum); 2137 nodenum);
@@ -1991,8 +2140,17 @@ static int dlm_send_begin_reco_message(struct dlm_ctxt *dlm, u8 dead_node)
1991 /* negative status is handled ok by caller here */ 2140 /* negative status is handled ok by caller here */
1992 if (ret >= 0) 2141 if (ret >= 0)
1993 ret = status; 2142 ret = status;
2143 if (dlm_is_host_down(ret)) {
2144 /* node is down. not involved in recovery
2145 * so just keep going */
2146 mlog(0, "%s: node %u was down when sending "
2147 "begin reco msg (%d)\n", dlm->name, nodenum, ret);
2148 ret = 0;
2149 }
1994 if (ret < 0) { 2150 if (ret < 0) {
1995 struct dlm_lock_resource *res; 2151 struct dlm_lock_resource *res;
2152 /* this is now a serious problem, possibly ENOMEM
2153 * in the network stack. must retry */
1996 mlog_errno(ret); 2154 mlog_errno(ret);
1997 mlog(ML_ERROR, "begin reco of dlm %s to node %u " 2155 mlog(ML_ERROR, "begin reco of dlm %s to node %u "
1998 " returned %d\n", dlm->name, nodenum, ret); 2156 " returned %d\n", dlm->name, nodenum, ret);
@@ -2004,7 +2162,10 @@ static int dlm_send_begin_reco_message(struct dlm_ctxt *dlm, u8 dead_node)
2004 } else { 2162 } else {
2005 mlog(ML_ERROR, "recovery lock not found\n"); 2163 mlog(ML_ERROR, "recovery lock not found\n");
2006 } 2164 }
2007 break; 2165 /* sleep for a bit in hopes that we can avoid
2166 * another ENOMEM */
2167 msleep(100);
2168 goto retry;
2008 } 2169 }
2009 } 2170 }
2010 2171
@@ -2027,19 +2188,34 @@ int dlm_begin_reco_handler(struct o2net_msg *msg, u32 len, void *data)
2027 2188
2028 spin_lock(&dlm->spinlock); 2189 spin_lock(&dlm->spinlock);
2029 if (dlm->reco.new_master != O2NM_INVALID_NODE_NUM) { 2190 if (dlm->reco.new_master != O2NM_INVALID_NODE_NUM) {
2030 mlog(0, "new_master already set to %u!\n", 2191 if (test_bit(dlm->reco.new_master, dlm->recovery_map)) {
2031 dlm->reco.new_master); 2192 mlog(0, "%s: new_master %u died, changing "
2193 "to %u\n", dlm->name, dlm->reco.new_master,
2194 br->node_idx);
2195 } else {
2196 mlog(0, "%s: new_master %u NOT DEAD, changing "
2197 "to %u\n", dlm->name, dlm->reco.new_master,
2198 br->node_idx);
2199 /* may not have seen the new master as dead yet */
2200 }
2032 } 2201 }
2033 if (dlm->reco.dead_node != O2NM_INVALID_NODE_NUM) { 2202 if (dlm->reco.dead_node != O2NM_INVALID_NODE_NUM) {
2034 mlog(0, "dead_node already set to %u!\n", 2203 mlog(ML_NOTICE, "%s: dead_node previously set to %u, "
2035 dlm->reco.dead_node); 2204 "node %u changing it to %u\n", dlm->name,
2205 dlm->reco.dead_node, br->node_idx, br->dead_node);
2036 } 2206 }
2037 dlm->reco.new_master = br->node_idx; 2207 dlm->reco.new_master = br->node_idx;
2038 dlm->reco.dead_node = br->dead_node; 2208 dlm->reco.dead_node = br->dead_node;
2039 if (!test_bit(br->dead_node, dlm->recovery_map)) { 2209 if (!test_bit(br->dead_node, dlm->recovery_map)) {
2040 mlog(ML_ERROR, "recovery master %u sees %u as dead, but this " 2210 mlog(0, "recovery master %u sees %u as dead, but this "
2041 "node has not yet. marking %u as dead\n", 2211 "node has not yet. marking %u as dead\n",
2042 br->node_idx, br->dead_node, br->dead_node); 2212 br->node_idx, br->dead_node, br->dead_node);
2213 if (!test_bit(br->dead_node, dlm->domain_map) ||
2214 !test_bit(br->dead_node, dlm->live_nodes_map))
2215 mlog(0, "%u not in domain/live_nodes map "
2216 "so setting it in reco map manually\n",
2217 br->dead_node);
2218 set_bit(br->dead_node, dlm->recovery_map);
2043 __dlm_hb_node_down(dlm, br->dead_node); 2219 __dlm_hb_node_down(dlm, br->dead_node);
2044 } 2220 }
2045 spin_unlock(&dlm->spinlock); 2221 spin_unlock(&dlm->spinlock);
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
index cec2ce1cd318..c95f08d2e925 100644
--- a/fs/ocfs2/dlm/dlmunlock.c
+++ b/fs/ocfs2/dlm/dlmunlock.c
@@ -188,6 +188,19 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,
188 actions &= ~(DLM_UNLOCK_REMOVE_LOCK| 188 actions &= ~(DLM_UNLOCK_REMOVE_LOCK|
189 DLM_UNLOCK_REGRANT_LOCK| 189 DLM_UNLOCK_REGRANT_LOCK|
190 DLM_UNLOCK_CLEAR_CONVERT_TYPE); 190 DLM_UNLOCK_CLEAR_CONVERT_TYPE);
191 } else if (status == DLM_RECOVERING ||
192 status == DLM_MIGRATING ||
193 status == DLM_FORWARD) {
194 /* must clear the actions because this unlock
195 * is about to be retried. cannot free or do
196 * any list manipulation. */
197 mlog(0, "%s:%.*s: clearing actions, %s\n",
198 dlm->name, res->lockname.len,
199 res->lockname.name,
200 status==DLM_RECOVERING?"recovering":
201 (status==DLM_MIGRATING?"migrating":
202 "forward"));
203 actions = 0;
191 } 204 }
192 if (flags & LKM_CANCEL) 205 if (flags & LKM_CANCEL)
193 lock->cancel_pending = 0; 206 lock->cancel_pending = 0;
diff --git a/fs/ocfs2/dlm/userdlm.c b/fs/ocfs2/dlm/userdlm.c
index e1fdd288796e..c3764f4744ee 100644
--- a/fs/ocfs2/dlm/userdlm.c
+++ b/fs/ocfs2/dlm/userdlm.c
@@ -27,7 +27,7 @@
27 * Boston, MA 021110-1307, USA. 27 * Boston, MA 021110-1307, USA.
28 */ 28 */
29 29
30#include <asm/signal.h> 30#include <linux/signal.h>
31 31
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/fs.h> 33#include <linux/fs.h>
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index f2fb40cd296a..b6ba292e9544 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -262,8 +262,7 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode,
262 el = &eb->h_list; 262 el = &eb->h_list;
263 } 263 }
264 264
265 if (el->l_tree_depth) 265 BUG_ON(el->l_tree_depth);
266 BUG();
267 266
268 for (i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { 267 for (i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) {
269 rec = &el->l_recs[i]; 268 rec = &el->l_recs[i];
@@ -364,8 +363,8 @@ static int ocfs2_extent_map_lookup_read(struct inode *inode,
364 return ret; 363 return ret;
365 } 364 }
366 365
367 if (ent->e_tree_depth) 366 /* FIXME: Make sure this isn't a corruption */
368 BUG(); /* FIXME: Make sure this isn't a corruption */ 367 BUG_ON(ent->e_tree_depth);
369 368
370 *ret_ent = ent; 369 *ret_ent = ent;
371 370
@@ -423,8 +422,7 @@ static int ocfs2_extent_map_try_insert(struct inode *inode,
423 le32_to_cpu(rec->e_clusters), NULL, 422 le32_to_cpu(rec->e_clusters), NULL,
424 NULL); 423 NULL);
425 424
426 if (!old_ent) 425 BUG_ON(!old_ent);
427 BUG();
428 426
429 ret = -EEXIST; 427 ret = -EEXIST;
430 if (old_ent->e_tree_depth < tree_depth) 428 if (old_ent->e_tree_depth < tree_depth)
@@ -988,7 +986,7 @@ int __init init_ocfs2_extent_maps(void)
988 return 0; 986 return 0;
989} 987}
990 988
991void __exit exit_ocfs2_extent_maps(void) 989void exit_ocfs2_extent_maps(void)
992{ 990{
993 kmem_cache_destroy(ocfs2_em_ent_cachep); 991 kmem_cache_destroy(ocfs2_em_ent_cachep);
994} 992}
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index eaf33caa0a1f..1715bc90e705 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1022,8 +1022,9 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1022 } 1022 }
1023 newsize = count + saved_pos; 1023 newsize = count + saved_pos;
1024 1024
1025 mlog(0, "pos=%lld newsize=%"MLFu64" cursize=%lld\n", 1025 mlog(0, "pos=%lld newsize=%lld cursize=%lld\n",
1026 saved_pos, newsize, i_size_read(inode)); 1026 (long long) saved_pos, (long long) newsize,
1027 (long long) i_size_read(inode));
1027 1028
1028 /* No need for a higher level metadata lock if we're 1029 /* No need for a higher level metadata lock if we're
1029 * never going past i_size. */ 1030 * never going past i_size. */
@@ -1042,8 +1043,9 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1042 spin_unlock(&OCFS2_I(inode)->ip_lock); 1043 spin_unlock(&OCFS2_I(inode)->ip_lock);
1043 1044
1044 mlog(0, "Writing at EOF, may need more allocation: " 1045 mlog(0, "Writing at EOF, may need more allocation: "
1045 "i_size = %lld, newsize = %"MLFu64", need %u clusters\n", 1046 "i_size = %lld, newsize = %lld, need %u clusters\n",
1046 i_size_read(inode), newsize, clusters); 1047 (long long) i_size_read(inode), (long long) newsize,
1048 clusters);
1047 1049
1048 /* We only want to continue the rest of this loop if 1050 /* We only want to continue the rest of this loop if
1049 * our extend will actually require more 1051 * our extend will actually require more
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index d4ecc0627716..8122489c5762 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -903,10 +903,10 @@ void ocfs2_clear_inode(struct inode *inode)
903 "Clear inode of %"MLFu64", inode is locked\n", 903 "Clear inode of %"MLFu64", inode is locked\n",
904 oi->ip_blkno); 904 oi->ip_blkno);
905 905
906 mlog_bug_on_msg(down_trylock(&oi->ip_io_sem), 906 mlog_bug_on_msg(!mutex_trylock(&oi->ip_io_mutex),
907 "Clear inode of %"MLFu64", io_sem is locked\n", 907 "Clear inode of %"MLFu64", io_mutex is locked\n",
908 oi->ip_blkno); 908 oi->ip_blkno);
909 up(&oi->ip_io_sem); 909 mutex_unlock(&oi->ip_io_mutex);
910 910
911 /* 911 /*
912 * down_trylock() returns 0, down_write_trylock() returns 1 912 * down_trylock() returns 0, down_write_trylock() returns 1
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h
index 9b0177433653..84c507961287 100644
--- a/fs/ocfs2/inode.h
+++ b/fs/ocfs2/inode.h
@@ -46,10 +46,10 @@ struct ocfs2_inode_info
46 struct list_head ip_io_markers; 46 struct list_head ip_io_markers;
47 int ip_orphaned_slot; 47 int ip_orphaned_slot;
48 48
49 struct semaphore ip_io_sem; 49 struct mutex ip_io_mutex;
50 50
51 /* Used by the journalling code to attach an inode to a 51 /* Used by the journalling code to attach an inode to a
52 * handle. These are protected by ip_io_sem in order to lock 52 * handle. These are protected by ip_io_mutex in order to lock
53 * out other I/O to the inode until we either commit or 53 * out other I/O to the inode until we either commit or
54 * abort. */ 54 * abort. */
55 struct list_head ip_handle_list; 55 struct list_head ip_handle_list;
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 303c8d96457f..fa0bcac5ceae 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -147,8 +147,7 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
147 147
148 mlog_entry("(max_buffs = %d)\n", max_buffs); 148 mlog_entry("(max_buffs = %d)\n", max_buffs);
149 149
150 if (!osb || !osb->journal->j_journal) 150 BUG_ON(!osb || !osb->journal->j_journal);
151 BUG();
152 151
153 if (ocfs2_is_hard_readonly(osb)) { 152 if (ocfs2_is_hard_readonly(osb)) {
154 ret = -EROFS; 153 ret = -EROFS;
@@ -401,7 +400,7 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle,
401 * j_trans_barrier for us. */ 400 * j_trans_barrier for us. */
402 ocfs2_set_inode_lock_trans(OCFS2_SB(inode->i_sb)->journal, inode); 401 ocfs2_set_inode_lock_trans(OCFS2_SB(inode->i_sb)->journal, inode);
403 402
404 down(&OCFS2_I(inode)->ip_io_sem); 403 mutex_lock(&OCFS2_I(inode)->ip_io_mutex);
405 switch (type) { 404 switch (type) {
406 case OCFS2_JOURNAL_ACCESS_CREATE: 405 case OCFS2_JOURNAL_ACCESS_CREATE:
407 case OCFS2_JOURNAL_ACCESS_WRITE: 406 case OCFS2_JOURNAL_ACCESS_WRITE:
@@ -416,7 +415,7 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle,
416 status = -EINVAL; 415 status = -EINVAL;
417 mlog(ML_ERROR, "Uknown access type!\n"); 416 mlog(ML_ERROR, "Uknown access type!\n");
418 } 417 }
419 up(&OCFS2_I(inode)->ip_io_sem); 418 mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
420 419
421 if (status < 0) 420 if (status < 0)
422 mlog(ML_ERROR, "Error %d getting %d access to buffer!\n", 421 mlog(ML_ERROR, "Error %d getting %d access to buffer!\n",
@@ -561,7 +560,11 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty)
561 SET_INODE_JOURNAL(inode); 560 SET_INODE_JOURNAL(inode);
562 OCFS2_I(inode)->ip_open_count++; 561 OCFS2_I(inode)->ip_open_count++;
563 562
564 status = ocfs2_meta_lock(inode, NULL, &bh, 1); 563 /* Skip recovery waits here - journal inode metadata never
564 * changes in a live cluster so it can be considered an
565 * exception to the rule. */
566 status = ocfs2_meta_lock_full(inode, NULL, &bh, 1,
567 OCFS2_META_LOCK_RECOVERY);
565 if (status < 0) { 568 if (status < 0) {
566 if (status != -ERESTARTSYS) 569 if (status != -ERESTARTSYS)
567 mlog(ML_ERROR, "Could not get lock on journal!\n"); 570 mlog(ML_ERROR, "Could not get lock on journal!\n");
@@ -672,8 +675,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
672 675
673 mlog_entry_void(); 676 mlog_entry_void();
674 677
675 if (!osb) 678 BUG_ON(!osb);
676 BUG();
677 679
678 journal = osb->journal; 680 journal = osb->journal;
679 if (!journal) 681 if (!journal)
@@ -805,8 +807,7 @@ int ocfs2_journal_wipe(struct ocfs2_journal *journal, int full)
805 807
806 mlog_entry_void(); 808 mlog_entry_void();
807 809
808 if (!journal) 810 BUG_ON(!journal);
809 BUG();
810 811
811 status = journal_wipe(journal->j_journal, full); 812 status = journal_wipe(journal->j_journal, full);
812 if (status < 0) { 813 if (status < 0) {
@@ -1072,10 +1073,10 @@ restart:
1072 NULL); 1073 NULL);
1073 1074
1074bail: 1075bail:
1075 down(&osb->recovery_lock); 1076 mutex_lock(&osb->recovery_lock);
1076 if (!status && 1077 if (!status &&
1077 !ocfs2_node_map_is_empty(osb, &osb->recovery_map)) { 1078 !ocfs2_node_map_is_empty(osb, &osb->recovery_map)) {
1078 up(&osb->recovery_lock); 1079 mutex_unlock(&osb->recovery_lock);
1079 goto restart; 1080 goto restart;
1080 } 1081 }
1081 1082
@@ -1083,7 +1084,7 @@ bail:
1083 mb(); /* sync with ocfs2_recovery_thread_running */ 1084 mb(); /* sync with ocfs2_recovery_thread_running */
1084 wake_up(&osb->recovery_event); 1085 wake_up(&osb->recovery_event);
1085 1086
1086 up(&osb->recovery_lock); 1087 mutex_unlock(&osb->recovery_lock);
1087 1088
1088 mlog_exit(status); 1089 mlog_exit(status);
1089 /* no one is callint kthread_stop() for us so the kthread() api 1090 /* no one is callint kthread_stop() for us so the kthread() api
@@ -1098,7 +1099,7 @@ void ocfs2_recovery_thread(struct ocfs2_super *osb, int node_num)
1098 mlog_entry("(node_num=%d, osb->node_num = %d)\n", 1099 mlog_entry("(node_num=%d, osb->node_num = %d)\n",
1099 node_num, osb->node_num); 1100 node_num, osb->node_num);
1100 1101
1101 down(&osb->recovery_lock); 1102 mutex_lock(&osb->recovery_lock);
1102 if (osb->disable_recovery) 1103 if (osb->disable_recovery)
1103 goto out; 1104 goto out;
1104 1105
@@ -1120,7 +1121,7 @@ void ocfs2_recovery_thread(struct ocfs2_super *osb, int node_num)
1120 } 1121 }
1121 1122
1122out: 1123out:
1123 up(&osb->recovery_lock); 1124 mutex_unlock(&osb->recovery_lock);
1124 wake_up(&osb->recovery_event); 1125 wake_up(&osb->recovery_event);
1125 1126
1126 mlog_exit_void(); 1127 mlog_exit_void();
@@ -1271,8 +1272,7 @@ static int ocfs2_recover_node(struct ocfs2_super *osb,
1271 1272
1272 /* Should not ever be called to recover ourselves -- in that 1273 /* Should not ever be called to recover ourselves -- in that
1273 * case we should've called ocfs2_journal_load instead. */ 1274 * case we should've called ocfs2_journal_load instead. */
1274 if (osb->node_num == node_num) 1275 BUG_ON(osb->node_num == node_num);
1275 BUG();
1276 1276
1277 slot_num = ocfs2_node_num_to_slot(si, node_num); 1277 slot_num = ocfs2_node_num_to_slot(si, node_num);
1278 if (slot_num == OCFS2_INVALID_SLOT) { 1278 if (slot_num == OCFS2_INVALID_SLOT) {
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index f468c600cf92..8d8e4779df92 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -33,6 +33,7 @@
33#include <linux/rbtree.h> 33#include <linux/rbtree.h>
34#include <linux/workqueue.h> 34#include <linux/workqueue.h>
35#include <linux/kref.h> 35#include <linux/kref.h>
36#include <linux/mutex.h>
36 37
37#include "cluster/nodemanager.h" 38#include "cluster/nodemanager.h"
38#include "cluster/heartbeat.h" 39#include "cluster/heartbeat.h"
@@ -233,7 +234,7 @@ struct ocfs2_super
233 struct proc_dir_entry *proc_sub_dir; /* points to /proc/fs/ocfs2/<maj_min> */ 234 struct proc_dir_entry *proc_sub_dir; /* points to /proc/fs/ocfs2/<maj_min> */
234 235
235 atomic_t vol_state; 236 atomic_t vol_state;
236 struct semaphore recovery_lock; 237 struct mutex recovery_lock;
237 struct task_struct *recovery_thread_task; 238 struct task_struct *recovery_thread_task;
238 int disable_recovery; 239 int disable_recovery;
239 wait_queue_head_t checkpoint_event; 240 wait_queue_head_t checkpoint_event;
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 364d64bd5f10..046824b6b625 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -932,7 +932,7 @@ static void ocfs2_inode_init_once(void *data,
932 oi->ip_dir_start_lookup = 0; 932 oi->ip_dir_start_lookup = 0;
933 933
934 init_rwsem(&oi->ip_alloc_sem); 934 init_rwsem(&oi->ip_alloc_sem);
935 init_MUTEX(&(oi->ip_io_sem)); 935 mutex_init(&oi->ip_io_mutex);
936 936
937 oi->ip_blkno = 0ULL; 937 oi->ip_blkno = 0ULL;
938 oi->ip_clusters = 0; 938 oi->ip_clusters = 0;
@@ -1137,9 +1137,9 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
1137 1137
1138 /* disable any new recovery threads and wait for any currently 1138 /* disable any new recovery threads and wait for any currently
1139 * running ones to exit. Do this before setting the vol_state. */ 1139 * running ones to exit. Do this before setting the vol_state. */
1140 down(&osb->recovery_lock); 1140 mutex_lock(&osb->recovery_lock);
1141 osb->disable_recovery = 1; 1141 osb->disable_recovery = 1;
1142 up(&osb->recovery_lock); 1142 mutex_unlock(&osb->recovery_lock);
1143 wait_event(osb->recovery_event, !ocfs2_recovery_thread_running(osb)); 1143 wait_event(osb->recovery_event, !ocfs2_recovery_thread_running(osb));
1144 1144
1145 /* At this point, we know that no more recovery threads can be 1145 /* At this point, we know that no more recovery threads can be
@@ -1254,8 +1254,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
1254 osb->sb = sb; 1254 osb->sb = sb;
1255 /* Save off for ocfs2_rw_direct */ 1255 /* Save off for ocfs2_rw_direct */
1256 osb->s_sectsize_bits = blksize_bits(sector_size); 1256 osb->s_sectsize_bits = blksize_bits(sector_size);
1257 if (!osb->s_sectsize_bits) 1257 BUG_ON(!osb->s_sectsize_bits);
1258 BUG();
1259 1258
1260 osb->net_response_ids = 0; 1259 osb->net_response_ids = 0;
1261 spin_lock_init(&osb->net_response_lock); 1260 spin_lock_init(&osb->net_response_lock);
@@ -1283,7 +1282,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
1283 snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u", 1282 snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u",
1284 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev)); 1283 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
1285 1284
1286 init_MUTEX(&osb->recovery_lock); 1285 mutex_init(&osb->recovery_lock);
1287 1286
1288 osb->disable_recovery = 0; 1287 osb->disable_recovery = 0;
1289 osb->recovery_thread_task = NULL; 1288 osb->recovery_thread_task = NULL;
diff --git a/fs/ocfs2/sysfile.c b/fs/ocfs2/sysfile.c
index 600a8bc5b541..fc29cb7a437d 100644
--- a/fs/ocfs2/sysfile.c
+++ b/fs/ocfs2/sysfile.c
@@ -77,8 +77,7 @@ struct inode *ocfs2_get_system_file_inode(struct ocfs2_super *osb,
77 if (arr && ((inode = *arr) != NULL)) { 77 if (arr && ((inode = *arr) != NULL)) {
78 /* get a ref in addition to the array ref */ 78 /* get a ref in addition to the array ref */
79 inode = igrab(inode); 79 inode = igrab(inode);
80 if (!inode) 80 BUG_ON(!inode);
81 BUG();
82 81
83 return inode; 82 return inode;
84 } 83 }
@@ -89,8 +88,7 @@ struct inode *ocfs2_get_system_file_inode(struct ocfs2_super *osb,
89 /* add one more if putting into array for first time */ 88 /* add one more if putting into array for first time */
90 if (arr && inode) { 89 if (arr && inode) {
91 *arr = igrab(inode); 90 *arr = igrab(inode);
92 if (!*arr) 91 BUG_ON(!*arr);
93 BUG();
94 } 92 }
95 return inode; 93 return inode;
96} 94}
diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c
index 3a0458fd3e1b..300b5bedfb21 100644
--- a/fs/ocfs2/uptodate.c
+++ b/fs/ocfs2/uptodate.c
@@ -388,7 +388,7 @@ out_free:
388 } 388 }
389} 389}
390 390
391/* Item insertion is guarded by ip_io_sem, so the insertion path takes 391/* Item insertion is guarded by ip_io_mutex, so the insertion path takes
392 * advantage of this by not rechecking for a duplicate insert during 392 * advantage of this by not rechecking for a duplicate insert during
393 * the slow case. Additionally, if the cache needs to be bumped up to 393 * the slow case. Additionally, if the cache needs to be bumped up to
394 * a tree, the code will not recheck after acquiring the lock -- 394 * a tree, the code will not recheck after acquiring the lock --
@@ -418,7 +418,7 @@ void ocfs2_set_buffer_uptodate(struct inode *inode,
418 (unsigned long long) bh->b_blocknr); 418 (unsigned long long) bh->b_blocknr);
419 419
420 /* No need to recheck under spinlock - insertion is guarded by 420 /* No need to recheck under spinlock - insertion is guarded by
421 * ip_io_sem */ 421 * ip_io_mutex */
422 spin_lock(&oi->ip_lock); 422 spin_lock(&oi->ip_lock);
423 if (ocfs2_insert_can_use_array(oi, ci)) { 423 if (ocfs2_insert_can_use_array(oi, ci)) {
424 /* Fast case - it's an array and there's a free 424 /* Fast case - it's an array and there's a free
@@ -440,7 +440,7 @@ void ocfs2_set_buffer_uptodate(struct inode *inode,
440 440
441/* Called against a newly allocated buffer. Most likely nobody should 441/* Called against a newly allocated buffer. Most likely nobody should
442 * be able to read this sort of metadata while it's still being 442 * be able to read this sort of metadata while it's still being
443 * allocated, but this is careful to take ip_io_sem anyway. */ 443 * allocated, but this is careful to take ip_io_mutex anyway. */
444void ocfs2_set_new_buffer_uptodate(struct inode *inode, 444void ocfs2_set_new_buffer_uptodate(struct inode *inode,
445 struct buffer_head *bh) 445 struct buffer_head *bh)
446{ 446{
@@ -451,9 +451,9 @@ void ocfs2_set_new_buffer_uptodate(struct inode *inode,
451 451
452 set_buffer_uptodate(bh); 452 set_buffer_uptodate(bh);
453 453
454 down(&oi->ip_io_sem); 454 mutex_lock(&oi->ip_io_mutex);
455 ocfs2_set_buffer_uptodate(inode, bh); 455 ocfs2_set_buffer_uptodate(inode, bh);
456 up(&oi->ip_io_sem); 456 mutex_unlock(&oi->ip_io_mutex);
457} 457}
458 458
459/* Requires ip_lock. */ 459/* Requires ip_lock. */
@@ -537,7 +537,7 @@ int __init init_ocfs2_uptodate_cache(void)
537 return 0; 537 return 0;
538} 538}
539 539
540void __exit exit_ocfs2_uptodate_cache(void) 540void exit_ocfs2_uptodate_cache(void)
541{ 541{
542 if (ocfs2_uptodate_cachep) 542 if (ocfs2_uptodate_cachep)
543 kmem_cache_destroy(ocfs2_uptodate_cachep); 543 kmem_cache_destroy(ocfs2_uptodate_cachep);
diff --git a/fs/ocfs2/uptodate.h b/fs/ocfs2/uptodate.h
index e5aacdf4eabf..01cd32d26b06 100644
--- a/fs/ocfs2/uptodate.h
+++ b/fs/ocfs2/uptodate.h
@@ -27,7 +27,7 @@
27#define OCFS2_UPTODATE_H 27#define OCFS2_UPTODATE_H
28 28
29int __init init_ocfs2_uptodate_cache(void); 29int __init init_ocfs2_uptodate_cache(void);
30void __exit exit_ocfs2_uptodate_cache(void); 30void exit_ocfs2_uptodate_cache(void);
31 31
32void ocfs2_metadata_cache_init(struct inode *inode); 32void ocfs2_metadata_cache_init(struct inode *inode);
33void ocfs2_metadata_cache_purge(struct inode *inode); 33void ocfs2_metadata_cache_purge(struct inode *inode);
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 8f8014285a34..1d24fead51a6 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -548,7 +548,7 @@ static int show_stat(struct seq_file *p, void *v)
548 } 548 }
549 seq_printf(p, "intr %llu", (unsigned long long)sum); 549 seq_printf(p, "intr %llu", (unsigned long long)sum);
550 550
551#if !defined(CONFIG_PPC64) && !defined(CONFIG_ALPHA) 551#if !defined(CONFIG_PPC64) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
552 for (i = 0; i < NR_IRQS; i++) 552 for (i = 0; i < NR_IRQS; i++)
553 seq_printf(p, " %u", kstat_irqs(i)); 553 seq_printf(p, " %u", kstat_irqs(i));
554#endif 554#endif
diff --git a/fs/quota_v2.c b/fs/quota_v2.c
index a4ef91bb4f3b..b4199ec3ece4 100644
--- a/fs/quota_v2.c
+++ b/fs/quota_v2.c
@@ -35,7 +35,7 @@ static int v2_check_quota_file(struct super_block *sb, int type)
35 35
36 size = sb->s_op->quota_read(sb, type, (char *)&dqhead, sizeof(struct v2_disk_dqheader), 0); 36 size = sb->s_op->quota_read(sb, type, (char *)&dqhead, sizeof(struct v2_disk_dqheader), 0);
37 if (size != sizeof(struct v2_disk_dqheader)) { 37 if (size != sizeof(struct v2_disk_dqheader)) {
38 printk("quota_v2: failed read expected=%d got=%d\n", 38 printk("quota_v2: failed read expected=%zd got=%zd\n",
39 sizeof(struct v2_disk_dqheader), size); 39 sizeof(struct v2_disk_dqheader), size);
40 return 0; 40 return 0;
41 } 41 }
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
index 9dd71e807034..d71ac6579289 100644
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
@@ -150,18 +150,15 @@ static int reiserfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
150 if (d_reclen <= 32) { 150 if (d_reclen <= 32) {
151 local_buf = small_buf; 151 local_buf = small_buf;
152 } else { 152 } else {
153 local_buf = 153 local_buf = kmalloc(d_reclen,
154 reiserfs_kmalloc(d_reclen, GFP_NOFS, 154 GFP_NOFS);
155 inode->i_sb);
156 if (!local_buf) { 155 if (!local_buf) {
157 pathrelse(&path_to_entry); 156 pathrelse(&path_to_entry);
158 ret = -ENOMEM; 157 ret = -ENOMEM;
159 goto out; 158 goto out;
160 } 159 }
161 if (item_moved(&tmp_ih, &path_to_entry)) { 160 if (item_moved(&tmp_ih, &path_to_entry)) {
162 reiserfs_kfree(local_buf, 161 kfree(local_buf);
163 d_reclen,
164 inode->i_sb);
165 goto research; 162 goto research;
166 } 163 }
167 } 164 }
@@ -174,15 +171,12 @@ static int reiserfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
174 (dirent, local_buf, d_reclen, d_off, d_ino, 171 (dirent, local_buf, d_reclen, d_off, d_ino,
175 DT_UNKNOWN) < 0) { 172 DT_UNKNOWN) < 0) {
176 if (local_buf != small_buf) { 173 if (local_buf != small_buf) {
177 reiserfs_kfree(local_buf, 174 kfree(local_buf);
178 d_reclen,
179 inode->i_sb);
180 } 175 }
181 goto end; 176 goto end;
182 } 177 }
183 if (local_buf != small_buf) { 178 if (local_buf != small_buf) {
184 reiserfs_kfree(local_buf, d_reclen, 179 kfree(local_buf);
185 inode->i_sb);
186 } 180 }
187 // next entry should be looked for with such offset 181 // next entry should be looked for with such offset
188 next_pos = deh_offset(deh) + 1; 182 next_pos = deh_offset(deh) + 1;
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index ad6fa964b0e7..f3473176c83a 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -192,6 +192,8 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
192 192
193 allocated_blocks = kmalloc((blocks_to_allocate + will_prealloc) * 193 allocated_blocks = kmalloc((blocks_to_allocate + will_prealloc) *
194 sizeof(b_blocknr_t), GFP_NOFS); 194 sizeof(b_blocknr_t), GFP_NOFS);
195 if (!allocated_blocks)
196 return -ENOMEM;
195 197
196 /* First we compose a key to point at the writing position, we want to do 198 /* First we compose a key to point at the writing position, we want to do
197 that outside of any locking region. */ 199 that outside of any locking region. */
@@ -1285,6 +1287,23 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1285 struct reiserfs_transaction_handle th; 1287 struct reiserfs_transaction_handle th;
1286 th.t_trans_id = 0; 1288 th.t_trans_id = 0;
1287 1289
1290 /* If a filesystem is converted from 3.5 to 3.6, we'll have v3.5 items
1291 * lying around (most of the disk, in fact). Despite the filesystem
1292 * now being a v3.6 format, the old items still can't support large
1293 * file sizes. Catch this case here, as the rest of the VFS layer is
1294 * oblivious to the different limitations between old and new items.
1295 * reiserfs_setattr catches this for truncates. This chunk is lifted
1296 * from generic_write_checks. */
1297 if (get_inode_item_key_version (inode) == KEY_FORMAT_3_5 &&
1298 *ppos + count > MAX_NON_LFS) {
1299 if (*ppos >= MAX_NON_LFS) {
1300 send_sig(SIGXFSZ, current, 0);
1301 return -EFBIG;
1302 }
1303 if (count > MAX_NON_LFS - (unsigned long)*ppos)
1304 count = MAX_NON_LFS - (unsigned long)*ppos;
1305 }
1306
1288 if (file->f_flags & O_DIRECT) { // Direct IO needs treatment 1307 if (file->f_flags & O_DIRECT) { // Direct IO needs treatment
1289 ssize_t result, after_file_end = 0; 1308 ssize_t result, after_file_end = 0;
1290 if ((*ppos + count >= inode->i_size) 1309 if ((*ppos + count >= inode->i_size)
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c
index 45829889dcdc..aa22588019ec 100644
--- a/fs/reiserfs/fix_node.c
+++ b/fs/reiserfs/fix_node.c
@@ -2021,38 +2021,6 @@ static int get_neighbors(struct tree_balance *p_s_tb, int n_h)
2021 return CARRY_ON; 2021 return CARRY_ON;
2022} 2022}
2023 2023
2024#ifdef CONFIG_REISERFS_CHECK
2025void *reiserfs_kmalloc(size_t size, gfp_t flags, struct super_block *s)
2026{
2027 void *vp;
2028 static size_t malloced;
2029
2030 vp = kmalloc(size, flags);
2031 if (vp) {
2032 REISERFS_SB(s)->s_kmallocs += size;
2033 if (REISERFS_SB(s)->s_kmallocs > malloced + 200000) {
2034 reiserfs_warning(s,
2035 "vs-8301: reiserfs_kmalloc: allocated memory %d",
2036 REISERFS_SB(s)->s_kmallocs);
2037 malloced = REISERFS_SB(s)->s_kmallocs;
2038 }
2039 }
2040 return vp;
2041}
2042
2043void reiserfs_kfree(const void *vp, size_t size, struct super_block *s)
2044{
2045 kfree(vp);
2046
2047 REISERFS_SB(s)->s_kmallocs -= size;
2048 if (REISERFS_SB(s)->s_kmallocs < 0)
2049 reiserfs_warning(s,
2050 "vs-8302: reiserfs_kfree: allocated memory %d",
2051 REISERFS_SB(s)->s_kmallocs);
2052
2053}
2054#endif
2055
2056static int get_virtual_node_size(struct super_block *sb, struct buffer_head *bh) 2024static int get_virtual_node_size(struct super_block *sb, struct buffer_head *bh)
2057{ 2025{
2058 int max_num_of_items; 2026 int max_num_of_items;
@@ -2086,7 +2054,7 @@ static int get_mem_for_virtual_node(struct tree_balance *tb)
2086 /* we have to allocate more memory for virtual node */ 2054 /* we have to allocate more memory for virtual node */
2087 if (tb->vn_buf) { 2055 if (tb->vn_buf) {
2088 /* free memory allocated before */ 2056 /* free memory allocated before */
2089 reiserfs_kfree(tb->vn_buf, tb->vn_buf_size, tb->tb_sb); 2057 kfree(tb->vn_buf);
2090 /* this is not needed if kfree is atomic */ 2058 /* this is not needed if kfree is atomic */
2091 check_fs = 1; 2059 check_fs = 1;
2092 } 2060 }
@@ -2095,24 +2063,15 @@ static int get_mem_for_virtual_node(struct tree_balance *tb)
2095 tb->vn_buf_size = size; 2063 tb->vn_buf_size = size;
2096 2064
2097 /* get memory for virtual item */ 2065 /* get memory for virtual item */
2098 buf = 2066 buf = kmalloc(size, GFP_ATOMIC | __GFP_NOWARN);
2099 reiserfs_kmalloc(size, GFP_ATOMIC | __GFP_NOWARN,
2100 tb->tb_sb);
2101 if (!buf) { 2067 if (!buf) {
2102 /* getting memory with GFP_KERNEL priority may involve 2068 /* getting memory with GFP_KERNEL priority may involve
2103 balancing now (due to indirect_to_direct conversion on 2069 balancing now (due to indirect_to_direct conversion on
2104 dcache shrinking). So, release path and collected 2070 dcache shrinking). So, release path and collected
2105 resources here */ 2071 resources here */
2106 free_buffers_in_tb(tb); 2072 free_buffers_in_tb(tb);
2107 buf = reiserfs_kmalloc(size, GFP_NOFS, tb->tb_sb); 2073 buf = kmalloc(size, GFP_NOFS);
2108 if (!buf) { 2074 if (!buf) {
2109#ifdef CONFIG_REISERFS_CHECK
2110 reiserfs_warning(tb->tb_sb,
2111 "vs-8345: get_mem_for_virtual_node: "
2112 "kmalloc failed. reiserfs kmalloced %d bytes",
2113 REISERFS_SB(tb->tb_sb)->
2114 s_kmallocs);
2115#endif
2116 tb->vn_buf_size = 0; 2075 tb->vn_buf_size = 0;
2117 } 2076 }
2118 tb->vn_buf = buf; 2077 tb->vn_buf = buf;
@@ -2619,7 +2578,6 @@ void unfix_nodes(struct tree_balance *tb)
2619 } 2578 }
2620 } 2579 }
2621 2580
2622 if (tb->vn_buf) 2581 kfree(tb->vn_buf);
2623 reiserfs_kfree(tb->vn_buf, tb->vn_buf_size, tb->tb_sb);
2624 2582
2625} 2583}
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index ffa34b861bdb..b33d67bba2fd 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -2363,6 +2363,13 @@ static int reiserfs_write_full_page(struct page *page,
2363 int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize; 2363 int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize;
2364 th.t_trans_id = 0; 2364 th.t_trans_id = 0;
2365 2365
2366 /* no logging allowed when nonblocking or from PF_MEMALLOC */
2367 if (checked && (current->flags & PF_MEMALLOC)) {
2368 redirty_page_for_writepage(wbc, page);
2369 unlock_page(page);
2370 return 0;
2371 }
2372
2366 /* The page dirty bit is cleared before writepage is called, which 2373 /* The page dirty bit is cleared before writepage is called, which
2367 * means we have to tell create_empty_buffers to make dirty buffers 2374 * means we have to tell create_empty_buffers to make dirty buffers
2368 * The page really should be up to date at this point, so tossing 2375 * The page really should be up to date at this point, so tossing
@@ -2743,6 +2750,7 @@ static int invalidatepage_can_drop(struct inode *inode, struct buffer_head *bh)
2743 int ret = 1; 2750 int ret = 1;
2744 struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb); 2751 struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb);
2745 2752
2753 lock_buffer(bh);
2746 spin_lock(&j->j_dirty_buffers_lock); 2754 spin_lock(&j->j_dirty_buffers_lock);
2747 if (!buffer_mapped(bh)) { 2755 if (!buffer_mapped(bh)) {
2748 goto free_jh; 2756 goto free_jh;
@@ -2758,7 +2766,7 @@ static int invalidatepage_can_drop(struct inode *inode, struct buffer_head *bh)
2758 if (buffer_journaled(bh) || buffer_journal_dirty(bh)) { 2766 if (buffer_journaled(bh) || buffer_journal_dirty(bh)) {
2759 ret = 0; 2767 ret = 0;
2760 } 2768 }
2761 } else if (buffer_dirty(bh) || buffer_locked(bh)) { 2769 } else if (buffer_dirty(bh)) {
2762 struct reiserfs_journal_list *jl; 2770 struct reiserfs_journal_list *jl;
2763 struct reiserfs_jh *jh = bh->b_private; 2771 struct reiserfs_jh *jh = bh->b_private;
2764 2772
@@ -2784,6 +2792,7 @@ static int invalidatepage_can_drop(struct inode *inode, struct buffer_head *bh)
2784 reiserfs_free_jh(bh); 2792 reiserfs_free_jh(bh);
2785 } 2793 }
2786 spin_unlock(&j->j_dirty_buffers_lock); 2794 spin_unlock(&j->j_dirty_buffers_lock);
2795 unlock_buffer(bh);
2787 return ret; 2796 return ret;
2788} 2797}
2789 2798
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 4491fcf2a0e6..b7a179560ab4 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -152,18 +152,16 @@ static struct reiserfs_bitmap_node *allocate_bitmap_node(struct super_block
152 struct reiserfs_bitmap_node *bn; 152 struct reiserfs_bitmap_node *bn;
153 static int id; 153 static int id;
154 154
155 bn = reiserfs_kmalloc(sizeof(struct reiserfs_bitmap_node), GFP_NOFS, 155 bn = kmalloc(sizeof(struct reiserfs_bitmap_node), GFP_NOFS);
156 p_s_sb);
157 if (!bn) { 156 if (!bn) {
158 return NULL; 157 return NULL;
159 } 158 }
160 bn->data = reiserfs_kmalloc(p_s_sb->s_blocksize, GFP_NOFS, p_s_sb); 159 bn->data = kzalloc(p_s_sb->s_blocksize, GFP_NOFS);
161 if (!bn->data) { 160 if (!bn->data) {
162 reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb); 161 kfree(bn);
163 return NULL; 162 return NULL;
164 } 163 }
165 bn->id = id++; 164 bn->id = id++;
166 memset(bn->data, 0, p_s_sb->s_blocksize);
167 INIT_LIST_HEAD(&bn->list); 165 INIT_LIST_HEAD(&bn->list);
168 return bn; 166 return bn;
169} 167}
@@ -197,8 +195,8 @@ static inline void free_bitmap_node(struct super_block *p_s_sb,
197 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 195 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
198 journal->j_used_bitmap_nodes--; 196 journal->j_used_bitmap_nodes--;
199 if (journal->j_free_bitmap_nodes > REISERFS_MAX_BITMAP_NODES) { 197 if (journal->j_free_bitmap_nodes > REISERFS_MAX_BITMAP_NODES) {
200 reiserfs_kfree(bn->data, p_s_sb->s_blocksize, p_s_sb); 198 kfree(bn->data);
201 reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb); 199 kfree(bn);
202 } else { 200 } else {
203 list_add(&bn->list, &journal->j_bitmap_nodes); 201 list_add(&bn->list, &journal->j_bitmap_nodes);
204 journal->j_free_bitmap_nodes++; 202 journal->j_free_bitmap_nodes++;
@@ -276,8 +274,8 @@ static int free_bitmap_nodes(struct super_block *p_s_sb)
276 while (next != &journal->j_bitmap_nodes) { 274 while (next != &journal->j_bitmap_nodes) {
277 bn = list_entry(next, struct reiserfs_bitmap_node, list); 275 bn = list_entry(next, struct reiserfs_bitmap_node, list);
278 list_del(next); 276 list_del(next);
279 reiserfs_kfree(bn->data, p_s_sb->s_blocksize, p_s_sb); 277 kfree(bn->data);
280 reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb); 278 kfree(bn);
281 next = journal->j_bitmap_nodes.next; 279 next = journal->j_bitmap_nodes.next;
282 journal->j_free_bitmap_nodes--; 280 journal->j_free_bitmap_nodes--;
283 } 281 }
@@ -581,7 +579,7 @@ static inline void put_journal_list(struct super_block *s,
581 jl->j_trans_id, jl->j_refcount); 579 jl->j_trans_id, jl->j_refcount);
582 } 580 }
583 if (--jl->j_refcount == 0) 581 if (--jl->j_refcount == 0)
584 reiserfs_kfree(jl, sizeof(struct reiserfs_journal_list), s); 582 kfree(jl);
585} 583}
586 584
587/* 585/*
@@ -848,6 +846,14 @@ static int write_ordered_buffers(spinlock_t * lock,
848 spin_lock(lock); 846 spin_lock(lock);
849 goto loop_next; 847 goto loop_next;
850 } 848 }
849 /* in theory, dirty non-uptodate buffers should never get here,
850 * but the upper layer io error paths still have a few quirks.
851 * Handle them here as gracefully as we can
852 */
853 if (!buffer_uptodate(bh) && buffer_dirty(bh)) {
854 clear_buffer_dirty(bh);
855 ret = -EIO;
856 }
851 if (buffer_dirty(bh)) { 857 if (buffer_dirty(bh)) {
852 list_del_init(&jh->list); 858 list_del_init(&jh->list);
853 list_add(&jh->list, &tmp); 859 list_add(&jh->list, &tmp);
@@ -879,6 +885,19 @@ static int write_ordered_buffers(spinlock_t * lock,
879 if (!buffer_uptodate(bh)) { 885 if (!buffer_uptodate(bh)) {
880 ret = -EIO; 886 ret = -EIO;
881 } 887 }
888 /* ugly interaction with invalidatepage here.
889 * reiserfs_invalidate_page will pin any buffer that has a valid
890 * journal head from an older transaction. If someone else sets
891 * our buffer dirty after we write it in the first loop, and
892 * then someone truncates the page away, nobody will ever write
893 * the buffer. We're safe if we write the page one last time
894 * after freeing the journal header.
895 */
896 if (buffer_dirty(bh) && unlikely(bh->b_page->mapping == NULL)) {
897 spin_unlock(lock);
898 ll_rw_block(WRITE, 1, &bh);
899 spin_lock(lock);
900 }
882 put_bh(bh); 901 put_bh(bh);
883 cond_resched_lock(lock); 902 cond_resched_lock(lock);
884 } 903 }
@@ -977,6 +996,7 @@ static int flush_commit_list(struct super_block *s,
977 struct reiserfs_journal *journal = SB_JOURNAL(s); 996 struct reiserfs_journal *journal = SB_JOURNAL(s);
978 int barrier = 0; 997 int barrier = 0;
979 int retval = 0; 998 int retval = 0;
999 int write_len;
980 1000
981 reiserfs_check_lock_depth(s, "flush_commit_list"); 1001 reiserfs_check_lock_depth(s, "flush_commit_list");
982 1002
@@ -1018,24 +1038,35 @@ static int flush_commit_list(struct super_block *s,
1018 } 1038 }
1019 1039
1020 if (!list_empty(&jl->j_bh_list)) { 1040 if (!list_empty(&jl->j_bh_list)) {
1041 int ret;
1021 unlock_kernel(); 1042 unlock_kernel();
1022 write_ordered_buffers(&journal->j_dirty_buffers_lock, 1043 ret = write_ordered_buffers(&journal->j_dirty_buffers_lock,
1023 journal, jl, &jl->j_bh_list); 1044 journal, jl, &jl->j_bh_list);
1045 if (ret < 0 && retval == 0)
1046 retval = ret;
1024 lock_kernel(); 1047 lock_kernel();
1025 } 1048 }
1026 BUG_ON(!list_empty(&jl->j_bh_list)); 1049 BUG_ON(!list_empty(&jl->j_bh_list));
1027 /* 1050 /*
1028 * for the description block and all the log blocks, submit any buffers 1051 * for the description block and all the log blocks, submit any buffers
1029 * that haven't already reached the disk 1052 * that haven't already reached the disk. Try to write at least 256
1053 * log blocks. later on, we will only wait on blocks that correspond
1054 * to this transaction, but while we're unplugging we might as well
1055 * get a chunk of data on there.
1030 */ 1056 */
1031 atomic_inc(&journal->j_async_throttle); 1057 atomic_inc(&journal->j_async_throttle);
1032 for (i = 0; i < (jl->j_len + 1); i++) { 1058 write_len = jl->j_len + 1;
1059 if (write_len < 256)
1060 write_len = 256;
1061 for (i = 0 ; i < write_len ; i++) {
1033 bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) + (jl->j_start + i) % 1062 bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) + (jl->j_start + i) %
1034 SB_ONDISK_JOURNAL_SIZE(s); 1063 SB_ONDISK_JOURNAL_SIZE(s);
1035 tbh = journal_find_get_block(s, bn); 1064 tbh = journal_find_get_block(s, bn);
1036 if (buffer_dirty(tbh)) /* redundant, ll_rw_block() checks */ 1065 if (tbh) {
1037 ll_rw_block(SWRITE, 1, &tbh); 1066 if (buffer_dirty(tbh))
1038 put_bh(tbh); 1067 ll_rw_block(WRITE, 1, &tbh) ;
1068 put_bh(tbh) ;
1069 }
1039 } 1070 }
1040 atomic_dec(&journal->j_async_throttle); 1071 atomic_dec(&journal->j_async_throttle);
1041 1072
@@ -1818,8 +1849,7 @@ void remove_journal_hash(struct super_block *sb,
1818static void free_journal_ram(struct super_block *p_s_sb) 1849static void free_journal_ram(struct super_block *p_s_sb)
1819{ 1850{
1820 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 1851 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
1821 reiserfs_kfree(journal->j_current_jl, 1852 kfree(journal->j_current_jl);
1822 sizeof(struct reiserfs_journal_list), p_s_sb);
1823 journal->j_num_lists--; 1853 journal->j_num_lists--;
1824 1854
1825 vfree(journal->j_cnode_free_orig); 1855 vfree(journal->j_cnode_free_orig);
@@ -2093,21 +2123,15 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2093 } 2123 }
2094 trans_id = get_desc_trans_id(desc); 2124 trans_id = get_desc_trans_id(desc);
2095 /* now we know we've got a good transaction, and it was inside the valid time ranges */ 2125 /* now we know we've got a good transaction, and it was inside the valid time ranges */
2096 log_blocks = 2126 log_blocks = kmalloc(get_desc_trans_len(desc) *
2097 reiserfs_kmalloc(get_desc_trans_len(desc) * 2127 sizeof(struct buffer_head *), GFP_NOFS);
2098 sizeof(struct buffer_head *), GFP_NOFS, p_s_sb); 2128 real_blocks = kmalloc(get_desc_trans_len(desc) *
2099 real_blocks = 2129 sizeof(struct buffer_head *), GFP_NOFS);
2100 reiserfs_kmalloc(get_desc_trans_len(desc) *
2101 sizeof(struct buffer_head *), GFP_NOFS, p_s_sb);
2102 if (!log_blocks || !real_blocks) { 2130 if (!log_blocks || !real_blocks) {
2103 brelse(c_bh); 2131 brelse(c_bh);
2104 brelse(d_bh); 2132 brelse(d_bh);
2105 reiserfs_kfree(log_blocks, 2133 kfree(log_blocks);
2106 get_desc_trans_len(desc) * 2134 kfree(real_blocks);
2107 sizeof(struct buffer_head *), p_s_sb);
2108 reiserfs_kfree(real_blocks,
2109 get_desc_trans_len(desc) *
2110 sizeof(struct buffer_head *), p_s_sb);
2111 reiserfs_warning(p_s_sb, 2135 reiserfs_warning(p_s_sb,
2112 "journal-1169: kmalloc failed, unable to mount FS"); 2136 "journal-1169: kmalloc failed, unable to mount FS");
2113 return -1; 2137 return -1;
@@ -2145,12 +2169,8 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2145 brelse_array(real_blocks, i); 2169 brelse_array(real_blocks, i);
2146 brelse(c_bh); 2170 brelse(c_bh);
2147 brelse(d_bh); 2171 brelse(d_bh);
2148 reiserfs_kfree(log_blocks, 2172 kfree(log_blocks);
2149 get_desc_trans_len(desc) * 2173 kfree(real_blocks);
2150 sizeof(struct buffer_head *), p_s_sb);
2151 reiserfs_kfree(real_blocks,
2152 get_desc_trans_len(desc) *
2153 sizeof(struct buffer_head *), p_s_sb);
2154 return -1; 2174 return -1;
2155 } 2175 }
2156 } 2176 }
@@ -2166,12 +2186,8 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2166 brelse_array(real_blocks, get_desc_trans_len(desc)); 2186 brelse_array(real_blocks, get_desc_trans_len(desc));
2167 brelse(c_bh); 2187 brelse(c_bh);
2168 brelse(d_bh); 2188 brelse(d_bh);
2169 reiserfs_kfree(log_blocks, 2189 kfree(log_blocks);
2170 get_desc_trans_len(desc) * 2190 kfree(real_blocks);
2171 sizeof(struct buffer_head *), p_s_sb);
2172 reiserfs_kfree(real_blocks,
2173 get_desc_trans_len(desc) *
2174 sizeof(struct buffer_head *), p_s_sb);
2175 return -1; 2191 return -1;
2176 } 2192 }
2177 memcpy(real_blocks[i]->b_data, log_blocks[i]->b_data, 2193 memcpy(real_blocks[i]->b_data, log_blocks[i]->b_data,
@@ -2193,12 +2209,8 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2193 get_desc_trans_len(desc) - i); 2209 get_desc_trans_len(desc) - i);
2194 brelse(c_bh); 2210 brelse(c_bh);
2195 brelse(d_bh); 2211 brelse(d_bh);
2196 reiserfs_kfree(log_blocks, 2212 kfree(log_blocks);
2197 get_desc_trans_len(desc) * 2213 kfree(real_blocks);
2198 sizeof(struct buffer_head *), p_s_sb);
2199 reiserfs_kfree(real_blocks,
2200 get_desc_trans_len(desc) *
2201 sizeof(struct buffer_head *), p_s_sb);
2202 return -1; 2214 return -1;
2203 } 2215 }
2204 brelse(real_blocks[i]); 2216 brelse(real_blocks[i]);
@@ -2217,12 +2229,8 @@ static int journal_read_transaction(struct super_block *p_s_sb,
2217 journal->j_trans_id = trans_id + 1; 2229 journal->j_trans_id = trans_id + 1;
2218 brelse(c_bh); 2230 brelse(c_bh);
2219 brelse(d_bh); 2231 brelse(d_bh);
2220 reiserfs_kfree(log_blocks, 2232 kfree(log_blocks);
2221 le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), 2233 kfree(real_blocks);
2222 p_s_sb);
2223 reiserfs_kfree(real_blocks,
2224 le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *),
2225 p_s_sb);
2226 return 0; 2234 return 0;
2227} 2235}
2228 2236
@@ -2471,14 +2479,8 @@ static int journal_read(struct super_block *p_s_sb)
2471static struct reiserfs_journal_list *alloc_journal_list(struct super_block *s) 2479static struct reiserfs_journal_list *alloc_journal_list(struct super_block *s)
2472{ 2480{
2473 struct reiserfs_journal_list *jl; 2481 struct reiserfs_journal_list *jl;
2474 retry: 2482 jl = kzalloc(sizeof(struct reiserfs_journal_list),
2475 jl = reiserfs_kmalloc(sizeof(struct reiserfs_journal_list), GFP_NOFS, 2483 GFP_NOFS | __GFP_NOFAIL);
2476 s);
2477 if (!jl) {
2478 yield();
2479 goto retry;
2480 }
2481 memset(jl, 0, sizeof(*jl));
2482 INIT_LIST_HEAD(&jl->j_list); 2484 INIT_LIST_HEAD(&jl->j_list);
2483 INIT_LIST_HEAD(&jl->j_working_list); 2485 INIT_LIST_HEAD(&jl->j_working_list);
2484 INIT_LIST_HEAD(&jl->j_tail_bh_list); 2486 INIT_LIST_HEAD(&jl->j_tail_bh_list);
@@ -2821,6 +2823,9 @@ int journal_transaction_should_end(struct reiserfs_transaction_handle *th,
2821 journal->j_cnode_free < (journal->j_trans_max * 3)) { 2823 journal->j_cnode_free < (journal->j_trans_max * 3)) {
2822 return 1; 2824 return 1;
2823 } 2825 }
2826 /* protected by the BKL here */
2827 journal->j_len_alloc += new_alloc;
2828 th->t_blocks_allocated += new_alloc ;
2824 return 0; 2829 return 0;
2825} 2830}
2826 2831
@@ -3042,14 +3047,12 @@ struct reiserfs_transaction_handle *reiserfs_persistent_transaction(struct
3042 } 3047 }
3043 return th; 3048 return th;
3044 } 3049 }
3045 th = reiserfs_kmalloc(sizeof(struct reiserfs_transaction_handle), 3050 th = kmalloc(sizeof(struct reiserfs_transaction_handle), GFP_NOFS);
3046 GFP_NOFS, s);
3047 if (!th) 3051 if (!th)
3048 return NULL; 3052 return NULL;
3049 ret = journal_begin(th, s, nblocks); 3053 ret = journal_begin(th, s, nblocks);
3050 if (ret) { 3054 if (ret) {
3051 reiserfs_kfree(th, sizeof(struct reiserfs_transaction_handle), 3055 kfree(th);
3052 s);
3053 return NULL; 3056 return NULL;
3054 } 3057 }
3055 3058
@@ -3067,8 +3070,7 @@ int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *th)
3067 ret = -EIO; 3070 ret = -EIO;
3068 if (th->t_refcount == 0) { 3071 if (th->t_refcount == 0) {
3069 SB_JOURNAL(s)->j_persistent_trans--; 3072 SB_JOURNAL(s)->j_persistent_trans--;
3070 reiserfs_kfree(th, sizeof(struct reiserfs_transaction_handle), 3073 kfree(th);
3071 s);
3072 } 3074 }
3073 return ret; 3075 return ret;
3074} 3076}
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 8f8d8d01107c..c8123308e060 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -456,7 +456,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
456 /* get memory for composing the entry */ 456 /* get memory for composing the entry */
457 buflen = DEH_SIZE + ROUND_UP(namelen); 457 buflen = DEH_SIZE + ROUND_UP(namelen);
458 if (buflen > sizeof(small_buf)) { 458 if (buflen > sizeof(small_buf)) {
459 buffer = reiserfs_kmalloc(buflen, GFP_NOFS, dir->i_sb); 459 buffer = kmalloc(buflen, GFP_NOFS);
460 if (buffer == 0) 460 if (buffer == 0)
461 return -ENOMEM; 461 return -ENOMEM;
462 } else 462 } else
@@ -490,7 +490,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
490 retval = reiserfs_find_entry(dir, name, namelen, &path, &de); 490 retval = reiserfs_find_entry(dir, name, namelen, &path, &de);
491 if (retval != NAME_NOT_FOUND) { 491 if (retval != NAME_NOT_FOUND) {
492 if (buffer != small_buf) 492 if (buffer != small_buf)
493 reiserfs_kfree(buffer, buflen, dir->i_sb); 493 kfree(buffer);
494 pathrelse(&path); 494 pathrelse(&path);
495 495
496 if (retval == IO_ERROR) { 496 if (retval == IO_ERROR) {
@@ -515,7 +515,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
515 reiserfs_warning(dir->i_sb, 515 reiserfs_warning(dir->i_sb,
516 "reiserfs_add_entry: Congratulations! we have got hash function screwed up"); 516 "reiserfs_add_entry: Congratulations! we have got hash function screwed up");
517 if (buffer != small_buf) 517 if (buffer != small_buf)
518 reiserfs_kfree(buffer, buflen, dir->i_sb); 518 kfree(buffer);
519 pathrelse(&path); 519 pathrelse(&path);
520 return -EBUSY; 520 return -EBUSY;
521 } 521 }
@@ -535,7 +535,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
535 &entry_key); 535 &entry_key);
536 536
537 if (buffer != small_buf) 537 if (buffer != small_buf)
538 reiserfs_kfree(buffer, buflen, dir->i_sb); 538 kfree(buffer);
539 pathrelse(&path); 539 pathrelse(&path);
540 return -EBUSY; 540 return -EBUSY;
541 } 541 }
@@ -546,7 +546,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
546 reiserfs_paste_into_item(th, &path, &entry_key, dir, buffer, 546 reiserfs_paste_into_item(th, &path, &entry_key, dir, buffer,
547 paste_size); 547 paste_size);
548 if (buffer != small_buf) 548 if (buffer != small_buf)
549 reiserfs_kfree(buffer, buflen, dir->i_sb); 549 kfree(buffer);
550 if (retval) { 550 if (retval) {
551 reiserfs_check_path(&path); 551 reiserfs_check_path(&path);
552 return retval; 552 return retval;
@@ -1065,7 +1065,7 @@ static int reiserfs_symlink(struct inode *parent_dir,
1065 goto out_failed; 1065 goto out_failed;
1066 } 1066 }
1067 1067
1068 name = reiserfs_kmalloc(item_len, GFP_NOFS, parent_dir->i_sb); 1068 name = kmalloc(item_len, GFP_NOFS);
1069 if (!name) { 1069 if (!name) {
1070 drop_new_inode(inode); 1070 drop_new_inode(inode);
1071 retval = -ENOMEM; 1071 retval = -ENOMEM;
@@ -1079,14 +1079,14 @@ static int reiserfs_symlink(struct inode *parent_dir,
1079 retval = journal_begin(&th, parent_dir->i_sb, jbegin_count); 1079 retval = journal_begin(&th, parent_dir->i_sb, jbegin_count);
1080 if (retval) { 1080 if (retval) {
1081 drop_new_inode(inode); 1081 drop_new_inode(inode);
1082 reiserfs_kfree(name, item_len, parent_dir->i_sb); 1082 kfree(name);
1083 goto out_failed; 1083 goto out_failed;
1084 } 1084 }
1085 1085
1086 retval = 1086 retval =
1087 reiserfs_new_inode(&th, parent_dir, mode, name, strlen(symname), 1087 reiserfs_new_inode(&th, parent_dir, mode, name, strlen(symname),
1088 dentry, inode); 1088 dentry, inode);
1089 reiserfs_kfree(name, item_len, parent_dir->i_sb); 1089 kfree(name);
1090 if (retval) { /* reiserfs_new_inode iputs for us */ 1090 if (retval) { /* reiserfs_new_inode iputs for us */
1091 goto out_failed; 1091 goto out_failed;
1092 } 1092 }
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index fc2f43c75df4..ef6caed9336b 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -88,7 +88,6 @@ static int show_super(struct seq_file *m, struct super_block *sb)
88 seq_printf(m, "state: \t%s\n" 88 seq_printf(m, "state: \t%s\n"
89 "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n" 89 "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n"
90 "gen. counter: \t%i\n" 90 "gen. counter: \t%i\n"
91 "s_kmallocs: \t%i\n"
92 "s_disk_reads: \t%i\n" 91 "s_disk_reads: \t%i\n"
93 "s_disk_writes: \t%i\n" 92 "s_disk_writes: \t%i\n"
94 "s_fix_nodes: \t%i\n" 93 "s_fix_nodes: \t%i\n"
@@ -128,7 +127,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
128 "SMALL_TAILS " : "NO_TAILS ", 127 "SMALL_TAILS " : "NO_TAILS ",
129 replay_only(sb) ? "REPLAY_ONLY " : "", 128 replay_only(sb) ? "REPLAY_ONLY " : "",
130 convert_reiserfs(sb) ? "CONV " : "", 129 convert_reiserfs(sb) ? "CONV " : "",
131 atomic_read(&r->s_generation_counter), SF(s_kmallocs), 130 atomic_read(&r->s_generation_counter),
132 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes), 131 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
133 SF(s_do_balance), SF(s_unneeded_left_neighbor), 132 SF(s_do_balance), SF(s_unneeded_left_neighbor),
134 SF(s_good_search_by_key_reada), SF(s_bmaps), 133 SF(s_good_search_by_key_reada), SF(s_bmaps),
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 397d9590c8f2..ef5e5414e7a8 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -472,12 +472,6 @@ static void reiserfs_put_super(struct super_block *s)
472 472
473 print_statistics(s); 473 print_statistics(s);
474 474
475 if (REISERFS_SB(s)->s_kmallocs != 0) {
476 reiserfs_warning(s,
477 "vs-2004: reiserfs_put_super: allocated memory left %d",
478 REISERFS_SB(s)->s_kmallocs);
479 }
480
481 if (REISERFS_SB(s)->reserved_blocks != 0) { 475 if (REISERFS_SB(s)->reserved_blocks != 0) {
482 reiserfs_warning(s, 476 reiserfs_warning(s,
483 "green-2005: reiserfs_put_super: reserved blocks left %d", 477 "green-2005: reiserfs_put_super: reserved blocks left %d",
@@ -1131,7 +1125,7 @@ static void handle_attrs(struct super_block *s)
1131 REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS); 1125 REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
1132 } 1126 }
1133 } else if (le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared) { 1127 } else if (le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared) {
1134 REISERFS_SB(s)->s_mount_opt |= REISERFS_ATTRS; 1128 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ATTRS);
1135 } 1129 }
1136} 1130}
1137 1131
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index cc061bfd437b..ffb79c48c5bf 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -368,15 +368,13 @@ static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir)
368 if (d_reclen <= 32) { 368 if (d_reclen <= 32) {
369 local_buf = small_buf; 369 local_buf = small_buf;
370 } else { 370 } else {
371 local_buf = 371 local_buf = kmalloc(d_reclen, GFP_NOFS);
372 reiserfs_kmalloc(d_reclen, GFP_NOFS, inode->i_sb);
373 if (!local_buf) { 372 if (!local_buf) {
374 pathrelse(&path_to_entry); 373 pathrelse(&path_to_entry);
375 return -ENOMEM; 374 return -ENOMEM;
376 } 375 }
377 if (item_moved(&tmp_ih, &path_to_entry)) { 376 if (item_moved(&tmp_ih, &path_to_entry)) {
378 reiserfs_kfree(local_buf, d_reclen, 377 kfree(local_buf);
379 inode->i_sb);
380 378
381 /* sigh, must retry. Do this same offset again */ 379 /* sigh, must retry. Do this same offset again */
382 next_pos = d_off; 380 next_pos = d_off;
@@ -399,13 +397,12 @@ static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir)
399 if (filldir(dirent, local_buf, d_reclen, d_off, d_ino, 397 if (filldir(dirent, local_buf, d_reclen, d_off, d_ino,
400 DT_UNKNOWN) < 0) { 398 DT_UNKNOWN) < 0) {
401 if (local_buf != small_buf) { 399 if (local_buf != small_buf) {
402 reiserfs_kfree(local_buf, d_reclen, 400 kfree(local_buf);
403 inode->i_sb);
404 } 401 }
405 goto end; 402 goto end;
406 } 403 }
407 if (local_buf != small_buf) { 404 if (local_buf != small_buf) {
408 reiserfs_kfree(local_buf, d_reclen, inode->i_sb); 405 kfree(local_buf);
409 } 406 }
410 } /* while */ 407 } /* while */
411 408
@@ -1322,109 +1319,44 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
1322 return err; 1319 return err;
1323} 1320}
1324 1321
1325static int 1322static int reiserfs_check_acl(struct inode *inode, int mask)
1326__reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd,
1327 int need_lock)
1328{ 1323{
1329 umode_t mode = inode->i_mode; 1324 struct posix_acl *acl;
1330 1325 int error = -EAGAIN; /* do regular unix permission checks by default */
1331 if (mask & MAY_WRITE) {
1332 /*
1333 * Nobody gets write access to a read-only fs.
1334 */
1335 if (IS_RDONLY(inode) &&
1336 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
1337 return -EROFS;
1338 1326
1339 /* 1327 reiserfs_read_lock_xattr_i(inode);
1340 * Nobody gets write access to an immutable file. 1328 reiserfs_read_lock_xattrs(inode->i_sb);
1341 */
1342 if (IS_IMMUTABLE(inode))
1343 return -EACCES;
1344 }
1345 1329
1346 /* We don't do permission checks on the internal objects. 1330 acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
1347 * Permissions are determined by the "owning" object. */
1348 if (is_reiserfs_priv_object(inode))
1349 return 0;
1350 1331
1351 if (current->fsuid == inode->i_uid) { 1332 reiserfs_read_unlock_xattrs(inode->i_sb);
1352 mode >>= 6; 1333 reiserfs_read_unlock_xattr_i(inode);
1353#ifdef CONFIG_REISERFS_FS_POSIX_ACL
1354 } else if (reiserfs_posixacl(inode->i_sb) &&
1355 get_inode_sd_version(inode) != STAT_DATA_V1) {
1356 struct posix_acl *acl;
1357
1358 /* ACL can't contain additional permissions if
1359 the ACL_MASK entry is 0 */
1360 if (!(mode & S_IRWXG))
1361 goto check_groups;
1362
1363 if (need_lock) {
1364 reiserfs_read_lock_xattr_i(inode);
1365 reiserfs_read_lock_xattrs(inode->i_sb);
1366 }
1367 acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
1368 if (need_lock) {
1369 reiserfs_read_unlock_xattrs(inode->i_sb);
1370 reiserfs_read_unlock_xattr_i(inode);
1371 }
1372 if (IS_ERR(acl)) {
1373 if (PTR_ERR(acl) == -ENODATA)
1374 goto check_groups;
1375 return PTR_ERR(acl);
1376 }
1377 1334
1378 if (acl) { 1335 if (acl) {
1379 int err = posix_acl_permission(inode, acl, mask); 1336 if (!IS_ERR(acl)) {
1337 error = posix_acl_permission(inode, acl, mask);
1380 posix_acl_release(acl); 1338 posix_acl_release(acl);
1381 if (err == -EACCES) { 1339 } else if (PTR_ERR(acl) != -ENODATA)
1382 goto check_capabilities; 1340 error = PTR_ERR(acl);
1383 }
1384 return err;
1385 } else {
1386 goto check_groups;
1387 }
1388#endif
1389 } else {
1390 check_groups:
1391 if (in_group_p(inode->i_gid))
1392 mode >>= 3;
1393 } 1341 }
1394 1342
1395 /* 1343 return error;
1396 * If the DACs are ok we don't need any capability check. 1344}
1397 */
1398 if (((mode & mask & (MAY_READ | MAY_WRITE | MAY_EXEC)) == mask))
1399 return 0;
1400 1345
1401 check_capabilities: 1346int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd)
1347{
1402 /* 1348 /*
1403 * Read/write DACs are always overridable. 1349 * We don't do permission checks on the internal objects.
1404 * Executable DACs are overridable if at least one exec bit is set. 1350 * Permissions are determined by the "owning" object.
1405 */ 1351 */
1406 if (!(mask & MAY_EXEC) || 1352 if (is_reiserfs_priv_object(inode))
1407 (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode)) 1353 return 0;
1408 if (capable(CAP_DAC_OVERRIDE))
1409 return 0;
1410 1354
1411 /* 1355 /*
1412 * Searching includes executable on directories, else just read. 1356 * Stat data v1 doesn't support ACLs.
1413 */ 1357 */
1414 if (mask == MAY_READ || (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE))) 1358 if (get_inode_sd_version(inode) == STAT_DATA_V1)
1415 if (capable(CAP_DAC_READ_SEARCH)) 1359 return generic_permission(inode, mask, NULL);
1416 return 0; 1360 else
1417 1361 return generic_permission(inode, mask, reiserfs_check_acl);
1418 return -EACCES;
1419}
1420
1421int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd)
1422{
1423 return __reiserfs_permission(inode, mask, nd, 1);
1424}
1425
1426int
1427reiserfs_permission_locked(struct inode *inode, int mask, struct nameidata *nd)
1428{
1429 return __reiserfs_permission(inode, mask, nd, 0);
1430} 1362}
diff --git a/fs/smbfs/dir.c b/fs/smbfs/dir.c
index c6c33e15143a..0424d06b147e 100644
--- a/fs/smbfs/dir.c
+++ b/fs/smbfs/dir.c
@@ -209,6 +209,8 @@ init_cache:
209 ctl.valid = 1; 209 ctl.valid = 1;
210read_really: 210read_really:
211 result = server->ops->readdir(filp, dirent, filldir, &ctl); 211 result = server->ops->readdir(filp, dirent, filldir, &ctl);
212 if (result == -ERESTARTSYS && page)
213 ClearPageUptodate(page);
212 if (ctl.idx == -1) 214 if (ctl.idx == -1)
213 goto invalid_cache; /* retry */ 215 goto invalid_cache; /* retry */
214 ctl.head.end = ctl.fpos - 1; 216 ctl.head.end = ctl.fpos - 1;
@@ -217,7 +219,8 @@ finished:
217 if (page) { 219 if (page) {
218 cache->head = ctl.head; 220 cache->head = ctl.head;
219 kunmap(page); 221 kunmap(page);
220 SetPageUptodate(page); 222 if (result != -ERESTARTSYS)
223 SetPageUptodate(page);
221 unlock_page(page); 224 unlock_page(page);
222 page_cache_release(page); 225 page_cache_release(page);
223 } 226 }
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 4fae57d9d115..201049ac8a96 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -579,10 +579,9 @@ static void udf_table_free_blocks(struct super_block * sb,
579 { 579 {
580 loffset = nextoffset; 580 loffset = nextoffset;
581 aed->lengthAllocDescs = cpu_to_le32(adsize); 581 aed->lengthAllocDescs = cpu_to_le32(adsize);
582 if (obh) 582 sptr = UDF_I_DATA(inode) + nextoffset -
583 sptr = UDF_I_DATA(inode) + nextoffset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode) - adsize; 583 udf_file_entry_alloc_offset(inode) +
584 else 584 UDF_I_LENEATTR(inode) - adsize;
585 sptr = obh->b_data + nextoffset - adsize;
586 dptr = nbh->b_data + sizeof(struct allocExtDesc); 585 dptr = nbh->b_data + sizeof(struct allocExtDesc);
587 memcpy(dptr, sptr, adsize); 586 memcpy(dptr, sptr, adsize);
588 nextoffset = sizeof(struct allocExtDesc) + adsize; 587 nextoffset = sizeof(struct allocExtDesc) + adsize;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index ca732e79c48b..ab9a7629d23e 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -296,7 +296,7 @@ static struct dentry *
296udf_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) 296udf_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
297{ 297{
298 struct inode *inode = NULL; 298 struct inode *inode = NULL;
299 struct fileIdentDesc cfi, *fi; 299 struct fileIdentDesc cfi;
300 struct udf_fileident_bh fibh; 300 struct udf_fileident_bh fibh;
301 301
302 if (dentry->d_name.len > UDF_NAME_LEN-2) 302 if (dentry->d_name.len > UDF_NAME_LEN-2)
@@ -318,7 +318,7 @@ udf_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
318 else 318 else
319#endif /* UDF_RECOVERY */ 319#endif /* UDF_RECOVERY */
320 320
321 if ((fi = udf_find_entry(dir, dentry, &fibh, &cfi))) 321 if (udf_find_entry(dir, dentry, &fibh, &cfi))
322 { 322 {
323 if (fibh.sbh != fibh.ebh) 323 if (fibh.sbh != fibh.ebh)
324 udf_release_data(fibh.ebh); 324 udf_release_data(fibh.ebh);
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index e0c04e36a051..3c3f62ce2ad9 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -376,7 +376,7 @@ out:
376 * This function gets the block which contains the fragment. 376 * This function gets the block which contains the fragment.
377 */ 377 */
378 378
379static int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create) 379int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create)
380{ 380{
381 struct super_block * sb = inode->i_sb; 381 struct super_block * sb = inode->i_sb;
382 struct ufs_sb_private_info * uspi = UFS_SB(sb)->s_uspi; 382 struct ufs_sb_private_info * uspi = UFS_SB(sb)->s_uspi;
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index d4aacee593ff..e9055ef7f5ac 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -388,7 +388,8 @@ static int ufs_parse_options (char * options, unsigned * mount_options)
388/* 388/*
389 * Read on-disk structures associated with cylinder groups 389 * Read on-disk structures associated with cylinder groups
390 */ 390 */
391static int ufs_read_cylinder_structures (struct super_block *sb) { 391static int ufs_read_cylinder_structures (struct super_block *sb)
392{
392 struct ufs_sb_info * sbi = UFS_SB(sb); 393 struct ufs_sb_info * sbi = UFS_SB(sb);
393 struct ufs_sb_private_info * uspi; 394 struct ufs_sb_private_info * uspi;
394 struct ufs_super_block *usb; 395 struct ufs_super_block *usb;
@@ -415,6 +416,7 @@ static int ufs_read_cylinder_structures (struct super_block *sb) {
415 base = space = kmalloc(size, GFP_KERNEL); 416 base = space = kmalloc(size, GFP_KERNEL);
416 if (!base) 417 if (!base)
417 goto failed; 418 goto failed;
419 sbi->s_csp = (struct ufs_csum *)space;
418 for (i = 0; i < blks; i += uspi->s_fpb) { 420 for (i = 0; i < blks; i += uspi->s_fpb) {
419 size = uspi->s_bsize; 421 size = uspi->s_bsize;
420 if (i + uspi->s_fpb > blks) 422 if (i + uspi->s_fpb > blks)
@@ -430,7 +432,6 @@ static int ufs_read_cylinder_structures (struct super_block *sb) {
430 goto failed; 432 goto failed;
431 433
432 ubh_ubhcpymem (space, ubh, size); 434 ubh_ubhcpymem (space, ubh, size);
433 sbi->s_csp[ufs_fragstoblks(i)]=(struct ufs_csum *)space;
434 435
435 space += size; 436 space += size;
436 ubh_brelse (ubh); 437 ubh_brelse (ubh);
@@ -486,7 +487,8 @@ failed:
486 * Put on-disk structures associated with cylinder groups and 487 * Put on-disk structures associated with cylinder groups and
487 * write them back to disk 488 * write them back to disk
488 */ 489 */
489static void ufs_put_cylinder_structures (struct super_block *sb) { 490static void ufs_put_cylinder_structures (struct super_block *sb)
491{
490 struct ufs_sb_info * sbi = UFS_SB(sb); 492 struct ufs_sb_info * sbi = UFS_SB(sb);
491 struct ufs_sb_private_info * uspi; 493 struct ufs_sb_private_info * uspi;
492 struct ufs_buffer_head * ubh; 494 struct ufs_buffer_head * ubh;
@@ -499,7 +501,7 @@ static void ufs_put_cylinder_structures (struct super_block *sb) {
499 501
500 size = uspi->s_cssize; 502 size = uspi->s_cssize;
501 blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift; 503 blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift;
502 base = space = (char*) sbi->s_csp[0]; 504 base = space = (char*) sbi->s_csp;
503 for (i = 0; i < blks; i += uspi->s_fpb) { 505 for (i = 0; i < blks; i += uspi->s_fpb) {
504 size = uspi->s_bsize; 506 size = uspi->s_bsize;
505 if (i + uspi->s_fpb > blks) 507 if (i + uspi->s_fpb > blks)
diff --git a/fs/ufs/truncate.c b/fs/ufs/truncate.c
index 61d2e35012a4..02e86291ef8a 100644
--- a/fs/ufs/truncate.c
+++ b/fs/ufs/truncate.c
@@ -29,6 +29,11 @@
29 * Idea from Pierre del Perugia <delperug@gla.ecoledoc.ibp.fr> 29 * Idea from Pierre del Perugia <delperug@gla.ecoledoc.ibp.fr>
30 */ 30 */
31 31
32/*
33 * Modified to avoid infinite loop on 2006 by
34 * Evgeniy Dushistov <dushistov@mail.ru>
35 */
36
32#include <linux/errno.h> 37#include <linux/errno.h>
33#include <linux/fs.h> 38#include <linux/fs.h>
34#include <linux/ufs_fs.h> 39#include <linux/ufs_fs.h>
@@ -65,19 +70,16 @@
65#define DIRECT_BLOCK ((inode->i_size + uspi->s_bsize - 1) >> uspi->s_bshift) 70#define DIRECT_BLOCK ((inode->i_size + uspi->s_bsize - 1) >> uspi->s_bshift)
66#define DIRECT_FRAGMENT ((inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift) 71#define DIRECT_FRAGMENT ((inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift)
67 72
68#define DATA_BUFFER_USED(bh) \
69 (atomic_read(&bh->b_count)>1 || buffer_locked(bh))
70 73
71static int ufs_trunc_direct (struct inode * inode) 74static int ufs_trunc_direct (struct inode * inode)
72{ 75{
73 struct ufs_inode_info *ufsi = UFS_I(inode); 76 struct ufs_inode_info *ufsi = UFS_I(inode);
74 struct super_block * sb; 77 struct super_block * sb;
75 struct ufs_sb_private_info * uspi; 78 struct ufs_sb_private_info * uspi;
76 struct buffer_head * bh;
77 __fs32 * p; 79 __fs32 * p;
78 unsigned frag1, frag2, frag3, frag4, block1, block2; 80 unsigned frag1, frag2, frag3, frag4, block1, block2;
79 unsigned frag_to_free, free_count; 81 unsigned frag_to_free, free_count;
80 unsigned i, j, tmp; 82 unsigned i, tmp;
81 int retry; 83 int retry;
82 84
83 UFSD(("ENTER\n")) 85 UFSD(("ENTER\n"))
@@ -117,15 +119,7 @@ static int ufs_trunc_direct (struct inode * inode)
117 ufs_panic (sb, "ufs_trunc_direct", "internal error"); 119 ufs_panic (sb, "ufs_trunc_direct", "internal error");
118 frag1 = ufs_fragnum (frag1); 120 frag1 = ufs_fragnum (frag1);
119 frag2 = ufs_fragnum (frag2); 121 frag2 = ufs_fragnum (frag2);
120 for (j = frag1; j < frag2; j++) { 122
121 bh = sb_find_get_block (sb, tmp + j);
122 if ((bh && DATA_BUFFER_USED(bh)) || tmp != fs32_to_cpu(sb, *p)) {
123 retry = 1;
124 brelse (bh);
125 goto next1;
126 }
127 bforget (bh);
128 }
129 inode->i_blocks -= (frag2-frag1) << uspi->s_nspfshift; 123 inode->i_blocks -= (frag2-frag1) << uspi->s_nspfshift;
130 mark_inode_dirty(inode); 124 mark_inode_dirty(inode);
131 ufs_free_fragments (inode, tmp + frag1, frag2 - frag1); 125 ufs_free_fragments (inode, tmp + frag1, frag2 - frag1);
@@ -140,15 +134,7 @@ next1:
140 tmp = fs32_to_cpu(sb, *p); 134 tmp = fs32_to_cpu(sb, *p);
141 if (!tmp) 135 if (!tmp)
142 continue; 136 continue;
143 for (j = 0; j < uspi->s_fpb; j++) { 137
144 bh = sb_find_get_block(sb, tmp + j);
145 if ((bh && DATA_BUFFER_USED(bh)) || tmp != fs32_to_cpu(sb, *p)) {
146 retry = 1;
147 brelse (bh);
148 goto next2;
149 }
150 bforget (bh);
151 }
152 *p = 0; 138 *p = 0;
153 inode->i_blocks -= uspi->s_nspb; 139 inode->i_blocks -= uspi->s_nspb;
154 mark_inode_dirty(inode); 140 mark_inode_dirty(inode);
@@ -162,7 +148,6 @@ next1:
162 frag_to_free = tmp; 148 frag_to_free = tmp;
163 free_count = uspi->s_fpb; 149 free_count = uspi->s_fpb;
164 } 150 }
165next2:;
166 } 151 }
167 152
168 if (free_count > 0) 153 if (free_count > 0)
@@ -179,15 +164,7 @@ next2:;
179 if (!tmp ) 164 if (!tmp )
180 ufs_panic(sb, "ufs_truncate_direct", "internal error"); 165 ufs_panic(sb, "ufs_truncate_direct", "internal error");
181 frag4 = ufs_fragnum (frag4); 166 frag4 = ufs_fragnum (frag4);
182 for (j = 0; j < frag4; j++) { 167
183 bh = sb_find_get_block (sb, tmp + j);
184 if ((bh && DATA_BUFFER_USED(bh)) || tmp != fs32_to_cpu(sb, *p)) {
185 retry = 1;
186 brelse (bh);
187 goto next1;
188 }
189 bforget (bh);
190 }
191 *p = 0; 168 *p = 0;
192 inode->i_blocks -= frag4 << uspi->s_nspfshift; 169 inode->i_blocks -= frag4 << uspi->s_nspfshift;
193 mark_inode_dirty(inode); 170 mark_inode_dirty(inode);
@@ -204,9 +181,8 @@ static int ufs_trunc_indirect (struct inode * inode, unsigned offset, __fs32 *p)
204 struct super_block * sb; 181 struct super_block * sb;
205 struct ufs_sb_private_info * uspi; 182 struct ufs_sb_private_info * uspi;
206 struct ufs_buffer_head * ind_ubh; 183 struct ufs_buffer_head * ind_ubh;
207 struct buffer_head * bh;
208 __fs32 * ind; 184 __fs32 * ind;
209 unsigned indirect_block, i, j, tmp; 185 unsigned indirect_block, i, tmp;
210 unsigned frag_to_free, free_count; 186 unsigned frag_to_free, free_count;
211 int retry; 187 int retry;
212 188
@@ -238,15 +214,7 @@ static int ufs_trunc_indirect (struct inode * inode, unsigned offset, __fs32 *p)
238 tmp = fs32_to_cpu(sb, *ind); 214 tmp = fs32_to_cpu(sb, *ind);
239 if (!tmp) 215 if (!tmp)
240 continue; 216 continue;
241 for (j = 0; j < uspi->s_fpb; j++) { 217
242 bh = sb_find_get_block(sb, tmp + j);
243 if ((bh && DATA_BUFFER_USED(bh)) || tmp != fs32_to_cpu(sb, *ind)) {
244 retry = 1;
245 brelse (bh);
246 goto next;
247 }
248 bforget (bh);
249 }
250 *ind = 0; 218 *ind = 0;
251 ubh_mark_buffer_dirty(ind_ubh); 219 ubh_mark_buffer_dirty(ind_ubh);
252 if (free_count == 0) { 220 if (free_count == 0) {
@@ -261,7 +229,6 @@ static int ufs_trunc_indirect (struct inode * inode, unsigned offset, __fs32 *p)
261 } 229 }
262 inode->i_blocks -= uspi->s_nspb; 230 inode->i_blocks -= uspi->s_nspb;
263 mark_inode_dirty(inode); 231 mark_inode_dirty(inode);
264next:;
265 } 232 }
266 233
267 if (free_count > 0) { 234 if (free_count > 0) {
@@ -430,9 +397,7 @@ void ufs_truncate (struct inode * inode)
430 struct ufs_inode_info *ufsi = UFS_I(inode); 397 struct ufs_inode_info *ufsi = UFS_I(inode);
431 struct super_block * sb; 398 struct super_block * sb;
432 struct ufs_sb_private_info * uspi; 399 struct ufs_sb_private_info * uspi;
433 struct buffer_head * bh; 400 int retry;
434 unsigned offset;
435 int err, retry;
436 401
437 UFSD(("ENTER\n")) 402 UFSD(("ENTER\n"))
438 sb = inode->i_sb; 403 sb = inode->i_sb;
@@ -442,6 +407,9 @@ void ufs_truncate (struct inode * inode)
442 return; 407 return;
443 if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) 408 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
444 return; 409 return;
410
411 block_truncate_page(inode->i_mapping, inode->i_size, ufs_getfrag_block);
412
445 lock_kernel(); 413 lock_kernel();
446 while (1) { 414 while (1) {
447 retry = ufs_trunc_direct(inode); 415 retry = ufs_trunc_direct(inode);
@@ -457,15 +425,7 @@ void ufs_truncate (struct inode * inode)
457 blk_run_address_space(inode->i_mapping); 425 blk_run_address_space(inode->i_mapping);
458 yield(); 426 yield();
459 } 427 }
460 offset = inode->i_size & uspi->s_fshift; 428
461 if (offset) {
462 bh = ufs_bread (inode, inode->i_size >> uspi->s_fshift, 0, &err);
463 if (bh) {
464 memset (bh->b_data + offset, 0, uspi->s_fsize - offset);
465 mark_buffer_dirty (bh);
466 brelse (bh);
467 }
468 }
469 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; 429 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
470 ufsi->i_lastfrag = DIRECT_FRAGMENT; 430 ufsi->i_lastfrag = DIRECT_FRAGMENT;
471 unlock_kernel(); 431 unlock_kernel();
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 120626789406..9892268e3005 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -1462,4 +1462,5 @@ struct address_space_operations linvfs_aops = {
1462 .commit_write = generic_commit_write, 1462 .commit_write = generic_commit_write,
1463 .bmap = linvfs_bmap, 1463 .bmap = linvfs_bmap,
1464 .direct_IO = linvfs_direct_IO, 1464 .direct_IO = linvfs_direct_IO,
1465 .migratepage = buffer_migrate_page,
1465}; 1466};
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index e44b7c1a3a36..bfb4f2917bb6 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -822,6 +822,13 @@ xfs_buf_rele(
822 822
823 XB_TRACE(bp, "rele", bp->b_relse); 823 XB_TRACE(bp, "rele", bp->b_relse);
824 824
825 if (unlikely(!hash)) {
826 ASSERT(!bp->b_relse);
827 if (atomic_dec_and_test(&bp->b_hold))
828 xfs_buf_free(bp);
829 return;
830 }
831
825 if (atomic_dec_and_lock(&bp->b_hold, &hash->bh_lock)) { 832 if (atomic_dec_and_lock(&bp->b_hold, &hash->bh_lock)) {
826 if (bp->b_relse) { 833 if (bp->b_relse) {
827 atomic_inc(&bp->b_hold); 834 atomic_inc(&bp->b_hold);
@@ -1514,6 +1521,7 @@ xfs_mapping_buftarg(
1514 struct address_space *mapping; 1521 struct address_space *mapping;
1515 static struct address_space_operations mapping_aops = { 1522 static struct address_space_operations mapping_aops = {
1516 .sync_page = block_sync_page, 1523 .sync_page = block_sync_page,
1524 .migratepage = fail_migrate_page,
1517 }; 1525 };
1518 1526
1519 inode = new_inode(bdev->bd_inode->i_sb); 1527 inode = new_inode(bdev->bd_inode->i_sb);
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 76c6df34d0db..eda7919b70a1 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -262,6 +262,31 @@ has_fs_struct(struct task_struct *task)
262 return (task->fs != init_task.fs); 262 return (task->fs != init_task.fs);
263} 263}
264 264
265STATIC inline void
266cleanup_inode(
267 vnode_t *dvp,
268 vnode_t *vp,
269 struct dentry *dentry,
270 int mode)
271{
272 struct dentry teardown = {};
273 int err2;
274
275 /* Oh, the horror.
276 * If we can't add the ACL or we fail in
277 * linvfs_init_security we must back out.
278 * ENOSPC can hit here, among other things.
279 */
280 teardown.d_inode = LINVFS_GET_IP(vp);
281 teardown.d_name = dentry->d_name;
282
283 if (S_ISDIR(mode))
284 VOP_RMDIR(dvp, &teardown, NULL, err2);
285 else
286 VOP_REMOVE(dvp, &teardown, NULL, err2);
287 VN_RELE(vp);
288}
289
265STATIC int 290STATIC int
266linvfs_mknod( 291linvfs_mknod(
267 struct inode *dir, 292 struct inode *dir,
@@ -316,30 +341,19 @@ linvfs_mknod(
316 } 341 }
317 342
318 if (!error) 343 if (!error)
344 {
319 error = linvfs_init_security(vp, dir); 345 error = linvfs_init_security(vp, dir);
346 if (error)
347 cleanup_inode(dvp, vp, dentry, mode);
348 }
320 349
321 if (default_acl) { 350 if (default_acl) {
322 if (!error) { 351 if (!error) {
323 error = _ACL_INHERIT(vp, &va, default_acl); 352 error = _ACL_INHERIT(vp, &va, default_acl);
324 if (!error) { 353 if (!error)
325 VMODIFY(vp); 354 VMODIFY(vp);
326 } else { 355 else
327 struct dentry teardown = {}; 356 cleanup_inode(dvp, vp, dentry, mode);
328 int err2;
329
330 /* Oh, the horror.
331 * If we can't add the ACL we must back out.
332 * ENOSPC can hit here, among other things.
333 */
334 teardown.d_inode = ip = LINVFS_GET_IP(vp);
335 teardown.d_name = dentry->d_name;
336
337 if (S_ISDIR(mode))
338 VOP_RMDIR(dvp, &teardown, NULL, err2);
339 else
340 VOP_REMOVE(dvp, &teardown, NULL, err2);
341 VN_RELE(vp);
342 }
343 } 357 }
344 _ACL_FREE(default_acl); 358 _ACL_FREE(default_acl);
345 } 359 }
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index 427cff1a3f83..e27dc8f29972 100644
--- a/include/acpi/acconfig.h
+++ b/include/acpi/acconfig.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -61,9 +61,9 @@
61 * 61 *
62 */ 62 */
63 63
64/* Version string */ 64/* Current ACPICA subsystem version in YYYYMMDD format */
65 65
66#define ACPI_CA_VERSION 0x20050902 66#define ACPI_CA_VERSION 0x20060127
67 67
68/* 68/*
69 * OS name, used for the _OS object. The _OS object is essentially obsolete, 69 * OS name, used for the _OS object. The _OS object is essentially obsolete,
@@ -83,7 +83,7 @@
83#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ 83#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */
84 84
85/* 85/*
86 * Should the subystem abort the loading of an ACPI table if the 86 * Should the subsystem abort the loading of an ACPI table if the
87 * table checksum is incorrect? 87 * table checksum is incorrect?
88 */ 88 */
89#define ACPI_CHECKSUM_ABORT FALSE 89#define ACPI_CHECKSUM_ABORT FALSE
@@ -98,11 +98,6 @@
98 98
99#define ACPI_CA_SUPPORT_LEVEL 3 99#define ACPI_CA_SUPPORT_LEVEL 3
100 100
101/* String size constants */
102
103#define ACPI_MAX_STRING_LENGTH 512
104#define ACPI_PATHNAME_MAX 256 /* A full namespace pathname */
105
106/* Maximum count for a semaphore object */ 101/* Maximum count for a semaphore object */
107 102
108#define ACPI_MAX_SEMAPHORE_COUNT 256 103#define ACPI_MAX_SEMAPHORE_COUNT 256
@@ -115,6 +110,10 @@
115 110
116#define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096 111#define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096
117 112
113/* owner_id tracking. 8 entries allows for 255 owner_ids */
114
115#define ACPI_NUM_OWNERID_MASKS 8
116
118/****************************************************************************** 117/******************************************************************************
119 * 118 *
120 * ACPI Specification constants (Do not change unless the specification changes) 119 * ACPI Specification constants (Do not change unless the specification changes)
@@ -134,14 +133,11 @@
134#define ACPI_METHOD_NUM_ARGS 7 133#define ACPI_METHOD_NUM_ARGS 7
135#define ACPI_METHOD_MAX_ARG 6 134#define ACPI_METHOD_MAX_ARG 6
136 135
137/* Maximum length of resulting string when converting from a buffer */ 136/* Length of _HID, _UID, _CID, and UUID values */
138
139#define ACPI_MAX_STRING_CONVERSION 200
140
141/* Length of _HID, _UID, and _CID values */
142 137
143#define ACPI_DEVICE_ID_LENGTH 0x09 138#define ACPI_DEVICE_ID_LENGTH 0x09
144#define ACPI_MAX_CID_LENGTH 48 139#define ACPI_MAX_CID_LENGTH 48
140#define ACPI_UUID_LENGTH 16
145 141
146/* 142/*
147 * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG 143 * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG
diff --git a/include/acpi/acdebug.h b/include/acpi/acdebug.h
index 70ce3b4d006e..d8167095caf3 100644
--- a/include/acpi/acdebug.h
+++ b/include/acpi/acdebug.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h
index 3d96dcb1bb4b..11a8fe39cb04 100644
--- a/include/acpi/acdisasm.h
+++ b/include/acpi/acdisasm.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -57,26 +57,11 @@ struct acpi_external_list {
57}; 57};
58 58
59extern struct acpi_external_list *acpi_gbl_external_list; 59extern struct acpi_external_list *acpi_gbl_external_list;
60extern const char *acpi_gbl_io_decode[2]; 60
61/* Strings used for decoding flags to ASL keywords */
62
61extern const char *acpi_gbl_word_decode[4]; 63extern const char *acpi_gbl_word_decode[4];
62extern const char *acpi_gbl_consume_decode[2];
63extern const char *acpi_gbl_min_decode[2];
64extern const char *acpi_gbl_max_decode[2];
65extern const char *acpi_gbl_DECdecode[2];
66extern const char *acpi_gbl_RNGdecode[4];
67extern const char *acpi_gbl_MEMdecode[4];
68extern const char *acpi_gbl_RWdecode[2];
69extern const char *acpi_gbl_irq_decode[2]; 64extern const char *acpi_gbl_irq_decode[2];
70extern const char *acpi_gbl_HEdecode[2];
71extern const char *acpi_gbl_LLdecode[2];
72extern const char *acpi_gbl_SHRdecode[2];
73extern const char *acpi_gbl_TYPdecode[4];
74extern const char *acpi_gbl_BMdecode[2];
75extern const char *acpi_gbl_SIZdecode[4];
76extern const char *acpi_gbl_TTPdecode[2];
77extern const char *acpi_gbl_MTPdecode[4];
78extern const char *acpi_gbl_TRSdecode[2];
79
80extern const char *acpi_gbl_lock_rule[ACPI_NUM_LOCK_RULES]; 65extern const char *acpi_gbl_lock_rule[ACPI_NUM_LOCK_RULES];
81extern const char *acpi_gbl_access_types[ACPI_NUM_ACCESS_TYPES]; 66extern const char *acpi_gbl_access_types[ACPI_NUM_ACCESS_TYPES];
82extern const char *acpi_gbl_update_rules[ACPI_NUM_UPDATE_RULES]; 67extern const char *acpi_gbl_update_rules[ACPI_NUM_UPDATE_RULES];
@@ -171,11 +156,19 @@ u8 acpi_dm_is_string_buffer(union acpi_parse_object *op);
171/* 156/*
172 * dmresrc 157 * dmresrc
173 */ 158 */
159void acpi_dm_dump_integer8(u8 value, char *name);
160
161void acpi_dm_dump_integer16(u16 value, char *name);
162
163void acpi_dm_dump_integer32(u32 value, char *name);
164
165void acpi_dm_dump_integer64(u64 value, char *name);
166
174void 167void
175acpi_dm_resource_descriptor(struct acpi_op_walk_info *info, 168acpi_dm_resource_template(struct acpi_op_walk_info *info,
176 u8 * byte_data, u32 byte_count); 169 u8 * byte_data, u32 byte_count);
177 170
178u8 acpi_dm_is_resource_descriptor(union acpi_parse_object *op); 171u8 acpi_dm_is_resource_template(union acpi_parse_object *op);
179 172
180void acpi_dm_indent(u32 level); 173void acpi_dm_indent(u32 level);
181 174
@@ -187,73 +180,69 @@ void acpi_dm_decode_attribute(u8 attribute);
187 * dmresrcl 180 * dmresrcl
188 */ 181 */
189void 182void
190acpi_dm_word_descriptor(struct asl_word_address_desc *resource, 183acpi_dm_word_descriptor(union aml_resource *resource, u32 length, u32 level);
191 u32 length, u32 level);
192 184
193void 185void
194acpi_dm_dword_descriptor(struct asl_dword_address_desc *resource, 186acpi_dm_dword_descriptor(union aml_resource *resource, u32 length, u32 level);
195 u32 length, u32 level);
196 187
197void 188void
198acpi_dm_extended_descriptor(struct asl_extended_address_desc *resource, 189acpi_dm_extended_descriptor(union aml_resource *resource,
199 u32 length, u32 level); 190 u32 length, u32 level);
200 191
201void 192void
202acpi_dm_qword_descriptor(struct asl_qword_address_desc *resource, 193acpi_dm_qword_descriptor(union aml_resource *resource, u32 length, u32 level);
203 u32 length, u32 level);
204 194
205void 195void
206acpi_dm_memory24_descriptor(struct asl_memory_24_desc *resource, 196acpi_dm_memory24_descriptor(union aml_resource *resource,
207 u32 length, u32 level); 197 u32 length, u32 level);
208 198
209void 199void
210acpi_dm_memory32_descriptor(struct asl_memory_32_desc *resource, 200acpi_dm_memory32_descriptor(union aml_resource *resource,
211 u32 length, u32 level); 201 u32 length, u32 level);
212 202
213void 203void
214acpi_dm_fixed_mem32_descriptor(struct asl_fixed_memory_32_desc *resource, 204acpi_dm_fixed_memory32_descriptor(union aml_resource *resource,
215 u32 length, u32 level); 205 u32 length, u32 level);
216 206
217void 207void
218acpi_dm_generic_register_descriptor(struct asl_general_register_desc *resource, 208acpi_dm_generic_register_descriptor(union aml_resource *resource,
219 u32 length, u32 level); 209 u32 length, u32 level);
220 210
221void 211void
222acpi_dm_interrupt_descriptor(struct asl_extended_xrupt_desc *resource, 212acpi_dm_interrupt_descriptor(union aml_resource *resource,
223 u32 length, u32 level); 213 u32 length, u32 level);
224 214
225void 215void
226acpi_dm_vendor_large_descriptor(struct asl_large_vendor_desc *resource, 216acpi_dm_vendor_large_descriptor(union aml_resource *resource,
227 u32 length, u32 level); 217 u32 length, u32 level);
228 218
219void acpi_dm_vendor_common(char *name, u8 * byte_data, u32 length, u32 level);
220
229/* 221/*
230 * dmresrcs 222 * dmresrcs
231 */ 223 */
232void 224void
233acpi_dm_irq_descriptor(struct asl_irq_format_desc *resource, 225acpi_dm_irq_descriptor(union aml_resource *resource, u32 length, u32 level);
234 u32 length, u32 level);
235 226
236void 227void
237acpi_dm_dma_descriptor(struct asl_dma_format_desc *resource, 228acpi_dm_dma_descriptor(union aml_resource *resource, u32 length, u32 level);
238 u32 length, u32 level);
239 229
240void 230void acpi_dm_io_descriptor(union aml_resource *resource, u32 length, u32 level);
241acpi_dm_io_descriptor(struct asl_io_port_desc *resource, u32 length, u32 level);
242 231
243void 232void
244acpi_dm_fixed_io_descriptor(struct asl_fixed_io_port_desc *resource, 233acpi_dm_fixed_io_descriptor(union aml_resource *resource,
245 u32 length, u32 level); 234 u32 length, u32 level);
246 235
247void 236void
248acpi_dm_start_dependent_descriptor(struct asl_start_dependent_desc *resource, 237acpi_dm_start_dependent_descriptor(union aml_resource *resource,
249 u32 length, u32 level); 238 u32 length, u32 level);
250 239
251void 240void
252acpi_dm_end_dependent_descriptor(struct asl_start_dependent_desc *resource, 241acpi_dm_end_dependent_descriptor(union aml_resource *resource,
253 u32 length, u32 level); 242 u32 length, u32 level);
254 243
255void 244void
256acpi_dm_vendor_small_descriptor(struct asl_small_vendor_desc *resource, 245acpi_dm_vendor_small_descriptor(union aml_resource *resource,
257 u32 length, u32 level); 246 u32 length, u32 level);
258 247
259/* 248/*
diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h
index 065f24a77cfc..c41a926ff317 100644
--- a/include/acpi/acdispat.h
+++ b/include/acpi/acdispat.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -201,6 +201,9 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
201 union acpi_operand_object *obj_desc, 201 union acpi_operand_object *obj_desc,
202 struct acpi_namespace_node *calling_method_node); 202 struct acpi_namespace_node *calling_method_node);
203 203
204acpi_status
205acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state);
206
204/* 207/*
205 * dsinit 208 * dsinit
206 */ 209 */
diff --git a/include/acpi/acevents.h b/include/acpi/acevents.h
index bfa54600ecd9..f2717be4fe0d 100644
--- a/include/acpi/acevents.h
+++ b/include/acpi/acevents.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,8 @@ acpi_status acpi_ev_initialize_events(void);
51 51
52acpi_status acpi_ev_install_xrupt_handlers(void); 52acpi_status acpi_ev_install_xrupt_handlers(void);
53 53
54acpi_status acpi_ev_install_fadt_gpes(void);
55
54u32 acpi_ev_fixed_event_detect(void); 56u32 acpi_ev_fixed_event_detect(void);
55 57
56/* 58/*
@@ -105,6 +107,10 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
105 u32 interrupt_number, 107 u32 interrupt_number,
106 struct acpi_gpe_block_info **return_gpe_block); 108 struct acpi_gpe_block_info **return_gpe_block);
107 109
110acpi_status
111acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
112 struct acpi_gpe_block_info *gpe_block);
113
108acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block); 114acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block);
109 115
110u32 116u32
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index 4f005eb65928..dc768aa580e4 100644
--- a/include/acpi/acexcep.h
+++ b/include/acpi/acexcep.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h
index 4ab2ca18b8df..734cc77bf2c7 100644
--- a/include/acpi/acglobal.h
+++ b/include/acpi/acglobal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -80,6 +80,15 @@ extern u32 acpi_dbg_layer;
80 80
81extern u32 acpi_gbl_nesting_level; 81extern u32 acpi_gbl_nesting_level;
82 82
83/* Support for dynamic control method tracing mechanism */
84
85ACPI_EXTERN u32 acpi_gbl_original_dbg_level;
86ACPI_EXTERN u32 acpi_gbl_original_dbg_layer;
87ACPI_EXTERN acpi_name acpi_gbl_trace_method_name;
88ACPI_EXTERN u32 acpi_gbl_trace_dbg_level;
89ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer;
90ACPI_EXTERN u32 acpi_gbl_trace_flags;
91
83/***************************************************************************** 92/*****************************************************************************
84 * 93 *
85 * Runtime configuration (static defaults that can be overriden at runtime) 94 * Runtime configuration (static defaults that can be overriden at runtime)
@@ -89,11 +98,15 @@ extern u32 acpi_gbl_nesting_level;
89/* 98/*
90 * Enable "slack" in the AML interpreter? Default is FALSE, and the 99 * Enable "slack" in the AML interpreter? Default is FALSE, and the
91 * interpreter strictly follows the ACPI specification. Setting to TRUE 100 * interpreter strictly follows the ACPI specification. Setting to TRUE
92 * allows the interpreter to forgive certain bad AML constructs. Currently: 101 * allows the interpreter to ignore certain errors and/or bad AML constructs.
102 *
103 * Currently, these features are enabled by this flag:
104 *
93 * 1) Allow "implicit return" of last value in a control method 105 * 1) Allow "implicit return" of last value in a control method
94 * 2) Allow access beyond end of operation region 106 * 2) Allow access beyond the end of an operation region
95 * 3) Allow access to uninitialized locals/args (auto-init to integer 0) 107 * 3) Allow access to uninitialized locals/args (auto-init to integer 0)
96 * 4) Allow ANY object type to be a source operand for the Store() operator 108 * 4) Allow ANY object type to be a source operand for the Store() operator
109 * 5) Allow unresolved references (invalid target name) in package objects
97 */ 110 */
98ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE); 111ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE);
99 112
@@ -211,9 +224,11 @@ ACPI_EXTERN u32 acpi_gbl_original_mode;
211ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; 224ACPI_EXTERN u32 acpi_gbl_rsdp_original_location;
212ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; 225ACPI_EXTERN u32 acpi_gbl_ns_lookup_count;
213ACPI_EXTERN u32 acpi_gbl_ps_find_count; 226ACPI_EXTERN u32 acpi_gbl_ps_find_count;
214ACPI_EXTERN u64 acpi_gbl_owner_id_mask; 227ACPI_EXTERN u32 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS];
215ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; 228ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save;
216ACPI_EXTERN u16 acpi_gbl_global_lock_handle; 229ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
230ACPI_EXTERN u8 acpi_gbl_last_owner_id_index;
231ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset;
217ACPI_EXTERN u8 acpi_gbl_debugger_configuration; 232ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
218ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; 233ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
219ACPI_EXTERN u8 acpi_gbl_step_to_next_call; 234ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
diff --git a/include/acpi/achware.h b/include/acpi/achware.h
index 3644d7248e7e..29b60a8c0593 100644
--- a/include/acpi/achware.h
+++ b/include/acpi/achware.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acinterp.h b/include/acpi/acinterp.h
index 2c9c1a1d1b7f..9f22cfcb624b 100644
--- a/include/acpi/acinterp.h
+++ b/include/acpi/acinterp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,49 @@
44#ifndef __ACINTERP_H__ 44#ifndef __ACINTERP_H__
45#define __ACINTERP_H__ 45#define __ACINTERP_H__
46 46
47#define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1])) 47#define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1]))
48
49/* Macros for tables used for debug output */
50
51#define ACPI_EXD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_operand_object,f)
52#define ACPI_EXD_NSOFFSET(f) (u8) ACPI_OFFSET (struct acpi_namespace_node,f)
53#define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_exdump_info))
54
55/*
56 * If possible, pack the following structure to byte alignment, since we
57 * don't care about performance for debug output
58 */
59#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
60#pragma pack(1)
61#endif
62
63typedef const struct acpi_exdump_info {
64 u8 opcode;
65 u8 offset;
66 char *name;
67
68} acpi_exdump_info;
69
70/* Values for the Opcode field above */
71
72#define ACPI_EXD_INIT 0
73#define ACPI_EXD_TYPE 1
74#define ACPI_EXD_UINT8 2
75#define ACPI_EXD_UINT16 3
76#define ACPI_EXD_UINT32 4
77#define ACPI_EXD_UINT64 5
78#define ACPI_EXD_LITERAL 6
79#define ACPI_EXD_POINTER 7
80#define ACPI_EXD_ADDRESS 8
81#define ACPI_EXD_STRING 9
82#define ACPI_EXD_BUFFER 10
83#define ACPI_EXD_PACKAGE 11
84#define ACPI_EXD_FIELD 12
85#define ACPI_EXD_REFERENCE 13
86
87/* restore default alignment */
88
89#pragma pack()
48 90
49/* 91/*
50 * exconvrt - object conversion 92 * exconvrt - object conversion
@@ -327,7 +369,7 @@ acpi_ex_dump_operands(union acpi_operand_object **operands,
327void 369void
328acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags); 370acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags);
329 371
330void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags); 372void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags);
331#endif /* ACPI_FUTURE_USAGE */ 373#endif /* ACPI_FUTURE_USAGE */
332 374
333/* 375/*
diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h
index 9fba0fddda90..8361820d2970 100644
--- a/include/acpi/aclocal.h
+++ b/include/acpi/aclocal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -276,6 +276,37 @@ struct acpi_create_field_info {
276 u8 field_type; 276 u8 field_type;
277}; 277};
278 278
279/*
280 * Bitmapped ACPI types. Used internally only
281 */
282#define ACPI_BTYPE_ANY 0x00000000
283#define ACPI_BTYPE_INTEGER 0x00000001
284#define ACPI_BTYPE_STRING 0x00000002
285#define ACPI_BTYPE_BUFFER 0x00000004
286#define ACPI_BTYPE_PACKAGE 0x00000008
287#define ACPI_BTYPE_FIELD_UNIT 0x00000010
288#define ACPI_BTYPE_DEVICE 0x00000020
289#define ACPI_BTYPE_EVENT 0x00000040
290#define ACPI_BTYPE_METHOD 0x00000080
291#define ACPI_BTYPE_MUTEX 0x00000100
292#define ACPI_BTYPE_REGION 0x00000200
293#define ACPI_BTYPE_POWER 0x00000400
294#define ACPI_BTYPE_PROCESSOR 0x00000800
295#define ACPI_BTYPE_THERMAL 0x00001000
296#define ACPI_BTYPE_BUFFER_FIELD 0x00002000
297#define ACPI_BTYPE_DDB_HANDLE 0x00004000
298#define ACPI_BTYPE_DEBUG_OBJECT 0x00008000
299#define ACPI_BTYPE_REFERENCE 0x00010000
300#define ACPI_BTYPE_RESOURCE 0x00020000
301
302#define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
303
304#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE)
305#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
306#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
307#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */
308#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF
309
279/***************************************************************************** 310/*****************************************************************************
280 * 311 *
281 * Event typedefs and structs 312 * Event typedefs and structs
@@ -385,13 +416,13 @@ struct acpi_field_info {
385#define ACPI_CONTROL_PREDICATE_FALSE 0xC3 416#define ACPI_CONTROL_PREDICATE_FALSE 0xC3
386#define ACPI_CONTROL_PREDICATE_TRUE 0xC4 417#define ACPI_CONTROL_PREDICATE_TRUE 0xC4
387 418
388#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ 419#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\
389 u8 data_type; /* To differentiate various internal objs */\ 420 u8 data_type; /* To differentiate various internal objs */\
390 u8 flags; \ 421 u8 flags; \
391 u16 value; \ 422 u16 value; \
392 u16 state; \ 423 u16 state; \
393 u16 reserved; \ 424 u16 reserved; \
394 void *next; \ 425 void *next;
395 426
396struct acpi_common_state { 427struct acpi_common_state {
397ACPI_STATE_COMMON}; 428ACPI_STATE_COMMON};
@@ -544,8 +575,7 @@ union acpi_parse_value {
544 char aml_op_name[16]) /* Op name (debug only) */\ 575 char aml_op_name[16]) /* Op name (debug only) */\
545 /* NON-DEBUG members below: */\ 576 /* NON-DEBUG members below: */\
546 struct acpi_namespace_node *node; /* For use by interpreter */\ 577 struct acpi_namespace_node *node; /* For use by interpreter */\
547 union acpi_parse_value value; /* Value or args associated with the opcode */\ 578 union acpi_parse_value value; /* Value or args associated with the opcode */
548
549 579
550#define ACPI_DASM_BUFFER 0x00 580#define ACPI_DASM_BUFFER 0x00
551#define ACPI_DASM_RESOURCE 0x01 581#define ACPI_DASM_RESOURCE 0x01
@@ -573,6 +603,8 @@ struct acpi_parse_obj_named {
573 603
574/* The parse node is the fundamental element of the parse tree */ 604/* The parse node is the fundamental element of the parse tree */
575 605
606#define ACPI_MAX_PARSEOP_NAME 20
607
576struct acpi_parse_obj_asl { 608struct acpi_parse_obj_asl {
577 ACPI_PARSE_COMMON union acpi_parse_object *child; 609 ACPI_PARSE_COMMON union acpi_parse_object *child;
578 union acpi_parse_object *parent_method; 610 union acpi_parse_object *parent_method;
@@ -597,7 +629,7 @@ struct acpi_parse_obj_asl {
597 u8 aml_opcode_length; 629 u8 aml_opcode_length;
598 u8 aml_pkg_len_bytes; 630 u8 aml_pkg_len_bytes;
599 u8 extra; 631 u8 extra;
600 char parse_op_name[12]; 632 char parse_op_name[ACPI_MAX_PARSEOP_NAME];
601}; 633};
602 634
603union acpi_parse_object { 635union acpi_parse_object {
@@ -735,44 +767,52 @@ struct acpi_bit_register_info {
735 767
736/* resource_type values */ 768/* resource_type values */
737 769
738#define ACPI_RESOURCE_TYPE_MEMORY_RANGE 0 770#define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0
739#define ACPI_RESOURCE_TYPE_IO_RANGE 1 771#define ACPI_ADDRESS_TYPE_IO_RANGE 1
740#define ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE 2 772#define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2
741 773
742/* Resource descriptor types and masks */ 774/* Resource descriptor types and masks */
743 775
744#define ACPI_RDESC_TYPE_LARGE 0x80 776#define ACPI_RESOURCE_NAME_LARGE 0x80
745#define ACPI_RDESC_TYPE_SMALL 0x00 777#define ACPI_RESOURCE_NAME_SMALL 0x00
746 778
747#define ACPI_RDESC_TYPE_MASK 0x80 779#define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */
748#define ACPI_RDESC_SMALL_MASK 0x78 /* Only bits 6:3 contain the type */ 780#define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */
781#define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */
749 782
750/* 783/*
751 * Small resource descriptor types 784 * Small resource descriptor "names" as defined by the ACPI specification.
752 * Note: The 3 length bits (2:0) must be zero 785 * Note: Bits 2:0 are used for the descriptor length
753 */ 786 */
754#define ACPI_RDESC_TYPE_IRQ_FORMAT 0x20 787#define ACPI_RESOURCE_NAME_IRQ 0x20
755#define ACPI_RDESC_TYPE_DMA_FORMAT 0x28 788#define ACPI_RESOURCE_NAME_DMA 0x28
756#define ACPI_RDESC_TYPE_START_DEPENDENT 0x30 789#define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30
757#define ACPI_RDESC_TYPE_END_DEPENDENT 0x38 790#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38
758#define ACPI_RDESC_TYPE_IO_PORT 0x40 791#define ACPI_RESOURCE_NAME_IO 0x40
759#define ACPI_RDESC_TYPE_FIXED_IO_PORT 0x48 792#define ACPI_RESOURCE_NAME_FIXED_IO 0x48
760#define ACPI_RDESC_TYPE_SMALL_VENDOR 0x70 793#define ACPI_RESOURCE_NAME_RESERVED_S1 0x50
761#define ACPI_RDESC_TYPE_END_TAG 0x78 794#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58
795#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60
796#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68
797#define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70
798#define ACPI_RESOURCE_NAME_END_TAG 0x78
762 799
763/* 800/*
764 * Large resource descriptor types 801 * Large resource descriptor "names" as defined by the ACPI specification.
802 * Note: includes the Large Descriptor bit in bit[7]
765 */ 803 */
766#define ACPI_RDESC_TYPE_MEMORY_24 0x81 804#define ACPI_RESOURCE_NAME_MEMORY24 0x81
767#define ACPI_RDESC_TYPE_GENERAL_REGISTER 0x82 805#define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82
768#define ACPI_RDESC_TYPE_LARGE_VENDOR 0x84 806#define ACPI_RESOURCE_NAME_RESERVED_L1 0x83
769#define ACPI_RDESC_TYPE_MEMORY_32 0x85 807#define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84
770#define ACPI_RDESC_TYPE_FIXED_MEMORY_32 0x86 808#define ACPI_RESOURCE_NAME_MEMORY32 0x85
771#define ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE 0x87 809#define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86
772#define ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE 0x88 810#define ACPI_RESOURCE_NAME_ADDRESS32 0x87
773#define ACPI_RDESC_TYPE_EXTENDED_XRUPT 0x89 811#define ACPI_RESOURCE_NAME_ADDRESS16 0x88
774#define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A 812#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89
775#define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B 813#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A
814#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B
815#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B
776 816
777/***************************************************************************** 817/*****************************************************************************
778 * 818 *
@@ -780,7 +820,7 @@ struct acpi_bit_register_info {
780 * 820 *
781 ****************************************************************************/ 821 ****************************************************************************/
782 822
783#define ACPI_ASCII_ZERO 0x30 823#define ACPI_ASCII_ZERO 0x30
784 824
785/***************************************************************************** 825/*****************************************************************************
786 * 826 *
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index 702cc4e57f5f..f2be2a881730 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -60,7 +60,7 @@
60 60
61/* 61/*
62 * For 16-bit addresses, we have to assume that the upper 32 bits 62 * For 16-bit addresses, we have to assume that the upper 32 bits
63 * are zero. 63 * (out of 64) are zero.
64 */ 64 */
65#define ACPI_LODWORD(l) ((u32)(l)) 65#define ACPI_LODWORD(l) ((u32)(l))
66#define ACPI_HIDWORD(l) ((u32)(0)) 66#define ACPI_HIDWORD(l) ((u32)(0))
@@ -104,30 +104,38 @@
104#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i) 104#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i)
105 105
106/* 106/*
107 * Extract a byte of data using a pointer. Any more than a byte and we 107 * Extract data using a pointer. Any more than a byte and we
108 * get into potential aligment issues -- see the STORE macros below 108 * get into potential aligment issues -- see the STORE macros below.
109 * Use with care.
109 */ 110 */
110#define ACPI_GET8(addr) (*(u8*)(addr)) 111#define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr)
112#define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr)
113#define ACPI_GET32(ptr) *ACPI_CAST_PTR (u32, ptr)
114#define ACPI_GET64(ptr) *ACPI_CAST_PTR (u64, ptr)
115#define ACPI_SET8(ptr) *ACPI_CAST_PTR (u8, ptr)
116#define ACPI_SET16(ptr) *ACPI_CAST_PTR (u16, ptr)
117#define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr)
118#define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr)
111 119
112/* Pointer arithmetic */ 120/*
113 121 * Pointer manipulation
114#define ACPI_PTR_ADD(t,a,b) (t *) (void *)((char *)(a) + (acpi_native_uint)(b)) 122 */
115#define ACPI_PTR_DIFF(a,b) (acpi_native_uint) ((char *)(a) - (char *)(b)) 123#define ACPI_CAST_PTR(t, p) ((t *) (acpi_uintptr_t) (p))
124#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (acpi_uintptr_t) (p))
125#define ACPI_ADD_PTR(t,a,b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8,(a)) + (acpi_native_uint)(b)))
126#define ACPI_PTR_DIFF(a,b) (acpi_native_uint) (ACPI_CAST_PTR (u8,(a)) - ACPI_CAST_PTR (u8,(b)))
116 127
117/* Pointer/Integer type conversions */ 128/* Pointer/Integer type conversions */
118 129
119#define ACPI_TO_POINTER(i) ACPI_PTR_ADD (void, (void *) NULL,(acpi_native_uint)i) 130#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void,(void *) NULL,(acpi_native_uint) i)
120#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) 131#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL)
121#define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) 132#define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL)
122#define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f) 133#define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f)
123 134
124#define ACPI_CAST_PTR(t, p) ((t *)(void *)(p))
125#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **)(void *)(p))
126
127#if ACPI_MACHINE_WIDTH == 16 135#if ACPI_MACHINE_WIDTH == 16
128#define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) 136#define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s)
129#define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) 137#define ACPI_PHYSADDR_TO_PTR(i) (void *)(i)
130#define ACPI_PTR_TO_PHYSADDR(i) (u32) (char *)(i) 138#define ACPI_PTR_TO_PHYSADDR(i) (u32) ACPI_CAST_PTR (u8,(i))
131#else 139#else
132#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) 140#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i)
133#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) 141#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)
@@ -202,7 +210,7 @@
202 210
203#define ACPI_BUFFER_INDEX(buf_len,buf_offset,byte_gran) (buf_offset) 211#define ACPI_BUFFER_INDEX(buf_len,buf_offset,byte_gran) (buf_offset)
204 212
205#ifdef ACPI_MISALIGNED_TRANSFERS 213#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
206 214
207/* The hardware supports unaligned transfers, just do the little-endian move */ 215/* The hardware supports unaligned transfers, just do the little-endian move */
208 216
@@ -326,11 +334,19 @@
326#define ACPI_MUL_16(a) _ACPI_MUL(a,4) 334#define ACPI_MUL_16(a) _ACPI_MUL(a,4)
327#define ACPI_MOD_16(a) _ACPI_MOD(a,16) 335#define ACPI_MOD_16(a) _ACPI_MOD(a,16)
328 336
337#define ACPI_DIV_32(a) _ACPI_DIV(a,5)
338#define ACPI_MUL_32(a) _ACPI_MUL(a,5)
339#define ACPI_MOD_32(a) _ACPI_MOD(a,32)
340
329/* 341/*
330 * Rounding macros (Power of two boundaries only) 342 * Rounding macros (Power of two boundaries only)
331 */ 343 */
332#define ACPI_ROUND_DOWN(value,boundary) (((acpi_native_uint)(value)) & (~(((acpi_native_uint) boundary)-1))) 344#define ACPI_ROUND_DOWN(value,boundary) (((acpi_native_uint)(value)) & \
333#define ACPI_ROUND_UP(value,boundary) ((((acpi_native_uint)(value)) + (((acpi_native_uint) boundary)-1)) & (~(((acpi_native_uint) boundary)-1))) 345 (~(((acpi_native_uint) boundary)-1)))
346
347#define ACPI_ROUND_UP(value,boundary) ((((acpi_native_uint)(value)) + \
348 (((acpi_native_uint) boundary)-1)) & \
349 (~(((acpi_native_uint) boundary)-1)))
334 350
335#define ACPI_ROUND_DOWN_TO_32_BITS(a) ACPI_ROUND_DOWN(a,4) 351#define ACPI_ROUND_DOWN_TO_32_BITS(a) ACPI_ROUND_DOWN(a,4)
336#define ACPI_ROUND_DOWN_TO_64_BITS(a) ACPI_ROUND_DOWN(a,8) 352#define ACPI_ROUND_DOWN_TO_64_BITS(a) ACPI_ROUND_DOWN(a,8)
@@ -365,6 +381,14 @@
365#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) 381#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask)
366#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask) 382#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
367 383
384/* Generate a UUID */
385
386#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
387 (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \
388 (b) & 0xFF, ((b) >> 8) & 0xFF, \
389 (c) & 0xFF, ((c) >> 8) & 0xFF, \
390 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)
391
368/* 392/*
369 * An struct acpi_namespace_node * can appear in some contexts, 393 * An struct acpi_namespace_node * can appear in some contexts,
370 * where a pointer to an union acpi_operand_object can also 394 * where a pointer to an union acpi_operand_object can also
@@ -423,57 +447,52 @@
423#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F)) 447#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F))
424#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH)) 448#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH))
425 449
450#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES)
426/* 451/*
427 * Reporting macros that are never compiled out 452 * Module name is include in both debug and non-debug versions primarily for
453 * error messages. The __FILE__ macro is not very useful for this, because it
454 * often includes the entire pathname to the module
428 */ 455 */
429#define ACPI_PARAM_LIST(pl) pl 456#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_acpi_module_name = name;
457#else
458#define ACPI_MODULE_NAME(name)
459#endif
430 460
431/* 461/*
432 * Error reporting. These versions add callers module and line#. 462 * Ascii error messages can be configured out
433 *
434 * Since _acpi_module_name gets compiled out when ACPI_DEBUG_OUTPUT
435 * isn't defined, only use it in debug mode.
436 */ 463 */
437#ifdef ACPI_DEBUG_OUTPUT 464#ifndef ACPI_NO_ERROR_MESSAGES
465#define AE_INFO _acpi_module_name, __LINE__
438 466
439#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info(_acpi_module_name,__LINE__,_COMPONENT); \ 467/*
440 acpi_os_printf ACPI_PARAM_LIST(fp);} 468 * Error reporting. Callers module and line number are inserted by AE_INFO,
441#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error(_acpi_module_name,__LINE__,_COMPONENT); \ 469 * the plist contains a set of parens to allow variable-length lists.
442 acpi_os_printf ACPI_PARAM_LIST(fp);} 470 * These macros are used for both the debug and non-debug versions of the code.
443#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning(_acpi_module_name,__LINE__,_COMPONENT); \ 471 */
444 acpi_os_printf ACPI_PARAM_LIST(fp);} 472#define ACPI_INFO(plist) acpi_ut_info plist
445#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error(_acpi_module_name,__LINE__,_COMPONENT, s, e); 473#define ACPI_WARNING(plist) acpi_ut_warning plist
446 474#define ACPI_EXCEPTION(plist) acpi_ut_exception plist
447#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) acpi_ns_report_method_error(_acpi_module_name,__LINE__,_COMPONENT, s, n, p, e); 475#define ACPI_ERROR(plist) acpi_ut_error plist
476#define ACPI_ERROR_NAMESPACE(s,e) acpi_ns_report_error (AE_INFO, s, e);
477#define ACPI_ERROR_METHOD(s,n,p,e) acpi_ns_report_method_error (AE_INFO, s, n, p, e);
448 478
449#else 479#else
450 480
451#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info("ACPI",__LINE__,_COMPONENT); \ 481/* No error messages */
452 acpi_os_printf ACPI_PARAM_LIST(fp);}
453#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error("ACPI",__LINE__,_COMPONENT); \
454 acpi_os_printf ACPI_PARAM_LIST(fp);}
455#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning("ACPI",__LINE__,_COMPONENT); \
456 acpi_os_printf ACPI_PARAM_LIST(fp);}
457#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error("ACPI",__LINE__,_COMPONENT, s, e);
458 482
459#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) acpi_ns_report_method_error("ACPI",__LINE__,_COMPONENT, s, n, p, e); 483#define ACPI_INFO(plist)
484#define ACPI_WARNING(plist)
485#define ACPI_EXCEPTION(plist)
486#define ACPI_ERROR(plist)
487#define ACPI_ERROR_NAMESPACE(s,e)
488#define ACPI_ERROR_METHOD(s,n,p,e)
460 489
461#endif 490#endif
462 491
463/* Error reporting. These versions pass thru the module and line# */
464
465#define _ACPI_REPORT_INFO(a,b,c,fp) {acpi_ut_report_info(a,b,c); \
466 acpi_os_printf ACPI_PARAM_LIST(fp);}
467#define _ACPI_REPORT_ERROR(a,b,c,fp) {acpi_ut_report_error(a,b,c); \
468 acpi_os_printf ACPI_PARAM_LIST(fp);}
469#define _ACPI_REPORT_WARNING(a,b,c,fp) {acpi_ut_report_warning(a,b,c); \
470 acpi_os_printf ACPI_PARAM_LIST(fp);}
471
472/* 492/*
473 * Debug macros that are conditionally compiled 493 * Debug macros that are conditionally compiled
474 */ 494 */
475#ifdef ACPI_DEBUG_OUTPUT 495#ifdef ACPI_DEBUG_OUTPUT
476#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_acpi_module_name = name;
477 496
478/* 497/*
479 * Common parameters used for debug output functions: 498 * Common parameters used for debug output functions:
@@ -509,7 +528,7 @@
509#endif 528#endif
510 529
511#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ 530#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
512 acpi_ut_trace(ACPI_DEBUG_PARAMETERS) 531 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
513#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ 532#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \
514 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b) 533 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b)
515#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ 534#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \
@@ -525,6 +544,9 @@
525 * bad form, but having a separate exit macro is very ugly and difficult to maintain. 544 * bad form, but having a separate exit macro is very ugly and difficult to maintain.
526 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros 545 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
527 * so that "_acpi_function_name" is defined. 546 * so that "_acpi_function_name" is defined.
547 *
548 * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining
549 * about these constructs.
528 */ 550 */
529#ifdef ACPI_USE_DO_WHILE_0 551#ifdef ACPI_USE_DO_WHILE_0
530#define ACPI_DO_WHILE0(a) do a while(0) 552#define ACPI_DO_WHILE0(a) do a while(0)
@@ -532,10 +554,55 @@
532#define ACPI_DO_WHILE0(a) a 554#define ACPI_DO_WHILE0(a) a
533#endif 555#endif
534 556
535#define return_VOID ACPI_DO_WHILE0 ({acpi_ut_exit(ACPI_DEBUG_PARAMETERS);return;}) 557#define return_VOID ACPI_DO_WHILE0 ({ \
536#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({acpi_ut_status_exit(ACPI_DEBUG_PARAMETERS,(s));return((s));}) 558 acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \
537#define return_VALUE(s) ACPI_DO_WHILE0 ({acpi_ut_value_exit(ACPI_DEBUG_PARAMETERS,(acpi_integer)(s));return((s));}) 559 return;})
538#define return_PTR(s) ACPI_DO_WHILE0 ({acpi_ut_ptr_exit(ACPI_DEBUG_PARAMETERS,(u8 *)(s));return((s));}) 560/*
561 * There are two versions of most of the return macros. The default version is
562 * safer, since it avoids side-effects by guaranteeing that the argument will
563 * not be evaluated twice.
564 *
565 * A less-safe version of the macros is provided for optional use if the
566 * compiler uses excessive CPU stack (for example, this may happen in the
567 * debug case if code optimzation is disabled.)
568 */
569#ifndef ACPI_SIMPLE_RETURN_MACROS
570
571#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \
572 register acpi_status _s = (s); \
573 acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, _s); \
574 return (_s); })
575#define return_PTR(s) ACPI_DO_WHILE0 ({ \
576 register void *_s = (void *) (s); \
577 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \
578 return (_s); })
579#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
580 register acpi_integer _s = (s); \
581 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \
582 return (_s); })
583#define return_UINT8(s) ACPI_DO_WHILE0 ({ \
584 register u8 _s = (u8) (s); \
585 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \
586 return (_s); })
587#define return_UINT32(s) ACPI_DO_WHILE0 ({ \
588 register u32 _s = (u32) (s); \
589 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \
590 return (_s); })
591#else /* Use original less-safe macros */
592
593#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \
594 acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, (s)); \
595 return((s)); })
596#define return_PTR(s) ACPI_DO_WHILE0 ({ \
597 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \
598 return((s)); })
599#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
600 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) (s)); \
601 return((s)); })
602#define return_UINT8(s) return_VALUE(s)
603#define return_UINT32(s) return_VALUE(s)
604
605#endif /* ACPI_SIMPLE_RETURN_MACROS */
539 606
540/* Conditional execution */ 607/* Conditional execution */
541 608
@@ -555,18 +622,6 @@
555#define ACPI_DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d) 622#define ACPI_DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d)
556#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a) 623#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a)
557#define ACPI_DUMP_BUFFER(a,b) acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) 624#define ACPI_DUMP_BUFFER(a,b) acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
558#define ACPI_BREAK_MSG(a) acpi_os_signal (ACPI_SIGNAL_BREAKPOINT,(a))
559
560/*
561 * Generate INT3 on ACPI_ERROR (Debug only!)
562 */
563#define ACPI_ERROR_BREAK
564#ifdef ACPI_ERROR_BREAK
565#define ACPI_BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) \
566 acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,"Fatal error encountered\n")
567#else
568#define ACPI_BREAK_ON_ERROR(lvl)
569#endif
570 625
571/* 626/*
572 * Master debug print macros 627 * Master debug print macros
@@ -574,17 +629,14 @@
574 * 1) Debug print for the current component is enabled 629 * 1) Debug print for the current component is enabled
575 * 2) Debug error level or trace level for the print statement is enabled 630 * 2) Debug error level or trace level for the print statement is enabled
576 */ 631 */
577#define ACPI_DEBUG_PRINT(pl) acpi_ut_debug_print ACPI_PARAM_LIST(pl) 632#define ACPI_DEBUG_PRINT(plist) acpi_ut_debug_print plist
578#define ACPI_DEBUG_PRINT_RAW(pl) acpi_ut_debug_print_raw ACPI_PARAM_LIST(pl) 633#define ACPI_DEBUG_PRINT_RAW(plist) acpi_ut_debug_print_raw plist
579 634
580#else 635#else
581/* 636/*
582 * This is the non-debug case -- make everything go away, 637 * This is the non-debug case -- make everything go away,
583 * leaving no executable debug code! 638 * leaving no executable debug code!
584 */ 639 */
585#define ACPI_MODULE_NAME(name)
586#define _acpi_module_name ""
587
588#define ACPI_DEBUG_EXEC(a) 640#define ACPI_DEBUG_EXEC(a)
589#define ACPI_NORMAL_EXEC(a) a; 641#define ACPI_NORMAL_EXEC(a) a;
590 642
@@ -607,11 +659,12 @@
607#define ACPI_DUMP_BUFFER(a,b) 659#define ACPI_DUMP_BUFFER(a,b)
608#define ACPI_DEBUG_PRINT(pl) 660#define ACPI_DEBUG_PRINT(pl)
609#define ACPI_DEBUG_PRINT_RAW(pl) 661#define ACPI_DEBUG_PRINT_RAW(pl)
610#define ACPI_BREAK_MSG(a)
611 662
612#define return_VOID return 663#define return_VOID return
613#define return_ACPI_STATUS(s) return(s) 664#define return_ACPI_STATUS(s) return(s)
614#define return_VALUE(s) return(s) 665#define return_VALUE(s) return(s)
666#define return_UINT8(s) return(s)
667#define return_UINT32(s) return(s)
615#define return_PTR(s) return(s) 668#define return_PTR(s) return(s)
616 669
617#endif 670#endif
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h
index 4f9063f3e951..b67da3636899 100644
--- a/include/acpi/acnames.h
+++ b/include/acpi/acnames.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h
index dd3501f7e5d6..b667a804fc8a 100644
--- a/include/acpi/acnamesp.h
+++ b/include/acpi/acnamesp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -263,13 +263,11 @@ u32 acpi_ns_local(acpi_object_type type);
263void 263void
264acpi_ns_report_error(char *module_name, 264acpi_ns_report_error(char *module_name,
265 u32 line_number, 265 u32 line_number,
266 u32 component_id,
267 char *internal_name, acpi_status lookup_status); 266 char *internal_name, acpi_status lookup_status);
268 267
269void 268void
270acpi_ns_report_method_error(char *module_name, 269acpi_ns_report_method_error(char *module_name,
271 u32 line_number, 270 u32 line_number,
272 u32 component_id,
273 char *message, 271 char *message,
274 struct acpi_namespace_node *node, 272 struct acpi_namespace_node *node,
275 char *path, acpi_status lookup_status); 273 char *path, acpi_status lookup_status);
diff --git a/include/acpi/acobject.h b/include/acpi/acobject.h
index 4a326ba6d482..d130cfed8d55 100644
--- a/include/acpi/acobject.h
+++ b/include/acpi/acobject.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -69,7 +69,7 @@
69 u8 type; /* acpi_object_type */\ 69 u8 type; /* acpi_object_type */\
70 u16 reference_count; /* For object deletion management */\ 70 u16 reference_count; /* For object deletion management */\
71 union acpi_operand_object *next_object; /* Objects linked to parent NS node */\ 71 union acpi_operand_object *next_object; /* Objects linked to parent NS node */\
72 u8 flags; \ 72 u8 flags;
73 73
74/* Values for flag byte above */ 74/* Values for flag byte above */
75 75
diff --git a/include/acpi/acopcode.h b/include/acpi/acopcode.h
index 64da42992199..e6d78bd9e90a 100644
--- a/include/acpi/acopcode.h
+++ b/include/acpi/acopcode.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h
index 68d7edf0f697..7785d481dc3e 100644
--- a/include/acpi/acoutput.h
+++ b/include/acpi/acoutput.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -137,13 +137,19 @@
137 137
138/* Exception level -- used in the global "debug_level" */ 138/* Exception level -- used in the global "debug_level" */
139 139
140#define ACPI_DB_ERROR ACPI_DEBUG_LEVEL (ACPI_LV_ERROR)
141#define ACPI_DB_WARN ACPI_DEBUG_LEVEL (ACPI_LV_WARN)
142#define ACPI_DB_INIT ACPI_DEBUG_LEVEL (ACPI_LV_INIT) 140#define ACPI_DB_INIT ACPI_DEBUG_LEVEL (ACPI_LV_INIT)
143#define ACPI_DB_DEBUG_OBJECT ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT) 141#define ACPI_DB_DEBUG_OBJECT ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT)
144#define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO) 142#define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO)
145#define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS) 143#define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS)
146 144
145/*
146 * These two levels are essentially obsolete, all instances in the
147 * ACPICA core code have been replaced by REPORT_ERROR and REPORT_WARNING
148 * (Kept here because some drivers may still use them)
149 */
150#define ACPI_DB_ERROR ACPI_DEBUG_LEVEL (ACPI_LV_ERROR)
151#define ACPI_DB_WARN ACPI_DEBUG_LEVEL (ACPI_LV_WARN)
152
147/* Trace level -- also used in the global "debug_level" */ 153/* Trace level -- also used in the global "debug_level" */
148 154
149#define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES) 155#define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES)
diff --git a/include/acpi/acparser.h b/include/acpi/acparser.h
index d352d40de1f3..5a1ff484af33 100644
--- a/include/acpi/acparser.h
+++ b/include/acpi/acparser.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
index ccf34f9dac64..b9a39d1009bd 100644
--- a/include/acpi/acpi.h
+++ b/include/acpi/acpi.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index c1b4e1f882e4..b425f9bb6d43 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -52,8 +52,8 @@
52/* ACPI PCI Interrupt Link (pci_link.c) */ 52/* ACPI PCI Interrupt Link (pci_link.c) */
53 53
54int acpi_irq_penalty_init(void); 54int acpi_irq_penalty_init(void);
55int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *edge_level, 55int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
56 int *active_high_low, char **name); 56 int *polarity, char **name);
57int acpi_pci_link_free_irq(acpi_handle handle); 57int acpi_pci_link_free_irq(acpi_handle handle);
58 58
59/* ACPI PCI Interrupt Routing (pci_irq.c) */ 59/* ACPI PCI Interrupt Routing (pci_irq.c) */
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 98e0b8cd14ed..970e9a6372c3 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -8,7 +8,7 @@
8 *****************************************************************************/ 8 *****************************************************************************/
9 9
10/* 10/*
11 * Copyright (C) 2000 - 2005, R. Byron Moore 11 * Copyright (C) 2000 - 2006, R. Byron Moore
12 * All rights reserved. 12 * All rights reserved.
13 * 13 *
14 * Redistribution and use in source and binary forms, with or without 14 * Redistribution and use in source and binary forms, with or without
@@ -108,9 +108,9 @@ acpi_status acpi_os_create_lock(acpi_handle * out_handle);
108 108
109void acpi_os_delete_lock(acpi_handle handle); 109void acpi_os_delete_lock(acpi_handle handle);
110 110
111unsigned long acpi_os_acquire_lock(acpi_handle handle); 111acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle);
112 112
113void acpi_os_release_lock(acpi_handle handle, unsigned long flags); 113void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags);
114 114
115/* 115/*
116 * Memory allocation and mapping 116 * Memory allocation and mapping
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 2a9dbc13b0f2..66cf2ecef57a 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -149,6 +149,9 @@ acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler);
149acpi_status 149acpi_status
150acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data); 150acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data);
151 151
152acpi_status
153acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags);
154
152/* 155/*
153 * Object manipulation and enumeration 156 * Object manipulation and enumeration
154 */ 157 */
@@ -269,6 +272,12 @@ acpi_status(*ACPI_WALK_RESOURCE_CALLBACK) (struct acpi_resource * resource,
269 void *context); 272 void *context);
270 273
271acpi_status 274acpi_status
275acpi_get_vendor_resource(acpi_handle device_handle,
276 char *name,
277 struct acpi_vendor_uuid *uuid,
278 struct acpi_buffer *ret_buffer);
279
280acpi_status
272acpi_get_current_resources(acpi_handle device_handle, 281acpi_get_current_resources(acpi_handle device_handle,
273 struct acpi_buffer *ret_buffer); 282 struct acpi_buffer *ret_buffer);
274 283
@@ -280,7 +289,7 @@ acpi_get_possible_resources(acpi_handle device_handle,
280 289
281acpi_status 290acpi_status
282acpi_walk_resources(acpi_handle device_handle, 291acpi_walk_resources(acpi_handle device_handle,
283 char *path, 292 char *name,
284 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context); 293 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context);
285 294
286acpi_status 295acpi_status
diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h
index 38e798b05d08..fa02e8083381 100644
--- a/include/acpi/acresrc.h
+++ b/include/acpi/acresrc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,216 +44,284 @@
44#ifndef __ACRESRC_H__ 44#ifndef __ACRESRC_H__
45#define __ACRESRC_H__ 45#define __ACRESRC_H__
46 46
47/* 47/* Need the AML resource descriptor structs */
48 * Function prototypes called from Acpi* APIs
49 */
50acpi_status
51acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
52 48
53acpi_status 49#include "amlresrc.h"
54acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
55 50
56#ifdef ACPI_FUTURE_USAGE 51/*
57acpi_status 52 * If possible, pack the following structures to byte alignment, since we
58acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer); 53 * don't care about performance for debug output
59#endif /* ACPI_FUTURE_USAGE */ 54 */
60 55#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
61acpi_status 56#pragma pack(1)
62acpi_rs_get_method_data(acpi_handle handle, 57#endif
63 char *path, struct acpi_buffer *ret_buffer);
64 58
65acpi_status 59/*
66acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer); 60 * Individual entry for the resource conversion tables
61 */
62typedef const struct acpi_rsconvert_info {
63 u8 opcode;
64 u8 resource_offset;
65 u8 aml_offset;
66 u8 value;
67
68} acpi_rsconvert_info;
69
70/* Resource conversion opcodes */
71
72#define ACPI_RSC_INITGET 0
73#define ACPI_RSC_INITSET 1
74#define ACPI_RSC_FLAGINIT 2
75#define ACPI_RSC_1BITFLAG 3
76#define ACPI_RSC_2BITFLAG 4
77#define ACPI_RSC_COUNT 5
78#define ACPI_RSC_COUNT16 6
79#define ACPI_RSC_LENGTH 7
80#define ACPI_RSC_MOVE8 8
81#define ACPI_RSC_MOVE16 9
82#define ACPI_RSC_MOVE32 10
83#define ACPI_RSC_MOVE64 11
84#define ACPI_RSC_SET8 12
85#define ACPI_RSC_DATA8 13
86#define ACPI_RSC_ADDRESS 14
87#define ACPI_RSC_SOURCE 15
88#define ACPI_RSC_SOURCEX 16
89#define ACPI_RSC_BITMASK 17
90#define ACPI_RSC_BITMASK16 18
91#define ACPI_RSC_EXIT_NE 19
92#define ACPI_RSC_EXIT_LE 20
93
94/* Resource Conversion sub-opcodes */
95
96#define ACPI_RSC_COMPARE_AML_LENGTH 0
97#define ACPI_RSC_COMPARE_VALUE 1
98
99#define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (struct acpi_rsconvert_info))
100
101#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f)
102#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f)
103
104typedef const struct acpi_rsdump_info {
105 u8 opcode;
106 u8 offset;
107 char *name;
108 const char **pointer;
109
110} acpi_rsdump_info;
111
112/* Values for the Opcode field above */
113
114#define ACPI_RSD_TITLE 0
115#define ACPI_RSD_LITERAL 1
116#define ACPI_RSD_STRING 2
117#define ACPI_RSD_UINT8 3
118#define ACPI_RSD_UINT16 4
119#define ACPI_RSD_UINT32 5
120#define ACPI_RSD_UINT64 6
121#define ACPI_RSD_1BITFLAG 7
122#define ACPI_RSD_2BITFLAG 8
123#define ACPI_RSD_SHORTLIST 9
124#define ACPI_RSD_LONGLIST 10
125#define ACPI_RSD_DWORDLIST 11
126#define ACPI_RSD_ADDRESS 12
127#define ACPI_RSD_SOURCE 13
128
129/* restore default alignment */
130
131#pragma pack()
132
133/* Resource tables indexed by internal resource type */
134
135extern const u8 acpi_gbl_aml_resource_sizes[];
136extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
137
138/* Resource tables indexed by raw AML resource descriptor type */
139
140extern const u8 acpi_gbl_resource_struct_sizes[];
141extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
142
143struct acpi_vendor_walk_info {
144 struct acpi_vendor_uuid *uuid;
145 struct acpi_buffer *buffer;
146 acpi_status status;
147};
67 148
149/*
150 * rscreate
151 */
68acpi_status 152acpi_status
69acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, 153acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
70 struct acpi_buffer *output_buffer); 154 struct acpi_buffer *output_buffer);
71 155
72acpi_status 156acpi_status
73acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, 157acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
74 struct acpi_buffer *output_buffer); 158 struct acpi_buffer *output_buffer);
75 159
76acpi_status 160acpi_status
77acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, 161acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
78 struct acpi_buffer *output_buffer); 162 struct acpi_buffer *output_buffer);
79 163
80/* 164/*
81 * rsdump 165 * rsutils
82 */ 166 */
83#ifdef ACPI_FUTURE_USAGE
84void acpi_rs_dump_resource_list(struct acpi_resource *resource);
85
86void acpi_rs_dump_irq_list(u8 * route_table);
87#endif /* ACPI_FUTURE_USAGE */
88
89/*
90 * rscalc
91 */
92acpi_status
93acpi_rs_get_byte_stream_start(u8 * byte_stream_buffer,
94 u8 ** byte_stream_start, u32 * size);
95
96acpi_status
97acpi_rs_get_list_length(u8 * byte_stream_buffer,
98 u32 byte_stream_buffer_length, acpi_size * size_needed);
99
100acpi_status
101acpi_rs_get_byte_stream_length(struct acpi_resource *linked_list_buffer,
102 acpi_size * size_needed);
103
104acpi_status
105acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
106 acpi_size * buffer_size_needed);
107
108acpi_status
109acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer,
110 u32 byte_stream_buffer_length, u8 * output_buffer);
111
112acpi_status
113acpi_rs_list_to_byte_stream(struct acpi_resource *linked_list,
114 acpi_size byte_stream_size_needed,
115 u8 * output_buffer);
116
117acpi_status
118acpi_rs_io_resource(u8 * byte_stream_buffer,
119 acpi_size * bytes_consumed,
120 u8 ** output_buffer, acpi_size * structure_size);
121
122acpi_status
123acpi_rs_fixed_io_resource(u8 * byte_stream_buffer,
124 acpi_size * bytes_consumed,
125 u8 ** output_buffer, acpi_size * structure_size);
126
127acpi_status 167acpi_status
128acpi_rs_io_stream(struct acpi_resource *linked_list, 168acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
129 u8 ** output_buffer, acpi_size * bytes_consumed);
130
131acpi_status
132acpi_rs_fixed_io_stream(struct acpi_resource *linked_list,
133 u8 ** output_buffer, acpi_size * bytes_consumed);
134
135acpi_status
136acpi_rs_irq_resource(u8 * byte_stream_buffer,
137 acpi_size * bytes_consumed,
138 u8 ** output_buffer, acpi_size * structure_size);
139
140acpi_status
141acpi_rs_irq_stream(struct acpi_resource *linked_list,
142 u8 ** output_buffer, acpi_size * bytes_consumed);
143
144acpi_status
145acpi_rs_dma_resource(u8 * byte_stream_buffer,
146 acpi_size * bytes_consumed,
147 u8 ** output_buffer, acpi_size * structure_size);
148 169
149acpi_status 170acpi_status
150acpi_rs_dma_stream(struct acpi_resource *linked_list, 171acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
151 u8 ** output_buffer, acpi_size * bytes_consumed);
152 172
173#ifdef ACPI_FUTURE_USAGE
153acpi_status 174acpi_status
154acpi_rs_address16_resource(u8 * byte_stream_buffer, 175acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
155 acpi_size * bytes_consumed, 176#endif /* ACPI_FUTURE_USAGE */
156 u8 ** output_buffer, acpi_size * structure_size);
157 177
158acpi_status 178acpi_status
159acpi_rs_address16_stream(struct acpi_resource *linked_list, 179acpi_rs_get_method_data(acpi_handle handle,
160 u8 ** output_buffer, acpi_size * bytes_consumed); 180 char *path, struct acpi_buffer *ret_buffer);
161 181
162acpi_status 182acpi_status
163acpi_rs_address32_resource(u8 * byte_stream_buffer, 183acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
164 acpi_size * bytes_consumed,
165 u8 ** output_buffer, acpi_size * structure_size);
166 184
185/*
186 * rscalc
187 */
167acpi_status 188acpi_status
168acpi_rs_address32_stream(struct acpi_resource *linked_list, 189acpi_rs_get_list_length(u8 * aml_buffer,
169 u8 ** output_buffer, acpi_size * bytes_consumed); 190 u32 aml_buffer_length, acpi_size * size_needed);
170 191
171acpi_status 192acpi_status
172acpi_rs_address64_resource(u8 * byte_stream_buffer, 193acpi_rs_get_aml_length(struct acpi_resource *linked_list_buffer,
173 acpi_size * bytes_consumed, 194 acpi_size * size_needed);
174 u8 ** output_buffer, acpi_size * structure_size);
175 195
176acpi_status 196acpi_status
177acpi_rs_address64_stream(struct acpi_resource *linked_list, 197acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
178 u8 ** output_buffer, acpi_size * bytes_consumed); 198 acpi_size * buffer_size_needed);
179 199
180acpi_status 200acpi_status
181acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, 201acpi_rs_convert_aml_to_resources(u8 * aml_buffer,
182 acpi_size * bytes_consumed, 202 u32 aml_buffer_length, u8 * output_buffer);
183 u8 ** output_buffer,
184 acpi_size * structure_size);
185 203
186acpi_status 204acpi_status
187acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, 205acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
188 acpi_size * bytes_consumed, 206 acpi_size aml_size_needed, u8 * output_buffer);
189 u8 ** output_buffer,
190 acpi_size * structure_size);
191 207
192acpi_status 208/*
193acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list, 209 * rsaddr
194 u8 ** output_buffer, 210 */
195 acpi_size * bytes_consumed); 211void
212acpi_rs_set_address_common(union aml_resource *aml,
213 struct acpi_resource *resource);
196 214
197acpi_status 215u8
198acpi_rs_end_depend_fns_stream(struct acpi_resource *linked_list, 216acpi_rs_get_address_common(struct acpi_resource *resource,
199 u8 ** output_buffer, acpi_size * bytes_consumed); 217 union aml_resource *aml);
200 218
219/*
220 * rsmisc
221 */
201acpi_status 222acpi_status
202acpi_rs_memory24_resource(u8 * byte_stream_buffer, 223acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
203 acpi_size * bytes_consumed, 224 union aml_resource *aml,
204 u8 ** output_buffer, acpi_size * structure_size); 225 struct acpi_rsconvert_info *info);
205 226
206acpi_status 227acpi_status
207acpi_rs_memory24_stream(struct acpi_resource *linked_list, 228acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
208 u8 ** output_buffer, acpi_size * bytes_consumed); 229 union aml_resource *aml,
230 struct acpi_rsconvert_info *info);
209 231
210acpi_status 232/*
211acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, 233 * rsutils
212 acpi_size * bytes_consumed, 234 */
213 u8 ** output_buffer, 235void
214 acpi_size * structure_size); 236acpi_rs_move_data(void *destination,
237 void *source, u16 item_count, u8 move_type);
215 238
216acpi_status 239u8 acpi_rs_decode_bitmask(u16 mask, u8 * list);
217acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer,
218 acpi_size * bytes_consumed,
219 u8 ** output_buffer,
220 acpi_size * structure_size);
221 240
222acpi_status 241u16 acpi_rs_encode_bitmask(u8 * list, u8 count);
223acpi_rs_memory32_range_stream(struct acpi_resource *linked_list,
224 u8 ** output_buffer, acpi_size * bytes_consumed);
225 242
226acpi_status 243acpi_rs_length
227acpi_rs_fixed_memory32_stream(struct acpi_resource *linked_list, 244acpi_rs_get_resource_source(acpi_rs_length resource_length,
228 u8 ** output_buffer, acpi_size * bytes_consumed); 245 acpi_rs_length minimum_length,
246 struct acpi_resource_source *resource_source,
247 union aml_resource *aml, char *string_ptr);
229 248
230acpi_status 249acpi_rsdesc_size
231acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, 250acpi_rs_set_resource_source(union aml_resource *aml,
232 acpi_size * bytes_consumed, 251 acpi_rs_length minimum_length,
233 u8 ** output_buffer, acpi_size * structure_size); 252 struct acpi_resource_source *resource_source);
234 253
235acpi_status 254void
236acpi_rs_extended_irq_stream(struct acpi_resource *linked_list, 255acpi_rs_set_resource_header(u8 descriptor_type,
237 u8 ** output_buffer, acpi_size * bytes_consumed); 256 acpi_rsdesc_size total_length,
257 union aml_resource *aml);
238 258
239acpi_status 259void
240acpi_rs_end_tag_resource(u8 * byte_stream_buffer, 260acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
241 acpi_size * bytes_consumed, 261 union aml_resource *aml);
242 u8 ** output_buffer, acpi_size * structure_size);
243 262
244acpi_status 263/*
245acpi_rs_end_tag_stream(struct acpi_resource *linked_list, 264 * rsdump
246 u8 ** output_buffer, acpi_size * bytes_consumed); 265 */
266void acpi_rs_dump_resource_list(struct acpi_resource *resource);
247 267
248acpi_status 268void acpi_rs_dump_irq_list(u8 * route_table);
249acpi_rs_vendor_resource(u8 * byte_stream_buffer,
250 acpi_size * bytes_consumed,
251 u8 ** output_buffer, acpi_size * structure_size);
252 269
253acpi_status 270/*
254acpi_rs_vendor_stream(struct acpi_resource *linked_list, 271 * Resource conversion tables
255 u8 ** output_buffer, acpi_size * bytes_consumed); 272 */
273extern struct acpi_rsconvert_info acpi_rs_convert_dma[];
274extern struct acpi_rsconvert_info acpi_rs_convert_end_dpf[];
275extern struct acpi_rsconvert_info acpi_rs_convert_io[];
276extern struct acpi_rsconvert_info acpi_rs_convert_fixed_io[];
277extern struct acpi_rsconvert_info acpi_rs_convert_end_tag[];
278extern struct acpi_rsconvert_info acpi_rs_convert_memory24[];
279extern struct acpi_rsconvert_info acpi_rs_convert_generic_reg[];
280extern struct acpi_rsconvert_info acpi_rs_convert_memory32[];
281extern struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[];
282extern struct acpi_rsconvert_info acpi_rs_convert_address32[];
283extern struct acpi_rsconvert_info acpi_rs_convert_address16[];
284extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[];
285extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
286extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
287
288/* These resources require separate get/set tables */
289
290extern struct acpi_rsconvert_info acpi_rs_get_irq[];
291extern struct acpi_rsconvert_info acpi_rs_get_start_dpf[];
292extern struct acpi_rsconvert_info acpi_rs_get_vendor_small[];
293extern struct acpi_rsconvert_info acpi_rs_get_vendor_large[];
294
295extern struct acpi_rsconvert_info acpi_rs_set_irq[];
296extern struct acpi_rsconvert_info acpi_rs_set_start_dpf[];
297extern struct acpi_rsconvert_info acpi_rs_set_vendor[];
298
299#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
300/*
301 * rsinfo
302 */
303extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
256 304
257u8 acpi_rs_get_resource_type(u8 resource_start_byte); 305/*
306 * rsdump
307 */
308extern struct acpi_rsdump_info acpi_rs_dump_irq[];
309extern struct acpi_rsdump_info acpi_rs_dump_dma[];
310extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[];
311extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[];
312extern struct acpi_rsdump_info acpi_rs_dump_io[];
313extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[];
314extern struct acpi_rsdump_info acpi_rs_dump_vendor[];
315extern struct acpi_rsdump_info acpi_rs_dump_end_tag[];
316extern struct acpi_rsdump_info acpi_rs_dump_memory24[];
317extern struct acpi_rsdump_info acpi_rs_dump_memory32[];
318extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[];
319extern struct acpi_rsdump_info acpi_rs_dump_address16[];
320extern struct acpi_rsdump_info acpi_rs_dump_address32[];
321extern struct acpi_rsdump_info acpi_rs_dump_address64[];
322extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[];
323extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[];
324extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[];
325#endif
258 326
259#endif /* __ACRESRC_H__ */ 327#endif /* __ACRESRC_H__ */
diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h
index 99d235339801..d8c1c2cdac0c 100644
--- a/include/acpi/acstruct.h
+++ b/include/acpi/acstruct.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actables.h b/include/acpi/actables.h
index f92c1858b808..30a47542e1c8 100644
--- a/include/acpi/actables.h
+++ b/include/acpi/actables.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index a46f406e1c94..ed53f842dad4 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,12 @@
45#define __ACTBL_H__ 45#define __ACTBL_H__
46 46
47/* 47/*
48 * Note about bitfields: The u8 type is used for bitfields in ACPI tables.
49 * This is the only type that is even remotely portable. Anything else is not
50 * portable, so do not use any other bitfield types.
51 */
52
53/*
48 * Values for description table header signatures 54 * Values for description table header signatures
49 */ 55 */
50#define RSDP_NAME "RSDP" 56#define RSDP_NAME "RSDP"
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index 67312c3a915a..cd428d57add0 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index 50305ce2681a..dfc7ac1094bb 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 6213b27516e8..7ca89cde706e 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,15 @@
44#ifndef __ACTYPES_H__ 44#ifndef __ACTYPES_H__
45#define __ACTYPES_H__ 45#define __ACTYPES_H__
46 46
47/*! [Begin] no source code translation (keep the typedefs) */ 47/*
48 * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent header
49 * and must be either 16, 32, or 64
50 */
51#ifndef ACPI_MACHINE_WIDTH
52#error ACPI_MACHINE_WIDTH not defined
53#endif
54
55/*! [Begin] no source code translation */
48 56
49/* 57/*
50 * Data type ranges 58 * Data type ranges
@@ -58,87 +66,150 @@
58#define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */ 66#define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */
59#define ACPI_ASCII_MAX 0x7F 67#define ACPI_ASCII_MAX 0x7F
60 68
61#ifdef DEFINE_ALTERNATE_TYPES
62/* 69/*
63 * Types used only in translated source, defined here to enable 70 * Architecture-specific ACPICA Subsystem Data Types
64 * cross-platform compilation only. 71 *
72 * The goal of these types is to provide source code portability across
73 * 16-bit, 32-bit, and 64-bit targets.
74 *
75 * 1) The following types are of fixed size for all targets (16/32/64):
76 *
77 * BOOLEAN Logical boolean
78 *
79 * UINT8 8-bit (1 byte) unsigned value
80 * UINT16 16-bit (2 byte) unsigned value
81 * UINT32 32-bit (4 byte) unsigned value
82 * UINT64 64-bit (8 byte) unsigned value
83 *
84 * INT16 16-bit (2 byte) signed value
85 * INT32 32-bit (4 byte) signed value
86 * INT64 64-bit (8 byte) signed value
87 *
88 * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the
89 * compiler-dependent header(s) and were introduced because there is no common
90 * 64-bit integer type across the various compilation models, as shown in
91 * the table below.
92 *
93 * Datatype LP64 ILP64 LLP64 ILP32 LP32 16bit
94 * char 8 8 8 8 8 8
95 * short 16 16 16 16 16 16
96 * _int32 32
97 * int 32 64 32 32 16 16
98 * long 64 64 32 32 32 32
99 * long long 64 64
100 * pointer 64 64 64 32 32 32
101 *
102 * Note: ILP64 and LP32 are currently not supported.
103 *
104 *
105 * 2) These types represent the native word size of the target mode of the
106 * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are
107 * usually used for memory allocation, efficient loop counters, and array
108 * indexes. The types are similar to the size_t type in the C library and are
109 * required because there is no C type that consistently represents the native
110 * data width.
111 *
112 * ACPI_SIZE 16/32/64-bit unsigned value
113 * ACPI_NATIVE_UINT 16/32/64-bit unsigned value
114 * ACPI_NATIVE_INT 16/32/64-bit signed value
115 *
65 */ 116 */
66typedef int s32;
67typedef unsigned char u8;
68typedef unsigned short u16;
69typedef unsigned int u32;
70typedef COMPILER_DEPENDENT_UINT64 u64;
71
72#endif
73 117
74/* 118/*******************************************************************************
75 * Data types - Fixed across all compilation models (16/32/64)
76 * 119 *
77 * BOOLEAN Logical Boolean. 120 * Common types for all compilers, all targets
78 * INT8 8-bit (1 byte) signed value 121 *
79 * UINT8 8-bit (1 byte) unsigned value 122 ******************************************************************************/
80 * INT16 16-bit (2 byte) signed value
81 * UINT16 16-bit (2 byte) unsigned value
82 * INT32 32-bit (4 byte) signed value
83 * UINT32 32-bit (4 byte) unsigned value
84 * INT64 64-bit (8 byte) signed value
85 * UINT64 64-bit (8 byte) unsigned value
86 * ACPI_NATIVE_INT 32-bit on IA-32, 64-bit on IA-64 signed value
87 * ACPI_NATIVE_UINT 32-bit on IA-32, 64-bit on IA-64 unsigned value
88 */
89 123
90#ifndef ACPI_MACHINE_WIDTH 124typedef unsigned char BOOLEAN;
91#error ACPI_MACHINE_WIDTH not defined 125typedef unsigned char UINT8;
92#endif 126typedef unsigned short UINT16;
127typedef COMPILER_DEPENDENT_UINT64 UINT64;
128typedef COMPILER_DEPENDENT_INT64 INT64;
129
130/*! [End] no source code translation !*/
131
132/*******************************************************************************
133 *
134 * Types specific to 64-bit targets
135 *
136 ******************************************************************************/
93 137
94#if ACPI_MACHINE_WIDTH == 64 138#if ACPI_MACHINE_WIDTH == 64
95 139
96/*! [Begin] no source code translation (keep the typedefs) */ 140/*! [Begin] no source code translation (keep the typedefs as-is) */
97 141
98/*
99 * 64-bit type definitions
100 */
101typedef unsigned char UINT8;
102typedef unsigned char BOOLEAN;
103typedef unsigned short UINT16;
104typedef int INT32;
105typedef unsigned int UINT32; 142typedef unsigned int UINT32;
106typedef COMPILER_DEPENDENT_INT64 INT64; 143typedef int INT32;
107typedef COMPILER_DEPENDENT_UINT64 UINT64;
108 144
109/*! [End] no source code translation !*/ 145/*! [End] no source code translation !*/
110 146
111typedef s64 acpi_native_int;
112typedef u64 acpi_native_uint; 147typedef u64 acpi_native_uint;
148typedef s64 acpi_native_int;
113 149
114typedef u64 acpi_table_ptr; 150typedef u64 acpi_table_ptr;
115typedef u64 acpi_io_address; 151typedef u64 acpi_io_address;
116typedef u64 acpi_physical_address; 152typedef u64 acpi_physical_address;
117typedef u64 acpi_size;
118 153
119#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 /* No hardware alignment support in IA64 */
120#define ACPI_USE_NATIVE_DIVIDE /* Native 64-bit integer support */
121#define ACPI_MAX_PTR ACPI_UINT64_MAX 154#define ACPI_MAX_PTR ACPI_UINT64_MAX
122#define ACPI_SIZE_MAX ACPI_UINT64_MAX 155#define ACPI_SIZE_MAX ACPI_UINT64_MAX
123 156
124#elif ACPI_MACHINE_WIDTH == 16 157#define ALIGNED_ADDRESS_BOUNDARY 0x00000008
125 158#define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */
126/*! [Begin] no source code translation (keep the typedefs) */
127 159
128/* 160/*
129 * 16-bit type definitions 161 * In the case of the Itanium Processor Family (IPF), the hardware does not
162 * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag
163 * to indicate that special precautions must be taken to avoid alignment faults.
164 * (IA64 or ia64 is currently used by existing compilers to indicate IPF.)
165 *
166 * Note: Em64_t and other X86-64 processors support misaligned transfers,
167 * so there is no need to define this flag.
130 */ 168 */
131typedef unsigned char UINT8; 169#if defined (__IA64__) || defined (__ia64__)
132typedef unsigned char BOOLEAN; 170#define ACPI_MISALIGNMENT_NOT_SUPPORTED
133typedef unsigned int UINT16; 171#endif
134typedef long INT32;
135typedef int INT16;
136typedef unsigned long UINT32;
137 172
138struct { 173/*******************************************************************************
139 UINT32 Lo; 174 *
140 UINT32 Hi; 175 * Types specific to 32-bit targets
141}; 176 *
177 ******************************************************************************/
178
179#elif ACPI_MACHINE_WIDTH == 32
180
181/*! [Begin] no source code translation (keep the typedefs as-is) */
182
183typedef unsigned int UINT32;
184typedef int INT32;
185
186/*! [End] no source code translation !*/
187
188typedef u32 acpi_native_uint;
189typedef s32 acpi_native_int;
190
191typedef u64 acpi_table_ptr;
192typedef u32 acpi_io_address;
193typedef u64 acpi_physical_address;
194
195#define ACPI_MAX_PTR ACPI_UINT32_MAX
196#define ACPI_SIZE_MAX ACPI_UINT32_MAX
197
198#define ALIGNED_ADDRESS_BOUNDARY 0x00000004
199
200/*******************************************************************************
201 *
202 * Types specific to 16-bit targets
203 *
204 ******************************************************************************/
205
206#elif ACPI_MACHINE_WIDTH == 16
207
208/*! [Begin] no source code translation (keep the typedefs as-is) */
209
210typedef unsigned long UINT32;
211typedef short INT16;
212typedef long INT32;
142 213
143/*! [End] no source code translation !*/ 214/*! [End] no source code translation !*/
144 215
@@ -148,61 +219,84 @@ typedef s16 acpi_native_int;
148typedef u32 acpi_table_ptr; 219typedef u32 acpi_table_ptr;
149typedef u32 acpi_io_address; 220typedef u32 acpi_io_address;
150typedef char *acpi_physical_address; 221typedef char *acpi_physical_address;
151typedef u16 acpi_size;
152 222
153#define ALIGNED_ADDRESS_BOUNDARY 0x00000002
154#define ACPI_MISALIGNED_TRANSFERS
155#define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */
156#define ACPI_MAX_PTR ACPI_UINT16_MAX 223#define ACPI_MAX_PTR ACPI_UINT16_MAX
157#define ACPI_SIZE_MAX ACPI_UINT16_MAX 224#define ACPI_SIZE_MAX ACPI_UINT16_MAX
158 225
159/* 226#define ALIGNED_ADDRESS_BOUNDARY 0x00000002
160 * (16-bit only) internal integers must be 32-bits, so 227#define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */
161 * 64-bit integers cannot be supported 228
162 */ 229/* 64-bit integers cannot be supported */
230
163#define ACPI_NO_INTEGER64_SUPPORT 231#define ACPI_NO_INTEGER64_SUPPORT
164 232
165#elif ACPI_MACHINE_WIDTH == 32 233#else
166 234
167/*! [Begin] no source code translation (keep the typedefs) */ 235/* ACPI_MACHINE_WIDTH must be either 64, 32, or 16 */
168 236
169/* 237#error unknown ACPI_MACHINE_WIDTH
170 * 32-bit type definitions (default) 238#endif
171 */
172typedef unsigned char UINT8;
173typedef unsigned char BOOLEAN;
174typedef unsigned short UINT16;
175typedef int INT32;
176typedef unsigned int UINT32;
177typedef COMPILER_DEPENDENT_INT64 INT64;
178typedef COMPILER_DEPENDENT_UINT64 UINT64;
179 239
180/*! [End] no source code translation !*/ 240/* Variable-width type, used instead of clib size_t */
181 241
182typedef s32 acpi_native_int; 242typedef acpi_native_uint acpi_size;
183typedef u32 acpi_native_uint;
184 243
185typedef u64 acpi_table_ptr; 244/*******************************************************************************
186typedef u32 acpi_io_address; 245 *
187typedef u64 acpi_physical_address; 246 * OS- or compiler-dependent types
188typedef u32 acpi_size; 247 *
248 * If the defaults below are not appropriate for the host system, they can
249 * be defined in the compiler-specific or OS-specific header, and this will
250 * take precedence.
251 *
252 ******************************************************************************/
189 253
190#define ALIGNED_ADDRESS_BOUNDARY 0x00000004 254/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */
191#define ACPI_MISALIGNED_TRANSFERS
192#define ACPI_MAX_PTR ACPI_UINT32_MAX
193#define ACPI_SIZE_MAX ACPI_UINT32_MAX
194 255
195#else 256#ifndef acpi_uintptr_t
196#error unknown ACPI_MACHINE_WIDTH 257#define acpi_uintptr_t void *
197#endif 258#endif
198 259
199/* 260/*
200 * This type is used for bitfields in ACPI tables. The only type that is 261 * If acpi_cache_t was not defined in the OS-dependent header,
201 * even remotely portable is u8. Anything else is not portable, so 262 * define it now. This is typically the case where the local cache
202 * do not add any more bitfield types. 263 * manager implementation is to be used (ACPI_USE_LOCAL_CACHE)
264 */
265#ifndef acpi_cache_t
266#define acpi_cache_t struct acpi_memory_list
267#endif
268
269/*
270 * Allow the CPU flags word to be defined per-OS to simplify the use of the
271 * lock and unlock OSL interfaces.
272 */
273#ifndef acpi_cpu_flags
274#define acpi_cpu_flags acpi_native_uint
275#endif
276
277/*
278 * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because
279 * some compilers can catch printf format string problems
203 */ 280 */
204typedef u8 UINT8_BIT; 281#ifndef ACPI_PRINTF_LIKE
205typedef acpi_native_uint ACPI_PTRDIFF; 282#define ACPI_PRINTF_LIKE(c)
283#endif
284
285/*
286 * Some compilers complain about unused variables. Sometimes we don't want to
287 * use all the variables (for example, _acpi_module_name). This allows us
288 * to to tell the compiler in a per-variable manner that a variable
289 * is unused
290 */
291#ifndef ACPI_UNUSED_VAR
292#define ACPI_UNUSED_VAR
293#endif
294
295/*******************************************************************************
296 *
297 * Independent types
298 *
299 ******************************************************************************/
206 300
207/* 301/*
208 * Pointer overlays to avoid lots of typecasting for 302 * Pointer overlays to avoid lots of typecasting for
@@ -234,18 +328,8 @@ struct acpi_pointer {
234#define ACPI_LOGMODE_PHYSPTR ACPI_LOGICAL_ADDRESSING | ACPI_PHYSICAL_POINTER 328#define ACPI_LOGMODE_PHYSPTR ACPI_LOGICAL_ADDRESSING | ACPI_PHYSICAL_POINTER
235#define ACPI_LOGMODE_LOGPTR ACPI_LOGICAL_ADDRESSING | ACPI_LOGICAL_POINTER 329#define ACPI_LOGMODE_LOGPTR ACPI_LOGICAL_ADDRESSING | ACPI_LOGICAL_POINTER
236 330
237/* 331/* Logical defines and NULL */
238 * If acpi_cache_t was not defined in the OS-dependent header,
239 * define it now. This is typically the case where the local cache
240 * manager implementation is to be used (ACPI_USE_LOCAL_CACHE)
241 */
242#ifndef acpi_cache_t
243#define acpi_cache_t struct acpi_memory_list
244#endif
245 332
246/*
247 * Useful defines
248 */
249#ifdef FALSE 333#ifdef FALSE
250#undef FALSE 334#undef FALSE
251#endif 335#endif
@@ -261,12 +345,12 @@ struct acpi_pointer {
261#endif 345#endif
262 346
263/* 347/*
264 * Local datatypes 348 * Mescellaneous types
265 */ 349 */
266typedef u32 acpi_status; /* All ACPI Exceptions */ 350typedef u32 acpi_status; /* All ACPI Exceptions */
267typedef u32 acpi_name; /* 4-byte ACPI name */ 351typedef u32 acpi_name; /* 4-byte ACPI name */
268typedef char *acpi_string; /* Null terminated ASCII string */ 352typedef char *acpi_string; /* Null terminated ASCII string */
269typedef void *acpi_handle; /* Actually a ptr to an Node */ 353typedef void *acpi_handle; /* Actually a ptr to a NS Node */
270 354
271struct uint64_struct { 355struct uint64_struct {
272 u32 lo; 356 u32 lo;
@@ -323,7 +407,7 @@ typedef u64 acpi_integer;
323/* 407/*
324 * Constants with special meanings 408 * Constants with special meanings
325 */ 409 */
326#define ACPI_ROOT_OBJECT (acpi_handle) ACPI_PTR_ADD (char, NULL, ACPI_MAX_PTR) 410#define ACPI_ROOT_OBJECT ACPI_ADD_PTR (acpi_handle, NULL, ACPI_MAX_PTR)
327 411
328/* 412/*
329 * Initialization sequence 413 * Initialization sequence
@@ -470,37 +554,6 @@ typedef u32 acpi_object_type;
470#define ACPI_TYPE_NOT_FOUND 0xFF 554#define ACPI_TYPE_NOT_FOUND 0xFF
471 555
472/* 556/*
473 * Bitmapped ACPI types. Used internally only
474 */
475#define ACPI_BTYPE_ANY 0x00000000
476#define ACPI_BTYPE_INTEGER 0x00000001
477#define ACPI_BTYPE_STRING 0x00000002
478#define ACPI_BTYPE_BUFFER 0x00000004
479#define ACPI_BTYPE_PACKAGE 0x00000008
480#define ACPI_BTYPE_FIELD_UNIT 0x00000010
481#define ACPI_BTYPE_DEVICE 0x00000020
482#define ACPI_BTYPE_EVENT 0x00000040
483#define ACPI_BTYPE_METHOD 0x00000080
484#define ACPI_BTYPE_MUTEX 0x00000100
485#define ACPI_BTYPE_REGION 0x00000200
486#define ACPI_BTYPE_POWER 0x00000400
487#define ACPI_BTYPE_PROCESSOR 0x00000800
488#define ACPI_BTYPE_THERMAL 0x00001000
489#define ACPI_BTYPE_BUFFER_FIELD 0x00002000
490#define ACPI_BTYPE_DDB_HANDLE 0x00004000
491#define ACPI_BTYPE_DEBUG_OBJECT 0x00008000
492#define ACPI_BTYPE_REFERENCE 0x00010000
493#define ACPI_BTYPE_RESOURCE 0x00020000
494
495#define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
496
497#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE)
498#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
499#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
500#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */
501#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF
502
503/*
504 * All I/O 557 * All I/O
505 */ 558 */
506#define ACPI_READ 0 559#define ACPI_READ 0
@@ -853,6 +906,14 @@ struct acpi_compatible_id_list {
853#define ACPI_VALID_CID 0x0010 906#define ACPI_VALID_CID 0x0010
854#define ACPI_VALID_SXDS 0x0020 907#define ACPI_VALID_SXDS 0x0020
855 908
909/* Flags for _STA method */
910
911#define ACPI_STA_DEVICE_PRESENT 0x01
912#define ACPI_STA_DEVICE_ENABLED 0x02
913#define ACPI_STA_DEVICE_UI 0x04
914#define ACPI_STA_DEVICE_OK 0x08
915#define ACPI_STA_BATTERY_PRESENT 0x10
916
856#define ACPI_COMMON_OBJ_INFO \ 917#define ACPI_COMMON_OBJ_INFO \
857 acpi_object_type type; /* ACPI object type */ \ 918 acpi_object_type type; /* ACPI object type */ \
858 acpi_name name /* ACPI object Name */ 919 acpi_name name /* ACPI object Name */
@@ -895,6 +956,8 @@ struct acpi_mem_space_context {
895/* 956/*
896 * Definitions for Resource Attributes 957 * Definitions for Resource Attributes
897 */ 958 */
959typedef u16 acpi_rs_length; /* Resource Length field is fixed at 16 bits */
960typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (length+3) = (64_k-1)+3 */
898 961
899/* 962/*
900 * Memory Attributes 963 * Memory Attributes
@@ -916,7 +979,9 @@ struct acpi_mem_space_context {
916#define ACPI_ISA_ONLY_RANGES (u8) 0x02 979#define ACPI_ISA_ONLY_RANGES (u8) 0x02
917#define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES) 980#define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES)
918 981
919#define ACPI_SPARSE_TRANSLATION (u8) 0x03 982/* Type of translation - 1=Sparse, 0=Dense */
983
984#define ACPI_SPARSE_TRANSLATION (u8) 0x01
920 985
921/* 986/*
922 * IO Port Descriptor Decode 987 * IO Port Descriptor Decode
@@ -927,8 +992,8 @@ struct acpi_mem_space_context {
927/* 992/*
928 * IRQ Attributes 993 * IRQ Attributes
929 */ 994 */
930#define ACPI_EDGE_SENSITIVE (u8) 0x00 995#define ACPI_LEVEL_SENSITIVE (u8) 0x00
931#define ACPI_LEVEL_SENSITIVE (u8) 0x01 996#define ACPI_EDGE_SENSITIVE (u8) 0x01
932 997
933#define ACPI_ACTIVE_HIGH (u8) 0x00 998#define ACPI_ACTIVE_HIGH (u8) 0x00
934#define ACPI_ACTIVE_LOW (u8) 0x01 999#define ACPI_ACTIVE_LOW (u8) 0x01
@@ -975,27 +1040,45 @@ struct acpi_mem_space_context {
975#define ACPI_CONSUMER (u8) 0x01 1040#define ACPI_CONSUMER (u8) 0x01
976 1041
977/* 1042/*
1043 * If possible, pack the following structures to byte alignment
1044 */
1045#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
1046#pragma pack(1)
1047#endif
1048
1049/* UUID data structures for use in vendor-defined resource descriptors */
1050
1051struct acpi_uuid {
1052 u8 data[ACPI_UUID_LENGTH];
1053};
1054
1055struct acpi_vendor_uuid {
1056 u8 subtype;
1057 u8 data[ACPI_UUID_LENGTH];
1058};
1059
1060/*
978 * Structures used to describe device resources 1061 * Structures used to describe device resources
979 */ 1062 */
980struct acpi_resource_irq { 1063struct acpi_resource_irq {
981 u32 edge_level; 1064 u8 triggering;
982 u32 active_high_low; 1065 u8 polarity;
983 u32 shared_exclusive; 1066 u8 sharable;
984 u32 number_of_interrupts; 1067 u8 interrupt_count;
985 u32 interrupts[1]; 1068 u8 interrupts[1];
986}; 1069};
987 1070
988struct acpi_resource_dma { 1071struct acpi_resource_dma {
989 u32 type; 1072 u8 type;
990 u32 bus_master; 1073 u8 bus_master;
991 u32 transfer; 1074 u8 transfer;
992 u32 number_of_channels; 1075 u8 channel_count;
993 u32 channels[1]; 1076 u8 channels[1];
994}; 1077};
995 1078
996struct acpi_resource_start_dpf { 1079struct acpi_resource_start_dependent {
997 u32 compatibility_priority; 1080 u8 compatibility_priority;
998 u32 performance_robustness; 1081 u8 performance_robustness;
999}; 1082};
1000 1083
1001/* 1084/*
@@ -1004,179 +1087,217 @@ struct acpi_resource_start_dpf {
1004 */ 1087 */
1005 1088
1006struct acpi_resource_io { 1089struct acpi_resource_io {
1007 u32 io_decode; 1090 u8 io_decode;
1008 u32 min_base_address; 1091 u8 alignment;
1009 u32 max_base_address; 1092 u8 address_length;
1010 u32 alignment; 1093 u16 minimum;
1011 u32 range_length; 1094 u16 maximum;
1012}; 1095};
1013 1096
1014struct acpi_resource_fixed_io { 1097struct acpi_resource_fixed_io {
1015 u32 base_address; 1098 u16 address;
1016 u32 range_length; 1099 u8 address_length;
1017}; 1100};
1018 1101
1019struct acpi_resource_vendor { 1102struct acpi_resource_vendor {
1020 u32 length; 1103 u16 byte_length;
1021 u8 reserved[1]; 1104 u8 byte_data[1];
1105};
1106
1107/* Vendor resource with UUID info (introduced in ACPI 3.0) */
1108
1109struct acpi_resource_vendor_typed {
1110 u16 byte_length;
1111 u8 uuid_subtype;
1112 u8 uuid[ACPI_UUID_LENGTH];
1113 u8 byte_data[1];
1022}; 1114};
1023 1115
1024struct acpi_resource_end_tag { 1116struct acpi_resource_end_tag {
1025 u8 checksum; 1117 u8 checksum;
1026}; 1118};
1027 1119
1028struct acpi_resource_mem24 { 1120struct acpi_resource_memory24 {
1029 u32 read_write_attribute; 1121 u8 write_protect;
1030 u32 min_base_address; 1122 u16 minimum;
1031 u32 max_base_address; 1123 u16 maximum;
1032 u32 alignment; 1124 u16 alignment;
1033 u32 range_length; 1125 u16 address_length;
1034}; 1126};
1035 1127
1036struct acpi_resource_mem32 { 1128struct acpi_resource_memory32 {
1037 u32 read_write_attribute; 1129 u8 write_protect;
1038 u32 min_base_address; 1130 u32 minimum;
1039 u32 max_base_address; 1131 u32 maximum;
1040 u32 alignment; 1132 u32 alignment;
1041 u32 range_length; 1133 u32 address_length;
1042}; 1134};
1043 1135
1044struct acpi_resource_fixed_mem32 { 1136struct acpi_resource_fixed_memory32 {
1045 u32 read_write_attribute; 1137 u8 write_protect;
1046 u32 range_base_address; 1138 u32 address;
1047 u32 range_length; 1139 u32 address_length;
1048}; 1140};
1049 1141
1050struct acpi_memory_attribute { 1142struct acpi_memory_attribute {
1051 u16 cache_attribute; 1143 u8 write_protect;
1052 u16 read_write_attribute; 1144 u8 caching;
1145 u8 range_type;
1146 u8 translation;
1053}; 1147};
1054 1148
1055struct acpi_io_attribute { 1149struct acpi_io_attribute {
1056 u16 range_attribute; 1150 u8 range_type;
1057 u16 translation_attribute; 1151 u8 translation;
1058}; 1152 u8 translation_type;
1059 1153 u8 reserved1;
1060struct acpi_bus_attribute {
1061 u16 reserved1;
1062 u16 reserved2;
1063}; 1154};
1064 1155
1065union acpi_resource_attribute { 1156union acpi_resource_attribute {
1066 struct acpi_memory_attribute memory; 1157 struct acpi_memory_attribute mem;
1067 struct acpi_io_attribute io; 1158 struct acpi_io_attribute io;
1068 struct acpi_bus_attribute bus; 1159
1160 /* Used for the *word_space macros */
1161
1162 u8 type_specific;
1069}; 1163};
1070 1164
1071struct acpi_resource_source { 1165struct acpi_resource_source {
1072 u32 index; 1166 u8 index;
1073 u32 string_length; 1167 u16 string_length;
1074 char *string_ptr; 1168 char *string_ptr;
1075}; 1169};
1076 1170
1077/* Fields common to all address descriptors, 16/32/64 bit */ 1171/* Fields common to all address descriptors, 16/32/64 bit */
1078 1172
1079#define ACPI_RESOURCE_ADDRESS_COMMON \ 1173#define ACPI_RESOURCE_ADDRESS_COMMON \
1080 u32 resource_type; \ 1174 u8 resource_type; \
1081 u32 producer_consumer; \ 1175 u8 producer_consumer; \
1082 u32 decode; \ 1176 u8 decode; \
1083 u32 min_address_fixed; \ 1177 u8 min_address_fixed; \
1084 u32 max_address_fixed; \ 1178 u8 max_address_fixed; \
1085 union acpi_resource_attribute attribute; 1179 union acpi_resource_attribute info;
1086 1180
1087struct acpi_resource_address { 1181struct acpi_resource_address {
1088ACPI_RESOURCE_ADDRESS_COMMON}; 1182ACPI_RESOURCE_ADDRESS_COMMON};
1089 1183
1090struct acpi_resource_address16 { 1184struct acpi_resource_address16 {
1091 ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; 1185 ACPI_RESOURCE_ADDRESS_COMMON u16 granularity;
1092 u32 min_address_range; 1186 u16 minimum;
1093 u32 max_address_range; 1187 u16 maximum;
1094 u32 address_translation_offset; 1188 u16 translation_offset;
1095 u32 address_length; 1189 u16 address_length;
1096 struct acpi_resource_source resource_source; 1190 struct acpi_resource_source resource_source;
1097}; 1191};
1098 1192
1099struct acpi_resource_address32 { 1193struct acpi_resource_address32 {
1100 ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; 1194 ACPI_RESOURCE_ADDRESS_COMMON u32 granularity;
1101 u32 min_address_range; 1195 u32 minimum;
1102 u32 max_address_range; 1196 u32 maximum;
1103 u32 address_translation_offset; 1197 u32 translation_offset;
1104 u32 address_length; 1198 u32 address_length;
1105 struct acpi_resource_source resource_source; 1199 struct acpi_resource_source resource_source;
1106}; 1200};
1107 1201
1108struct acpi_resource_address64 { 1202struct acpi_resource_address64 {
1109 ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; 1203 ACPI_RESOURCE_ADDRESS_COMMON u64 granularity;
1110 u64 min_address_range; 1204 u64 minimum;
1111 u64 max_address_range; 1205 u64 maximum;
1112 u64 address_translation_offset; 1206 u64 translation_offset;
1113 u64 address_length; 1207 u64 address_length;
1114 u64 type_specific_attributes;
1115 struct acpi_resource_source resource_source; 1208 struct acpi_resource_source resource_source;
1116}; 1209};
1117 1210
1118struct acpi_resource_ext_irq { 1211struct acpi_resource_extended_address64 {
1119 u32 producer_consumer; 1212 ACPI_RESOURCE_ADDRESS_COMMON u8 revision_iD;
1120 u32 edge_level; 1213 u64 granularity;
1121 u32 active_high_low; 1214 u64 minimum;
1122 u32 shared_exclusive; 1215 u64 maximum;
1123 u32 number_of_interrupts; 1216 u64 translation_offset;
1217 u64 address_length;
1218 u64 type_specific;
1219};
1220
1221struct acpi_resource_extended_irq {
1222 u8 producer_consumer;
1223 u8 triggering;
1224 u8 polarity;
1225 u8 sharable;
1226 u8 interrupt_count;
1124 struct acpi_resource_source resource_source; 1227 struct acpi_resource_source resource_source;
1125 u32 interrupts[1]; 1228 u32 interrupts[1];
1126}; 1229};
1127 1230
1231struct acpi_resource_generic_register {
1232 u8 space_id;
1233 u8 bit_width;
1234 u8 bit_offset;
1235 u8 access_size;
1236 u64 address;
1237};
1238
1128/* ACPI_RESOURCE_TYPEs */ 1239/* ACPI_RESOURCE_TYPEs */
1129 1240
1130#define ACPI_RSTYPE_IRQ 0 1241#define ACPI_RESOURCE_TYPE_IRQ 0
1131#define ACPI_RSTYPE_DMA 1 1242#define ACPI_RESOURCE_TYPE_DMA 1
1132#define ACPI_RSTYPE_START_DPF 2 1243#define ACPI_RESOURCE_TYPE_START_DEPENDENT 2
1133#define ACPI_RSTYPE_END_DPF 3 1244#define ACPI_RESOURCE_TYPE_END_DEPENDENT 3
1134#define ACPI_RSTYPE_IO 4 1245#define ACPI_RESOURCE_TYPE_IO 4
1135#define ACPI_RSTYPE_FIXED_IO 5 1246#define ACPI_RESOURCE_TYPE_FIXED_IO 5
1136#define ACPI_RSTYPE_VENDOR 6 1247#define ACPI_RESOURCE_TYPE_VENDOR 6
1137#define ACPI_RSTYPE_END_TAG 7 1248#define ACPI_RESOURCE_TYPE_END_TAG 7
1138#define ACPI_RSTYPE_MEM24 8 1249#define ACPI_RESOURCE_TYPE_MEMORY24 8
1139#define ACPI_RSTYPE_MEM32 9 1250#define ACPI_RESOURCE_TYPE_MEMORY32 9
1140#define ACPI_RSTYPE_FIXED_MEM32 10 1251#define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10
1141#define ACPI_RSTYPE_ADDRESS16 11 1252#define ACPI_RESOURCE_TYPE_ADDRESS16 11
1142#define ACPI_RSTYPE_ADDRESS32 12 1253#define ACPI_RESOURCE_TYPE_ADDRESS32 12
1143#define ACPI_RSTYPE_ADDRESS64 13 1254#define ACPI_RESOURCE_TYPE_ADDRESS64 13
1144#define ACPI_RSTYPE_EXT_IRQ 14 1255#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */
1145 1256#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15
1146typedef u32 acpi_resource_type; 1257#define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16
1258#define ACPI_RESOURCE_TYPE_MAX 16
1147 1259
1148union acpi_resource_data { 1260union acpi_resource_data {
1149 struct acpi_resource_irq irq; 1261 struct acpi_resource_irq irq;
1150 struct acpi_resource_dma dma; 1262 struct acpi_resource_dma dma;
1151 struct acpi_resource_start_dpf start_dpf; 1263 struct acpi_resource_start_dependent start_dpf;
1152 struct acpi_resource_io io; 1264 struct acpi_resource_io io;
1153 struct acpi_resource_fixed_io fixed_io; 1265 struct acpi_resource_fixed_io fixed_io;
1154 struct acpi_resource_vendor vendor_specific; 1266 struct acpi_resource_vendor vendor;
1267 struct acpi_resource_vendor_typed vendor_typed;
1155 struct acpi_resource_end_tag end_tag; 1268 struct acpi_resource_end_tag end_tag;
1156 struct acpi_resource_mem24 memory24; 1269 struct acpi_resource_memory24 memory24;
1157 struct acpi_resource_mem32 memory32; 1270 struct acpi_resource_memory32 memory32;
1158 struct acpi_resource_fixed_mem32 fixed_memory32; 1271 struct acpi_resource_fixed_memory32 fixed_memory32;
1159 struct acpi_resource_address address; /* Common 16/32/64 address fields */
1160 struct acpi_resource_address16 address16; 1272 struct acpi_resource_address16 address16;
1161 struct acpi_resource_address32 address32; 1273 struct acpi_resource_address32 address32;
1162 struct acpi_resource_address64 address64; 1274 struct acpi_resource_address64 address64;
1163 struct acpi_resource_ext_irq extended_irq; 1275 struct acpi_resource_extended_address64 ext_address64;
1276 struct acpi_resource_extended_irq extended_irq;
1277 struct acpi_resource_generic_register generic_reg;
1278
1279 /* Common fields */
1280
1281 struct acpi_resource_address address; /* Common 16/32/64 address fields */
1164}; 1282};
1165 1283
1166struct acpi_resource { 1284struct acpi_resource {
1167 acpi_resource_type id; 1285 u32 type;
1168 u32 length; 1286 u32 length;
1169 union acpi_resource_data data; 1287 union acpi_resource_data data;
1170}; 1288};
1171 1289
1172#define ACPI_RESOURCE_LENGTH 12 1290/* restore default alignment */
1173#define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */ 1291
1292#pragma pack()
1174 1293
1175#define ACPI_SIZEOF_RESOURCE(type) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type)) 1294#define ACPI_RS_SIZE_MIN 12
1295#define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */
1296#define ACPI_RS_SIZE(type) (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type))
1176 1297
1177#define ACPI_NEXT_RESOURCE(res) (struct acpi_resource *)((u8 *) res + res->length) 1298#define ACPI_NEXT_RESOURCE(res) (struct acpi_resource *)((u8 *) res + res->length)
1178 1299
1179#ifdef ACPI_MISALIGNED_TRANSFERS 1300#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
1180#define ACPI_ALIGN_RESOURCE_SIZE(length) (length) 1301#define ACPI_ALIGN_RESOURCE_SIZE(length) (length)
1181#else 1302#else
1182#define ACPI_ALIGN_RESOURCE_SIZE(length) ACPI_ROUND_UP_TO_NATIVE_WORD(length) 1303#define ACPI_ALIGN_RESOURCE_SIZE(length) ACPI_ROUND_UP_TO_NATIVE_WORD(length)
diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h
index c1086452696e..0927765df6aa 100644
--- a/include/acpi/acutils.h
+++ b/include/acpi/acutils.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,39 @@
44#ifndef _ACUTILS_H 44#ifndef _ACUTILS_H
45#define _ACUTILS_H 45#define _ACUTILS_H
46 46
47extern const u8 acpi_gbl_resource_aml_sizes[];
48
49/* Strings used by the disassembler and debugger resource dump routines */
50
51#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
52
53extern const char *acpi_gbl_BMdecode[2];
54extern const char *acpi_gbl_config_decode[4];
55extern const char *acpi_gbl_consume_decode[2];
56extern const char *acpi_gbl_DECdecode[2];
57extern const char *acpi_gbl_HEdecode[2];
58extern const char *acpi_gbl_io_decode[2];
59extern const char *acpi_gbl_LLdecode[2];
60extern const char *acpi_gbl_max_decode[2];
61extern const char *acpi_gbl_MEMdecode[4];
62extern const char *acpi_gbl_min_decode[2];
63extern const char *acpi_gbl_MTPdecode[4];
64extern const char *acpi_gbl_RNGdecode[4];
65extern const char *acpi_gbl_RWdecode[2];
66extern const char *acpi_gbl_SHRdecode[2];
67extern const char *acpi_gbl_SIZdecode[4];
68extern const char *acpi_gbl_TRSdecode[2];
69extern const char *acpi_gbl_TTPdecode[2];
70extern const char *acpi_gbl_TYPdecode[4];
71#endif
72
73/* Types for Resource descriptor entries */
74
75#define ACPI_INVALID_RESOURCE 0
76#define ACPI_FIXED_LENGTH 1
77#define ACPI_VARIABLE_LENGTH 2
78#define ACPI_SMALL_VARIABLE_LENGTH 3
79
47typedef 80typedef
48acpi_status(*acpi_pkg_callback) (u8 object_type, 81acpi_status(*acpi_pkg_callback) (u8 object_type,
49 union acpi_operand_object * source_object, 82 union acpi_operand_object * source_object,
@@ -159,7 +192,6 @@ extern const u8 _acpi_ctype[];
159#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) 192#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
160#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) 193#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
161#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) 194#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
162#define ACPI_IS_ASCII(c) ((c) < 0x80)
163 195
164#endif /* ACPI_USE_SYSTEM_CLIBRARY */ 196#endif /* ACPI_USE_SYSTEM_CLIBRARY */
165 197
@@ -243,21 +275,22 @@ acpi_ut_ptr_exit(u32 line_number,
243 const char *function_name, 275 const char *function_name,
244 char *module_name, u32 component_id, u8 * ptr); 276 char *module_name, u32 component_id, u8 * ptr);
245 277
246void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id); 278void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id);
247 279
248void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id); 280void acpi_ut_report_error(char *module_name, u32 line_number);
249 281
250void 282void acpi_ut_report_info(char *module_name, u32 line_number);
251acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id);
252 283
253void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id); 284void acpi_ut_report_warning(char *module_name, u32 line_number);
285
286/* Error and message reporting interfaces */
254 287
255void ACPI_INTERNAL_VAR_XFACE 288void ACPI_INTERNAL_VAR_XFACE
256acpi_ut_debug_print(u32 requested_debug_level, 289acpi_ut_debug_print(u32 requested_debug_level,
257 u32 line_number, 290 u32 line_number,
258 const char *function_name, 291 const char *function_name,
259 char *module_name, 292 char *module_name,
260 u32 component_id, char *format, ...) ACPI_PRINTF_LIKE_FUNC; 293 u32 component_id, char *format, ...) ACPI_PRINTF_LIKE(6);
261 294
262void ACPI_INTERNAL_VAR_XFACE 295void ACPI_INTERNAL_VAR_XFACE
263acpi_ut_debug_print_raw(u32 requested_debug_level, 296acpi_ut_debug_print_raw(u32 requested_debug_level,
@@ -265,7 +298,24 @@ acpi_ut_debug_print_raw(u32 requested_debug_level,
265 const char *function_name, 298 const char *function_name,
266 char *module_name, 299 char *module_name,
267 u32 component_id, 300 u32 component_id,
268 char *format, ...) ACPI_PRINTF_LIKE_FUNC; 301 char *format, ...) ACPI_PRINTF_LIKE(6);
302
303void ACPI_INTERNAL_VAR_XFACE
304acpi_ut_error(char *module_name,
305 u32 line_number, char *format, ...) ACPI_PRINTF_LIKE(3);
306
307void ACPI_INTERNAL_VAR_XFACE
308acpi_ut_exception(char *module_name,
309 u32 line_number,
310 acpi_status status, char *format, ...) ACPI_PRINTF_LIKE(4);
311
312void ACPI_INTERNAL_VAR_XFACE
313acpi_ut_warning(char *module_name,
314 u32 line_number, char *format, ...) ACPI_PRINTF_LIKE(3);
315
316void ACPI_INTERNAL_VAR_XFACE
317acpi_ut_info(char *module_name,
318 u32 line_number, char *format, ...) ACPI_PRINTF_LIKE(3);
269 319
270/* 320/*
271 * utdelete - Object deletion and reference counts 321 * utdelete - Object deletion and reference counts
@@ -419,7 +469,19 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer);
419 469
420#define ACPI_ANY_BASE 0 470#define ACPI_ANY_BASE 0
421 471
422u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc); 472acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index);
473
474u32 acpi_ut_get_descriptor_length(void *aml);
475
476u16 acpi_ut_get_resource_length(void *aml);
477
478u8 acpi_ut_get_resource_header_length(void *aml);
479
480u8 acpi_ut_get_resource_type(void *aml);
481
482acpi_status
483acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc,
484 u8 ** end_tag);
423 485
424u8 acpi_ut_generate_checksum(u8 * buffer, u32 length); 486u8 acpi_ut_generate_checksum(u8 * buffer, u32 length);
425 487
diff --git a/include/acpi/amlcode.h b/include/acpi/amlcode.h
index 7fdf5299f501..37964a59aef8 100644
--- a/include/acpi/amlcode.h
+++ b/include/acpi/amlcode.h
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2005, R. Byron Moore 10 * Copyright (C) 2000 - 2006, R. Byron Moore
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h
index 051786e4b210..fb4735315ad3 100644
--- a/include/acpi/amlresrc.h
+++ b/include/acpi/amlresrc.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2005, R. Byron Moore 9 * Copyright (C) 2000 - 2006, R. Byron Moore
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -92,182 +92,168 @@ struct asl_resource_node {
92 struct asl_resource_node *next; 92 struct asl_resource_node *next;
93}; 93};
94 94
95/* Macros used to generate AML resource length fields */
96
97#define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header))
98#define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header))
99
95/* 100/*
96 * Resource descriptors defined in the ACPI specification. 101 * Resource descriptors defined in the ACPI specification.
97 * 102 *
98 * Packing/alignment must be BYTE because these descriptors 103 * Packing/alignment must be BYTE because these descriptors
99 * are used to overlay the AML byte stream. 104 * are used to overlay the raw AML byte stream.
100 */ 105 */
101#pragma pack(1) 106#pragma pack(1)
102 107
103struct asl_irq_format_desc { 108/*
104 u8 descriptor_type; 109 * SMALL descriptors
105 u16 irq_mask; 110 */
111#define AML_RESOURCE_SMALL_HEADER_COMMON \
112 u8 descriptor_type;
113
114struct aml_resource_small_header {
115AML_RESOURCE_SMALL_HEADER_COMMON};
116
117struct aml_resource_irq {
118 AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
106 u8 flags; 119 u8 flags;
107}; 120};
108 121
109struct asl_irq_noflags_desc { 122struct aml_resource_irq_noflags {
110 u8 descriptor_type; 123 AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
111 u16 irq_mask;
112}; 124};
113 125
114struct asl_dma_format_desc { 126struct aml_resource_dma {
115 u8 descriptor_type; 127 AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask;
116 u8 dma_channel_mask;
117 u8 flags; 128 u8 flags;
118}; 129};
119 130
120struct asl_start_dependent_desc { 131struct aml_resource_start_dependent {
121 u8 descriptor_type; 132 AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
122 u8 flags;
123}; 133};
124 134
125struct asl_start_dependent_noprio_desc { 135struct aml_resource_start_dependent_noprio {
126 u8 descriptor_type; 136AML_RESOURCE_SMALL_HEADER_COMMON};
127};
128 137
129struct asl_end_dependent_desc { 138struct aml_resource_end_dependent {
130 u8 descriptor_type; 139AML_RESOURCE_SMALL_HEADER_COMMON};
131};
132 140
133struct asl_io_port_desc { 141struct aml_resource_io {
134 u8 descriptor_type; 142 AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
135 u8 information; 143 u16 minimum;
136 u16 address_min; 144 u16 maximum;
137 u16 address_max;
138 u8 alignment; 145 u8 alignment;
139 u8 length; 146 u8 address_length;
140}; 147};
141 148
142struct asl_fixed_io_port_desc { 149struct aml_resource_fixed_io {
143 u8 descriptor_type; 150 AML_RESOURCE_SMALL_HEADER_COMMON u16 address;
144 u16 base_address; 151 u8 address_length;
145 u8 length;
146}; 152};
147 153
148struct asl_small_vendor_desc { 154struct aml_resource_vendor_small {
149 u8 descriptor_type; 155AML_RESOURCE_SMALL_HEADER_COMMON};
150 u8 vendor_defined[7];
151};
152 156
153struct asl_end_tag_desc { 157struct aml_resource_end_tag {
154 u8 descriptor_type; 158 AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum;
155 u8 checksum;
156}; 159};
157 160
158/* LARGE descriptors */ 161/*
162 * LARGE descriptors
163 */
164#define AML_RESOURCE_LARGE_HEADER_COMMON \
165 u8 descriptor_type;\
166 u16 resource_length;
167
168struct aml_resource_large_header {
169AML_RESOURCE_LARGE_HEADER_COMMON};
159 170
160struct asl_memory_24_desc { 171struct aml_resource_memory24 {
161 u8 descriptor_type; 172 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
162 u16 length; 173 u16 minimum;
163 u8 information; 174 u16 maximum;
164 u16 address_min;
165 u16 address_max;
166 u16 alignment; 175 u16 alignment;
167 u16 range_length; 176 u16 address_length;
168}; 177};
169 178
170struct asl_large_vendor_desc { 179struct aml_resource_vendor_large {
171 u8 descriptor_type; 180AML_RESOURCE_LARGE_HEADER_COMMON};
172 u16 length;
173 u8 vendor_defined[1];
174};
175 181
176struct asl_memory_32_desc { 182struct aml_resource_memory32 {
177 u8 descriptor_type; 183 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
178 u16 length; 184 u32 minimum;
179 u8 information; 185 u32 maximum;
180 u32 address_min;
181 u32 address_max;
182 u32 alignment; 186 u32 alignment;
183 u32 range_length; 187 u32 address_length;
184}; 188};
185 189
186struct asl_fixed_memory_32_desc { 190struct aml_resource_fixed_memory32 {
187 u8 descriptor_type; 191 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
188 u16 length; 192 u32 address;
189 u8 information; 193 u32 address_length;
190 u32 base_address;
191 u32 range_length;
192}; 194};
193 195
194struct asl_extended_address_desc { 196#define AML_RESOURCE_ADDRESS_COMMON \
195 u8 descriptor_type; 197 u8 resource_type; \
196 u16 length; 198 u8 flags; \
197 u8 resource_type; 199 u8 specific_flags;
198 u8 flags; 200
199 u8 specific_flags; 201struct aml_resource_address {
200 u8 revision_iD; 202AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON};
203
204struct aml_resource_extended_address64 {
205 AML_RESOURCE_LARGE_HEADER_COMMON
206 AML_RESOURCE_ADDRESS_COMMON u8 revision_iD;
201 u8 reserved; 207 u8 reserved;
202 u64 granularity; 208 u64 granularity;
203 u64 address_min; 209 u64 minimum;
204 u64 address_max; 210 u64 maximum;
205 u64 translation_offset; 211 u64 translation_offset;
206 u64 address_length; 212 u64 address_length;
207 u64 type_specific_attributes; 213 u64 type_specific;
208 u8 optional_fields[2]; /* Used for length calculation only */
209}; 214};
210 215
211#define ASL_EXTENDED_ADDRESS_DESC_REVISION 1 /* ACPI 3.0 */ 216#define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */
212 217
213struct asl_qword_address_desc { 218struct aml_resource_address64 {
214 u8 descriptor_type; 219 AML_RESOURCE_LARGE_HEADER_COMMON
215 u16 length; 220 AML_RESOURCE_ADDRESS_COMMON u64 granularity;
216 u8 resource_type; 221 u64 minimum;
217 u8 flags; 222 u64 maximum;
218 u8 specific_flags;
219 u64 granularity;
220 u64 address_min;
221 u64 address_max;
222 u64 translation_offset; 223 u64 translation_offset;
223 u64 address_length; 224 u64 address_length;
224 u8 optional_fields[2];
225}; 225};
226 226
227struct asl_dword_address_desc { 227struct aml_resource_address32 {
228 u8 descriptor_type; 228 AML_RESOURCE_LARGE_HEADER_COMMON
229 u16 length; 229 AML_RESOURCE_ADDRESS_COMMON u32 granularity;
230 u8 resource_type; 230 u32 minimum;
231 u8 flags; 231 u32 maximum;
232 u8 specific_flags;
233 u32 granularity;
234 u32 address_min;
235 u32 address_max;
236 u32 translation_offset; 232 u32 translation_offset;
237 u32 address_length; 233 u32 address_length;
238 u8 optional_fields[2];
239}; 234};
240 235
241struct asl_word_address_desc { 236struct aml_resource_address16 {
242 u8 descriptor_type; 237 AML_RESOURCE_LARGE_HEADER_COMMON
243 u16 length; 238 AML_RESOURCE_ADDRESS_COMMON u16 granularity;
244 u8 resource_type; 239 u16 minimum;
245 u8 flags; 240 u16 maximum;
246 u8 specific_flags;
247 u16 granularity;
248 u16 address_min;
249 u16 address_max;
250 u16 translation_offset; 241 u16 translation_offset;
251 u16 address_length; 242 u16 address_length;
252 u8 optional_fields[2];
253}; 243};
254 244
255struct asl_extended_xrupt_desc { 245struct aml_resource_extended_irq {
256 u8 descriptor_type; 246 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
257 u16 length; 247 u8 interrupt_count;
258 u8 flags; 248 u32 interrupts[1];
259 u8 table_length;
260 u32 interrupt_number[1];
261 /* res_source_index, res_source optional fields follow */ 249 /* res_source_index, res_source optional fields follow */
262}; 250};
263 251
264struct asl_general_register_desc { 252struct aml_resource_generic_register {
265 u8 descriptor_type; 253 AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id;
266 u16 length;
267 u8 address_space_id;
268 u8 bit_width; 254 u8 bit_width;
269 u8 bit_offset; 255 u8 bit_offset;
270 u8 access_size; /* ACPI 3.0, was Reserved */ 256 u8 access_size; /* ACPI 3.0, was previously Reserved */
271 u64 address; 257 u64 address;
272}; 258};
273 259
@@ -277,26 +263,39 @@ struct asl_general_register_desc {
277 263
278/* Union of all resource descriptors, so we can allocate the worst case */ 264/* Union of all resource descriptors, so we can allocate the worst case */
279 265
280union asl_resource_desc { 266union aml_resource {
281 struct asl_irq_format_desc irq; 267 /* Descriptor headers */
282 struct asl_dma_format_desc dma; 268
283 struct asl_start_dependent_desc std; 269 struct aml_resource_small_header small_header;
284 struct asl_end_dependent_desc end; 270 struct aml_resource_large_header large_header;
285 struct asl_io_port_desc iop; 271
286 struct asl_fixed_io_port_desc fio; 272 /* Small resource descriptors */
287 struct asl_small_vendor_desc smv; 273
288 struct asl_end_tag_desc et; 274 struct aml_resource_irq irq;
289 275 struct aml_resource_dma dma;
290 struct asl_memory_24_desc M24; 276 struct aml_resource_start_dependent start_dpf;
291 struct asl_large_vendor_desc lgv; 277 struct aml_resource_end_dependent end_dpf;
292 struct asl_memory_32_desc M32; 278 struct aml_resource_io io;
293 struct asl_fixed_memory_32_desc F32; 279 struct aml_resource_fixed_io fixed_io;
294 struct asl_qword_address_desc qas; 280 struct aml_resource_vendor_small vendor_small;
295 struct asl_dword_address_desc das; 281 struct aml_resource_end_tag end_tag;
296 struct asl_word_address_desc was; 282
297 struct asl_extended_address_desc eas; 283 /* Large resource descriptors */
298 struct asl_extended_xrupt_desc exx; 284
299 struct asl_general_register_desc grg; 285 struct aml_resource_memory24 memory24;
286 struct aml_resource_generic_register generic_reg;
287 struct aml_resource_vendor_large vendor_large;
288 struct aml_resource_memory32 memory32;
289 struct aml_resource_fixed_memory32 fixed_memory32;
290 struct aml_resource_address16 address16;
291 struct aml_resource_address32 address32;
292 struct aml_resource_address64 address64;
293 struct aml_resource_extended_address64 ext_address64;
294 struct aml_resource_extended_irq extended_irq;
295
296 /* Utility overlays */
297
298 struct aml_resource_address address;
300 u32 u32_item; 299 u32 u32_item;
301 u16 u16_item; 300 u16 u16_item;
302 u8 U8item; 301 u8 U8item;
diff --git a/include/acpi/pdc_intel.h b/include/acpi/pdc_intel.h
index 91f4a12a99a1..3fa81d55cd0c 100644
--- a/include/acpi/pdc_intel.h
+++ b/include/acpi/pdc_intel.h
@@ -15,9 +15,7 @@
15#define ACPI_PDC_C_C1_FFH (0x0100) 15#define ACPI_PDC_C_C1_FFH (0x0100)
16 16
17#define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \ 17#define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \
18 ACPI_PDC_C_C1_HALT) 18 ACPI_PDC_C_C1_HALT | \
19
20#define ACPI_PDC_EST_CAPABILITY_SMP_MSR (ACPI_PDC_EST_CAPABILITY_SMP | \
21 ACPI_PDC_P_FFH) 19 ACPI_PDC_P_FFH)
22 20
23#define ACPI_PDC_C_CAPABILITY_SMP (ACPI_PDC_SMP_C2C3 | \ 21#define ACPI_PDC_C_CAPABILITY_SMP (ACPI_PDC_SMP_C2C3 | \
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index 16609c1ab2eb..223ec6467108 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -68,6 +68,7 @@
68#define ACPI_APPLICATION 68#define ACPI_APPLICATION
69#define ACPI_DEBUGGER 69#define ACPI_DEBUGGER
70#define ACPI_DISASSEMBLER 70#define ACPI_DISASSEMBLER
71#define ACPI_MUTEX_DEBUG
71#endif 72#endif
72 73
73#ifdef ACPI_ASL_COMPILER 74#ifdef ACPI_ASL_COMPILER
@@ -148,6 +149,9 @@
148#elif defined(NETWARE) 149#elif defined(NETWARE)
149#include "acnetware.h" 150#include "acnetware.h"
150 151
152#elif defined(__sun)
153#include "acsolaris.h"
154
151#else 155#else
152 156
153/* All other environments */ 157/* All other environments */
@@ -157,13 +161,6 @@
157#define COMPILER_DEPENDENT_INT64 long long 161#define COMPILER_DEPENDENT_INT64 long long
158#define COMPILER_DEPENDENT_UINT64 unsigned long long 162#define COMPILER_DEPENDENT_UINT64 unsigned long long
159 163
160/*
161 * This macro is used to tag functions as "printf-like" because
162 * some compilers can catch printf format string problems. MSVC
163 * doesn't, so this is proprocessed away.
164 */
165#define ACPI_PRINTF_LIKE_FUNC
166
167#endif 164#endif
168 165
169/* 166/*
@@ -205,6 +202,8 @@
205 * 202 *
206 *****************************************************************************/ 203 *****************************************************************************/
207 204
205#define ACPI_IS_ASCII(c) ((c) < 0x80)
206
208#ifdef ACPI_USE_SYSTEM_CLIBRARY 207#ifdef ACPI_USE_SYSTEM_CLIBRARY
209/* 208/*
210 * Use the standard C library headers. 209 * Use the standard C library headers.
@@ -234,7 +233,7 @@
234#define ACPI_STRCAT(d,s) (void) strcat((d), (s)) 233#define ACPI_STRCAT(d,s) (void) strcat((d), (s))
235#define ACPI_STRNCAT(d,s,n) strncat((d), (s), (acpi_size)(n)) 234#define ACPI_STRNCAT(d,s,n) strncat((d), (s), (acpi_size)(n))
236#define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (acpi_size)(n)) 235#define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (acpi_size)(n))
237#define ACPI_MEMCMP(s1,s2,n) memcmp((s1), (s2), (acpi_size)(n)) 236#define ACPI_MEMCMP(s1,s2,n) memcmp((const char *)(s1), (const char *)(s2), (acpi_size)(n))
238#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (acpi_size)(n)) 237#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (acpi_size)(n))
239#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (acpi_size)(n)) 238#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (acpi_size)(n))
240 239
@@ -246,7 +245,6 @@
246#define ACPI_IS_UPPER(i) isupper((int) (i)) 245#define ACPI_IS_UPPER(i) isupper((int) (i))
247#define ACPI_IS_PRINT(i) isprint((int) (i)) 246#define ACPI_IS_PRINT(i) isprint((int) (i))
248#define ACPI_IS_ALPHA(i) isalpha((int) (i)) 247#define ACPI_IS_ALPHA(i) isalpha((int) (i))
249#define ACPI_IS_ASCII(i) isascii((int) (i))
250 248
251#else 249#else
252 250
@@ -273,8 +271,8 @@ typedef char *va_list;
273/* 271/*
274 * Storage alignment properties 272 * Storage alignment properties
275 */ 273 */
276#define _AUPBND (sizeof (acpi_native_int) - 1) 274#define _AUPBND (sizeof (acpi_native_uint) - 1)
277#define _ADNBND (sizeof (acpi_native_int) - 1) 275#define _ADNBND (sizeof (acpi_native_uint) - 1)
278 276
279/* 277/*
280 * Variable argument list macro definitions 278 * Variable argument list macro definitions
@@ -296,7 +294,7 @@ typedef char *va_list;
296#define ACPI_STRCAT(d,s) (void) acpi_ut_strcat ((d), (s)) 294#define ACPI_STRCAT(d,s) (void) acpi_ut_strcat ((d), (s))
297#define ACPI_STRNCAT(d,s,n) acpi_ut_strncat ((d), (s), (acpi_size)(n)) 295#define ACPI_STRNCAT(d,s,n) acpi_ut_strncat ((d), (s), (acpi_size)(n))
298#define ACPI_STRTOUL(d,s,n) acpi_ut_strtoul ((d), (s), (acpi_size)(n)) 296#define ACPI_STRTOUL(d,s,n) acpi_ut_strtoul ((d), (s), (acpi_size)(n))
299#define ACPI_MEMCMP(s1,s2,n) acpi_ut_memcmp((s1), (s2), (acpi_size)(n)) 297#define ACPI_MEMCMP(s1,s2,n) acpi_ut_memcmp((const char *)(s1), (const char *)(s2), (acpi_size)(n))
300#define ACPI_MEMCPY(d,s,n) (void) acpi_ut_memcpy ((d), (s), (acpi_size)(n)) 298#define ACPI_MEMCPY(d,s,n) (void) acpi_ut_memcpy ((d), (s), (acpi_size)(n))
301#define ACPI_MEMSET(d,v,n) (void) acpi_ut_memset ((d), (v), (acpi_size)(n)) 299#define ACPI_MEMSET(d,v,n) (void) acpi_ut_memset ((d), (v), (acpi_size)(n))
302#define ACPI_TOUPPER acpi_ut_to_upper 300#define ACPI_TOUPPER acpi_ut_to_upper
diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h
index 4c0e0ba09ba0..da80933963db 100644
--- a/include/acpi/platform/acgcc.h
+++ b/include/acpi/platform/acgcc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -48,12 +48,14 @@
48 48
49#define ACPI_GET_FUNCTION_NAME __FUNCTION__ 49#define ACPI_GET_FUNCTION_NAME __FUNCTION__
50 50
51/* This macro is used to tag functions as "printf-like" because 51/*
52 * This macro is used to tag functions as "printf-like" because
52 * some compilers (like GCC) can catch printf format string problems. 53 * some compilers (like GCC) can catch printf format string problems.
53 */ 54 */
54#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 6, 7))) 55#define ACPI_PRINTF_LIKE(c) __attribute__ ((__format__ (__printf__, c, c+1)))
55 56
56/* Some compilers complain about unused variables. Sometimes we don't want to 57/*
58 * Some compilers complain about unused variables. Sometimes we don't want to
57 * use all the variables (for example, _acpi_module_name). This allows us 59 * use all the variables (for example, _acpi_module_name). This allows us
58 * to to tell the compiler warning in a per-variable manner that a variable 60 * to to tell the compiler warning in a per-variable manner that a variable
59 * is unused. 61 * is unused.
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index c93e6562f0e1..2e6d54569ee8 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -71,6 +71,10 @@
71#define acpi_cache_t kmem_cache_t 71#define acpi_cache_t kmem_cache_t
72#endif 72#endif
73 73
74/* Full namespace pathname length limit - arbitrary */
75
76#define ACPI_PATHNAME_MAX 256
77
74#else /* !__KERNEL__ */ 78#else /* !__KERNEL__ */
75 79
76#include <stdarg.h> 80#include <stdarg.h>
@@ -98,4 +102,6 @@
98 102
99#include "acgcc.h" 103#include "acgcc.h"
100 104
105#define acpi_cpu_flags unsigned long
106
101#endif /* __ACLINUX_H__ */ 107#endif /* __ACLINUX_H__ */
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 7a00d5089de9..badf0277b1be 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -62,9 +62,6 @@ struct acpi_processor_power {
62 u32 bm_activity; 62 u32 bm_activity;
63 int count; 63 int count;
64 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER]; 64 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
65
66 /* the _PDC objects passed by the driver, if any */
67 struct acpi_object_list *pdc;
68}; 65};
69 66
70/* Performance Management */ 67/* Performance Management */
@@ -96,8 +93,6 @@ struct acpi_processor_performance {
96 unsigned int state_count; 93 unsigned int state_count;
97 struct acpi_processor_px *states; 94 struct acpi_processor_px *states;
98 95
99 /* the _PDC objects passed by the driver, if any */
100 struct acpi_object_list *pdc;
101}; 96};
102 97
103/* Throttling Control */ 98/* Throttling Control */
@@ -151,6 +146,9 @@ struct acpi_processor {
151 struct acpi_processor_performance *performance; 146 struct acpi_processor_performance *performance;
152 struct acpi_processor_throttling throttling; 147 struct acpi_processor_throttling throttling;
153 struct acpi_processor_limit limit; 148 struct acpi_processor_limit limit;
149
150 /* the _PDC objects for this processor, if any */
151 struct acpi_object_list *pdc;
154}; 152};
155 153
156struct acpi_processor_errata { 154struct acpi_processor_errata {
@@ -178,22 +176,12 @@ int acpi_processor_notify_smm(struct module *calling_module);
178extern struct acpi_processor *processors[NR_CPUS]; 176extern struct acpi_processor *processors[NR_CPUS];
179extern struct acpi_processor_errata errata; 177extern struct acpi_processor_errata errata;
180 178
181int acpi_processor_set_pdc(struct acpi_processor *pr, 179void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
182 struct acpi_object_list *pdc_in);
183 180
184#ifdef ARCH_HAS_POWER_PDC_INIT 181#ifdef ARCH_HAS_POWER_INIT
185void acpi_processor_power_init_pdc(struct acpi_processor_power *pow,
186 unsigned int cpu);
187void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, 182void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
188 unsigned int cpu); 183 unsigned int cpu);
189#else 184#else
190static inline void acpi_processor_power_init_pdc(struct acpi_processor_power
191 *pow, unsigned int cpu)
192{
193 pow->pdc = NULL;
194 return;
195}
196
197static inline void acpi_processor_power_init_bm_check(struct 185static inline void acpi_processor_power_init_bm_check(struct
198 acpi_processor_flags 186 acpi_processor_flags
199 *flags, unsigned int cpu) 187 *flags, unsigned int cpu)
@@ -235,9 +223,6 @@ static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
235/* in processor_throttling.c */ 223/* in processor_throttling.c */
236int acpi_processor_get_throttling_info(struct acpi_processor *pr); 224int acpi_processor_get_throttling_info(struct acpi_processor *pr);
237int acpi_processor_set_throttling(struct acpi_processor *pr, int state); 225int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
238ssize_t acpi_processor_write_throttling(struct file *file,
239 const char __user * buffer,
240 size_t count, loff_t * data);
241extern struct file_operations acpi_processor_throttling_fops; 226extern struct file_operations acpi_processor_throttling_fops;
242 227
243/* in processor_idle.c */ 228/* in processor_idle.c */
@@ -249,9 +234,6 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
249 234
250/* in processor_thermal.c */ 235/* in processor_thermal.c */
251int acpi_processor_get_limit_info(struct acpi_processor *pr); 236int acpi_processor_get_limit_info(struct acpi_processor *pr);
252ssize_t acpi_processor_write_limit(struct file *file,
253 const char __user * buffer,
254 size_t count, loff_t * data);
255extern struct file_operations acpi_processor_limit_fops; 237extern struct file_operations acpi_processor_limit_fops;
256 238
257#ifdef CONFIG_CPU_FREQ 239#ifdef CONFIG_CPU_FREQ
diff --git a/include/asm-alpha/dma-mapping.h b/include/asm-alpha/dma-mapping.h
index 9dc7256cf979..62d0d6681aa9 100644
--- a/include/asm-alpha/dma-mapping.h
+++ b/include/asm-alpha/dma-mapping.h
@@ -30,6 +30,7 @@
30 30
31#else /* no PCI - no IOMMU. */ 31#else /* no PCI - no IOMMU. */
32 32
33struct scatterlist;
33void *dma_alloc_coherent(struct device *dev, size_t size, 34void *dma_alloc_coherent(struct device *dev, size_t size,
34 dma_addr_t *dma_handle, gfp_t gfp); 35 dma_addr_t *dma_handle, gfp_t gfp);
35int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 36int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
diff --git a/include/asm-arm/arch-s3c2410/debug-macro.S b/include/asm-arm/arch-s3c2410/debug-macro.S
index abfbe45cd17c..5f8223e700d3 100644
--- a/include/asm-arm/arch-s3c2410/debug-macro.S
+++ b/include/asm-arm/arch-s3c2410/debug-macro.S
@@ -25,7 +25,7 @@
25 .macro addruart, rx 25 .macro addruart, rx
26 mrc p15, 0, \rx, c1, c0 26 mrc p15, 0, \rx, c1, c0
27 tst \rx, #1 27 tst \rx, #1
28 ldreq \rx, = S3C2410_PA_UART 28 ldreq \rx, = S3C24XX_PA_UART
29 ldrne \rx, = S3C24XX_VA_UART 29 ldrne \rx, = S3C24XX_VA_UART
30#if CONFIG_DEBUG_S3C2410_UART != 0 30#if CONFIG_DEBUG_S3C2410_UART != 0
31 add \rx, \rx, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C2410_UART) 31 add \rx, \rx, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C2410_UART)
@@ -44,7 +44,7 @@
441003: 441003:
45 mrc p15, 0, \rd, c1, c0 45 mrc p15, 0, \rd, c1, c0
46 tst \rd, #1 46 tst \rd, #1
47 addeq \rd, \rx, #(S3C2410_PA_GPIO - S3C2410_PA_UART) 47 addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
48 addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART) 48 addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART)
49 bic \rd, \rd, #0xff000 49 bic \rd, \rd, #0xff000
50 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ] 50 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ]
@@ -75,7 +75,7 @@
751003: 751003:
76 mrc p15, 0, \rd, c1, c0 76 mrc p15, 0, \rd, c1, c0
77 tst \rd, #1 77 tst \rd, #1
78 addeq \rd, \rx, #(S3C2410_PA_GPIO - S3C2410_PA_UART) 78 addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
79 addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART) 79 addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART)
80 bic \rd, \rd, #0xff000 80 bic \rd, \rd, #0xff000
81 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ] 81 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ]
diff --git a/include/asm-arm/arch-s3c2410/hardware.h b/include/asm-arm/arch-s3c2410/hardware.h
index 1c9de29cafef..a2330bf83695 100644
--- a/include/asm-arm/arch-s3c2410/hardware.h
+++ b/include/asm-arm/arch-s3c2410/hardware.h
@@ -17,6 +17,7 @@
17 * 14-Sep-2004 BJD Added misccr and getpin to gpio 17 * 14-Sep-2004 BJD Added misccr and getpin to gpio
18 * 01-Oct-2004 BJD Added the new gpio functions 18 * 01-Oct-2004 BJD Added the new gpio functions
19 * 16-Oct-2004 BJD Removed the clock variables 19 * 16-Oct-2004 BJD Removed the clock variables
20 * 15-Jan-2006 LCVR Added s3c2400_gpio_getirq()
20*/ 21*/
21 22
22#ifndef __ASM_ARCH_HARDWARE_H 23#ifndef __ASM_ARCH_HARDWARE_H
@@ -55,6 +56,12 @@ extern unsigned int s3c2410_gpio_getcfg(unsigned int pin);
55 56
56extern int s3c2410_gpio_getirq(unsigned int pin); 57extern int s3c2410_gpio_getirq(unsigned int pin);
57 58
59#ifdef CONFIG_CPU_S3C2400
60
61extern int s3c2400_gpio_getirq(unsigned int pin);
62
63#endif /* CONFIG_CPU_S3C2400 */
64
58/* s3c2410_gpio_irqfilter 65/* s3c2410_gpio_irqfilter
59 * 66 *
60 * set the irq filtering on the given pin 67 * set the irq filtering on the given pin
diff --git a/include/asm-arm/arch-s3c2410/map.h b/include/asm-arm/arch-s3c2410/map.h
index 1833ea5c4220..c380d264a847 100644
--- a/include/asm-arm/arch-s3c2410/map.h
+++ b/include/asm-arm/arch-s3c2410/map.h
@@ -14,6 +14,7 @@
14 * 06-Jan-2003 BJD Linux 2.6.0 version, moved bast specifics out 14 * 06-Jan-2003 BJD Linux 2.6.0 version, moved bast specifics out
15 * 10-Feb-2005 BJD Added CAMIF definition from guillaume.gourat@nexvision.tv 15 * 10-Feb-2005 BJD Added CAMIF definition from guillaume.gourat@nexvision.tv
16 * 10-Mar-2005 LCVR Added support to S3C2400, changed {VA,SZ} names 16 * 10-Mar-2005 LCVR Added support to S3C2400, changed {VA,SZ} names
17 * 15-Jan-2006 LCVR Added S3C24XX_PA macros for common S3C24XX resources
17*/ 18*/
18 19
19#ifndef __ASM_ARCH_MAP_H 20#ifndef __ASM_ARCH_MAP_H
@@ -188,5 +189,42 @@
188 189
189#define S3C2400_SDRAM_PA (S3C2400_CS6) 190#define S3C2400_SDRAM_PA (S3C2400_CS6)
190 191
192/* Use a single interface for common resources between S3C24XX cpus */
193
194#ifdef CONFIG_CPU_S3C2400
195#define S3C24XX_PA_IRQ S3C2400_PA_IRQ
196#define S3C24XX_PA_MEMCTRL S3C2400_PA_MEMCTRL
197#define S3C24XX_PA_USBHOST S3C2400_PA_USBHOST
198#define S3C24XX_PA_DMA S3C2400_PA_DMA
199#define S3C24XX_PA_CLKPWR S3C2400_PA_CLKPWR
200#define S3C24XX_PA_LCD S3C2400_PA_LCD
201#define S3C24XX_PA_UART S3C2400_PA_UART
202#define S3C24XX_PA_TIMER S3C2400_PA_TIMER
203#define S3C24XX_PA_USBDEV S3C2400_PA_USBDEV
204#define S3C24XX_PA_WATCHDOG S3C2400_PA_WATCHDOG
205#define S3C24XX_PA_IIC S3C2400_PA_IIC
206#define S3C24XX_PA_IIS S3C2400_PA_IIS
207#define S3C24XX_PA_GPIO S3C2400_PA_GPIO
208#define S3C24XX_PA_RTC S3C2400_PA_RTC
209#define S3C24XX_PA_ADC S3C2400_PA_ADC
210#define S3C24XX_PA_SPI S3C2400_PA_SPI
211#else
212#define S3C24XX_PA_IRQ S3C2410_PA_IRQ
213#define S3C24XX_PA_MEMCTRL S3C2410_PA_MEMCTRL
214#define S3C24XX_PA_USBHOST S3C2410_PA_USBHOST
215#define S3C24XX_PA_DMA S3C2410_PA_DMA
216#define S3C24XX_PA_CLKPWR S3C2410_PA_CLKPWR
217#define S3C24XX_PA_LCD S3C2410_PA_LCD
218#define S3C24XX_PA_UART S3C2410_PA_UART
219#define S3C24XX_PA_TIMER S3C2410_PA_TIMER
220#define S3C24XX_PA_USBDEV S3C2410_PA_USBDEV
221#define S3C24XX_PA_WATCHDOG S3C2410_PA_WATCHDOG
222#define S3C24XX_PA_IIC S3C2410_PA_IIC
223#define S3C24XX_PA_IIS S3C2410_PA_IIS
224#define S3C24XX_PA_GPIO S3C2410_PA_GPIO
225#define S3C24XX_PA_RTC S3C2410_PA_RTC
226#define S3C24XX_PA_ADC S3C2410_PA_ADC
227#define S3C24XX_PA_SPI S3C2410_PA_SPI
228#endif
191 229
192#endif /* __ASM_ARCH_MAP_H */ 230#endif /* __ASM_ARCH_MAP_H */
diff --git a/include/asm-arm/arch-s3c2410/regs-gpio.h b/include/asm-arm/arch-s3c2410/regs-gpio.h
index 7f1be48ad67e..9697f93afe74 100644
--- a/include/asm-arm/arch-s3c2410/regs-gpio.h
+++ b/include/asm-arm/arch-s3c2410/regs-gpio.h
@@ -22,6 +22,7 @@
22 * 28-Mar-2005 LCVR Fixed definition of GPB10 22 * 28-Mar-2005 LCVR Fixed definition of GPB10
23 * 26-Oct-2005 BJD Added generic configuration types 23 * 26-Oct-2005 BJD Added generic configuration types
24 * 27-Nov-2005 LCVR Added definitions to S3C2400 registers 24 * 27-Nov-2005 LCVR Added definitions to S3C2400 registers
25 * 15-Jan-2006 LCVR Written S3C24XX_GPIO_BASE() macro
25*/ 26*/
26 27
27 28
@@ -39,6 +40,27 @@
39#define S3C2410_GPIO_BANKG (32*6) 40#define S3C2410_GPIO_BANKG (32*6)
40#define S3C2410_GPIO_BANKH (32*7) 41#define S3C2410_GPIO_BANKH (32*7)
41 42
43#ifdef CONFIG_CPU_S3C2400
44#define S3C24XX_GPIO_BASE(x) S3C2400_GPIO_BASE(x)
45#define S3C24XX_MISCCR S3C2400_MISCCR
46#else
47#define S3C24XX_GPIO_BASE(x) S3C2410_GPIO_BASE(x)
48#define S3C24XX_MISCCR S3C2410_MISCCR
49#endif /* CONFIG_CPU_S3C2400 */
50
51
52/* S3C2400 doesn't have a 1:1 mapping to S3C2410 gpio base pins */
53
54#define S3C2400_BANKNUM(pin) (((pin) & ~31) / 32)
55#define S3C2400_BASEA2B(pin) ((((pin) & ~31) >> 2))
56#define S3C2400_BASEC2H(pin) ((S3C2400_BANKNUM(pin) * 10) + \
57 (2 * (S3C2400_BANKNUM(pin)-2)))
58
59#define S3C2400_GPIO_BASE(pin) (pin < S3C2410_GPIO_BANKC ? \
60 S3C2400_BASEA2B(pin)+S3C24XX_VA_GPIO : \
61 S3C2400_BASEC2H(pin)+S3C24XX_VA_GPIO)
62
63
42#define S3C2410_GPIO_BASE(pin) ((((pin) & ~31) >> 1) + S3C24XX_VA_GPIO) 64#define S3C2410_GPIO_BASE(pin) ((((pin) & ~31) >> 1) + S3C24XX_VA_GPIO)
43#define S3C2410_GPIO_OFFSET(pin) ((pin) & 31) 65#define S3C2410_GPIO_OFFSET(pin) ((pin) & 31)
44 66
diff --git a/include/asm-arm/arch-s3c2410/regs-serial.h b/include/asm-arm/arch-s3c2410/regs-serial.h
index ce1bbbaad6d3..83b01254c4ac 100644
--- a/include/asm-arm/arch-s3c2410/regs-serial.h
+++ b/include/asm-arm/arch-s3c2410/regs-serial.h
@@ -39,9 +39,9 @@
39#define S3C24XX_VA_UART1 (S3C24XX_VA_UART + 0x4000 ) 39#define S3C24XX_VA_UART1 (S3C24XX_VA_UART + 0x4000 )
40#define S3C24XX_VA_UART2 (S3C24XX_VA_UART + 0x8000 ) 40#define S3C24XX_VA_UART2 (S3C24XX_VA_UART + 0x8000 )
41 41
42#define S3C2410_PA_UART0 (S3C2410_PA_UART) 42#define S3C2410_PA_UART0 (S3C24XX_PA_UART)
43#define S3C2410_PA_UART1 (S3C2410_PA_UART + 0x4000 ) 43#define S3C2410_PA_UART1 (S3C24XX_PA_UART + 0x4000 )
44#define S3C2410_PA_UART2 (S3C2410_PA_UART + 0x8000 ) 44#define S3C2410_PA_UART2 (S3C24XX_PA_UART + 0x8000 )
45 45
46#define S3C2410_URXH (0x24) 46#define S3C2410_URXH (0x24)
47#define S3C2410_UTXH (0x20) 47#define S3C2410_UTXH (0x20)
diff --git a/include/asm-arm/arch-s3c2410/uncompress.h b/include/asm-arm/arch-s3c2410/uncompress.h
index ddd1578a7ee0..4367ec054b51 100644
--- a/include/asm-arm/arch-s3c2410/uncompress.h
+++ b/include/asm-arm/arch-s3c2410/uncompress.h
@@ -35,13 +35,13 @@
35#undef S3C2410_GPIOREG 35#undef S3C2410_GPIOREG
36#undef S3C2410_WDOGREG 36#undef S3C2410_WDOGREG
37 37
38#define S3C2410_GPIOREG(x) ((S3C2410_PA_GPIO + (x))) 38#define S3C2410_GPIOREG(x) ((S3C24XX_PA_GPIO + (x)))
39#define S3C2410_WDOGREG(x) ((S3C2410_PA_WATCHDOG + (x))) 39#define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x)))
40 40
41/* how many bytes we allow into the FIFO at a time in FIFO mode */ 41/* how many bytes we allow into the FIFO at a time in FIFO mode */
42#define FIFO_MAX (14) 42#define FIFO_MAX (14)
43 43
44#define uart_base S3C2410_PA_UART + (0x4000*CONFIG_S3C2410_LOWLEVEL_UART_PORT) 44#define uart_base S3C24XX_PA_UART + (0x4000*CONFIG_S3C2410_LOWLEVEL_UART_PORT)
45 45
46static __inline__ void 46static __inline__ void
47uart_wr(unsigned int reg, unsigned int val) 47uart_wr(unsigned int reg, unsigned int val)
diff --git a/include/asm-arm/checksum.h b/include/asm-arm/checksum.h
index d4256d5f3a7c..747bdd31a74b 100644
--- a/include/asm-arm/checksum.h
+++ b/include/asm-arm/checksum.h
@@ -77,7 +77,7 @@ ip_fast_csum(unsigned char * iph, unsigned int ihl)
77 mov %0, %0, lsr #16" 77 mov %0, %0, lsr #16"
78 : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (tmp1) 78 : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (tmp1)
79 : "1" (iph), "2" (ihl) 79 : "1" (iph), "2" (ihl)
80 : "cc"); 80 : "cc", "memory");
81 return sum; 81 return sum;
82} 82}
83 83
diff --git a/include/asm-arm/mach/map.h b/include/asm-arm/mach/map.h
index 3351b77fab36..e8ea67c97c73 100644
--- a/include/asm-arm/mach/map.h
+++ b/include/asm-arm/mach/map.h
@@ -26,6 +26,7 @@ struct meminfo;
26#define MT_MEMORY 5 26#define MT_MEMORY 5
27#define MT_ROM 6 27#define MT_ROM 6
28#define MT_IXP2000_DEVICE 7 28#define MT_IXP2000_DEVICE 7
29#define MT_NONSHARED_DEVICE 8
29 30
30extern void create_memmap_holes(struct meminfo *); 31extern void create_memmap_holes(struct meminfo *);
31extern void memtable_init(struct meminfo *); 32extern void memtable_init(struct meminfo *);
diff --git a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
index 5a0d19b466b0..70e00d08345e 100644
--- a/include/asm-arm/pgtable.h
+++ b/include/asm-arm/pgtable.h
@@ -168,6 +168,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
168#define PMD_SECT_WB (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) 168#define PMD_SECT_WB (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE)
169#define PMD_SECT_MINICACHE (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE) 169#define PMD_SECT_MINICACHE (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE)
170#define PMD_SECT_WBWA (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) 170#define PMD_SECT_WBWA (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE)
171#define PMD_SECT_NONSHARED_DEV (PMD_SECT_TEX(2))
171 172
172/* 173/*
173 * - coarse table (not used) 174 * - coarse table (not used)
diff --git a/include/asm-arm26/bitops.h b/include/asm-arm26/bitops.h
index 15cc6f2da792..d87f8634e625 100644
--- a/include/asm-arm26/bitops.h
+++ b/include/asm-arm26/bitops.h
@@ -186,7 +186,7 @@ extern void _change_bit_le(int nr, volatile unsigned long * p);
186extern int _test_and_set_bit_le(int nr, volatile unsigned long * p); 186extern int _test_and_set_bit_le(int nr, volatile unsigned long * p);
187extern int _test_and_clear_bit_le(int nr, volatile unsigned long * p); 187extern int _test_and_clear_bit_le(int nr, volatile unsigned long * p);
188extern int _test_and_change_bit_le(int nr, volatile unsigned long * p); 188extern int _test_and_change_bit_le(int nr, volatile unsigned long * p);
189extern int _find_first_zero_bit_le(void * p, unsigned size); 189extern int _find_first_zero_bit_le(const unsigned long * p, unsigned size);
190extern int _find_next_zero_bit_le(void * p, int size, int offset); 190extern int _find_next_zero_bit_le(void * p, int size, int offset);
191extern int _find_first_bit_le(const unsigned long *p, unsigned size); 191extern int _find_first_bit_le(const unsigned long *p, unsigned size);
192extern int _find_next_bit_le(const unsigned long *p, int size, int offset); 192extern int _find_next_bit_le(const unsigned long *p, int size, int offset);
@@ -326,7 +326,7 @@ static inline int sched_find_first_bit(unsigned long *b)
326#define minix_test_and_clear_bit(nr,p) \ 326#define minix_test_and_clear_bit(nr,p) \
327 __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) 327 __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
328#define minix_find_first_zero_bit(p,sz) \ 328#define minix_find_first_zero_bit(p,sz) \
329 _find_first_zero_bit_le(p,sz) 329 _find_first_zero_bit_le((unsigned long *)(p),sz)
330 330
331#endif /* __KERNEL__ */ 331#endif /* __KERNEL__ */
332 332
diff --git a/include/asm-arm26/hardirq.h b/include/asm-arm26/hardirq.h
index dc28daab8aa8..87c19d2bb6a8 100644
--- a/include/asm-arm26/hardirq.h
+++ b/include/asm-arm26/hardirq.h
@@ -4,6 +4,7 @@
4#include <linux/config.h> 4#include <linux/config.h>
5#include <linux/cache.h> 5#include <linux/cache.h>
6#include <linux/threads.h> 6#include <linux/threads.h>
7#include <asm/irq.h>
7 8
8typedef struct { 9typedef struct {
9 unsigned int __softirq_pending; 10 unsigned int __softirq_pending;
@@ -26,13 +27,6 @@ typedef struct {
26 27
27extern asmlinkage void __do_softirq(void); 28extern asmlinkage void __do_softirq(void);
28 29
29#define irq_exit() \
30 do { \
31 preempt_count() -= IRQ_EXIT_OFFSET; \
32 if (!in_interrupt() && local_softirq_pending()) \
33 __do_softirq(); \
34 preempt_enable_no_resched(); \
35 } while (0)
36#endif 30#endif
37 31
38 32
diff --git a/include/asm-arm26/posix_types.h b/include/asm-arm26/posix_types.h
index b88344ad390c..f8d1eb4f4cb1 100644
--- a/include/asm-arm26/posix_types.h
+++ b/include/asm-arm26/posix_types.h
@@ -44,6 +44,7 @@ typedef unsigned int __kernel_gid32_t;
44 44
45typedef unsigned short __kernel_old_uid_t; 45typedef unsigned short __kernel_old_uid_t;
46typedef unsigned short __kernel_old_gid_t; 46typedef unsigned short __kernel_old_gid_t;
47typedef unsigned short __kernel_old_dev_t;
47 48
48#ifdef __GNUC__ 49#ifdef __GNUC__
49typedef long long __kernel_loff_t; 50typedef long long __kernel_loff_t;
diff --git a/include/asm-arm26/system.h b/include/asm-arm26/system.h
index ca4ccfc4b578..702884926a55 100644
--- a/include/asm-arm26/system.h
+++ b/include/asm-arm26/system.h
@@ -98,9 +98,8 @@ extern unsigned int user_debug;
98 * spin_unlock_irq() and friends are implemented. This avoids 98 * spin_unlock_irq() and friends are implemented. This avoids
99 * us needlessly decrementing and incrementing the preempt count. 99 * us needlessly decrementing and incrementing the preempt count.
100 */ 100 */
101#define prepare_arch_switch(rq,next) local_irq_enable() 101#define prepare_arch_switch(next) local_irq_enable()
102#define finish_arch_switch(rq,prev) spin_unlock(&(rq)->lock) 102#define finish_arch_switch(prev) spin_unlock(&(rq)->lock)
103#define task_running(rq,p) ((rq)->curr == (p))
104 103
105/* 104/*
106 * switch_to(prev, next) should switch from task `prev' to `next' 105 * switch_to(prev, next) should switch from task `prev' to `next'
diff --git a/include/asm-cris/bitops.h b/include/asm-cris/bitops.h
index d3eb0f1e4208..b7fef1572dc0 100644
--- a/include/asm-cris/bitops.h
+++ b/include/asm-cris/bitops.h
@@ -290,7 +290,7 @@ static inline int find_next_zero_bit (const unsigned long * addr, int size, int
290 tmp = *p; 290 tmp = *p;
291 291
292 found_first: 292 found_first:
293 tmp |= ~0UL >> size; 293 tmp |= ~0UL << size;
294 found_middle: 294 found_middle:
295 return result + ffz(tmp); 295 return result + ffz(tmp);
296} 296}
diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h
index 02be7b3a8a83..f686b519878e 100644
--- a/include/asm-frv/bitops.h
+++ b/include/asm-frv/bitops.h
@@ -209,7 +209,7 @@ static inline int find_next_zero_bit(const void *addr, int size, int offset)
209 tmp = *p; 209 tmp = *p;
210 210
211found_first: 211found_first:
212 tmp |= ~0UL >> size; 212 tmp |= ~0UL << size;
213found_middle: 213found_middle:
214 return result + ffz(tmp); 214 return result + ffz(tmp);
215} 215}
diff --git a/include/asm-h8300/bitops.h b/include/asm-h8300/bitops.h
index c0411ec9d651..ff7c2b721594 100644
--- a/include/asm-h8300/bitops.h
+++ b/include/asm-h8300/bitops.h
@@ -227,7 +227,7 @@ static __inline__ int find_next_zero_bit (const unsigned long * addr, int size,
227 tmp = *p; 227 tmp = *p;
228 228
229found_first: 229found_first:
230 tmp |= ~0UL >> size; 230 tmp |= ~0UL << size;
231found_middle: 231found_middle:
232 return result + ffz(tmp); 232 return result + ffz(tmp);
233} 233}
diff --git a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h
index df4ed323aa4d..55059abf9c95 100644
--- a/include/asm-i386/acpi.h
+++ b/include/asm-i386/acpi.h
@@ -179,7 +179,7 @@ extern void acpi_reserve_bootmem(void);
179 179
180extern u8 x86_acpiid_to_apicid[]; 180extern u8 x86_acpiid_to_apicid[];
181 181
182#define ARCH_HAS_POWER_PDC_INIT 1 182#define ARCH_HAS_POWER_INIT 1
183 183
184#endif /*__KERNEL__*/ 184#endif /*__KERNEL__*/
185 185
diff --git a/include/asm-i386/page.h b/include/asm-i386/page.h
index 73296d9924fb..997ca5d17876 100644
--- a/include/asm-i386/page.h
+++ b/include/asm-i386/page.h
@@ -110,10 +110,10 @@ extern int page_is_ram(unsigned long pagenr);
110#endif /* __ASSEMBLY__ */ 110#endif /* __ASSEMBLY__ */
111 111
112#ifdef __ASSEMBLY__ 112#ifdef __ASSEMBLY__
113#define __PAGE_OFFSET (0xC0000000) 113#define __PAGE_OFFSET CONFIG_PAGE_OFFSET
114#define __PHYSICAL_START CONFIG_PHYSICAL_START 114#define __PHYSICAL_START CONFIG_PHYSICAL_START
115#else 115#else
116#define __PAGE_OFFSET (0xC0000000UL) 116#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET)
117#define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START) 117#define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START)
118#endif 118#endif
119#define __KERNEL_START (__PAGE_OFFSET + __PHYSICAL_START) 119#define __KERNEL_START (__PAGE_OFFSET + __PHYSICAL_START)
diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h
index 36a92ed6a9d0..399145a247f2 100644
--- a/include/asm-i386/system.h
+++ b/include/asm-i386/system.h
@@ -507,7 +507,7 @@ struct alt_instr {
507#define smp_rmb() rmb() 507#define smp_rmb() rmb()
508#define smp_wmb() wmb() 508#define smp_wmb() wmb()
509#define smp_read_barrier_depends() read_barrier_depends() 509#define smp_read_barrier_depends() read_barrier_depends()
510#define set_mb(var, value) do { xchg(&var, value); } while (0) 510#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
511#else 511#else
512#define smp_mb() barrier() 512#define smp_mb() barrier()
513#define smp_rmb() barrier() 513#define smp_rmb() barrier()
diff --git a/include/asm-i386/topology.h b/include/asm-i386/topology.h
index d7e19eb344b7..af503a122b23 100644
--- a/include/asm-i386/topology.h
+++ b/include/asm-i386/topology.h
@@ -27,6 +27,15 @@
27#ifndef _ASM_I386_TOPOLOGY_H 27#ifndef _ASM_I386_TOPOLOGY_H
28#define _ASM_I386_TOPOLOGY_H 28#define _ASM_I386_TOPOLOGY_H
29 29
30#ifdef CONFIG_SMP
31#define topology_physical_package_id(cpu) \
32 (phys_proc_id[cpu] == BAD_APICID ? -1 : phys_proc_id[cpu])
33#define topology_core_id(cpu) \
34 (cpu_core_id[cpu] == BAD_APICID ? 0 : cpu_core_id[cpu])
35#define topology_core_siblings(cpu) (cpu_core_map[cpu])
36#define topology_thread_siblings(cpu) (cpu_sibling_map[cpu])
37#endif
38
30#ifdef CONFIG_NUMA 39#ifdef CONFIG_NUMA
31 40
32#include <asm/mpspec.h> 41#include <asm/mpspec.h>
diff --git a/include/asm-ia64/ide.h b/include/asm-ia64/ide.h
index e62b95301d51..93f45c5f189f 100644
--- a/include/asm-ia64/ide.h
+++ b/include/asm-ia64/ide.h
@@ -17,14 +17,6 @@
17 17
18#include <linux/irq.h> 18#include <linux/irq.h>
19 19
20#ifndef MAX_HWIFS
21# ifdef CONFIG_PCI
22#define MAX_HWIFS 10
23# else
24#define MAX_HWIFS 6
25# endif
26#endif
27
28#define IDE_ARCH_OBSOLETE_DEFAULTS 20#define IDE_ARCH_OBSOLETE_DEFAULTS
29 21
30static inline int ide_default_irq(unsigned long base) 22static inline int ide_default_irq(unsigned long base)
diff --git a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h
index 09b99029ac1a..23c8e1be1911 100644
--- a/include/asm-ia64/processor.h
+++ b/include/asm-ia64/processor.h
@@ -559,6 +559,23 @@ ia64_eoi (void)
559 559
560#define cpu_relax() ia64_hint(ia64_hint_pause) 560#define cpu_relax() ia64_hint(ia64_hint_pause)
561 561
562static inline int
563ia64_get_irr(unsigned int vector)
564{
565 unsigned int reg = vector / 64;
566 unsigned int bit = vector % 64;
567 u64 irr;
568
569 switch (reg) {
570 case 0: irr = ia64_getreg(_IA64_REG_CR_IRR0); break;
571 case 1: irr = ia64_getreg(_IA64_REG_CR_IRR1); break;
572 case 2: irr = ia64_getreg(_IA64_REG_CR_IRR2); break;
573 case 3: irr = ia64_getreg(_IA64_REG_CR_IRR3); break;
574 }
575
576 return test_bit(bit, &irr);
577}
578
562static inline void 579static inline void
563ia64_set_lrr0 (unsigned long val) 580ia64_set_lrr0 (unsigned long val)
564{ 581{
diff --git a/include/asm-ia64/sal.h b/include/asm-ia64/sal.h
index 313cad0628d0..0b210abbe003 100644
--- a/include/asm-ia64/sal.h
+++ b/include/asm-ia64/sal.h
@@ -658,15 +658,7 @@ ia64_sal_freq_base (unsigned long which, unsigned long *ticks_per_second,
658 return isrv.status; 658 return isrv.status;
659} 659}
660 660
661/* Flush all the processor and platform level instruction and/or data caches */ 661extern s64 ia64_sal_cache_flush (u64 cache_type);
662static inline s64
663ia64_sal_cache_flush (u64 cache_type)
664{
665 struct ia64_sal_retval isrv;
666 SAL_CALL(isrv, SAL_CACHE_FLUSH, cache_type, 0, 0, 0, 0, 0, 0);
667 return isrv.status;
668}
669
670 662
671/* Initialize all the processor and platform level instruction and data caches */ 663/* Initialize all the processor and platform level instruction and data caches */
672static inline s64 664static inline s64
diff --git a/include/asm-ia64/sn/bte.h b/include/asm-ia64/sn/bte.h
index f50da3d91d07..01e5b4103235 100644
--- a/include/asm-ia64/sn/bte.h
+++ b/include/asm-ia64/sn/bte.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9 9
@@ -100,13 +100,28 @@
100#define BTE_LNSTAT_STORE(_bte, _x) \ 100#define BTE_LNSTAT_STORE(_bte, _x) \
101 HUB_S(_bte->bte_base_addr, (_x)) 101 HUB_S(_bte->bte_base_addr, (_x))
102#define BTE_SRC_STORE(_bte, _x) \ 102#define BTE_SRC_STORE(_bte, _x) \
103 HUB_S(_bte->bte_source_addr, (_x)) 103({ \
104 u64 __addr = ((_x) & ~AS_MASK); \
105 if (is_shub2()) \
106 __addr = SH2_TIO_PHYS_TO_DMA(__addr); \
107 HUB_S(_bte->bte_source_addr, __addr); \
108})
104#define BTE_DEST_STORE(_bte, _x) \ 109#define BTE_DEST_STORE(_bte, _x) \
105 HUB_S(_bte->bte_destination_addr, (_x)) 110({ \
111 u64 __addr = ((_x) & ~AS_MASK); \
112 if (is_shub2()) \
113 __addr = SH2_TIO_PHYS_TO_DMA(__addr); \
114 HUB_S(_bte->bte_destination_addr, __addr); \
115})
106#define BTE_CTRL_STORE(_bte, _x) \ 116#define BTE_CTRL_STORE(_bte, _x) \
107 HUB_S(_bte->bte_control_addr, (_x)) 117 HUB_S(_bte->bte_control_addr, (_x))
108#define BTE_NOTIF_STORE(_bte, _x) \ 118#define BTE_NOTIF_STORE(_bte, _x) \
109 HUB_S(_bte->bte_notify_addr, (_x)) 119({ \
120 u64 __addr = ia64_tpa((_x) & ~AS_MASK); \
121 if (is_shub2()) \
122 __addr = SH2_TIO_PHYS_TO_DMA(__addr); \
123 HUB_S(_bte->bte_notify_addr, __addr); \
124})
110 125
111#define BTE_START_TRANSFER(_bte, _len, _mode) \ 126#define BTE_START_TRANSFER(_bte, _len, _mode) \
112 is_shub2() ? BTE_CTRL_STORE(_bte, IBLS_BUSY | (_mode << 24) | _len) \ 127 is_shub2() ? BTE_CTRL_STORE(_bte, IBLS_BUSY | (_mode << 24) | _len) \
diff --git a/include/asm-ia64/sn/intr.h b/include/asm-ia64/sn/intr.h
index a3431372c6e7..60a51a406eec 100644
--- a/include/asm-ia64/sn/intr.h
+++ b/include/asm-ia64/sn/intr.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 1992 - 1997, 2000-2006 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8 8
9#ifndef _ASM_IA64_SN_INTR_H 9#ifndef _ASM_IA64_SN_INTR_H
@@ -11,26 +11,26 @@
11 11
12#include <linux/rcupdate.h> 12#include <linux/rcupdate.h>
13 13
14#define SGI_UART_VECTOR (0xe9) 14#define SGI_UART_VECTOR 0xe9
15 15
16/* Reserved IRQs : Note, not to exceed IA64_SN2_FIRST_DEVICE_VECTOR */ 16/* Reserved IRQs : Note, not to exceed IA64_SN2_FIRST_DEVICE_VECTOR */
17#define SGI_XPC_ACTIVATE (0x30) 17#define SGI_XPC_ACTIVATE 0x30
18#define SGI_II_ERROR (0x31) 18#define SGI_II_ERROR 0x31
19#define SGI_XBOW_ERROR (0x32) 19#define SGI_XBOW_ERROR 0x32
20#define SGI_PCIASIC_ERROR (0x33) 20#define SGI_PCIASIC_ERROR 0x33
21#define SGI_ACPI_SCI_INT (0x34) 21#define SGI_ACPI_SCI_INT 0x34
22#define SGI_TIOCA_ERROR (0x35) 22#define SGI_TIOCA_ERROR 0x35
23#define SGI_TIO_ERROR (0x36) 23#define SGI_TIO_ERROR 0x36
24#define SGI_TIOCX_ERROR (0x37) 24#define SGI_TIOCX_ERROR 0x37
25#define SGI_MMTIMER_VECTOR (0x38) 25#define SGI_MMTIMER_VECTOR 0x38
26#define SGI_XPC_NOTIFY (0xe7) 26#define SGI_XPC_NOTIFY 0xe7
27 27
28#define IA64_SN2_FIRST_DEVICE_VECTOR (0x3c) 28#define IA64_SN2_FIRST_DEVICE_VECTOR 0x3c
29#define IA64_SN2_LAST_DEVICE_VECTOR (0xe6) 29#define IA64_SN2_LAST_DEVICE_VECTOR 0xe6
30 30
31#define SN2_IRQ_RESERVED (0x1) 31#define SN2_IRQ_RESERVED 0x1
32#define SN2_IRQ_CONNECTED (0x2) 32#define SN2_IRQ_CONNECTED 0x2
33#define SN2_IRQ_SHARED (0x4) 33#define SN2_IRQ_SHARED 0x4
34 34
35// The SN PROM irq struct 35// The SN PROM irq struct
36struct sn_irq_info { 36struct sn_irq_info {
diff --git a/include/asm-ia64/sn/sn_feature_sets.h b/include/asm-ia64/sn/sn_feature_sets.h
index e68a80853d5d..9ca642cad338 100644
--- a/include/asm-ia64/sn/sn_feature_sets.h
+++ b/include/asm-ia64/sn/sn_feature_sets.h
@@ -8,7 +8,7 @@
8 * License. See the file "COPYING" in the main directory of this archive 8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details. 9 * for more details.
10 * 10 *
11 * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved. 11 * Copyright (c) 2005-2006 Silicon Graphics, Inc. All rights reserved.
12 */ 12 */
13 13
14 14
@@ -27,14 +27,12 @@ extern int sn_prom_feature_available(int id);
27 * "false" for new features. 27 * "false" for new features.
28 * 28 *
29 * Use: 29 * Use:
30 * if (sn_prom_feature_available(PRF_FEATURE_XXX)) 30 * if (sn_prom_feature_available(PRF_XXX))
31 * ... 31 * ...
32 */ 32 */
33 33
34/* 34#define PRF_PAL_CACHE_FLUSH_SAFE 0
35 * Example: feature XXX 35#define PRF_DEVICE_FLUSH_LIST 1
36 */
37#define PRF_FEATURE_XXX 0
38 36
39 37
40 38
@@ -51,7 +49,7 @@ extern int sn_prom_feature_available(int id);
51 * 49 *
52 * By default, features are disabled unless explicitly enabled. 50 * By default, features are disabled unless explicitly enabled.
53 */ 51 */
54#define OSF_MCA_SLV_TO_OS_INIT_SLV 0 52#define OSF_MCA_SLV_TO_OS_INIT_SLV 0
55#define OSF_FEAT_LOG_SBES 1 53#define OSF_FEAT_LOG_SBES 1
56 54
57#endif /* _ASM_IA64_SN_FEATURE_SETS_H */ 55#endif /* _ASM_IA64_SN_FEATURE_SETS_H */
diff --git a/include/asm-ia64/system.h b/include/asm-ia64/system.h
index 80c5a234e259..062538715623 100644
--- a/include/asm-ia64/system.h
+++ b/include/asm-ia64/system.h
@@ -249,32 +249,7 @@ extern void ia64_load_extra (struct task_struct *task);
249# define switch_to(prev,next,last) __switch_to(prev, next, last) 249# define switch_to(prev,next,last) __switch_to(prev, next, last)
250#endif 250#endif
251 251
252/*
253 * On IA-64, we don't want to hold the runqueue's lock during the low-level context-switch,
254 * because that could cause a deadlock. Here is an example by Erich Focht:
255 *
256 * Example:
257 * CPU#0:
258 * schedule()
259 * -> spin_lock_irq(&rq->lock)
260 * -> context_switch()
261 * -> wrap_mmu_context()
262 * -> read_lock(&tasklist_lock)
263 *
264 * CPU#1:
265 * sys_wait4() or release_task() or forget_original_parent()
266 * -> write_lock(&tasklist_lock)
267 * -> do_notify_parent()
268 * -> wake_up_parent()
269 * -> try_to_wake_up()
270 * -> spin_lock_irq(&parent_rq->lock)
271 *
272 * If the parent's rq happens to be on CPU#0, we'll wait for the rq->lock
273 * of that CPU which will not be released, because there we wait for the
274 * tasklist_lock to become available.
275 */
276#define __ARCH_WANT_UNLOCKED_CTXSW 252#define __ARCH_WANT_UNLOCKED_CTXSW
277
278#define ARCH_HAS_PREFETCH_SWITCH_STACK 253#define ARCH_HAS_PREFETCH_SWITCH_STACK
279#define ia64_platform_is(x) (strcmp(x, platform_name) == 0) 254#define ia64_platform_is(x) (strcmp(x, platform_name) == 0)
280 255
diff --git a/include/asm-ia64/topology.h b/include/asm-ia64/topology.h
index 412ef8e493a8..3ee19dfa46df 100644
--- a/include/asm-ia64/topology.h
+++ b/include/asm-ia64/topology.h
@@ -102,6 +102,13 @@ void build_cpu_to_node_map(void);
102 102
103#endif /* CONFIG_NUMA */ 103#endif /* CONFIG_NUMA */
104 104
105#ifdef CONFIG_SMP
106#define topology_physical_package_id(cpu) (cpu_data(cpu)->socket_id)
107#define topology_core_id(cpu) (cpu_data(cpu)->core_id)
108#define topology_core_siblings(cpu) (cpu_core_map[cpu])
109#define topology_thread_siblings(cpu) (cpu_sibling_map[cpu])
110#endif
111
105#include <asm-generic/topology.h> 112#include <asm-generic/topology.h>
106 113
107#endif /* _ASM_IA64_TOPOLOGY_H */ 114#endif /* _ASM_IA64_TOPOLOGY_H */
diff --git a/include/asm-parisc/atomic.h b/include/asm-parisc/atomic.h
index 2ca56d34aaad..4dc7253ff5d0 100644
--- a/include/asm-parisc/atomic.h
+++ b/include/asm-parisc/atomic.h
@@ -1,9 +1,13 @@
1/* Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
2 * Copyright (C) 2006 Kyle McMartin <kyle@parisc-linux.org>
3 */
4
1#ifndef _ASM_PARISC_ATOMIC_H_ 5#ifndef _ASM_PARISC_ATOMIC_H_
2#define _ASM_PARISC_ATOMIC_H_ 6#define _ASM_PARISC_ATOMIC_H_
3 7
4#include <linux/config.h> 8#include <linux/config.h>
9#include <linux/types.h>
5#include <asm/system.h> 10#include <asm/system.h>
6/* Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>. */
7 11
8/* 12/*
9 * Atomic operations that C can't guarantee us. Useful for 13 * Atomic operations that C can't guarantee us. Useful for
@@ -46,15 +50,6 @@ extern raw_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned;
46# define _atomic_spin_unlock_irqrestore(l,f) do { local_irq_restore(f); } while (0) 50# define _atomic_spin_unlock_irqrestore(l,f) do { local_irq_restore(f); } while (0)
47#endif 51#endif
48 52
49/* Note that we need not lock read accesses - aligned word writes/reads
50 * are atomic, so a reader never sees unconsistent values.
51 *
52 * Cache-line alignment would conflict with, for example, linux/module.h
53 */
54
55typedef struct { volatile int counter; } atomic_t;
56
57
58/* This should get optimized out since it's never called. 53/* This should get optimized out since it's never called.
59** Or get a link error if xchg is used "wrong". 54** Or get a link error if xchg is used "wrong".
60*/ 55*/
@@ -69,10 +64,9 @@ extern unsigned long __xchg64(unsigned long, unsigned long *);
69#endif 64#endif
70 65
71/* optimizer better get rid of switch since size is a constant */ 66/* optimizer better get rid of switch since size is a constant */
72static __inline__ unsigned long __xchg(unsigned long x, __volatile__ void * ptr, 67static __inline__ unsigned long
73 int size) 68__xchg(unsigned long x, __volatile__ void * ptr, int size)
74{ 69{
75
76 switch(size) { 70 switch(size) {
77#ifdef __LP64__ 71#ifdef __LP64__
78 case 8: return __xchg64(x,(unsigned long *) ptr); 72 case 8: return __xchg64(x,(unsigned long *) ptr);
@@ -129,7 +123,13 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
129 (unsigned long)_n_, sizeof(*(ptr))); \ 123 (unsigned long)_n_, sizeof(*(ptr))); \
130 }) 124 })
131 125
126/* Note that we need not lock read accesses - aligned word writes/reads
127 * are atomic, so a reader never sees unconsistent values.
128 *
129 * Cache-line alignment would conflict with, for example, linux/module.h
130 */
132 131
132typedef struct { volatile int counter; } atomic_t;
133 133
134/* It's possible to reduce all atomic operations to either 134/* It's possible to reduce all atomic operations to either
135 * __atomic_add_return, atomic_set and atomic_read (the latter 135 * __atomic_add_return, atomic_set and atomic_read (the latter
@@ -210,12 +210,66 @@ static __inline__ int atomic_read(const atomic_t *v)
210 210
211#define atomic_dec_and_test(v) (atomic_dec_return(v) == 0) 211#define atomic_dec_and_test(v) (atomic_dec_return(v) == 0)
212 212
213#define ATOMIC_INIT(i) { (i) } 213#define ATOMIC_INIT(i) ((atomic_t) { (i) })
214 214
215#define smp_mb__before_atomic_dec() smp_mb() 215#define smp_mb__before_atomic_dec() smp_mb()
216#define smp_mb__after_atomic_dec() smp_mb() 216#define smp_mb__after_atomic_dec() smp_mb()
217#define smp_mb__before_atomic_inc() smp_mb() 217#define smp_mb__before_atomic_inc() smp_mb()
218#define smp_mb__after_atomic_inc() smp_mb() 218#define smp_mb__after_atomic_inc() smp_mb()
219 219
220#ifdef __LP64__
221
222typedef struct { volatile s64 counter; } atomic64_t;
223
224#define ATOMIC64_INIT(i) ((atomic64_t) { (i) })
225
226static __inline__ int
227__atomic64_add_return(s64 i, atomic64_t *v)
228{
229 int ret;
230 unsigned long flags;
231 _atomic_spin_lock_irqsave(v, flags);
232
233 ret = (v->counter += i);
234
235 _atomic_spin_unlock_irqrestore(v, flags);
236 return ret;
237}
238
239static __inline__ void
240atomic64_set(atomic64_t *v, s64 i)
241{
242 unsigned long flags;
243 _atomic_spin_lock_irqsave(v, flags);
244
245 v->counter = i;
246
247 _atomic_spin_unlock_irqrestore(v, flags);
248}
249
250static __inline__ s64
251atomic64_read(const atomic64_t *v)
252{
253 return v->counter;
254}
255
256#define atomic64_add(i,v) ((void)(__atomic64_add_return( ((s64)i),(v))))
257#define atomic64_sub(i,v) ((void)(__atomic64_add_return(-((s64)i),(v))))
258#define atomic64_inc(v) ((void)(__atomic64_add_return( 1,(v))))
259#define atomic64_dec(v) ((void)(__atomic64_add_return( -1,(v))))
260
261#define atomic64_add_return(i,v) (__atomic64_add_return( ((s64)i),(v)))
262#define atomic64_sub_return(i,v) (__atomic64_add_return(-((s64)i),(v)))
263#define atomic64_inc_return(v) (__atomic64_add_return( 1,(v)))
264#define atomic64_dec_return(v) (__atomic64_add_return( -1,(v)))
265
266#define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
267
268#define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
269#define atomic64_dec_and_test(v) (atomic64_dec_return(v) == 0)
270
271#endif /* __LP64__ */
272
220#include <asm-generic/atomic.h> 273#include <asm-generic/atomic.h>
221#endif 274
275#endif /* _ASM_PARISC_ATOMIC_H_ */
diff --git a/include/asm-parisc/cacheflush.h b/include/asm-parisc/cacheflush.h
index 1bc3c83ee74b..c53af9ff41b5 100644
--- a/include/asm-parisc/cacheflush.h
+++ b/include/asm-parisc/cacheflush.h
@@ -183,4 +183,10 @@ flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long
183 __flush_cache_page(vma, vmaddr); 183 __flush_cache_page(vma, vmaddr);
184 184
185} 185}
186
187#ifdef CONFIG_DEBUG_RODATA
188void mark_rodata_ro(void);
186#endif 189#endif
190
191#endif /* _PARISC_CACHEFLUSH_H */
192
diff --git a/include/asm-parisc/compat_ucontext.h b/include/asm-parisc/compat_ucontext.h
index a1228a3d2071..2f7292afde3c 100644
--- a/include/asm-parisc/compat_ucontext.h
+++ b/include/asm-parisc/compat_ucontext.h
@@ -1,8 +1,7 @@
1#ifndef _ASM_PARISC_COMPAT_UCONTEXT_H 1#ifndef _ASM_PARISC_COMPAT_UCONTEXT_H
2#define _ASM_PARISC_COMPAT_UCONTEXT_H 2#define _ASM_PARISC_COMPAT_UCONTEXT_H
3 3
4#include<linux/compat.h> 4#include <linux/compat.h>
5#include<asm/compat_signal.h>
6 5
7/* 32-bit ucontext as seen from an 64-bit kernel */ 6/* 32-bit ucontext as seen from an 64-bit kernel */
8struct compat_ucontext { 7struct compat_ucontext {
diff --git a/include/asm-parisc/grfioctl.h b/include/asm-parisc/grfioctl.h
index 6a910311b56b..671e06042b40 100644
--- a/include/asm-parisc/grfioctl.h
+++ b/include/asm-parisc/grfioctl.h
@@ -58,7 +58,7 @@
58#define CRT_ID_ELK_1024DB 0x27849CA5 /* Elk 1024x768 double buffer */ 58#define CRT_ID_ELK_1024DB 0x27849CA5 /* Elk 1024x768 double buffer */
59#define CRT_ID_ELK_GS S9000_ID_A1924A /* Elk 1280x1024 GreyScale */ 59#define CRT_ID_ELK_GS S9000_ID_A1924A /* Elk 1280x1024 GreyScale */
60#define CRT_ID_CRX24 S9000_ID_A1439A /* Piranha */ 60#define CRT_ID_CRX24 S9000_ID_A1439A /* Piranha */
61#define CRT_ID_VISUALIZE_EG 0x2D08C0A7 /* Graffiti (built-in B132+/B160L) */ 61#define CRT_ID_VISUALIZE_EG 0x2D08C0A7 /* Graffiti, A4450A (built-in B132+/B160L) */
62#define CRT_ID_THUNDER 0x2F23E5FC /* Thunder 1 VISUALIZE 48*/ 62#define CRT_ID_THUNDER 0x2F23E5FC /* Thunder 1 VISUALIZE 48*/
63#define CRT_ID_THUNDER2 0x2F8D570E /* Thunder 2 VISUALIZE 48 XP*/ 63#define CRT_ID_THUNDER2 0x2F8D570E /* Thunder 2 VISUALIZE 48 XP*/
64#define CRT_ID_HCRX S9000_ID_HCRX /* Hyperdrive HCRX */ 64#define CRT_ID_HCRX S9000_ID_HCRX /* Hyperdrive HCRX */
diff --git a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h
index f277254159b7..fe7f6a2f5aa7 100644
--- a/include/asm-parisc/pci.h
+++ b/include/asm-parisc/pci.h
@@ -18,6 +18,18 @@
18*/ 18*/
19#define PCI_MAX_BUSSES 256 19#define PCI_MAX_BUSSES 256
20 20
21
22/* To be used as: mdelay(pci_post_reset_delay);
23 *
24 * post_reset is the time the kernel should stall to prevent anyone from
25 * accessing the PCI bus once #RESET is de-asserted.
26 * PCI spec somewhere says 1 second but with multi-PCI bus systems,
27 * this makes the boot time much longer than necessary.
28 * 20ms seems to work for all the HP PCI implementations to date.
29 */
30#define pci_post_reset_delay 50
31
32
21/* 33/*
22** pci_hba_data (aka H2P_OBJECT in HP/UX) 34** pci_hba_data (aka H2P_OBJECT in HP/UX)
23** 35**
@@ -83,7 +95,7 @@ static __inline__ int pci_is_lmmio(struct pci_hba_data *hba, unsigned long a)
83 95
84/* 96/*
85** Convert between PCI (IO_VIEW) addresses and processor (PA_VIEW) addresses. 97** Convert between PCI (IO_VIEW) addresses and processor (PA_VIEW) addresses.
86** See pcibios.c for more conversions used by Generic PCI code. 98** See pci.c for more conversions used by Generic PCI code.
87** 99**
88** Platform characteristics/firmware guarantee that 100** Platform characteristics/firmware guarantee that
89** (1) PA_VIEW - IO_VIEW = lmmio_offset for both LMMIO and ELMMIO 101** (1) PA_VIEW - IO_VIEW = lmmio_offset for both LMMIO and ELMMIO
@@ -191,9 +203,6 @@ struct pci_bios_ops {
191*/ 203*/
192extern struct pci_port_ops *pci_port; 204extern struct pci_port_ops *pci_port;
193extern struct pci_bios_ops *pci_bios; 205extern struct pci_bios_ops *pci_bios;
194extern int pci_post_reset_delay; /* delay after de-asserting #RESET */
195extern int pci_hba_count;
196extern struct pci_hba_data *parisc_pci_hba[];
197 206
198#ifdef CONFIG_PCI 207#ifdef CONFIG_PCI
199extern void pcibios_register_hba(struct pci_hba_data *); 208extern void pcibios_register_hba(struct pci_hba_data *);
diff --git a/include/asm-parisc/pgalloc.h b/include/asm-parisc/pgalloc.h
index 6291d6692e5d..3122fad38a1b 100644
--- a/include/asm-parisc/pgalloc.h
+++ b/include/asm-parisc/pgalloc.h
@@ -137,7 +137,6 @@ static inline void pte_free_kernel(pte_t *pte)
137 137
138#define pte_free(page) pte_free_kernel(page_address(page)) 138#define pte_free(page) pte_free_kernel(page_address(page))
139 139
140extern int do_check_pgt_cache(int, int);
141#define check_pgt_cache() do { } while (0) 140#define check_pgt_cache() do { } while (0)
142 141
143#endif 142#endif
diff --git a/include/asm-parisc/pgtable.h b/include/asm-parisc/pgtable.h
index b4554711c3e7..4e34c6b44059 100644
--- a/include/asm-parisc/pgtable.h
+++ b/include/asm-parisc/pgtable.h
@@ -213,7 +213,7 @@ extern void *vmalloc_start;
213#define PAGE_COPY PAGE_EXECREAD 213#define PAGE_COPY PAGE_EXECREAD
214#define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED) 214#define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
215#define PAGE_KERNEL __pgprot(_PAGE_KERNEL) 215#define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
216#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_EXEC | _PAGE_READ | _PAGE_DIRTY | _PAGE_ACCESSED) 216#define PAGE_KERNEL_RO __pgprot(_PAGE_KERNEL & ~_PAGE_WRITE)
217#define PAGE_KERNEL_UNC __pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE) 217#define PAGE_KERNEL_UNC __pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE)
218#define PAGE_GATEWAY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_GATEWAY| _PAGE_READ) 218#define PAGE_GATEWAY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_GATEWAY| _PAGE_READ)
219#define PAGE_FLUSH __pgprot(_PAGE_FLUSH) 219#define PAGE_FLUSH __pgprot(_PAGE_FLUSH)
diff --git a/include/asm-parisc/rt_sigframe.h b/include/asm-parisc/rt_sigframe.h
index 5623c032b64c..f0dd3b30f6c4 100644
--- a/include/asm-parisc/rt_sigframe.h
+++ b/include/asm-parisc/rt_sigframe.h
@@ -1,10 +1,6 @@
1#ifndef _ASM_PARISC_RT_SIGFRAME_H 1#ifndef _ASM_PARISC_RT_SIGFRAME_H
2#define _ASM_PARISC_RT_SIGFRAME_H 2#define _ASM_PARISC_RT_SIGFRAME_H
3 3
4#ifdef CONFIG_COMPAT
5#include <asm/compat_rt_sigframe.h>
6#endif
7
8#define SIGRETURN_TRAMP 4 4#define SIGRETURN_TRAMP 4
9#define SIGRESTARTBLOCK_TRAMP 5 5#define SIGRESTARTBLOCK_TRAMP 5
10#define TRAMP_SIZE (SIGRETURN_TRAMP + SIGRESTARTBLOCK_TRAMP) 6#define TRAMP_SIZE (SIGRETURN_TRAMP + SIGRESTARTBLOCK_TRAMP)
diff --git a/include/asm-parisc/unistd.h b/include/asm-parisc/unistd.h
index 80b7b98c70a1..c56fccbf34ad 100644
--- a/include/asm-parisc/unistd.h
+++ b/include/asm-parisc/unistd.h
@@ -761,8 +761,27 @@
761#define __NR_keyctl (__NR_Linux + 266) 761#define __NR_keyctl (__NR_Linux + 266)
762#define __NR_ioprio_set (__NR_Linux + 267) 762#define __NR_ioprio_set (__NR_Linux + 267)
763#define __NR_ioprio_get (__NR_Linux + 268) 763#define __NR_ioprio_get (__NR_Linux + 268)
764#define __NR_inotify_init (__NR_Linux + 269)
765#define __NR_inotify_add_watch (__NR_Linux + 270)
766#define __NR_inotify_rm_watch (__NR_Linux + 271)
767#define __NR_migrate_pages (__NR_Linux + 272)
768#define __NR_pselect6 (__NR_Linux + 273)
769#define __NR_ppoll (__NR_Linux + 274)
770#define __NR_openat (__NR_Linux + 275)
771#define __NR_mkdirat (__NR_Linux + 276)
772#define __NR_mknodat (__NR_Linux + 277)
773#define __NR_fchownat (__NR_Linux + 278)
774#define __NR_futimesat (__NR_Linux + 279)
775#define __NR_newfstatat (__NR_Linux + 280)
776#define __NR_unlinkat (__NR_Linux + 281)
777#define __NR_renameat (__NR_Linux + 282)
778#define __NR_linkat (__NR_Linux + 283)
779#define __NR_symlinkat (__NR_Linux + 284)
780#define __NR_readlinkat (__NR_Linux + 285)
781#define __NR_fchmodat (__NR_Linux + 286)
782#define __NR_faccessat (__NR_Linux + 287)
764 783
765#define __NR_Linux_syscalls 269 784#define __NR_Linux_syscalls 288
766 785
767#define HPUX_GATEWAY_ADDR 0xC0000004 786#define HPUX_GATEWAY_ADDR 0xC0000004
768#define LINUX_GATEWAY_ADDR 0x100 787#define LINUX_GATEWAY_ADDR 0x100
diff --git a/include/asm-powerpc/kexec.h b/include/asm-powerpc/kexec.h
index 640a6459f2f4..bda2f217e6fe 100644
--- a/include/asm-powerpc/kexec.h
+++ b/include/asm-powerpc/kexec.h
@@ -33,6 +33,7 @@
33 33
34#ifdef CONFIG_KEXEC 34#ifdef CONFIG_KEXEC
35 35
36#ifndef __ASSEMBLY__
36#ifdef __powerpc64__ 37#ifdef __powerpc64__
37/* 38/*
38 * This function is responsible for capturing register states if coming 39 * This function is responsible for capturing register states if coming
@@ -104,7 +105,6 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
104 struct pt_regs *oldregs) { } 105 struct pt_regs *oldregs) { }
105#endif /* !__powerpc64 __ */ 106#endif /* !__powerpc64 __ */
106 107
107#ifndef __ASSEMBLY__
108#define MAX_NOTE_BYTES 1024 108#define MAX_NOTE_BYTES 1024
109 109
110#ifdef __powerpc64__ 110#ifdef __powerpc64__
@@ -121,6 +121,8 @@ extern void default_machine_kexec(struct kimage *image);
121extern int default_machine_kexec_prepare(struct kimage *image); 121extern int default_machine_kexec_prepare(struct kimage *image);
122extern void default_machine_crash_shutdown(struct pt_regs *regs); 122extern void default_machine_crash_shutdown(struct pt_regs *regs);
123 123
124extern void machine_kexec_simple(struct kimage *image);
125
124#endif /* ! __ASSEMBLY__ */ 126#endif /* ! __ASSEMBLY__ */
125#endif /* CONFIG_KEXEC */ 127#endif /* CONFIG_KEXEC */
126#endif /* __KERNEL__ */ 128#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/pmac_pfunc.h b/include/asm-powerpc/pmac_pfunc.h
index d9728c80f86d..cef61304ffc2 100644
--- a/include/asm-powerpc/pmac_pfunc.h
+++ b/include/asm-powerpc/pmac_pfunc.h
@@ -167,6 +167,7 @@ struct pmf_irq_client {
167 void *data; 167 void *data;
168 struct module *owner; 168 struct module *owner;
169 struct list_head link; 169 struct list_head link;
170 struct pmf_function *func;
170}; 171};
171 172
172 173
@@ -187,9 +188,7 @@ extern int pmf_register_irq_client(struct device_node *np,
187 const char *name, 188 const char *name,
188 struct pmf_irq_client *client); 189 struct pmf_irq_client *client);
189 190
190extern void pmf_unregister_irq_client(struct device_node *np, 191extern void pmf_unregister_irq_client(struct pmf_irq_client *client);
191 const char *name,
192 struct pmf_irq_client *client);
193 192
194/* 193/*
195 * Called by the handlers when an irq happens 194 * Called by the handlers when an irq happens
diff --git a/include/asm-s390/dasd.h b/include/asm-s390/dasd.h
index 77b10d6adabd..c744ff33b1df 100644
--- a/include/asm-s390/dasd.h
+++ b/include/asm-s390/dasd.h
@@ -8,8 +8,6 @@
8 * any future changes wrt the API will result in a change of the APIVERSION reported 8 * any future changes wrt the API will result in a change of the APIVERSION reported
9 * to userspace by the DASDAPIVER-ioctl 9 * to userspace by the DASDAPIVER-ioctl
10 * 10 *
11 * $Revision: 1.6 $
12 *
13 */ 11 */
14 12
15#ifndef DASD_H 13#ifndef DASD_H
@@ -206,7 +204,8 @@ typedef struct attrib_data_t {
206 * 204 *
207 * Here ist how the ioctl-nr should be used: 205 * Here ist how the ioctl-nr should be used:
208 * 0 - 31 DASD driver itself 206 * 0 - 31 DASD driver itself
209 * 32 - 239 still open 207 * 32 - 229 still open
208 * 230 - 239 DASD extended error reporting
210 * 240 - 255 reserved for EMC 209 * 240 - 255 reserved for EMC
211 *******************************************************************************/ 210 *******************************************************************************/
212 211
@@ -238,12 +237,22 @@ typedef struct attrib_data_t {
238#define BIODASDPSRD _IOR(DASD_IOCTL_LETTER,4,dasd_rssd_perf_stats_t) 237#define BIODASDPSRD _IOR(DASD_IOCTL_LETTER,4,dasd_rssd_perf_stats_t)
239/* Get Attributes (cache operations) */ 238/* Get Attributes (cache operations) */
240#define BIODASDGATTR _IOR(DASD_IOCTL_LETTER,5,attrib_data_t) 239#define BIODASDGATTR _IOR(DASD_IOCTL_LETTER,5,attrib_data_t)
240/* retrieve extended error-reporting value */
241#define BIODASDEERGET _IOR(DASD_IOCTL_LETTER,6,int)
241 242
242 243
243/* #define BIODASDFORMAT _IOW(IOCTL_LETTER,0,format_data_t) , deprecated */ 244/* #define BIODASDFORMAT _IOW(IOCTL_LETTER,0,format_data_t) , deprecated */
244#define BIODASDFMT _IOW(DASD_IOCTL_LETTER,1,format_data_t) 245#define BIODASDFMT _IOW(DASD_IOCTL_LETTER,1,format_data_t)
245/* Set Attributes (cache operations) */ 246/* Set Attributes (cache operations) */
246#define BIODASDSATTR _IOW(DASD_IOCTL_LETTER,2,attrib_data_t) 247#define BIODASDSATTR _IOW(DASD_IOCTL_LETTER,2,attrib_data_t)
248/* retrieve extended error-reporting value */
249#define BIODASDEERSET _IOW(DASD_IOCTL_LETTER,3,int)
250
251
252/* remove all records from the eer buffer */
253#define DASD_EER_PURGE _IO(DASD_IOCTL_LETTER,230)
254/* set the number of pages that are used for the internal eer buffer */
255#define DASD_EER_SETBUFSIZE _IOW(DASD_IOCTL_LETTER,230,int)
247 256
248 257
249#endif /* DASD_H */ 258#endif /* DASD_H */
diff --git a/include/asm-s390/io.h b/include/asm-s390/io.h
index 71f55eb2350a..b05825dd16d7 100644
--- a/include/asm-s390/io.h
+++ b/include/asm-s390/io.h
@@ -90,10 +90,16 @@ extern void iounmap(void *addr);
90#define readb_relaxed(addr) readb(addr) 90#define readb_relaxed(addr) readb(addr)
91#define readw_relaxed(addr) readw(addr) 91#define readw_relaxed(addr) readw(addr)
92#define readl_relaxed(addr) readl(addr) 92#define readl_relaxed(addr) readl(addr)
93#define __raw_readb readb
94#define __raw_readw readw
95#define __raw_readl readl
93 96
94#define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b)) 97#define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
95#define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b)) 98#define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
96#define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b)) 99#define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
100#define __raw_writeb writeb
101#define __raw_writew writew
102#define __raw_writel writel
97 103
98#define memset_io(a,b,c) memset(__io_virt(a),(b),(c)) 104#define memset_io(a,b,c) memset(__io_virt(a),(b),(c))
99#define memcpy_fromio(a,b,c) memcpy((a),__io_virt(b),(c)) 105#define memcpy_fromio(a,b,c) memcpy((a),__io_virt(b),(c))
diff --git a/include/asm-s390/qdio.h b/include/asm-s390/qdio.h
index 7bc15f0231db..a2f37a9353d3 100644
--- a/include/asm-s390/qdio.h
+++ b/include/asm-s390/qdio.h
@@ -11,8 +11,6 @@
11#ifndef __QDIO_H__ 11#ifndef __QDIO_H__
12#define __QDIO_H__ 12#define __QDIO_H__
13 13
14#define VERSION_QDIO_H "$Revision: 1.57 $"
15
16/* note, that most of the typedef's are from ingo. */ 14/* note, that most of the typedef's are from ingo. */
17 15
18#include <linux/interrupt.h> 16#include <linux/interrupt.h>
diff --git a/include/asm-s390/thread_info.h b/include/asm-s390/thread_info.h
index f3797a52c4ea..8e0c7ed73d03 100644
--- a/include/asm-s390/thread_info.h
+++ b/include/asm-s390/thread_info.h
@@ -2,7 +2,7 @@
2 * include/asm-s390/thread_info.h 2 * include/asm-s390/thread_info.h
3 * 3 *
4 * S390 version 4 * S390 version
5 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, IBM Corporation 5 * Copyright (C) IBM Corp. 2002,2006
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 */ 7 */
8 8
@@ -88,7 +88,7 @@ static inline struct thread_info *current_thread_info(void)
88 * thread information flags bit numbers 88 * thread information flags bit numbers
89 */ 89 */
90#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 90#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
91#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 91#define TIF_RESTORE_SIGMASK 1 /* restore signal mask in do_signal() */
92#define TIF_SIGPENDING 2 /* signal pending */ 92#define TIF_SIGPENDING 2 /* signal pending */
93#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 93#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
94#define TIF_RESTART_SVC 4 /* restart svc with new svc number */ 94#define TIF_RESTART_SVC 4 /* restart svc with new svc number */
@@ -102,7 +102,7 @@ static inline struct thread_info *current_thread_info(void)
102#define TIF_MEMDIE 19 102#define TIF_MEMDIE 19
103 103
104#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 104#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
105#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 105#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
106#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 106#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
107#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 107#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
108#define _TIF_RESTART_SVC (1<<TIF_RESTART_SVC) 108#define _TIF_RESTART_SVC (1<<TIF_RESTART_SVC)
diff --git a/include/asm-s390/timer.h b/include/asm-s390/timer.h
index ea0788967c51..fcd6c256a2d1 100644
--- a/include/asm-s390/timer.h
+++ b/include/asm-s390/timer.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * include/asm-s390/timer.h 2 * include/asm-s390/timer.h
3 * 3 *
4 * (C) Copyright IBM Corp. 2003 4 * (C) Copyright IBM Corp. 2003,2006
5 * Virtual CPU timer 5 * Virtual CPU timer
6 * 6 *
7 * Author: Jan Glauber (jang@de.ibm.com) 7 * Author: Jan Glauber (jang@de.ibm.com)
@@ -10,6 +10,8 @@
10#ifndef _ASM_S390_TIMER_H 10#ifndef _ASM_S390_TIMER_H
11#define _ASM_S390_TIMER_H 11#define _ASM_S390_TIMER_H
12 12
13#ifdef __KERNEL__
14
13#include <linux/timer.h> 15#include <linux/timer.h>
14 16
15#define VTIMER_MAX_SLICE (0x7ffffffffffff000LL) 17#define VTIMER_MAX_SLICE (0x7ffffffffffff000LL)
@@ -43,4 +45,6 @@ extern void add_virt_timer_periodic(void *new);
43extern int mod_virt_timer(struct vtimer_list *timer, __u64 expires); 45extern int mod_virt_timer(struct vtimer_list *timer, __u64 expires);
44extern int del_virt_timer(struct vtimer_list *timer); 46extern int del_virt_timer(struct vtimer_list *timer);
45 47
46#endif 48#endif /* __KERNEL__ */
49
50#endif /* _ASM_S390_TIMER_H */
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h
index 2861cdc243ad..29a9f357eb9e 100644
--- a/include/asm-s390/unistd.h
+++ b/include/asm-s390/unistd.h
@@ -279,8 +279,24 @@
279#define __NR_inotify_init 284 279#define __NR_inotify_init 284
280#define __NR_inotify_add_watch 285 280#define __NR_inotify_add_watch 285
281#define __NR_inotify_rm_watch 286 281#define __NR_inotify_rm_watch 286
282/* Number 287 is reserved for new sys_migrate_pages */
283#define __NR_openat 288
284#define __NR_mkdirat 289
285#define __NR_mknodat 290
286#define __NR_fchownat 291
287#define __NR_futimesat 292
288#define __NR_newfstatat 293
289#define __NR_unlinkat 294
290#define __NR_renameat 295
291#define __NR_linkat 296
292#define __NR_symlinkat 297
293#define __NR_readlinkat 298
294#define __NR_fchmodat 299
295#define __NR_faccessat 300
296#define __NR_pselect6 301
297#define __NR_ppoll 302
282 298
283#define NR_syscalls 287 299#define NR_syscalls 303
284 300
285/* 301/*
286 * There are some system calls that are not present on 64 bit, some 302 * There are some system calls that are not present on 64 bit, some
@@ -539,11 +555,15 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
539#define __ARCH_WANT_SYS_SIGPENDING 555#define __ARCH_WANT_SYS_SIGPENDING
540#define __ARCH_WANT_SYS_SIGPROCMASK 556#define __ARCH_WANT_SYS_SIGPROCMASK
541#define __ARCH_WANT_SYS_RT_SIGACTION 557#define __ARCH_WANT_SYS_RT_SIGACTION
558#define __ARCH_WANT_SYS_RT_SIGSUSPEND
542# ifndef CONFIG_64BIT 559# ifndef CONFIG_64BIT
543# define __ARCH_WANT_STAT64 560# define __ARCH_WANT_STAT64
544# define __ARCH_WANT_SYS_TIME 561# define __ARCH_WANT_SYS_TIME
545# endif 562# endif
546# define __ARCH_WANT_COMPAT_SYS_TIME 563# ifdef CONFIG_COMPAT
564# define __ARCH_WANT_COMPAT_SYS_TIME
565# define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
566# endif
547#endif 567#endif
548 568
549#ifdef __KERNEL_SYSCALLS__ 569#ifdef __KERNEL_SYSCALLS__
diff --git a/include/asm-sh/bus-sh.h b/include/asm-sh/bus-sh.h
deleted file mode 100644
index e42d63b65cb5..000000000000
--- a/include/asm-sh/bus-sh.h
+++ /dev/null
@@ -1,66 +0,0 @@
1/*
2 * include/asm-sh/bus-sh.h
3 *
4 * Copyright (C) 2004 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __ASM_SH_BUS_SH_H
11#define __ASM_SH_BUS_SH_H
12
13extern struct bus_type sh_bus_types[];
14
15struct sh_dev {
16 struct device dev;
17 char *name;
18 unsigned int dev_id;
19 unsigned int bus_id;
20 struct resource res;
21 void *mapbase;
22 unsigned int irq[6];
23 u64 *dma_mask;
24 u64 coherent_dma_mask;
25};
26
27#define to_sh_dev(d) container_of((d), struct sh_dev, dev)
28
29#define sh_get_drvdata(d) dev_get_drvdata(&(d)->dev)
30#define sh_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
31
32struct sh_driver {
33 struct device_driver drv;
34 unsigned int dev_id;
35 unsigned int bus_id;
36 int (*probe)(struct sh_dev *);
37 int (*remove)(struct sh_dev *);
38 int (*suspend)(struct sh_dev *, pm_message_t);
39 int (*resume)(struct sh_dev *);
40};
41
42#define to_sh_driver(d) container_of((d), struct sh_driver, drv)
43#define sh_name(d) ((d)->dev.driver->name)
44
45/*
46 * Device ID numbers for bus types
47 */
48enum {
49 SH_DEV_ID_USB_OHCI,
50};
51
52#define SH_NR_BUSES 1
53#define SH_BUS_NAME_VIRT "shbus"
54
55enum {
56 SH_BUS_VIRT,
57};
58
59/* arch/sh/kernel/cpu/bus.c */
60extern int sh_device_register(struct sh_dev *dev);
61extern void sh_device_unregister(struct sh_dev *dev);
62extern int sh_driver_register(struct sh_driver *drv);
63extern void sh_driver_unregister(struct sh_driver *drv);
64
65#endif /* __ASM_SH_BUS_SH_H */
66
diff --git a/include/asm-sh/cpu-sh3/mmu_context.h b/include/asm-sh/cpu-sh3/mmu_context.h
index 5cfaa6bcf1ed..a844ea0965b6 100644
--- a/include/asm-sh/cpu-sh3/mmu_context.h
+++ b/include/asm-sh/cpu-sh3/mmu_context.h
@@ -24,5 +24,15 @@
24#define MMU_NTLB_WAYS 4 24#define MMU_NTLB_WAYS 4
25#define MMU_CONTROL_INIT 0x007 /* SV=0, TF=1, IX=1, AT=1 */ 25#define MMU_CONTROL_INIT 0x007 /* SV=0, TF=1, IX=1, AT=1 */
26 26
27#define TRA 0xffffffd0
28#define EXPEVT 0xffffffd4
29
30#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
31 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
32#define INTEVT 0xa4000000 /* INTEVTE2(0xa4000000) */
33#else
34#define INTEVT 0xffffffd8
35#endif
36
27#endif /* __ASM_CPU_SH3_MMU_CONTEXT_H */ 37#endif /* __ASM_CPU_SH3_MMU_CONTEXT_H */
28 38
diff --git a/include/asm-sh/cpu-sh4/mmu_context.h b/include/asm-sh/cpu-sh4/mmu_context.h
index 5b64d041f0b9..ff4c5fbbfaf0 100644
--- a/include/asm-sh/cpu-sh4/mmu_context.h
+++ b/include/asm-sh/cpu-sh4/mmu_context.h
@@ -23,7 +23,11 @@
23#define MMU_PAGE_ASSOC_BIT 0x80 23#define MMU_PAGE_ASSOC_BIT 0x80
24 24
25#define MMU_NTLB_ENTRIES 64 /* for 7750 */ 25#define MMU_NTLB_ENTRIES 64 /* for 7750 */
26#ifdef CONFIG_SH_STORE_QUEUES
27#define MMU_CONTROL_INIT 0x05 /* SQMD=0, SV=0, TI=1, AT=1 */
28#else
26#define MMU_CONTROL_INIT 0x205 /* SQMD=1, SV=0, TI=1, AT=1 */ 29#define MMU_CONTROL_INIT 0x205 /* SQMD=1, SV=0, TI=1, AT=1 */
30#endif
27 31
28#define MMU_ITLB_DATA_ARRAY 0xF3000000 32#define MMU_ITLB_DATA_ARRAY 0xF3000000
29#define MMU_UTLB_DATA_ARRAY 0xF7000000 33#define MMU_UTLB_DATA_ARRAY 0xF7000000
@@ -35,5 +39,9 @@
35#define MMU_I_ENTRY_SHIFT 8 39#define MMU_I_ENTRY_SHIFT 8
36#define MMU_ITLB_VALID 0x100 40#define MMU_ITLB_VALID 0x100
37 41
42#define TRA 0xff000020
43#define EXPEVT 0xff000024
44#define INTEVT 0xff000028
45
38#endif /* __ASM_CPU_SH4_MMU_CONTEXT_H */ 46#endif /* __ASM_CPU_SH4_MMU_CONTEXT_H */
39 47
diff --git a/include/asm-sh/ioctls.h b/include/asm-sh/ioctls.h
index 1866f3f90028..9d84a2d445a2 100644
--- a/include/asm-sh/ioctls.h
+++ b/include/asm-sh/ioctls.h
@@ -94,6 +94,6 @@
94#define TIOCSERSETMULTI _IOW('T', 91, struct serial_multiport_struct) /* 0x545B */ /* Set multiport config */ 94#define TIOCSERSETMULTI _IOW('T', 91, struct serial_multiport_struct) /* 0x545B */ /* Set multiport config */
95 95
96#define TIOCMIWAIT _IO('T', 92) /* 0x545C */ /* wait for a change on serial input line(s) */ 96#define TIOCMIWAIT _IO('T', 92) /* 0x545C */ /* wait for a change on serial input line(s) */
97#define TIOCGICOUNT _IOR('T', 93, struct async_icount) /* 0x545D */ /* read serial port inline interrupt counts */ 97#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
98 98
99#endif /* __ASM_SH_IOCTLS_H */ 99#endif /* __ASM_SH_IOCTLS_H */
diff --git a/include/asm-sh/irq-sh73180.h b/include/asm-sh/irq-sh73180.h
index bf2e4310ffac..d705252be260 100644
--- a/include/asm-sh/irq-sh73180.h
+++ b/include/asm-sh/irq-sh73180.h
@@ -25,11 +25,6 @@
25#undef DMA_IPR_POS 25#undef DMA_IPR_POS
26#undef DMA_PRIORITY 26#undef DMA_PRIORITY
27 27
28#undef NR_IRQS
29
30#undef __irq_demux
31#undef irq_demux
32
33#undef INTC_IMCR0 28#undef INTC_IMCR0
34#undef INTC_IMCR1 29#undef INTC_IMCR1
35#undef INTC_IMCR2 30#undef INTC_IMCR2
@@ -229,33 +224,6 @@
229#define SIU_IPR_POS 1 224#define SIU_IPR_POS 1
230#define SIU_PRIORITY 3 225#define SIU_PRIORITY 3
231 226
232
233/* ONCHIP_NR_IRQS */
234#define NR_IRQS 109
235
236/* In a generic kernel, NR_IRQS is an upper bound, and we should use
237 * ACTUAL_NR_IRQS (which uses the machine vector) to get the correct value.
238 */
239#define ACTUAL_NR_IRQS NR_IRQS
240
241
242extern void disable_irq(unsigned int);
243extern void disable_irq_nosync(unsigned int);
244extern void enable_irq(unsigned int);
245
246/*
247 * Simple Mask Register Support
248 */
249extern void make_maskreg_irq(unsigned int irq);
250extern unsigned short *irq_mask_register;
251
252/*
253 * Function for "on chip support modules".
254 */
255extern void make_ipr_irq(unsigned int irq, unsigned int addr,
256 int pos, int priority);
257extern void make_imask_irq(unsigned int irq);
258
259#define PORT_PACR 0xA4050100UL 227#define PORT_PACR 0xA4050100UL
260#define PORT_PBCR 0xA4050102UL 228#define PORT_PBCR 0xA4050102UL
261#define PORT_PCCR 0xA4050104UL 229#define PORT_PCCR 0xA4050104UL
@@ -343,8 +311,6 @@ extern void make_imask_irq(unsigned int irq);
343#define IRQ6_PRIORITY 1 311#define IRQ6_PRIORITY 1
344#define IRQ7_PRIORITY 1 312#define IRQ7_PRIORITY 1
345 313
346extern int shmse_irq_demux(int irq); 314int shmse_irq_demux(int irq);
347#define __irq_demux(irq) shmse_irq_demux(irq)
348#define irq_demux(irq) __irq_demux(irq)
349 315
350#endif /* __ASM_SH_IRQ_SH73180_H */ 316#endif /* __ASM_SH_IRQ_SH73180_H */
diff --git a/include/asm-sh/irq-sh7780.h b/include/asm-sh/irq-sh7780.h
index 8c8ca1281084..7f90315cd830 100644
--- a/include/asm-sh/irq-sh7780.h
+++ b/include/asm-sh/irq-sh7780.h
@@ -299,29 +299,6 @@
299#define GPIO_IPR_POS 2 299#define GPIO_IPR_POS 2
300#define GPIO_PRIORITY 3 300#define GPIO_PRIORITY 3
301 301
302/* ONCHIP_NR_IRQS */
303#define NR_IRQS 150 /* 111 + 16 */
304
305/* In a generic kernel, NR_IRQS is an upper bound, and we should use
306 * ACTUAL_NR_IRQS (which uses the machine vector) to get the correct value.
307 */
308#define ACTUAL_NR_IRQS NR_IRQS
309
310extern void disable_irq(unsigned int);
311extern void disable_irq_nosync(unsigned int);
312extern void enable_irq(unsigned int);
313
314/*
315 * Simple Mask Register Support
316 */
317extern void make_maskreg_irq(unsigned int irq);
318extern unsigned short *irq_mask_register;
319
320/*
321 * Function for "on chip support modules".
322 */
323extern void make_imask_irq(unsigned int irq);
324
325#define INTC_TMU0_MSK 0 302#define INTC_TMU0_MSK 0
326#define INTC_TMU3_MSK 1 303#define INTC_TMU3_MSK 1
327#define INTC_RTC_MSK 2 304#define INTC_RTC_MSK 2
diff --git a/include/asm-sh/irq.h b/include/asm-sh/irq.h
index 060ec3c27207..42b8394c04ed 100644
--- a/include/asm-sh/irq.h
+++ b/include/asm-sh/irq.h
@@ -245,6 +245,7 @@
245#endif /* ST40STB1 */ 245#endif /* ST40STB1 */
246 246
247#endif /* 775x / SH4-202 / ST40STB1 */ 247#endif /* 775x / SH4-202 / ST40STB1 */
248#endif /* 7780 */
248 249
249/* NR_IRQS is made from three components: 250/* NR_IRQS is made from three components:
250 * 1. ONCHIP_NR_IRQS - number of IRLS + on-chip peripherial modules 251 * 1. ONCHIP_NR_IRQS - number of IRLS + on-chip peripherial modules
@@ -274,8 +275,11 @@
274# define ONCHIP_NR_IRQS 72 275# define ONCHIP_NR_IRQS 72
275#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) 276#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
276# define ONCHIP_NR_IRQS 144 277# define ONCHIP_NR_IRQS 144
277#elif defined(CONFIG_CPU_SUBTYPE_SH7300) 278#elif defined(CONFIG_CPU_SUBTYPE_SH7300) || \
279 defined(CONFIG_CPU_SUBTYPE_SH73180)
278# define ONCHIP_NR_IRQS 109 280# define ONCHIP_NR_IRQS 109
281#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
282# define ONCHIP_NR_IRQS 111
279#elif defined(CONFIG_SH_UNKNOWN) /* Most be last */ 283#elif defined(CONFIG_SH_UNKNOWN) /* Most be last */
280# define ONCHIP_NR_IRQS 144 284# define ONCHIP_NR_IRQS 144
281#endif 285#endif
@@ -306,6 +310,8 @@
306# define OFFCHIP_NR_IRQS 96 310# define OFFCHIP_NR_IRQS 96
307#elif defined (CONFIG_SH_TITAN) 311#elif defined (CONFIG_SH_TITAN)
308# define OFFCHIP_NR_IRQS 4 312# define OFFCHIP_NR_IRQS 4
313#elif defined(CONFIG_SH_R7780RP)
314# define OFFCHIP_NR_IRQS 16
309#elif defined(CONFIG_SH_UNKNOWN) 315#elif defined(CONFIG_SH_UNKNOWN)
310# define OFFCHIP_NR_IRQS 16 /* Must also be last */ 316# define OFFCHIP_NR_IRQS 16 /* Must also be last */
311#else 317#else
@@ -550,7 +556,7 @@ extern int ipr_irq_demux(int irq);
550#define INTC_ICR_IRLM (1<<7) 556#define INTC_ICR_IRLM (1<<7)
551#endif 557#endif
552 558
553#else 559#ifdef CONFIG_CPU_SUBTYPE_SH7780
554#include <asm/irq-sh7780.h> 560#include <asm/irq-sh7780.h>
555#endif 561#endif
556 562
diff --git a/include/asm-sh/microdev/irq.h b/include/asm-sh/microdev.h
index 47f6f77a65f0..018332a9e590 100644
--- a/include/asm-sh/microdev/irq.h
+++ b/include/asm-sh/microdev.h
@@ -1,32 +1,27 @@
1/* 1/*
2 * linux/include/asm-sh/irq_microdev.h 2 * linux/include/asm-sh/microdev.h
3 * 3 *
4 * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com) 4 * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
5 * 5 *
6 * IRQ functions for the SuperH SH4-202 MicroDev board. 6 * Definitions for the SuperH SH4-202 MicroDev board.
7 * 7 *
8 * May be copied or modified under the terms of the GNU General Public 8 * May be copied or modified under the terms of the GNU General Public
9 * License. See linux/COPYING for more information. 9 * License. See linux/COPYING for more information.
10 *
11 */ 10 */
12 11#ifndef __ASM_SH_MICRODEV_H
13 12#define __ASM_SH_MICRODEV_H
14#ifndef _ASM_SH_IRQ_MICRODEV_H
15#define _ASM_SH_IRQ_MICRODEV_H
16 13
17extern void init_microdev_irq(void); 14extern void init_microdev_irq(void);
18extern void microdev_print_fpga_intc_status(void); 15extern void microdev_print_fpga_intc_status(void);
19 16
20 17/*
21 /* 18 * The following are useful macros for manipulating the interrupt
22 * The following are useful macros for manipulating the 19 * controller (INTC) on the CPU-board FPGA. should be noted that there
23 * interrupt controller (INTC) on the CPU-board FPGA. 20 * is an INTC on the FPGA, and a seperate INTC on the SH4-202 core -
24 * It should be noted that there is an INTC on the FPGA, 21 * these are two different things, both of which need to be prorammed to
25 * and a seperate INTC on the SH4-202 core - these are 22 * correctly route - unfortunately, they have the same name and
26 * two different things, both of which need to be prorammed 23 * abbreviations!
27 * to correctly route - unfortunately, they have the 24 */
28 * same name and abbreviations!
29 */
30#define MICRODEV_FPGA_INTC_BASE 0xa6110000ul /* INTC base address on CPU-board FPGA */ 25#define MICRODEV_FPGA_INTC_BASE 0xa6110000ul /* INTC base address on CPU-board FPGA */
31#define MICRODEV_FPGA_INTENB_REG (MICRODEV_FPGA_INTC_BASE+0ul) /* Interrupt Enable Register on INTC on CPU-board FPGA */ 26#define MICRODEV_FPGA_INTENB_REG (MICRODEV_FPGA_INTC_BASE+0ul) /* Interrupt Enable Register on INTC on CPU-board FPGA */
32#define MICRODEV_FPGA_INTDSB_REG (MICRODEV_FPGA_INTC_BASE+8ul) /* Interrupt Disable Register on INTC on CPU-board FPGA */ 27#define MICRODEV_FPGA_INTDSB_REG (MICRODEV_FPGA_INTC_BASE+8ul) /* Interrupt Disable Register on INTC on CPU-board FPGA */
@@ -38,10 +33,10 @@ extern void microdev_print_fpga_intc_status(void);
38#define MICRODEV_FPGA_INTREQ_REG (MICRODEV_FPGA_INTC_BASE+0x38ul) /* Interrupt Request Register on INTC on CPU-board FPGA */ 33#define MICRODEV_FPGA_INTREQ_REG (MICRODEV_FPGA_INTC_BASE+0x38ul) /* Interrupt Request Register on INTC on CPU-board FPGA */
39 34
40 35
41 /* 36/*
42 * The following are the IRQ numbers for the Linux Kernel for external interrupts. 37 * The following are the IRQ numbers for the Linux Kernel for external
43 * i.e. the numbers seen by 'cat /proc/interrupt'. 38 * interrupts. i.e. the numbers seen by 'cat /proc/interrupt'.
44 */ 39 */
45#define MICRODEV_LINUX_IRQ_KEYBOARD 1 /* SuperIO Keyboard */ 40#define MICRODEV_LINUX_IRQ_KEYBOARD 1 /* SuperIO Keyboard */
46#define MICRODEV_LINUX_IRQ_SERIAL1 2 /* SuperIO Serial #1 */ 41#define MICRODEV_LINUX_IRQ_SERIAL1 2 /* SuperIO Serial #1 */
47#define MICRODEV_LINUX_IRQ_ETHERNET 3 /* on-board Ethnernet */ 42#define MICRODEV_LINUX_IRQ_ETHERNET 3 /* on-board Ethnernet */
@@ -51,10 +46,11 @@ extern void microdev_print_fpga_intc_status(void);
51#define MICRODEV_LINUX_IRQ_IDE2 13 /* SuperIO IDE #2 */ 46#define MICRODEV_LINUX_IRQ_IDE2 13 /* SuperIO IDE #2 */
52#define MICRODEV_LINUX_IRQ_IDE1 14 /* SuperIO IDE #1 */ 47#define MICRODEV_LINUX_IRQ_IDE1 14 /* SuperIO IDE #1 */
53 48
54 /* 49/*
55 * The following are the IRQ numbers for the INTC on the FPGA for external interrupts. 50 * The following are the IRQ numbers for the INTC on the FPGA for
56 * i.e. the bits in the INTC registers in the FPGA. 51 * external interrupts. i.e. the bits in the INTC registers in the
57 */ 52 * FPGA.
53 */
58#define MICRODEV_FPGA_IRQ_KEYBOARD 1 /* SuperIO Keyboard */ 54#define MICRODEV_FPGA_IRQ_KEYBOARD 1 /* SuperIO Keyboard */
59#define MICRODEV_FPGA_IRQ_SERIAL1 3 /* SuperIO Serial #1 */ 55#define MICRODEV_FPGA_IRQ_SERIAL1 3 /* SuperIO Serial #1 */
60#define MICRODEV_FPGA_IRQ_SERIAL2 4 /* SuperIO Serial #2 */ 56#define MICRODEV_FPGA_IRQ_SERIAL2 4 /* SuperIO Serial #2 */
@@ -69,4 +65,16 @@ extern void microdev_print_fpga_intc_status(void);
69#define MICRODEV_IRQ_PCI_INTC 10 65#define MICRODEV_IRQ_PCI_INTC 10
70#define MICRODEV_IRQ_PCI_INTD 11 66#define MICRODEV_IRQ_PCI_INTD 11
71 67
72#endif /* _ASM_SH_IRQ_MICRODEV_H */ 68#define __IO_PREFIX microdev
69#include <asm/io_generic.h>
70
71#if defined(CONFIG_PCI)
72unsigned char microdev_pci_inb(unsigned long port);
73unsigned short microdev_pci_inw(unsigned long port);
74unsigned long microdev_pci_inl(unsigned long port);
75void microdev_pci_outb(unsigned char data, unsigned long port);
76void microdev_pci_outw(unsigned short data, unsigned long port);
77void microdev_pci_outl(unsigned long data, unsigned long port);
78#endif
79
80#endif /* __ASM_SH_MICRODEV_H */
diff --git a/include/asm-sh/microdev/io.h b/include/asm-sh/microdev/io.h
deleted file mode 100644
index f2ca4ac8c88a..000000000000
--- a/include/asm-sh/microdev/io.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * linux/include/asm-sh/io_microdev.h
3 *
4 * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
5 *
6 * IO functions for the SuperH SH4-202 MicroDev board.
7 *
8 * May be copied or modified under the terms of the GNU General Public
9 * License. See linux/COPYING for more information.
10 *
11 */
12
13
14#ifndef _ASM_SH_IO_MICRODEV_H
15#define _ASM_SH_IO_MICRODEV_H
16
17extern unsigned long microdev_isa_port2addr(unsigned long offset);
18
19extern unsigned char microdev_inb(unsigned long port);
20extern unsigned short microdev_inw(unsigned long port);
21extern unsigned int microdev_inl(unsigned long port);
22
23extern void microdev_outb(unsigned char value, unsigned long port);
24extern void microdev_outw(unsigned short value, unsigned long port);
25extern void microdev_outl(unsigned int value, unsigned long port);
26
27extern unsigned char microdev_inb_p(unsigned long port);
28extern unsigned short microdev_inw_p(unsigned long port);
29extern unsigned int microdev_inl_p(unsigned long port);
30
31extern void microdev_outb_p(unsigned char value, unsigned long port);
32extern void microdev_outw_p(unsigned short value, unsigned long port);
33extern void microdev_outl_p(unsigned int value, unsigned long port);
34
35extern void microdev_insb(unsigned long port, void *addr, unsigned long count);
36extern void microdev_insw(unsigned long port, void *addr, unsigned long count);
37extern void microdev_insl(unsigned long port, void *addr, unsigned long count);
38
39extern void microdev_outsb(unsigned long port, const void *addr, unsigned long count);
40extern void microdev_outsw(unsigned long port, const void *addr, unsigned long count);
41extern void microdev_outsl(unsigned long port, const void *addr, unsigned long count);
42
43#if defined(CONFIG_PCI)
44extern unsigned char microdev_pci_inb(unsigned long port);
45extern unsigned short microdev_pci_inw(unsigned long port);
46extern unsigned long microdev_pci_inl(unsigned long port);
47extern void microdev_pci_outb(unsigned char data, unsigned long port);
48extern void microdev_pci_outw(unsigned short data, unsigned long port);
49extern void microdev_pci_outl(unsigned long data, unsigned long port);
50#endif
51
52#endif /* _ASM_SH_IO_MICRODEV_H */
53
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index c4904797d6df..fa5bd2d8803e 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -12,7 +12,6 @@
12#include <asm/page.h> 12#include <asm/page.h>
13#include <asm/types.h> 13#include <asm/types.h>
14#include <asm/cache.h> 14#include <asm/cache.h>
15#include <linux/threads.h>
16#include <asm/ptrace.h> 15#include <asm/ptrace.h>
17 16
18/* 17/*
@@ -30,7 +29,7 @@
30 * CPU type and hardware bug flags. Kept separately for each CPU. 29 * CPU type and hardware bug flags. Kept separately for each CPU.
31 * 30 *
32 * Each one of these also needs a CONFIG_CPU_SUBTYPE_xxx entry 31 * Each one of these also needs a CONFIG_CPU_SUBTYPE_xxx entry
33 * in arch/sh/Kconfig, as well as an entry in arch/sh/kernel/setup.c 32 * in arch/sh/mm/Kconfig, as well as an entry in arch/sh/kernel/setup.c
34 * for parsing the subtype in get_cpu_subtype(). 33 * for parsing the subtype in get_cpu_subtype().
35 */ 34 */
36enum cpu_type { 35enum cpu_type {
@@ -44,7 +43,7 @@ enum cpu_type {
44 /* SH-4 types */ 43 /* SH-4 types */
45 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R, 44 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R,
46 CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501, 45 CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501,
47 CPU_SH73180, 46 CPU_SH73180, CPU_SH7770, CPU_SH7780, CPU_SH7781,
48 47
49 /* Unknown subtype */ 48 /* Unknown subtype */
50 CPU_SH_NONE 49 CPU_SH_NONE
@@ -52,14 +51,8 @@ enum cpu_type {
52 51
53struct sh_cpuinfo { 52struct sh_cpuinfo {
54 enum cpu_type type; 53 enum cpu_type type;
55 char hard_math;
56 unsigned long loops_per_jiffy; 54 unsigned long loops_per_jiffy;
57 55
58 unsigned int cpu_clock, master_clock, bus_clock, module_clock;
59#ifdef CONFIG_CPU_SUBTYPE_ST40STB1
60 unsigned int memory_clock;
61#endif
62
63 struct cache_info icache; 56 struct cache_info icache;
64 struct cache_info dcache; 57 struct cache_info dcache;
65 58
@@ -131,7 +124,7 @@ union sh_fpu_union {
131 struct sh_fpu_soft_struct soft; 124 struct sh_fpu_soft_struct soft;
132}; 125};
133 126
134/* 127/*
135 * Processor flags 128 * Processor flags
136 */ 129 */
137 130
@@ -140,6 +133,7 @@ union sh_fpu_union {
140#define CPU_HAS_MMU_PAGE_ASSOC 0x0004 /* SH3: TLB way selection bit support */ 133#define CPU_HAS_MMU_PAGE_ASSOC 0x0004 /* SH3: TLB way selection bit support */
141#define CPU_HAS_DSP 0x0008 /* SH-DSP: DSP support */ 134#define CPU_HAS_DSP 0x0008 /* SH-DSP: DSP support */
142#define CPU_HAS_PERF_COUNTER 0x0010 /* Hardware performance counters */ 135#define CPU_HAS_PERF_COUNTER 0x0010 /* Hardware performance counters */
136#define CPU_HAS_PTEA 0x0020 /* PTEA register */
143 137
144struct thread_struct { 138struct thread_struct {
145 unsigned long sp; 139 unsigned long sp;
@@ -160,10 +154,10 @@ extern int ubc_usercnt;
160#define INIT_THREAD { \ 154#define INIT_THREAD { \
161 sizeof(init_stack) + (long) &init_stack, /* sp */ \ 155 sizeof(init_stack) + (long) &init_stack, /* sp */ \
162 0, /* pc */ \ 156 0, /* pc */ \
163 0, 0, \ 157 0, 0, \
164 0, \ 158 0, \
165 0, \ 159 0, \
166 {{{0,}},} /* fpu state */ \ 160 {{{0,}},} /* fpu state */ \
167} 161}
168 162
169/* 163/*
@@ -171,7 +165,7 @@ extern int ubc_usercnt;
171 */ 165 */
172#define start_thread(regs, new_pc, new_sp) \ 166#define start_thread(regs, new_pc, new_sp) \
173 set_fs(USER_DS); \ 167 set_fs(USER_DS); \
174 regs->pr = 0; \ 168 regs->pr = 0; \
175 regs->sr = SR_FD; /* User mode. */ \ 169 regs->sr = SR_FD; /* User mode. */ \
176 regs->pc = new_pc; \ 170 regs->pc = new_pc; \
177 regs->regs[15] = new_sp 171 regs->regs[15] = new_sp
@@ -239,16 +233,16 @@ extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
239#define save_fpu(tsk) do { } while (0) 233#define save_fpu(tsk) do { } while (0)
240#endif 234#endif
241 235
242#define unlazy_fpu(tsk, regs) do { \ 236#define unlazy_fpu(tsk, regs) do { \
243 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \ 237 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
244 save_fpu(tsk, regs); \ 238 save_fpu(tsk, regs); \
245 } \ 239 } \
246} while (0) 240} while (0)
247 241
248#define clear_fpu(tsk, regs) do { \ 242#define clear_fpu(tsk, regs) do { \
249 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \ 243 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
250 clear_tsk_thread_flag(tsk, TIF_USEDFPU); \ 244 clear_tsk_thread_flag(tsk, TIF_USEDFPU); \
251 release_fpu(regs); \ 245 release_fpu(regs); \
252 } \ 246 } \
253} while (0) 247} while (0)
254 248
diff --git a/include/asm-sh64/ioctls.h b/include/asm-sh64/ioctls.h
index 08f3c1f2e419..6b0c04f63c57 100644
--- a/include/asm-sh64/ioctls.h
+++ b/include/asm-sh64/ioctls.h
@@ -111,6 +111,6 @@
111#define TIOCSERSETMULTI 0x40a8545b /* _IOW('T', 91, struct serial_multiport_struct) 0x545B */ /* Set multiport config */ 111#define TIOCSERSETMULTI 0x40a8545b /* _IOW('T', 91, struct serial_multiport_struct) 0x545B */ /* Set multiport config */
112 112
113#define TIOCMIWAIT 0x545c /* _IO('T', 92) wait for a change on serial input line(s) */ 113#define TIOCMIWAIT 0x545c /* _IO('T', 92) wait for a change on serial input line(s) */
114#define TIOCGICOUNT 0x802c545d /* _IOR('T', 93, struct async_icount) 0x545D */ /* read serial port inline interrupt counts */ 114#define TIOCGICOUNT 0x545d /* read serial port inline interrupt counts */
115 115
116#endif /* __ASM_SH64_IOCTLS_H */ 116#endif /* __ASM_SH64_IOCTLS_H */
diff --git a/include/asm-sparc64/spinlock.h b/include/asm-sparc64/spinlock.h
index ec85d12d73b9..508c416e9d6a 100644
--- a/include/asm-sparc64/spinlock.h
+++ b/include/asm-sparc64/spinlock.h
@@ -131,6 +131,28 @@ static void inline __read_lock(raw_rwlock_t *lock)
131 : "memory"); 131 : "memory");
132} 132}
133 133
134static int inline __read_trylock(raw_rwlock_t *lock)
135{
136 int tmp1, tmp2;
137
138 __asm__ __volatile__ (
139"1: ldsw [%2], %0\n"
140" brlz,a,pn %0, 2f\n"
141" mov 0, %0\n"
142" add %0, 1, %1\n"
143" cas [%2], %0, %1\n"
144" cmp %0, %1\n"
145" membar #StoreLoad | #StoreStore\n"
146" bne,pn %%icc, 1b\n"
147" mov 1, %0\n"
148"2:"
149 : "=&r" (tmp1), "=&r" (tmp2)
150 : "r" (lock)
151 : "memory");
152
153 return tmp1;
154}
155
134static void inline __read_unlock(raw_rwlock_t *lock) 156static void inline __read_unlock(raw_rwlock_t *lock)
135{ 157{
136 unsigned long tmp1, tmp2; 158 unsigned long tmp1, tmp2;
@@ -211,12 +233,12 @@ static int inline __write_trylock(raw_rwlock_t *lock)
211} 233}
212 234
213#define __raw_read_lock(p) __read_lock(p) 235#define __raw_read_lock(p) __read_lock(p)
236#define __raw_read_trylock(p) __read_trylock(p)
214#define __raw_read_unlock(p) __read_unlock(p) 237#define __raw_read_unlock(p) __read_unlock(p)
215#define __raw_write_lock(p) __write_lock(p) 238#define __raw_write_lock(p) __write_lock(p)
216#define __raw_write_unlock(p) __write_unlock(p) 239#define __raw_write_unlock(p) __write_unlock(p)
217#define __raw_write_trylock(p) __write_trylock(p) 240#define __raw_write_trylock(p) __write_trylock(p)
218 241
219#define __raw_read_trylock(lock) generic__raw_read_trylock(lock)
220#define __raw_read_can_lock(rw) (!((rw)->lock & 0x80000000UL)) 242#define __raw_read_can_lock(rw) (!((rw)->lock & 0x80000000UL))
221#define __raw_write_can_lock(rw) (!(rw)->lock) 243#define __raw_write_can_lock(rw) (!(rw)->lock)
222 244
diff --git a/include/asm-um/ldt-x86_64.h b/include/asm-um/ldt-x86_64.h
index 175722a91164..96b35aada79a 100644
--- a/include/asm-um/ldt-x86_64.h
+++ b/include/asm-um/ldt-x86_64.h
@@ -5,8 +5,8 @@
5 * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com> 5 * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
6 */ 6 */
7 7
8#ifndef __ASM_LDT_I386_H 8#ifndef __ASM_LDT_X86_64_H
9#define __ASM_LDT_I386_H 9#define __ASM_LDT_X86_64_H
10 10
11#include "asm/semaphore.h" 11#include "asm/semaphore.h"
12#include "asm/arch/ldt.h" 12#include "asm/arch/ldt.h"
@@ -39,11 +39,13 @@ typedef struct uml_ldt {
39} uml_ldt_t; 39} uml_ldt_t;
40 40
41/* 41/*
42 * macros stolen from include/asm-i386/desc.h 42 * macros stolen from include/asm-x86_64/desc.h
43 */ 43 */
44#define LDT_entry_a(info) \ 44#define LDT_entry_a(info) \
45 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) 45 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
46 46
47/* Don't allow setting of the lm bit. It is useless anyways because
48 * 64bit system calls require __USER_CS. */
47#define LDT_entry_b(info) \ 49#define LDT_entry_b(info) \
48 (((info)->base_addr & 0xff000000) | \ 50 (((info)->base_addr & 0xff000000) | \
49 (((info)->base_addr & 0x00ff0000) >> 16) | \ 51 (((info)->base_addr & 0x00ff0000) >> 16) | \
@@ -54,6 +56,7 @@ typedef struct uml_ldt {
54 ((info)->seg_32bit << 22) | \ 56 ((info)->seg_32bit << 22) | \
55 ((info)->limit_in_pages << 23) | \ 57 ((info)->limit_in_pages << 23) | \
56 ((info)->useable << 20) | \ 58 ((info)->useable << 20) | \
59 /* ((info)->lm << 21) | */ \
57 0x7000) 60 0x7000)
58 61
59#define LDT_empty(info) (\ 62#define LDT_empty(info) (\
@@ -64,6 +67,7 @@ typedef struct uml_ldt {
64 (info)->seg_32bit == 0 && \ 67 (info)->seg_32bit == 0 && \
65 (info)->limit_in_pages == 0 && \ 68 (info)->limit_in_pages == 0 && \
66 (info)->seg_not_present == 1 && \ 69 (info)->seg_not_present == 1 && \
67 (info)->useable == 0 ) 70 (info)->useable == 0 && \
71 (info)->lm == 0)
68 72
69#endif 73#endif
diff --git a/include/asm-um/smp.h b/include/asm-um/smp.h
index d879eba2b52c..aeda6657f366 100644
--- a/include/asm-um/smp.h
+++ b/include/asm-um/smp.h
@@ -23,6 +23,8 @@ extern inline void smp_cpus_done(unsigned int maxcpus)
23{ 23{
24} 24}
25 25
26extern struct task_struct *idle_threads[NR_CPUS];
27
26#endif 28#endif
27 29
28#endif 30#endif
diff --git a/include/asm-v850/bitops.h b/include/asm-v850/bitops.h
index 8955d2376ac8..609b9e87222a 100644
--- a/include/asm-v850/bitops.h
+++ b/include/asm-v850/bitops.h
@@ -188,7 +188,7 @@ static inline int find_next_zero_bit(const void *addr, int size, int offset)
188 tmp = *p; 188 tmp = *p;
189 189
190 found_first: 190 found_first:
191 tmp |= ~0UL >> size; 191 tmp |= ~0UL << size;
192 found_middle: 192 found_middle:
193 return result + ffz (tmp); 193 return result + ffz (tmp);
194} 194}
diff --git a/include/asm-x86_64/apic.h b/include/asm-x86_64/apic.h
index 4f6a4dc455bb..bdbd8935612a 100644
--- a/include/asm-x86_64/apic.h
+++ b/include/asm-x86_64/apic.h
@@ -17,6 +17,7 @@
17#define APIC_DEBUG 2 17#define APIC_DEBUG 2
18 18
19extern int apic_verbosity; 19extern int apic_verbosity;
20extern int apic_runs_main_timer;
20 21
21/* 22/*
22 * Define the default level of output to be very little 23 * Define the default level of output to be very little
diff --git a/include/asm-x86_64/cpufeature.h b/include/asm-x86_64/cpufeature.h
index 41c0ac8559be..76bb6193ae91 100644
--- a/include/asm-x86_64/cpufeature.h
+++ b/include/asm-x86_64/cpufeature.h
@@ -61,7 +61,7 @@
61#define X86_FEATURE_K6_MTRR (3*32+ 1) /* AMD K6 nonstandard MTRRs */ 61#define X86_FEATURE_K6_MTRR (3*32+ 1) /* AMD K6 nonstandard MTRRs */
62#define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */ 62#define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
63#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */ 63#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */
64/* 4 free */ 64#define X86_FEATURE_REP_GOOD (3*32+ 4) /* rep microcode works well on this CPU */
65#define X86_FEATURE_CONSTANT_TSC (3*32+5) /* TSC runs at constant rate */ 65#define X86_FEATURE_CONSTANT_TSC (3*32+5) /* TSC runs at constant rate */
66#define X86_FEATURE_SYNC_RDTSC (3*32+6) /* RDTSC syncs CPU core */ 66#define X86_FEATURE_SYNC_RDTSC (3*32+6) /* RDTSC syncs CPU core */
67 67
diff --git a/include/asm-x86_64/hardirq.h b/include/asm-x86_64/hardirq.h
index 8661b476fb40..8689951e3503 100644
--- a/include/asm-x86_64/hardirq.h
+++ b/include/asm-x86_64/hardirq.h
@@ -16,23 +16,6 @@
16#define set_softirq_pending(x) write_pda(__softirq_pending, (x)) 16#define set_softirq_pending(x) write_pda(__softirq_pending, (x))
17#define or_softirq_pending(x) or_pda(__softirq_pending, (x)) 17#define or_softirq_pending(x) or_pda(__softirq_pending, (x))
18 18
19/* 19extern void ack_bad_irq(unsigned int irq);
20 * 'what should we do if we get a hw irq event on an illegal vector'. 20
21 * each architecture has to answer this themselves.
22 */
23static inline void ack_bad_irq(unsigned int irq)
24{
25 printk("unexpected IRQ trap at vector %02x\n", irq);
26#ifdef CONFIG_X86_LOCAL_APIC
27 /*
28 * Currently unexpected vectors happen only on SMP and APIC.
29 * We _must_ ack these because every local APIC has only N
30 * irq slots per priority level, and a 'hanging, unacked' IRQ
31 * holds up an irq slot - in excessive cases (when multiple
32 * unexpected vectors occur) that might lock up the APIC
33 * completely.
34 */
35 ack_APIC_irq();
36#endif
37}
38#endif /* __ASM_HARDIRQ_H */ 21#endif /* __ASM_HARDIRQ_H */
diff --git a/include/asm-x86_64/ia32_unistd.h b/include/asm-x86_64/ia32_unistd.h
index e87cd83a0e86..9afc0c7d3661 100644
--- a/include/asm-x86_64/ia32_unistd.h
+++ b/include/asm-x86_64/ia32_unistd.h
@@ -300,7 +300,7 @@
300#define __NR_ia32_inotify_add_watch 292 300#define __NR_ia32_inotify_add_watch 292
301#define __NR_ia32_inotify_rm_watch 293 301#define __NR_ia32_inotify_rm_watch 293
302#define __NR_ia32_migrate_pages 294 302#define __NR_ia32_migrate_pages 294
303#define __NR_ia32_opanat 295 303#define __NR_ia32_openat 295
304#define __NR_ia32_mkdirat 296 304#define __NR_ia32_mkdirat 296
305#define __NR_ia32_mknodat 297 305#define __NR_ia32_mknodat 297
306#define __NR_ia32_fchownat 298 306#define __NR_ia32_fchownat 298
diff --git a/include/asm-x86_64/kexec.h b/include/asm-x86_64/kexec.h
index ae28cd44bcd3..c564bae03433 100644
--- a/include/asm-x86_64/kexec.h
+++ b/include/asm-x86_64/kexec.h
@@ -1,8 +1,9 @@
1#ifndef _X86_64_KEXEC_H 1#ifndef _X86_64_KEXEC_H
2#define _X86_64_KEXEC_H 2#define _X86_64_KEXEC_H
3 3
4#include <linux/string.h>
5
4#include <asm/page.h> 6#include <asm/page.h>
5#include <asm/proto.h>
6#include <asm/ptrace.h> 7#include <asm/ptrace.h>
7 8
8/* 9/*
diff --git a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h
index 10248a9a0582..14fc3ddd9031 100644
--- a/include/asm-x86_64/mpspec.h
+++ b/include/asm-x86_64/mpspec.h
@@ -188,7 +188,7 @@ extern void mp_register_lapic_address (u64 address);
188extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base); 188extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base);
189extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi); 189extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi);
190extern void mp_config_acpi_legacy_irqs (void); 190extern void mp_config_acpi_legacy_irqs (void);
191extern int mp_register_gsi (u32 gsi, int edge_level, int active_high_low); 191extern int mp_register_gsi (u32 gsi, int triggering, int polarity);
192#endif /*CONFIG_X86_IO_APIC*/ 192#endif /*CONFIG_X86_IO_APIC*/
193#endif 193#endif
194 194
diff --git a/include/asm-x86_64/proto.h b/include/asm-x86_64/proto.h
index 115e496c6139..c99832e7bf3f 100644
--- a/include/asm-x86_64/proto.h
+++ b/include/asm-x86_64/proto.h
@@ -41,10 +41,18 @@ extern void iommu_hole_init(void);
41 41
42extern void time_init_gtod(void); 42extern void time_init_gtod(void);
43extern int pmtimer_mark_offset(void); 43extern int pmtimer_mark_offset(void);
44extern void pmtimer_resume(void);
45extern void pmtimer_wait(unsigned);
44extern unsigned int do_gettimeoffset_pm(void); 46extern unsigned int do_gettimeoffset_pm(void);
47#ifdef CONFIG_X86_PM_TIMER
45extern u32 pmtmr_ioport; 48extern u32 pmtmr_ioport;
49#else
50#define pmtmr_ioport 0
51#endif
46extern unsigned long long monotonic_base; 52extern unsigned long long monotonic_base;
47extern int sysctl_vsyscall; 53extern int sysctl_vsyscall;
54extern int nohpet;
55extern unsigned long vxtime_hz;
48 56
49extern void do_softirq_thunk(void); 57extern void do_softirq_thunk(void);
50 58
@@ -65,6 +73,9 @@ extern void free_bootmem_generic(unsigned long phys, unsigned len);
65 73
66extern void load_gs_index(unsigned gs); 74extern void load_gs_index(unsigned gs);
67 75
76extern void stop_timer_interrupt(void);
77extern void main_timer_handler(struct pt_regs *regs);
78
68extern unsigned long end_pfn_map; 79extern unsigned long end_pfn_map;
69 80
70extern void show_trace(unsigned long * rsp); 81extern void show_trace(unsigned long * rsp);
diff --git a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h
index a73f0c789d8b..b7f66034ae7a 100644
--- a/include/asm-x86_64/system.h
+++ b/include/asm-x86_64/system.h
@@ -327,7 +327,7 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
327#define wmb() asm volatile("" ::: "memory") 327#define wmb() asm volatile("" ::: "memory")
328#endif 328#endif
329#define read_barrier_depends() do {} while(0) 329#define read_barrier_depends() do {} while(0)
330#define set_mb(var, value) do { xchg(&var, value); } while (0) 330#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
331#define set_wmb(var, value) do { var = value; wmb(); } while (0) 331#define set_wmb(var, value) do { var = value; wmb(); } while (0)
332 332
333#define warn_if_not_ulong(x) do { unsigned long foo; (void) (&(x) == &foo); } while (0) 333#define warn_if_not_ulong(x) do { unsigned long foo; (void) (&(x) == &foo); } while (0)
diff --git a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h
index 2fa7f27381b4..c642f5d9882d 100644
--- a/include/asm-x86_64/topology.h
+++ b/include/asm-x86_64/topology.h
@@ -57,6 +57,15 @@ extern int __node_distance(int, int);
57 57
58#endif 58#endif
59 59
60#ifdef CONFIG_SMP
61#define topology_physical_package_id(cpu) \
62 (phys_proc_id[cpu] == BAD_APICID ? -1 : phys_proc_id[cpu])
63#define topology_core_id(cpu) \
64 (cpu_core_id[cpu] == BAD_APICID ? 0 : cpu_core_id[cpu])
65#define topology_core_siblings(cpu) (cpu_core_map[cpu])
66#define topology_thread_siblings(cpu) (cpu_sibling_map[cpu])
67#endif
68
60#include <asm-generic/topology.h> 69#include <asm-generic/topology.h>
61 70
62#endif 71#endif
diff --git a/include/asm-xtensa/futex.h b/include/asm-xtensa/futex.h
new file mode 100644
index 000000000000..0b745828f42b
--- /dev/null
+++ b/include/asm-xtensa/futex.h
@@ -0,0 +1 @@
#include <asm-generic/futex.h>
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 026c3c011dc0..84d3d9f034ce 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -435,7 +435,7 @@ extern int sbf_port ;
435 435
436#endif /* !CONFIG_ACPI */ 436#endif /* !CONFIG_ACPI */
437 437
438int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low); 438int acpi_register_gsi (u32 gsi, int triggering, int polarity);
439int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); 439int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
440 440
441/* 441/*
diff --git a/include/linux/agpgart.h b/include/linux/agpgart.h
index 17a17c55a17f..6d59c8efe3be 100644
--- a/include/linux/agpgart.h
+++ b/include/linux/agpgart.h
@@ -111,6 +111,7 @@ typedef struct _agp_unbind {
111} agp_unbind; 111} agp_unbind;
112 112
113#else /* __KERNEL__ */ 113#else /* __KERNEL__ */
114#include <linux/mutex.h>
114 115
115#define AGPGART_MINOR 175 116#define AGPGART_MINOR 175
116 117
@@ -201,7 +202,7 @@ struct agp_file_private {
201}; 202};
202 203
203struct agp_front_data { 204struct agp_front_data {
204 struct semaphore agp_mutex; 205 struct mutex agp_mutex;
205 struct agp_controller *current_controller; 206 struct agp_controller *current_controller;
206 struct agp_controller *controllers; 207 struct agp_controller *controllers;
207 struct agp_file_private *file_priv_list; 208 struct agp_file_private *file_priv_list;
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 6a2a19f14bb2..208650b1ad3a 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -81,7 +81,7 @@ static inline int generic_fls64(__u64 x)
81{ 81{
82 __u32 h = x >> 32; 82 __u32 h = x >> 32;
83 if (h) 83 if (h)
84 return fls(x) + 32; 84 return fls(h) + 32;
85 return fls(x); 85 return fls(x);
86} 86}
87 87
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 02a585faa62c..860e7a485a5f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -392,8 +392,8 @@ struct request_queue
392 unsigned int nr_congestion_off; 392 unsigned int nr_congestion_off;
393 unsigned int nr_batching; 393 unsigned int nr_batching;
394 394
395 unsigned short max_sectors; 395 unsigned int max_sectors;
396 unsigned short max_hw_sectors; 396 unsigned int max_hw_sectors;
397 unsigned short max_phys_segments; 397 unsigned short max_phys_segments;
398 unsigned short max_hw_segments; 398 unsigned short max_hw_segments;
399 unsigned short hardsect_size; 399 unsigned short hardsect_size;
@@ -697,7 +697,7 @@ extern request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *);
697extern void blk_cleanup_queue(request_queue_t *); 697extern void blk_cleanup_queue(request_queue_t *);
698extern void blk_queue_make_request(request_queue_t *, make_request_fn *); 698extern void blk_queue_make_request(request_queue_t *, make_request_fn *);
699extern void blk_queue_bounce_limit(request_queue_t *, u64); 699extern void blk_queue_bounce_limit(request_queue_t *, u64);
700extern void blk_queue_max_sectors(request_queue_t *, unsigned short); 700extern void blk_queue_max_sectors(request_queue_t *, unsigned int);
701extern void blk_queue_max_phys_segments(request_queue_t *, unsigned short); 701extern void blk_queue_max_phys_segments(request_queue_t *, unsigned short);
702extern void blk_queue_max_hw_segments(request_queue_t *, unsigned short); 702extern void blk_queue_max_hw_segments(request_queue_t *, unsigned short);
703extern void blk_queue_max_segment_size(request_queue_t *, unsigned int); 703extern void blk_queue_max_segment_size(request_queue_t *, unsigned int);
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index acffb8c9073a..a7f015027535 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -126,7 +126,7 @@ extern struct config_item *config_group_find_obj(struct config_group *, const ch
126 126
127 127
128struct configfs_attribute { 128struct configfs_attribute {
129 char *ca_name; 129 const char *ca_name;
130 struct module *ca_owner; 130 struct module *ca_owner;
131 mode_t ca_mode; 131 mode_t ca_mode;
132}; 132};
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index c31650df9241..17866d7e2b71 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -14,6 +14,7 @@
14#ifndef _LINUX_CPUFREQ_H 14#ifndef _LINUX_CPUFREQ_H
15#define _LINUX_CPUFREQ_H 15#define _LINUX_CPUFREQ_H
16 16
17#include <linux/mutex.h>
17#include <linux/config.h> 18#include <linux/config.h>
18#include <linux/notifier.h> 19#include <linux/notifier.h>
19#include <linux/threads.h> 20#include <linux/threads.h>
@@ -82,7 +83,7 @@ struct cpufreq_policy {
82 unsigned int policy; /* see above */ 83 unsigned int policy; /* see above */
83 struct cpufreq_governor *governor; /* see below */ 84 struct cpufreq_governor *governor; /* see below */
84 85
85 struct semaphore lock; /* CPU ->setpolicy or ->target may 86 struct mutex lock; /* CPU ->setpolicy or ->target may
86 only be called once a time */ 87 only be called once a time */
87 88
88 struct work_struct update; /* if update_policy() needs to be 89 struct work_struct update; /* if update_policy() needs to be
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index a3ed5e059d47..a3f09947940e 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -108,7 +108,9 @@ struct dentry {
108 struct dentry_operations *d_op; 108 struct dentry_operations *d_op;
109 struct super_block *d_sb; /* The root of the dentry tree */ 109 struct super_block *d_sb; /* The root of the dentry tree */
110 void *d_fsdata; /* fs-specific data */ 110 void *d_fsdata; /* fs-specific data */
111#ifdef CONFIG_PROFILING
111 struct dcookie_struct *d_cookie; /* cookie, if any */ 112 struct dcookie_struct *d_cookie; /* cookie, if any */
113#endif
112 int d_mounted; 114 int d_mounted;
113 unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */ 115 unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */
114}; 116};
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 83c7d207b80e..51e0e95a421a 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -91,7 +91,7 @@ struct target_type {
91}; 91};
92 92
93struct io_restrictions { 93struct io_restrictions {
94 unsigned short max_sectors; 94 unsigned int max_sectors;
95 unsigned short max_phys_segments; 95 unsigned short max_phys_segments;
96 unsigned short max_hw_segments; 96 unsigned short max_hw_segments;
97 unsigned short hardsect_size; 97 unsigned short hardsect_size;
diff --git a/include/linux/elfcore.h b/include/linux/elfcore.h
index dbd7bb4a33b7..0cf0bea010fe 100644
--- a/include/linux/elfcore.h
+++ b/include/linux/elfcore.h
@@ -5,6 +5,7 @@
5#include <linux/signal.h> 5#include <linux/signal.h>
6#include <linux/time.h> 6#include <linux/time.h>
7#include <linux/user.h> 7#include <linux/user.h>
8#include <linux/ptrace.h>
8 9
9struct elf_siginfo 10struct elf_siginfo
10{ 11{
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 84bb449b9b01..e059da947007 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -363,6 +363,8 @@ struct address_space_operations {
363 loff_t offset, unsigned long nr_segs); 363 loff_t offset, unsigned long nr_segs);
364 struct page* (*get_xip_page)(struct address_space *, sector_t, 364 struct page* (*get_xip_page)(struct address_space *, sector_t,
365 int); 365 int);
366 /* migrate the contents of a page to the specified target */
367 int (*migratepage) (struct page *, struct page *);
366}; 368};
367 369
368struct backing_dev_info; 370struct backing_dev_info;
@@ -1719,6 +1721,12 @@ extern void simple_release_fs(struct vfsmount **mount, int *count);
1719 1721
1720extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t); 1722extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t);
1721 1723
1724#ifdef CONFIG_MIGRATION
1725extern int buffer_migrate_page(struct page *, struct page *);
1726#else
1727#define buffer_migrate_page NULL
1728#endif
1729
1722extern int inode_change_ok(struct inode *, struct iattr *); 1730extern int inode_change_ok(struct inode *, struct iattr *);
1723extern int __must_check inode_setattr(struct inode *, struct iattr *); 1731extern int __must_check inode_setattr(struct inode *, struct iattr *);
1724 1732
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index 528959c52f1b..5425b60021e3 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -14,7 +14,7 @@
14#define FUSE_KERNEL_VERSION 7 14#define FUSE_KERNEL_VERSION 7
15 15
16/** Minor version number of this interface */ 16/** Minor version number of this interface */
17#define FUSE_KERNEL_MINOR_VERSION 5 17#define FUSE_KERNEL_MINOR_VERSION 6
18 18
19/** The node ID of the root inode */ 19/** The node ID of the root inode */
20#define FUSE_ROOT_ID 1 20#define FUSE_ROOT_ID 1
@@ -58,6 +58,9 @@ struct fuse_kstatfs {
58 __u32 spare[6]; 58 __u32 spare[6];
59}; 59};
60 60
61/**
62 * Bitmasks for fuse_setattr_in.valid
63 */
61#define FATTR_MODE (1 << 0) 64#define FATTR_MODE (1 << 0)
62#define FATTR_UID (1 << 1) 65#define FATTR_UID (1 << 1)
63#define FATTR_GID (1 << 2) 66#define FATTR_GID (1 << 2)
@@ -75,6 +78,11 @@ struct fuse_kstatfs {
75#define FOPEN_DIRECT_IO (1 << 0) 78#define FOPEN_DIRECT_IO (1 << 0)
76#define FOPEN_KEEP_CACHE (1 << 1) 79#define FOPEN_KEEP_CACHE (1 << 1)
77 80
81/**
82 * INIT request/reply flags
83 */
84#define FUSE_ASYNC_READ (1 << 0)
85
78enum fuse_opcode { 86enum fuse_opcode {
79 FUSE_LOOKUP = 1, 87 FUSE_LOOKUP = 1,
80 FUSE_FORGET = 2, /* no reply */ 88 FUSE_FORGET = 2, /* no reply */
@@ -247,12 +255,16 @@ struct fuse_access_in {
247struct fuse_init_in { 255struct fuse_init_in {
248 __u32 major; 256 __u32 major;
249 __u32 minor; 257 __u32 minor;
258 __u32 max_readahead;
259 __u32 flags;
250}; 260};
251 261
252struct fuse_init_out { 262struct fuse_init_out {
253 __u32 major; 263 __u32 major;
254 __u32 minor; 264 __u32 minor;
255 __u32 unused[3]; 265 __u32 max_readahead;
266 __u32 flags;
267 __u32 unused;
256 __u32 max_write; 268 __u32 max_write;
257}; 269};
258 270
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 089bfb1fa01a..6361544bb6ae 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -40,6 +40,7 @@ enum hrtimer_restart {
40enum hrtimer_state { 40enum hrtimer_state {
41 HRTIMER_INACTIVE, /* Timer is inactive */ 41 HRTIMER_INACTIVE, /* Timer is inactive */
42 HRTIMER_EXPIRED, /* Timer is expired */ 42 HRTIMER_EXPIRED, /* Timer is expired */
43 HRTIMER_RUNNING, /* Timer is running the callback function */
43 HRTIMER_PENDING, /* Timer is pending */ 44 HRTIMER_PENDING, /* Timer is pending */
44}; 45};
45 46
@@ -100,9 +101,8 @@ struct hrtimer_base {
100/* Exported timer functions: */ 101/* Exported timer functions: */
101 102
102/* Initialize timers: */ 103/* Initialize timers: */
103extern void hrtimer_init(struct hrtimer *timer, const clockid_t which_clock); 104extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
104extern void hrtimer_rebase(struct hrtimer *timer, const clockid_t which_clock); 105 enum hrtimer_mode mode);
105
106 106
107/* Basic timer operations: */ 107/* Basic timer operations: */
108extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, 108extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index 9ba806796667..5a9d8c599171 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -1115,9 +1115,11 @@ static inline struct i2o_message *i2o_msg_get(struct i2o_controller *c)
1115 return ERR_PTR(-ENOMEM); 1115 return ERR_PTR(-ENOMEM);
1116 1116
1117 mmsg->mfa = readl(c->in_port); 1117 mmsg->mfa = readl(c->in_port);
1118 if (mmsg->mfa == I2O_QUEUE_EMPTY) { 1118 if (unlikely(mmsg->mfa >= c->in_queue.len)) {
1119 mempool_free(mmsg, c->in_msg.mempool); 1119 mempool_free(mmsg, c->in_msg.mempool);
1120 return ERR_PTR(-EBUSY); 1120 if(mmsg->mfa == I2O_QUEUE_EMPTY)
1121 return ERR_PTR(-EBUSY);
1122 return ERR_PTR(-EFAULT);
1121 } 1123 }
1122 1124
1123 return &mmsg->msg; 1125 return &mmsg->msg;
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 110b3cfac021..a7fc4cc79b23 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -582,7 +582,6 @@ typedef struct ide_drive_s {
582 unsigned noprobe : 1; /* from: hdx=noprobe */ 582 unsigned noprobe : 1; /* from: hdx=noprobe */
583 unsigned removable : 1; /* 1 if need to do check_media_change */ 583 unsigned removable : 1; /* 1 if need to do check_media_change */
584 unsigned attach : 1; /* needed for removable devices */ 584 unsigned attach : 1; /* needed for removable devices */
585 unsigned is_flash : 1; /* 1 if probed as flash */
586 unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ 585 unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */
587 unsigned no_unmask : 1; /* disallow setting unmask bit */ 586 unsigned no_unmask : 1; /* disallow setting unmask bit */
588 unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ 587 unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */
@@ -1006,7 +1005,6 @@ extern ide_hwif_t ide_hwifs[]; /* master data repository */
1006extern int noautodma; 1005extern int noautodma;
1007 1006
1008extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); 1007extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);
1009extern int __ide_end_request (ide_drive_t *drive, struct request *rq, int uptodate, int nrsecs);
1010 1008
1011/* 1009/*
1012 * This is used on exit from the driver to designate the next irq handler 1010 * This is used on exit from the driver to designate the next irq handler
diff --git a/include/linux/io.h b/include/linux/io.h
new file mode 100644
index 000000000000..85533ec5aaa1
--- /dev/null
+++ b/include/linux/io.h
@@ -0,0 +1,25 @@
1/*
2 * Copyright 2006 PathScale, Inc. All Rights Reserved.
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18#ifndef _LINUX_IO_H
19#define _LINUX_IO_H
20
21#include <asm/io.h>
22
23void __iowrite32_copy(void __iomem *to, const void *from, size_t count);
24
25#endif /* _LINUX_IO_H */
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index 558cb4c26ec9..751bb3849467 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -23,6 +23,7 @@
23#define jfs_debug jbd_debug 23#define jfs_debug jbd_debug
24#else 24#else
25 25
26#include <linux/types.h>
26#include <linux/buffer_head.h> 27#include <linux/buffer_head.h>
27#include <linux/journal-head.h> 28#include <linux/journal-head.h>
28#include <linux/stddef.h> 29#include <linux/stddef.h>
@@ -618,6 +619,7 @@ struct transaction_s
618 * @j_wbuf: array of buffer_heads for journal_commit_transaction 619 * @j_wbuf: array of buffer_heads for journal_commit_transaction
619 * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the 620 * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the
620 * number that will fit in j_blocksize 621 * number that will fit in j_blocksize
622 * @j_last_sync_writer: most recent pid which did a synchronous write
621 * @j_private: An opaque pointer to fs-private information. 623 * @j_private: An opaque pointer to fs-private information.
622 */ 624 */
623 625
@@ -807,6 +809,8 @@ struct journal_s
807 struct buffer_head **j_wbuf; 809 struct buffer_head **j_wbuf;
808 int j_wbufsize; 810 int j_wbufsize;
809 811
812 pid_t j_last_sync_writer;
813
810 /* 814 /*
811 * An opaque pointer to fs-private information. ext3 puts its 815 * An opaque pointer to fs-private information. ext3 puts its
812 * superblock pointer here 816 * superblock pointer here
diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h
index 45f625d7d0b2..3aed37314ab8 100644
--- a/include/linux/kbd_kern.h
+++ b/include/linux/kbd_kern.h
@@ -151,6 +151,11 @@ extern unsigned int keymap_count;
151 151
152static inline void con_schedule_flip(struct tty_struct *t) 152static inline void con_schedule_flip(struct tty_struct *t)
153{ 153{
154 unsigned long flags;
155 spin_lock_irqsave(&t->buf.lock, flags);
156 if (t->buf.tail != NULL)
157 t->buf.tail->active = 0;
158 spin_unlock_irqrestore(&t->buf.lock, flags);
154 schedule_work(&t->buf.work); 159 schedule_work(&t->buf.work);
155} 160}
156 161
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index a5363324cf95..b49affa0ac5a 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -185,6 +185,7 @@ extern enum system_states {
185 SYSTEM_HALT, 185 SYSTEM_HALT,
186 SYSTEM_POWER_OFF, 186 SYSTEM_POWER_OFF,
187 SYSTEM_RESTART, 187 SYSTEM_RESTART,
188 SYSTEM_SUSPEND_DISK,
188} system_state; 189} system_state;
189 190
190#define TAINT_PROPRIETARY_MODULE (1<<0) 191#define TAINT_PROPRIETARY_MODULE (1<<0)
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 1bd6552cc341..6aca67a569a2 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -10,6 +10,12 @@
10 * 10 *
11 * Started by: Thomas Gleixner and Ingo Molnar 11 * Started by: Thomas Gleixner and Ingo Molnar
12 * 12 *
13 * Credits:
14 *
15 * Roman Zippel provided the ideas and primary code snippets of
16 * the ktime_t union and further simplifications of the original
17 * code.
18 *
13 * For licencing details see kernel-base/COPYING 19 * For licencing details see kernel-base/COPYING
14 */ 20 */
15#ifndef _LINUX_KTIME_H 21#ifndef _LINUX_KTIME_H
diff --git a/include/linux/list.h b/include/linux/list.h
index 945daa1f13dd..47208bd99f9e 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -34,9 +34,11 @@ struct list_head {
34#define LIST_HEAD(name) \ 34#define LIST_HEAD(name) \
35 struct list_head name = LIST_HEAD_INIT(name) 35 struct list_head name = LIST_HEAD_INIT(name)
36 36
37#define INIT_LIST_HEAD(ptr) do { \ 37static inline void INIT_LIST_HEAD(struct list_head *list)
38 (ptr)->next = (ptr); (ptr)->prev = (ptr); \ 38{
39} while (0) 39 list->next = list;
40 list->prev = list;
41}
40 42
41/* 43/*
42 * Insert a new entry between two known consecutive entries. 44 * Insert a new entry between two known consecutive entries.
@@ -534,7 +536,11 @@ struct hlist_node {
534#define HLIST_HEAD_INIT { .first = NULL } 536#define HLIST_HEAD_INIT { .first = NULL }
535#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } 537#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
536#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL) 538#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
537#define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL) 539static inline void INIT_HLIST_NODE(struct hlist_node *h)
540{
541 h->next = NULL;
542 h->pprev = NULL;
543}
538 544
539static inline int hlist_unhashed(const struct hlist_node *h) 545static inline int hlist_unhashed(const struct hlist_node *h)
540{ 546{
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 95c8fea293ba..920766cea79c 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -84,6 +84,7 @@ struct nlm_rqst {
84 struct nlm_args a_args; /* arguments */ 84 struct nlm_args a_args; /* arguments */
85 struct nlm_res a_res; /* result */ 85 struct nlm_res a_res; /* result */
86 struct nlm_wait * a_block; 86 struct nlm_wait * a_block;
87 unsigned int a_retries; /* Retry count */
87 char a_owner[NLMCLNT_OHSIZE]; 88 char a_owner[NLMCLNT_OHSIZE];
88}; 89};
89 90
@@ -148,7 +149,6 @@ struct nlm_rqst * nlmclnt_alloc_call(void);
148int nlmclnt_prepare_block(struct nlm_rqst *req, struct nlm_host *host, struct file_lock *fl); 149int nlmclnt_prepare_block(struct nlm_rqst *req, struct nlm_host *host, struct file_lock *fl);
149void nlmclnt_finish_block(struct nlm_rqst *req); 150void nlmclnt_finish_block(struct nlm_rqst *req);
150long nlmclnt_block(struct nlm_rqst *req, long timeout); 151long nlmclnt_block(struct nlm_rqst *req, long timeout);
151int nlmclnt_cancel(struct nlm_host *, struct file_lock *);
152u32 nlmclnt_grant(struct nlm_lock *); 152u32 nlmclnt_grant(struct nlm_lock *);
153void nlmclnt_recovery(struct nlm_host *, u32); 153void nlmclnt_recovery(struct nlm_host *, u32);
154int nlmclnt_reclaim(struct nlm_host *, struct file_lock *); 154int nlmclnt_reclaim(struct nlm_host *, struct file_lock *);
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index ccd3e13de1e8..f38872abc126 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -21,24 +21,35 @@ struct mmc_command {
21 u32 arg; 21 u32 arg;
22 u32 resp[4]; 22 u32 resp[4];
23 unsigned int flags; /* expected response type */ 23 unsigned int flags; /* expected response type */
24#define MMC_RSP_NONE (0 << 0) 24#define MMC_RSP_PRESENT (1 << 0)
25#define MMC_RSP_SHORT (1 << 0) 25#define MMC_RSP_136 (1 << 1) /* 136 bit response */
26#define MMC_RSP_LONG (2 << 0) 26#define MMC_RSP_CRC (1 << 2) /* expect valid crc */
27#define MMC_RSP_MASK (3 << 0) 27#define MMC_RSP_BUSY (1 << 3) /* card may send busy */
28#define MMC_RSP_CRC (1 << 3) /* expect valid crc */ 28#define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */
29#define MMC_RSP_BUSY (1 << 4) /* card may send busy */ 29#define MMC_CMD_MASK (3 << 5) /* command type */
30#define MMC_RSP_OPCODE (1 << 5) /* response contains opcode */ 30#define MMC_CMD_AC (0 << 5)
31#define MMC_CMD_ADTC (1 << 5)
32#define MMC_CMD_BC (2 << 5)
33#define MMC_CMD_BCR (3 << 5)
31 34
32/* 35/*
33 * These are the response types, and correspond to valid bit 36 * These are the response types, and correspond to valid bit
34 * patterns of the above flags. One additional valid pattern 37 * patterns of the above flags. One additional valid pattern
35 * is all zeros, which means we don't expect a response. 38 * is all zeros, which means we don't expect a response.
36 */ 39 */
37#define MMC_RSP_R1 (MMC_RSP_SHORT|MMC_RSP_CRC|MMC_RSP_OPCODE) 40#define MMC_RSP_NONE (0)
38#define MMC_RSP_R1B (MMC_RSP_SHORT|MMC_RSP_CRC|MMC_RSP_OPCODE|MMC_RSP_BUSY) 41#define MMC_RSP_R1 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
39#define MMC_RSP_R2 (MMC_RSP_LONG|MMC_RSP_CRC) 42#define MMC_RSP_R1B (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE|MMC_RSP_BUSY)
40#define MMC_RSP_R3 (MMC_RSP_SHORT) 43#define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC)
41#define MMC_RSP_R6 (MMC_RSP_SHORT|MMC_RSP_CRC) 44#define MMC_RSP_R3 (MMC_RSP_PRESENT)
45#define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC)
46
47#define mmc_resp_type(cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))
48
49/*
50 * These are the command types.
51 */
52#define mmc_cmd_type(cmd) ((cmd)->flags & MMC_CMD_TYPE)
42 53
43 unsigned int retries; /* max number of retries */ 54 unsigned int retries; /* max number of retries */
44 unsigned int error; /* command error */ 55 unsigned int error; /* command error */
diff --git a/include/linux/mmc/protocol.h b/include/linux/mmc/protocol.h
index a14dc306545b..81c3f77f652c 100644
--- a/include/linux/mmc/protocol.h
+++ b/include/linux/mmc/protocol.h
@@ -79,7 +79,7 @@
79/* SD commands type argument response */ 79/* SD commands type argument response */
80 /* class 8 */ 80 /* class 8 */
81/* This is basically the same command as for MMC with some quirks. */ 81/* This is basically the same command as for MMC with some quirks. */
82#define SD_SEND_RELATIVE_ADDR 3 /* ac R6 */ 82#define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */
83 83
84 /* Application commands */ 84 /* Application commands */
85#define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */ 85#define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 93a849f742db..ebfc238cc243 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -91,10 +91,21 @@ struct per_cpu_pageset {
91 * be 8 (2 ** 3) zonelists. GFP_ZONETYPES defines the number of possible 91 * be 8 (2 ** 3) zonelists. GFP_ZONETYPES defines the number of possible
92 * combinations of zone modifiers in "zone modifier space". 92 * combinations of zone modifiers in "zone modifier space".
93 * 93 *
94 * As an optimisation any zone modifier bits which are only valid when
95 * no other zone modifier bits are set (loners) should be placed in
96 * the highest order bits of this field. This allows us to reduce the
97 * extent of the zonelists thus saving space. For example in the case
98 * of three zone modifier bits, we could require up to eight zonelists.
99 * If the left most zone modifier is a "loner" then the highest valid
100 * zonelist would be four allowing us to allocate only five zonelists.
101 * Use the first form for GFP_ZONETYPES when the left most bit is not
102 * a "loner", otherwise use the second.
103 *
94 * NOTE! Make sure this matches the zones in <linux/gfp.h> 104 * NOTE! Make sure this matches the zones in <linux/gfp.h>
95 */ 105 */
96#define GFP_ZONEMASK 0x07 106#define GFP_ZONEMASK 0x07
97#define GFP_ZONETYPES 5 107/* #define GFP_ZONETYPES (GFP_ZONEMASK + 1) */ /* Non-loner */
108#define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1) /* Loner */
98 109
99/* 110/*
100 * On machines where it is needed (eg PCs) we divide physical memory 111 * On machines where it is needed (eg PCs) we divide physical memory
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 59ff6c430cf6..6500d4e59d46 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -19,7 +19,21 @@ struct xt_get_revision
19/* For standard target */ 19/* For standard target */
20#define XT_RETURN (-NF_REPEAT - 1) 20#define XT_RETURN (-NF_REPEAT - 1)
21 21
22#define XT_ALIGN(s) (((s) + (__alignof__(u_int64_t)-1)) & ~(__alignof__(u_int64_t)-1)) 22/* this is a dummy structure to find out the alignment requirement for a struct
23 * containing all the fundamental data types that are used in ipt_entry,
24 * ip6t_entry and arpt_entry. This sucks, and it is a hack. It will be my
25 * personal pleasure to remove it -HW
26 */
27struct _xt_align
28{
29 u_int8_t u8;
30 u_int16_t u16;
31 u_int32_t u32;
32 u_int64_t u64;
33};
34
35#define XT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) \
36 & ~(__alignof__(struct _xt_align)-1))
23 37
24/* Standard return verdict, or do jump. */ 38/* Standard return verdict, or do jump. */
25#define XT_STANDARD_TARGET "" 39#define XT_STANDARD_TARGET ""
diff --git a/include/linux/netfilter_ipv4/ipt_connbytes.h b/include/linux/netfilter_ipv4/ipt_connbytes.h
index b04dfa3083c9..f63e6ee91113 100644
--- a/include/linux/netfilter_ipv4/ipt_connbytes.h
+++ b/include/linux/netfilter_ipv4/ipt_connbytes.h
@@ -1,10 +1,10 @@
1#ifndef _IPT_CONNBYTES_H 1#ifndef _IPT_CONNBYTES_H
2#define _IPT_CONNBYTES_H 2#define _IPT_CONNBYTES_H
3 3
4#include <net/netfilter/xt_connbytes.h> 4#include <linux/netfilter/xt_connbytes.h>
5#define ipt_connbytes_what xt_connbytes_what 5#define ipt_connbytes_what xt_connbytes_what
6 6
7#define IPT_CONNBYTES_PKTS XT_CONNBYTES_PACKETS 7#define IPT_CONNBYTES_PKTS XT_CONNBYTES_PKTS
8#define IPT_CONNBYTES_BYTES XT_CONNBYTES_BYTES 8#define IPT_CONNBYTES_BYTES XT_CONNBYTES_BYTES
9#define IPT_CONNBYTES_AVGPKT XT_CONNBYTES_AVGPKT 9#define IPT_CONNBYTES_AVGPKT XT_CONNBYTES_AVGPKT
10 10
diff --git a/include/linux/netfilter_ipv4/ipt_policy.h b/include/linux/netfilter_ipv4/ipt_policy.h
index 7fd1bec453f1..a3f6eff39d33 100644
--- a/include/linux/netfilter_ipv4/ipt_policy.h
+++ b/include/linux/netfilter_ipv4/ipt_policy.h
@@ -27,16 +27,22 @@ struct ipt_policy_spec
27 reqid:1; 27 reqid:1;
28}; 28};
29 29
30union ipt_policy_addr
31{
32 struct in_addr a4;
33 struct in6_addr a6;
34};
35
30struct ipt_policy_elem 36struct ipt_policy_elem
31{ 37{
32 u_int32_t saddr; 38 union ipt_policy_addr saddr;
33 u_int32_t smask; 39 union ipt_policy_addr smask;
34 u_int32_t daddr; 40 union ipt_policy_addr daddr;
35 u_int32_t dmask; 41 union ipt_policy_addr dmask;
36 u_int32_t spi; 42 u_int32_t spi;
37 u_int32_t reqid; 43 u_int32_t reqid;
38 u_int8_t proto; 44 u_int8_t proto;
39 u_int8_t mode; 45 u_int8_t mode;
40 46
41 struct ipt_policy_spec match; 47 struct ipt_policy_spec match;
42 struct ipt_policy_spec invert; 48 struct ipt_policy_spec invert;
diff --git a/include/linux/netfilter_ipv6/ip6t_policy.h b/include/linux/netfilter_ipv6/ip6t_policy.h
index 5a93afcd2ff1..671bd818300f 100644
--- a/include/linux/netfilter_ipv6/ip6t_policy.h
+++ b/include/linux/netfilter_ipv6/ip6t_policy.h
@@ -27,16 +27,22 @@ struct ip6t_policy_spec
27 reqid:1; 27 reqid:1;
28}; 28};
29 29
30union ip6t_policy_addr
31{
32 struct in_addr a4;
33 struct in6_addr a6;
34};
35
30struct ip6t_policy_elem 36struct ip6t_policy_elem
31{ 37{
32 struct in6_addr saddr; 38 union ip6t_policy_addr saddr;
33 struct in6_addr smask; 39 union ip6t_policy_addr smask;
34 struct in6_addr daddr; 40 union ip6t_policy_addr daddr;
35 struct in6_addr dmask; 41 union ip6t_policy_addr dmask;
36 u_int32_t spi; 42 u_int32_t spi;
37 u_int32_t reqid; 43 u_int32_t reqid;
38 u_int8_t proto; 44 u_int8_t proto;
39 u_int8_t mode; 45 u_int8_t mode;
40 46
41 struct ip6t_policy_spec match; 47 struct ip6t_policy_spec match;
42 struct ip6t_policy_spec invert; 48 struct ip6t_policy_spec invert;
diff --git a/include/linux/parport.h b/include/linux/parport.h
index f67f838a3a1f..008d736a6c9a 100644
--- a/include/linux/parport.h
+++ b/include/linux/parport.h
@@ -128,6 +128,11 @@ struct amiga_parport_state {
128 unsigned char statusdir;/* ciab.ddrb & 7 */ 128 unsigned char statusdir;/* ciab.ddrb & 7 */
129}; 129};
130 130
131struct ip32_parport_state {
132 unsigned int dcr;
133 unsigned int ecr;
134};
135
131struct parport_state { 136struct parport_state {
132 union { 137 union {
133 struct pc_parport_state pc; 138 struct pc_parport_state pc;
@@ -135,6 +140,7 @@ struct parport_state {
135 struct ax_parport_state ax; 140 struct ax_parport_state ax;
136 struct amiga_parport_state amiga; 141 struct amiga_parport_state amiga;
137 /* Atari has not state. */ 142 /* Atari has not state. */
143 struct ip32_parport_state ip32;
138 void *misc; 144 void *misc;
139 } u; 145 } u;
140}; 146};
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 0a44072383ec..fe1a2b02fc55 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -406,7 +406,6 @@ struct pci_dev *pci_find_device_reverse (unsigned int vendor, unsigned int devic
406struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn); 406struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);
407int pci_find_capability (struct pci_dev *dev, int cap); 407int pci_find_capability (struct pci_dev *dev, int cap);
408int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap); 408int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap);
409int pci_find_ext_capability (struct pci_dev *dev, int cap);
410struct pci_bus * pci_find_next_bus(const struct pci_bus *from); 409struct pci_bus * pci_find_next_bus(const struct pci_bus *from);
411 410
412struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from); 411struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from);
@@ -626,7 +625,6 @@ static inline int pci_register_driver(struct pci_driver *drv) { return 0;}
626static inline void pci_unregister_driver(struct pci_driver *drv) { } 625static inline void pci_unregister_driver(struct pci_driver *drv) { }
627static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } 626static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; }
628static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; } 627static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; }
629static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; }
630static inline const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) { return NULL; } 628static inline const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) { return NULL; }
631 629
632/* Power management related routines */ 630/* Power management related routines */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index ecc1fc1f0f04..92a619ba163f 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -394,14 +394,9 @@
394#define PCI_DEVICE_ID_NS_SC1100_SMI 0x0511 394#define PCI_DEVICE_ID_NS_SC1100_SMI 0x0511
395#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515 395#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515
396#define PCI_DEVICE_ID_NS_87410 0xd001 396#define PCI_DEVICE_ID_NS_87410 0xd001
397#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d
398 397
399#define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE 0x0028 398#define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE 0x0028
400#define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE 0x002b 399#define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE 0x002b
401#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d
402#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e
403#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f
404#define PCI_DEVICE_ID_NS_CS5535_VIDEO 0x0030
405 400
406#define PCI_VENDOR_ID_TSENG 0x100c 401#define PCI_VENDOR_ID_TSENG 0x100c
407#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202 402#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202
@@ -511,8 +506,6 @@
511#define PCI_DEVICE_ID_AMD_CS5536_UOC 0x2097 506#define PCI_DEVICE_ID_AMD_CS5536_UOC 0x2097
512#define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A 507#define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A
513 508
514#define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A
515
516#define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081 509#define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081
517#define PCI_DEVICE_ID_AMD_LX_AES 0x2082 510#define PCI_DEVICE_ID_AMD_LX_AES 0x2082
518 511
@@ -1677,6 +1670,9 @@
1677#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060 1670#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060
1678#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061 1671#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061
1679#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062 1672#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062
1673#define PCI_DEVICE_ID_SIIG_8S_20x_550 0x2080
1674#define PCI_DEVICE_ID_SIIG_8S_20x_650 0x2081
1675#define PCI_DEVICE_ID_SIIG_8S_20x_850 0x2082
1680#define PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL 0x2050 1676#define PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL 0x2050
1681 1677
1682#define PCI_VENDOR_ID_RADISYS 0x1331 1678#define PCI_VENDOR_ID_RADISYS 0x1331
@@ -2065,6 +2061,7 @@
2065#define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5 2061#define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5
2066#define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6 2062#define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6
2067#define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db 2063#define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db
2064#define PCI_DEVICE_ID_INTEL_82801EB_13 0x24dd
2068#define PCI_DEVICE_ID_INTEL_ESB_1 0x25a1 2065#define PCI_DEVICE_ID_INTEL_ESB_1 0x25a1
2069#define PCI_DEVICE_ID_INTEL_ESB_2 0x25a2 2066#define PCI_DEVICE_ID_INTEL_ESB_2 0x25a2
2070#define PCI_DEVICE_ID_INTEL_ESB_4 0x25a4 2067#define PCI_DEVICE_ID_INTEL_ESB_4 0x25a4
@@ -2085,6 +2082,8 @@
2085#define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592 2082#define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592
2086#define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770 2083#define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770
2087#define PCI_DEVICE_ID_INTEL_82945G_IG 0x2772 2084#define PCI_DEVICE_ID_INTEL_82945G_IG 0x2772
2085#define PCI_DEVICE_ID_INTEL_82945GM_HB 0x27A0
2086#define PCI_DEVICE_ID_INTEL_82945GM_IG 0x27A2
2088#define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640 2087#define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640
2089#define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641 2088#define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641
2090#define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642 2089#define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642
@@ -2104,6 +2103,13 @@
2104#define PCI_DEVICE_ID_INTEL_ICH7_19 0x27dd 2103#define PCI_DEVICE_ID_INTEL_ICH7_19 0x27dd
2105#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de 2104#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de
2106#define PCI_DEVICE_ID_INTEL_ICH7_21 0x27df 2105#define PCI_DEVICE_ID_INTEL_ICH7_21 0x27df
2106#define PCI_DEVICE_ID_INTEL_ICH8_0 0x2810
2107#define PCI_DEVICE_ID_INTEL_ICH8_1 0x2811
2108#define PCI_DEVICE_ID_INTEL_ICH8_2 0x2812
2109#define PCI_DEVICE_ID_INTEL_ICH8_3 0x2814
2110#define PCI_DEVICE_ID_INTEL_ICH8_4 0x2815
2111#define PCI_DEVICE_ID_INTEL_ICH8_5 0x283e
2112#define PCI_DEVICE_ID_INTEL_ICH8_6 0x2850
2107#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 2113#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340
2108#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 2114#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575
2109#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 2115#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577
@@ -2147,6 +2153,7 @@
2147#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2 2153#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2
2148#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601 2154#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601
2149#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4 2155#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4
2156#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5
2150#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca 2157#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca
2151#define PCI_DEVICE_ID_INTEL_82454NX 0x84cb 2158#define PCI_DEVICE_ID_INTEL_82454NX 0x84cb
2152#define PCI_DEVICE_ID_INTEL_84460GX 0x84ea 2159#define PCI_DEVICE_ID_INTEL_84460GX 0x84ea
diff --git a/include/linux/pktcdvd.h b/include/linux/pktcdvd.h
index 2c177e4c8f22..8a94c717c266 100644
--- a/include/linux/pktcdvd.h
+++ b/include/linux/pktcdvd.h
@@ -114,7 +114,7 @@ struct pkt_ctrl_command {
114 114
115struct packet_settings 115struct packet_settings
116{ 116{
117 __u8 size; /* packet size in (512 byte) sectors */ 117 __u32 size; /* packet size in (512 byte) sectors */
118 __u8 fp; /* fixed packets */ 118 __u8 fp; /* fixed packets */
119 __u8 link_loss; /* the rest is specified 119 __u8 link_loss; /* the rest is specified
120 * as per Mt Fuji */ 120 * as per Mt Fuji */
@@ -169,8 +169,8 @@ struct packet_iosched
169#if (PAGE_SIZE % CD_FRAMESIZE) != 0 169#if (PAGE_SIZE % CD_FRAMESIZE) != 0
170#error "PAGE_SIZE must be a multiple of CD_FRAMESIZE" 170#error "PAGE_SIZE must be a multiple of CD_FRAMESIZE"
171#endif 171#endif
172#define PACKET_MAX_SIZE 32 172#define PACKET_MAX_SIZE 128
173#define PAGES_PER_PACKET (PACKET_MAX_SIZE * CD_FRAMESIZE / PAGE_SIZE) 173#define FRAMES_PER_PAGE (PAGE_SIZE / CD_FRAMESIZE)
174#define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9) 174#define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9)
175 175
176enum packet_data_state { 176enum packet_data_state {
@@ -219,7 +219,7 @@ struct packet_data
219 atomic_t io_errors; /* Number of read/write errors during IO */ 219 atomic_t io_errors; /* Number of read/write errors during IO */
220 220
221 struct bio *r_bios[PACKET_MAX_SIZE]; /* bios to use during data gathering */ 221 struct bio *r_bios[PACKET_MAX_SIZE]; /* bios to use during data gathering */
222 struct page *pages[PAGES_PER_PACKET]; 222 struct page *pages[PACKET_MAX_SIZE / FRAMES_PER_PAGE];
223 223
224 int cache_valid; /* If non-zero, the data for the zone defined */ 224 int cache_valid; /* If non-zero, the data for the zone defined */
225 /* by the sector variable is completely cached */ 225 /* by the sector variable is completely cached */
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 54faf5236da0..95572c434bc9 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -84,7 +84,6 @@ struct k_clock {
84void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock); 84void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock);
85 85
86/* error handlers for timer_create, nanosleep and settime */ 86/* error handlers for timer_create, nanosleep and settime */
87int do_posix_clock_notimer_create(struct k_itimer *timer);
88int do_posix_clock_nonanosleep(const clockid_t, int flags, struct timespec *, 87int do_posix_clock_nonanosleep(const clockid_t, int flags, struct timespec *,
89 struct timespec __user *); 88 struct timespec __user *);
90int do_posix_clock_nosettime(const clockid_t, struct timespec *tp); 89int do_posix_clock_nosettime(const clockid_t, struct timespec *tp);
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 4f34d3d60f2e..21e5a9124856 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -190,7 +190,6 @@ static __inline__ int DQUOT_OFF(struct super_block *sb)
190 */ 190 */
191#define sb_dquot_ops (NULL) 191#define sb_dquot_ops (NULL)
192#define sb_quotactl_ops (NULL) 192#define sb_quotactl_ops (NULL)
193#define sync_dquots_dev(dev,type) (NULL)
194#define DQUOT_INIT(inode) do { } while(0) 193#define DQUOT_INIT(inode) do { } while(0)
195#define DQUOT_DROP(inode) do { } while(0) 194#define DQUOT_DROP(inode) do { } while(0)
196#define DQUOT_ALLOC_INODE(inode) (0) 195#define DQUOT_ALLOC_INODE(inode) (0)
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 981f9aa43353..b87aefa082e2 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -240,11 +240,14 @@ extern int rcu_pending(int cpu);
240 * This means that all preempt_disable code sequences, including NMI and 240 * This means that all preempt_disable code sequences, including NMI and
241 * hardware-interrupt handlers, in progress on entry will have completed 241 * hardware-interrupt handlers, in progress on entry will have completed
242 * before this primitive returns. However, this does not guarantee that 242 * before this primitive returns. However, this does not guarantee that
243 * softirq handlers will have completed, since in some kernels 243 * softirq handlers will have completed, since in some kernels, these
244 * handlers can run in process context, and can block.
244 * 245 *
245 * This primitive provides the guarantees made by the (deprecated) 246 * This primitive provides the guarantees made by the (deprecated)
246 * synchronize_kernel() API. In contrast, synchronize_rcu() only 247 * synchronize_kernel() API. In contrast, synchronize_rcu() only
247 * guarantees that rcu_read_lock() sections will have completed. 248 * guarantees that rcu_read_lock() sections will have completed.
249 * In "classic RCU", these two guarantees happen to be one and
250 * the same, but can differ in realtime RCU implementations.
248 */ 251 */
249#define synchronize_sched() synchronize_rcu() 252#define synchronize_sched() synchronize_rcu()
250 253
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index 7ab2cdb83ef0..015297ff73fa 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -60,8 +60,7 @@ extern void machine_crash_shutdown(struct pt_regs *);
60 */ 60 */
61 61
62extern void kernel_restart_prepare(char *cmd); 62extern void kernel_restart_prepare(char *cmd);
63extern void kernel_halt_prepare(void); 63extern void kernel_shutdown_prepare(enum system_states state);
64extern void kernel_power_off_prepare(void);
65 64
66extern void kernel_restart(char *cmd); 65extern void kernel_restart(char *cmd);
67extern void kernel_halt(void); 66extern void kernel_halt(void);
diff --git a/include/linux/reiserfs_acl.h b/include/linux/reiserfs_acl.h
index 0a3605099c44..806ec5b06707 100644
--- a/include/linux/reiserfs_acl.h
+++ b/include/linux/reiserfs_acl.h
@@ -58,9 +58,13 @@ extern struct reiserfs_xattr_handler posix_acl_default_handler;
58extern struct reiserfs_xattr_handler posix_acl_access_handler; 58extern struct reiserfs_xattr_handler posix_acl_access_handler;
59#else 59#else
60 60
61#define reiserfs_get_acl NULL
62#define reiserfs_cache_default_acl(inode) 0 61#define reiserfs_cache_default_acl(inode) 0
63 62
63static inline struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
64{
65 return NULL;
66}
67
64static inline int reiserfs_xattr_posix_acl_init(void) 68static inline int reiserfs_xattr_posix_acl_init(void)
65{ 69{
66 return 0; 70 return 0;
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index e276c5ba2bb7..7d51149bd793 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -1971,22 +1971,6 @@ extern struct file_operations reiserfs_file_operations;
1971extern struct address_space_operations reiserfs_address_space_operations; 1971extern struct address_space_operations reiserfs_address_space_operations;
1972 1972
1973/* fix_nodes.c */ 1973/* fix_nodes.c */
1974#ifdef CONFIG_REISERFS_CHECK
1975void *reiserfs_kmalloc(size_t size, gfp_t flags, struct super_block *s);
1976void reiserfs_kfree(const void *vp, size_t size, struct super_block *s);
1977#else
1978static inline void *reiserfs_kmalloc(size_t size, int flags,
1979 struct super_block *s)
1980{
1981 return kmalloc(size, flags);
1982}
1983
1984static inline void reiserfs_kfree(const void *vp, size_t size,
1985 struct super_block *s)
1986{
1987 kfree(vp);
1988}
1989#endif
1990 1974
1991int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, 1975int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb,
1992 struct item_head *p_s_ins_ih, const void *); 1976 struct item_head *p_s_ins_ih, const void *);
diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
index 3e68592e52e9..31b4c0bd4fa0 100644
--- a/include/linux/reiserfs_fs_sb.h
+++ b/include/linux/reiserfs_fs_sb.h
@@ -382,7 +382,6 @@ struct reiserfs_sb_info {
382 on-disk FS format */ 382 on-disk FS format */
383 383
384 /* session statistics */ 384 /* session statistics */
385 int s_kmallocs;
386 int s_disk_reads; 385 int s_disk_reads;
387 int s_disk_writes; 386 int s_disk_writes;
388 int s_fix_nodes; 387 int s_fix_nodes;
diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h
index c84354e8374c..87280eb6083d 100644
--- a/include/linux/reiserfs_xattr.h
+++ b/include/linux/reiserfs_xattr.h
@@ -43,8 +43,6 @@ int reiserfs_delete_xattrs(struct inode *inode);
43int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs); 43int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
44int reiserfs_xattr_init(struct super_block *sb, int mount_flags); 44int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
45int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd); 45int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd);
46int reiserfs_permission_locked(struct inode *inode, int mask,
47 struct nameidata *nd);
48 46
49int reiserfs_xattr_del(struct inode *, const char *); 47int reiserfs_xattr_del(struct inode *, const char *);
50int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t); 48int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 9d6fbeef2104..d6b9bcd1384c 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -91,7 +91,8 @@ static inline void page_dup_rmap(struct page *page)
91 * Called from mm/vmscan.c to handle paging out 91 * Called from mm/vmscan.c to handle paging out
92 */ 92 */
93int page_referenced(struct page *, int is_locked); 93int page_referenced(struct page *, int is_locked);
94int try_to_unmap(struct page *); 94int try_to_unmap(struct page *, int ignore_refs);
95void remove_from_swap(struct page *page);
95 96
96/* 97/*
97 * Called from mm/filemap_xip.c to unmap empty zero page 98 * Called from mm/filemap_xip.c to unmap empty zero page
@@ -111,7 +112,7 @@ unsigned long page_address_in_vma(struct page *, struct vm_area_struct *);
111#define anon_vma_link(vma) do {} while (0) 112#define anon_vma_link(vma) do {} while (0)
112 113
113#define page_referenced(page,l) TestClearPageReferenced(page) 114#define page_referenced(page,l) TestClearPageReferenced(page)
114#define try_to_unmap(page) SWAP_FAIL 115#define try_to_unmap(page, refs) SWAP_FAIL
115 116
116#endif /* CONFIG_MMU */ 117#endif /* CONFIG_MMU */
117 118
diff --git a/include/linux/security.h b/include/linux/security.h
index ef753654daa5..7cbef482e13a 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1499,15 +1499,11 @@ static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1499 1499
1500static inline int security_inode_alloc (struct inode *inode) 1500static inline int security_inode_alloc (struct inode *inode)
1501{ 1501{
1502 if (unlikely (IS_PRIVATE (inode)))
1503 return 0;
1504 return security_ops->inode_alloc_security (inode); 1502 return security_ops->inode_alloc_security (inode);
1505} 1503}
1506 1504
1507static inline void security_inode_free (struct inode *inode) 1505static inline void security_inode_free (struct inode *inode)
1508{ 1506{
1509 if (unlikely (IS_PRIVATE (inode)))
1510 return;
1511 security_ops->inode_free_security (inode); 1507 security_ops->inode_free_security (inode);
1512} 1508}
1513 1509
@@ -2617,6 +2613,25 @@ static inline int security_netlink_recv (struct sk_buff *skb)
2617 return cap_netlink_recv (skb); 2613 return cap_netlink_recv (skb);
2618} 2614}
2619 2615
2616static inline struct dentry *securityfs_create_dir(const char *name,
2617 struct dentry *parent)
2618{
2619 return ERR_PTR(-ENODEV);
2620}
2621
2622static inline struct dentry *securityfs_create_file(const char *name,
2623 mode_t mode,
2624 struct dentry *parent,
2625 void *data,
2626 struct file_operations *fops)
2627{
2628 return ERR_PTR(-ENODEV);
2629}
2630
2631static inline void securityfs_remove(struct dentry *dentry)
2632{
2633}
2634
2620#endif /* CONFIG_SECURITY */ 2635#endif /* CONFIG_SECURITY */
2621 2636
2622#ifdef CONFIG_SECURITY_NETWORK 2637#ifdef CONFIG_SECURITY_NETWORK
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index cee302aefdb7..73b464f0926a 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -26,7 +26,7 @@ struct plat_serial8250_port {
26 unsigned char regshift; /* register shift */ 26 unsigned char regshift; /* register shift */
27 unsigned char iotype; /* UPIO_* */ 27 unsigned char iotype; /* UPIO_* */
28 unsigned char hub6; 28 unsigned char hub6;
29 unsigned int flags; /* UPF_* flags */ 29 upf_t flags; /* UPF_* flags */
30}; 30};
31 31
32/* 32/*
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index ec351005bf9d..4041122dabfc 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -203,6 +203,8 @@ struct uart_icount {
203 __u32 buf_overrun; 203 __u32 buf_overrun;
204}; 204};
205 205
206typedef unsigned int __bitwise__ upf_t;
207
206struct uart_port { 208struct uart_port {
207 spinlock_t lock; /* port lock */ 209 spinlock_t lock; /* port lock */
208 unsigned int iobase; /* in/out[bwl] */ 210 unsigned int iobase; /* in/out[bwl] */
@@ -230,36 +232,34 @@ struct uart_port {
230 unsigned long sysrq; /* sysrq timeout */ 232 unsigned long sysrq; /* sysrq timeout */
231#endif 233#endif
232 234
233 unsigned int flags; 235 upf_t flags;
234 236
235#define UPF_FOURPORT (1 << 1) 237#define UPF_FOURPORT ((__force upf_t) (1 << 1))
236#define UPF_SAK (1 << 2) 238#define UPF_SAK ((__force upf_t) (1 << 2))
237#define UPF_SPD_MASK (0x1030) 239#define UPF_SPD_MASK ((__force upf_t) (0x1030))
238#define UPF_SPD_HI (0x0010) 240#define UPF_SPD_HI ((__force upf_t) (0x0010))
239#define UPF_SPD_VHI (0x0020) 241#define UPF_SPD_VHI ((__force upf_t) (0x0020))
240#define UPF_SPD_CUST (0x0030) 242#define UPF_SPD_CUST ((__force upf_t) (0x0030))
241#define UPF_SPD_SHI (0x1000) 243#define UPF_SPD_SHI ((__force upf_t) (0x1000))
242#define UPF_SPD_WARP (0x1010) 244#define UPF_SPD_WARP ((__force upf_t) (0x1010))
243#define UPF_SKIP_TEST (1 << 6) 245#define UPF_SKIP_TEST ((__force upf_t) (1 << 6))
244#define UPF_AUTO_IRQ (1 << 7) 246#define UPF_AUTO_IRQ ((__force upf_t) (1 << 7))
245#define UPF_HARDPPS_CD (1 << 11) 247#define UPF_HARDPPS_CD ((__force upf_t) (1 << 11))
246#define UPF_LOW_LATENCY (1 << 13) 248#define UPF_LOW_LATENCY ((__force upf_t) (1 << 13))
247#define UPF_BUGGY_UART (1 << 14) 249#define UPF_BUGGY_UART ((__force upf_t) (1 << 14))
248#define UPF_AUTOPROBE (1 << 15) 250#define UPF_MAGIC_MULTIPLIER ((__force upf_t) (1 << 16))
249#define UPF_MAGIC_MULTIPLIER (1 << 16) 251#define UPF_CONS_FLOW ((__force upf_t) (1 << 23))
250#define UPF_BOOT_ONLYMCA (1 << 22) 252#define UPF_SHARE_IRQ ((__force upf_t) (1 << 24))
251#define UPF_CONS_FLOW (1 << 23) 253#define UPF_BOOT_AUTOCONF ((__force upf_t) (1 << 28))
252#define UPF_SHARE_IRQ (1 << 24) 254#define UPF_IOREMAP ((__force upf_t) (1 << 31))
253#define UPF_BOOT_AUTOCONF (1 << 28) 255
254#define UPF_IOREMAP (1 << 31) 256#define UPF_CHANGE_MASK ((__force upf_t) (0x17fff))
255 257#define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY))
256#define UPF_CHANGE_MASK (0x17fff)
257#define UPF_USR_MASK (UPF_SPD_MASK|UPF_LOW_LATENCY)
258 258
259 unsigned int mctrl; /* current modem ctrl settings */ 259 unsigned int mctrl; /* current modem ctrl settings */
260 unsigned int timeout; /* character-based timeout */ 260 unsigned int timeout; /* character-based timeout */
261 unsigned int type; /* port type */ 261 unsigned int type; /* port type */
262 struct uart_ops *ops; 262 const struct uart_ops *ops;
263 unsigned int custom_divisor; 263 unsigned int custom_divisor;
264 unsigned int line; /* port index */ 264 unsigned int line; /* port index */
265 unsigned long mapbase; /* for ioremap */ 265 unsigned long mapbase; /* for ioremap */
@@ -289,6 +289,9 @@ struct uart_state {
289}; 289};
290 290
291#define UART_XMIT_SIZE PAGE_SIZE 291#define UART_XMIT_SIZE PAGE_SIZE
292
293typedef unsigned int __bitwise__ uif_t;
294
292/* 295/*
293 * This is the state information which is only valid when the port 296 * This is the state information which is only valid when the port
294 * is open; it may be freed by the core driver once the device has 297 * is open; it may be freed by the core driver once the device has
@@ -298,17 +301,16 @@ struct uart_state {
298struct uart_info { 301struct uart_info {
299 struct tty_struct *tty; 302 struct tty_struct *tty;
300 struct circ_buf xmit; 303 struct circ_buf xmit;
301 unsigned int flags; 304 uif_t flags;
302 305
303/* 306/*
304 * These are the flags that specific to info->flags, and reflect our 307 * Definitions for info->flags. These are _private_ to serial_core, and
305 * internal state. They can not be accessed via port->flags. Low 308 * are specific to this structure. They may be queried by low level drivers.
306 * level drivers must not change these, but may query them instead.
307 */ 309 */
308#define UIF_CHECK_CD (1 << 25) 310#define UIF_CHECK_CD ((__force uif_t) (1 << 25))
309#define UIF_CTS_FLOW (1 << 26) 311#define UIF_CTS_FLOW ((__force uif_t) (1 << 26))
310#define UIF_NORMAL_ACTIVE (1 << 29) 312#define UIF_NORMAL_ACTIVE ((__force uif_t) (1 << 29))
311#define UIF_INITIALIZED (1 << 31) 313#define UIF_INITIALIZED ((__force uif_t) (1 << 31))
312 314
313 int blocked_open; 315 int blocked_open;
314 316
@@ -430,7 +432,7 @@ static inline int uart_handle_break(struct uart_port *port)
430 port->sysrq = 0; 432 port->sysrq = 0;
431 } 433 }
432#endif 434#endif
433 if (info->flags & UPF_SAK) 435 if (port->flags & UPF_SAK)
434 do_SAK(info->tty); 436 do_SAK(info->tty);
435 return 0; 437 return 0;
436} 438}
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 1fb77a9cc148..8cf52939d0ab 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -76,7 +76,14 @@ struct cache_sizes {
76 kmem_cache_t *cs_dmacachep; 76 kmem_cache_t *cs_dmacachep;
77}; 77};
78extern struct cache_sizes malloc_sizes[]; 78extern struct cache_sizes malloc_sizes[];
79
80#ifndef CONFIG_DEBUG_SLAB
79extern void *__kmalloc(size_t, gfp_t); 81extern void *__kmalloc(size_t, gfp_t);
82#else
83extern void *__kmalloc_track_caller(size_t, gfp_t, void*);
84#define __kmalloc(size, flags) \
85 __kmalloc_track_caller(size, flags, __builtin_return_address(0))
86#endif
80 87
81static inline void *kmalloc(size_t size, gfp_t flags) 88static inline void *kmalloc(size_t size, gfp_t flags)
82{ 89{
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h
index b68c11a2d6dd..be4772ed43c0 100644
--- a/include/linux/sunrpc/auth.h
+++ b/include/linux/sunrpc/auth.h
@@ -48,7 +48,7 @@ struct rpc_cred {
48 48
49 /* per-flavor data */ 49 /* per-flavor data */
50}; 50};
51#define RPCAUTH_CRED_LOCKED 0x0001 51#define RPCAUTH_CRED_NEW 0x0001
52#define RPCAUTH_CRED_UPTODATE 0x0002 52#define RPCAUTH_CRED_UPTODATE 0x0002
53 53
54#define RPCAUTH_CRED_MAGIC 0x0f4aa4f0 54#define RPCAUTH_CRED_MAGIC 0x0f4aa4f0
@@ -83,9 +83,10 @@ struct rpc_auth {
83 struct rpc_cred_cache * au_credcache; 83 struct rpc_cred_cache * au_credcache;
84 /* per-flavor data */ 84 /* per-flavor data */
85}; 85};
86#define RPC_AUTH_PROC_CREDS 0x0010 /* process creds (including 86
87 * uid/gid, fs[ug]id, gids) 87/* Flags for rpcauth_lookupcred() */
88 */ 88#define RPCAUTH_LOOKUP_NEW 0x01 /* Accept an uninitialised cred */
89#define RPCAUTH_LOOKUP_ROOTCREDS 0x02 /* This really ought to go! */
89 90
90/* 91/*
91 * Client authentication ops 92 * Client authentication ops
@@ -105,6 +106,7 @@ struct rpc_authops {
105 106
106struct rpc_credops { 107struct rpc_credops {
107 const char * cr_name; /* Name of the auth flavour */ 108 const char * cr_name; /* Name of the auth flavour */
109 int (*cr_init)(struct rpc_auth *, struct rpc_cred *);
108 void (*crdestroy)(struct rpc_cred *); 110 void (*crdestroy)(struct rpc_cred *);
109 111
110 int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); 112 int (*crmatch)(struct auth_cred *, struct rpc_cred *, int);
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 5dc94e777fab..43bcd13eb1ec 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -42,10 +42,6 @@ extern void mark_free_pages(struct zone *zone);
42#ifdef CONFIG_PM 42#ifdef CONFIG_PM
43/* kernel/power/swsusp.c */ 43/* kernel/power/swsusp.c */
44extern int software_suspend(void); 44extern int software_suspend(void);
45
46extern int pm_prepare_console(void);
47extern void pm_restore_console(void);
48
49#else 45#else
50static inline int software_suspend(void) 46static inline int software_suspend(void)
51{ 47{
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 4a99e4a7fbf3..f3e17d5963c3 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -178,6 +178,7 @@ extern int vm_swappiness;
178 178
179#ifdef CONFIG_NUMA 179#ifdef CONFIG_NUMA
180extern int zone_reclaim_mode; 180extern int zone_reclaim_mode;
181extern int zone_reclaim_interval;
181extern int zone_reclaim(struct zone *, gfp_t, unsigned int); 182extern int zone_reclaim(struct zone *, gfp_t, unsigned int);
182#else 183#else
183#define zone_reclaim_mode 0 184#define zone_reclaim_mode 0
@@ -190,13 +191,20 @@ static inline int zone_reclaim(struct zone *z, gfp_t mask, unsigned int order)
190#ifdef CONFIG_MIGRATION 191#ifdef CONFIG_MIGRATION
191extern int isolate_lru_page(struct page *p); 192extern int isolate_lru_page(struct page *p);
192extern int putback_lru_pages(struct list_head *l); 193extern int putback_lru_pages(struct list_head *l);
194extern int migrate_page(struct page *, struct page *);
195extern void migrate_page_copy(struct page *, struct page *);
196extern int migrate_page_remove_references(struct page *, struct page *, int);
193extern int migrate_pages(struct list_head *l, struct list_head *t, 197extern int migrate_pages(struct list_head *l, struct list_head *t,
194 struct list_head *moved, struct list_head *failed); 198 struct list_head *moved, struct list_head *failed);
199extern int fail_migrate_page(struct page *, struct page *);
195#else 200#else
196static inline int isolate_lru_page(struct page *p) { return -ENOSYS; } 201static inline int isolate_lru_page(struct page *p) { return -ENOSYS; }
197static inline int putback_lru_pages(struct list_head *l) { return 0; } 202static inline int putback_lru_pages(struct list_head *l) { return 0; }
198static inline int migrate_pages(struct list_head *l, struct list_head *t, 203static inline int migrate_pages(struct list_head *l, struct list_head *t,
199 struct list_head *moved, struct list_head *failed) { return -ENOSYS; } 204 struct list_head *moved, struct list_head *failed) { return -ENOSYS; }
205/* Possible settings for the migrate_page() method in address_operations */
206#define migrate_page NULL
207#define fail_migrate_page NULL
200#endif 208#endif
201 209
202#ifdef CONFIG_MMU 210#ifdef CONFIG_MMU
@@ -245,6 +253,7 @@ extern int remove_exclusive_swap_page(struct page *);
245struct backing_dev_info; 253struct backing_dev_info;
246 254
247extern spinlock_t swap_lock; 255extern spinlock_t swap_lock;
256extern int remove_vma_swap(struct vm_area_struct *vma, struct page *page);
248 257
249/* linux/mm/thrash.c */ 258/* linux/mm/thrash.c */
250extern struct mm_struct * swap_token_mm; 259extern struct mm_struct * swap_token_mm;
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index e666d6070569..3877209d23c3 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -50,6 +50,8 @@ struct timezone;
50struct tms; 50struct tms;
51struct utimbuf; 51struct utimbuf;
52struct mq_attr; 52struct mq_attr;
53struct compat_stat;
54struct compat_timeval;
53 55
54#include <linux/config.h> 56#include <linux/config.h>
55#include <linux/types.h> 57#include <linux/types.h>
@@ -534,4 +536,35 @@ asmlinkage long sys_spu_run(int fd, __u32 __user *unpc,
534asmlinkage long sys_spu_create(const char __user *name, 536asmlinkage long sys_spu_create(const char __user *name,
535 unsigned int flags, mode_t mode); 537 unsigned int flags, mode_t mode);
536 538
539asmlinkage long sys_mknodat(int dfd, const char __user * filename, int mode,
540 unsigned dev);
541asmlinkage long sys_mkdirat(int dfd, const char __user * pathname, int mode);
542asmlinkage long sys_unlinkat(int dfd, const char __user * pathname, int flag);
543asmlinkage long sys_symlinkat(const char __user * oldname,
544 int newdfd, const char __user * newname);
545asmlinkage long sys_linkat(int olddfd, const char __user *oldname,
546 int newdfd, const char __user *newname);
547asmlinkage long sys_renameat(int olddfd, const char __user * oldname,
548 int newdfd, const char __user * newname);
549asmlinkage long sys_futimesat(int dfd, char __user *filename,
550 struct timeval __user *utimes);
551asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode);
552asmlinkage long sys_fchmodat(int dfd, const char __user * filename,
553 mode_t mode);
554asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user,
555 gid_t group, int flag);
556asmlinkage long sys_openat(int dfd, const char __user *filename, int flags,
557 int mode);
558asmlinkage long sys_newfstatat(int dfd, char __user *filename,
559 struct stat __user *statbuf, int flag);
560asmlinkage long sys_readlinkat(int dfd, const char __user *path, char __user *buf,
561 int bufsiz);
562asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename,
563 struct compat_timeval __user *t);
564asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename,
565 struct compat_stat __user *statbuf,
566 int flag);
567asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
568 int flags, int mode);
569
537#endif 570#endif
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 8352a7ce5895..32a4139c4ad8 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -182,7 +182,8 @@ enum
182 VM_SWAP_TOKEN_TIMEOUT=28, /* default time for token time out */ 182 VM_SWAP_TOKEN_TIMEOUT=28, /* default time for token time out */
183 VM_DROP_PAGECACHE=29, /* int: nuke lots of pagecache */ 183 VM_DROP_PAGECACHE=29, /* int: nuke lots of pagecache */
184 VM_PERCPU_PAGELIST_FRACTION=30,/* int: fraction of pages in each percpu_pagelist */ 184 VM_PERCPU_PAGELIST_FRACTION=30,/* int: fraction of pages in each percpu_pagelist */
185 VM_ZONE_RECLAIM_MODE=31,/* reclaim local zone memory before going off node */ 185 VM_ZONE_RECLAIM_MODE=31, /* reclaim local zone memory before going off node */
186 VM_ZONE_RECLAIM_INTERVAL=32, /* time period to wait after reclaim failure */
186}; 187};
187 188
188 189
diff --git a/include/linux/time.h b/include/linux/time.h
index 614dd8465839..7b4dc36532bb 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -48,7 +48,7 @@ extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec);
48 * Returns true if the timespec is norm, false if denorm: 48 * Returns true if the timespec is norm, false if denorm:
49 */ 49 */
50#define timespec_valid(ts) \ 50#define timespec_valid(ts) \
51 (((ts)->tv_sec >= 0) && (((unsigned) (ts)->tv_nsec) < NSEC_PER_SEC)) 51 (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC))
52 52
53/* 53/*
54 * 64-bit nanosec type. Large enough to span 292+ years in nanosecond 54 * 64-bit nanosec type. Large enough to span 292+ years in nanosecond
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 3787102e4b12..a7bd3b4558d2 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -57,6 +57,7 @@ struct tty_buffer {
57 unsigned char *flag_buf_ptr; 57 unsigned char *flag_buf_ptr;
58 int used; 58 int used;
59 int size; 59 int size;
60 int active;
60 /* Data points here */ 61 /* Data points here */
61 unsigned long data[0]; 62 unsigned long data[0];
62}; 63};
@@ -64,6 +65,7 @@ struct tty_buffer {
64struct tty_bufhead { 65struct tty_bufhead {
65 struct work_struct work; 66 struct work_struct work;
66 struct semaphore pty_sem; 67 struct semaphore pty_sem;
68 spinlock_t lock;
67 struct tty_buffer *head; /* Queue head */ 69 struct tty_buffer *head; /* Queue head */
68 struct tty_buffer *tail; /* Active buffer */ 70 struct tty_buffer *tail; /* Active buffer */
69 struct tty_buffer *free; /* Free queue head */ 71 struct tty_buffer *free; /* Free queue head */
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index be1400e82482..82961eb19888 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -17,7 +17,7 @@ _INLINE_ int tty_insert_flip_char(struct tty_struct *tty,
17 unsigned char ch, char flag) 17 unsigned char ch, char flag)
18{ 18{
19 struct tty_buffer *tb = tty->buf.tail; 19 struct tty_buffer *tb = tty->buf.tail;
20 if (tb && tb->used < tb->size) { 20 if (tb && tb->active && tb->used < tb->size) {
21 tb->flag_buf_ptr[tb->used] = flag; 21 tb->flag_buf_ptr[tb->used] = flag;
22 tb->char_buf_ptr[tb->used++] = ch; 22 tb->char_buf_ptr[tb->used++] = ch;
23 return 1; 23 return 1;
@@ -27,6 +27,11 @@ _INLINE_ int tty_insert_flip_char(struct tty_struct *tty,
27 27
28_INLINE_ void tty_schedule_flip(struct tty_struct *tty) 28_INLINE_ void tty_schedule_flip(struct tty_struct *tty)
29{ 29{
30 unsigned long flags;
31 spin_lock_irqsave(&tty->buf.lock, flags);
32 if (tty->buf.tail != NULL)
33 tty->buf.tail->active = 0;
34 spin_unlock_irqrestore(&tty->buf.lock, flags);
30 schedule_delayed_work(&tty->buf.work, 1); 35 schedule_delayed_work(&tty->buf.work, 1);
31} 36}
32 37
diff --git a/include/linux/types.h b/include/linux/types.h
index 21b9ce803644..54ae2d59e71b 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -8,6 +8,8 @@
8 (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) 8 (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
9#define DECLARE_BITMAP(name,bits) \ 9#define DECLARE_BITMAP(name,bits) \
10 unsigned long name[BITS_TO_LONGS(bits)] 10 unsigned long name[BITS_TO_LONGS(bits)]
11
12#define BITS_PER_BYTE 8
11#endif 13#endif
12 14
13#include <linux/posix_types.h> 15#include <linux/posix_types.h>
diff --git a/include/linux/ufs_fs.h b/include/linux/ufs_fs.h
index 7a6babeca256..b0ffe4356e5a 100644
--- a/include/linux/ufs_fs.h
+++ b/include/linux/ufs_fs.h
@@ -148,11 +148,11 @@ typedef __u16 __bitwise __fs16;
148#define UFS_USEEFT ((__u16)65535) 148#define UFS_USEEFT ((__u16)65535)
149 149
150#define UFS_FSOK 0x7c269d38 150#define UFS_FSOK 0x7c269d38
151#define UFS_FSACTIVE ((char)0x00) 151#define UFS_FSACTIVE ((__s8)0x00)
152#define UFS_FSCLEAN ((char)0x01) 152#define UFS_FSCLEAN ((__s8)0x01)
153#define UFS_FSSTABLE ((char)0x02) 153#define UFS_FSSTABLE ((__s8)0x02)
154#define UFS_FSOSF1 ((char)0x03) /* is this correct for DEC OSF/1? */ 154#define UFS_FSOSF1 ((__s8)0x03) /* is this correct for DEC OSF/1? */
155#define UFS_FSBAD ((char)0xff) 155#define UFS_FSBAD ((__s8)0xff)
156 156
157/* From here to next blank line, s_flags for ufs_sb_info */ 157/* From here to next blank line, s_flags for ufs_sb_info */
158/* directory entry encoding */ 158/* directory entry encoding */
@@ -502,8 +502,7 @@ struct ufs_super_block {
502/* 502/*
503 * Convert cylinder group to base address of its global summary info. 503 * Convert cylinder group to base address of its global summary info.
504 */ 504 */
505#define fs_cs(indx) \ 505#define fs_cs(indx) s_csp[(indx)]
506 s_csp[(indx) >> uspi->s_csshift][(indx) & ~uspi->s_csmask]
507 506
508/* 507/*
509 * Cylinder group block for a file system. 508 * Cylinder group block for a file system.
@@ -913,6 +912,7 @@ extern int ufs_sync_inode (struct inode *);
913extern void ufs_delete_inode (struct inode *); 912extern void ufs_delete_inode (struct inode *);
914extern struct buffer_head * ufs_getfrag (struct inode *, unsigned, int, int *); 913extern struct buffer_head * ufs_getfrag (struct inode *, unsigned, int, int *);
915extern struct buffer_head * ufs_bread (struct inode *, unsigned, int, int *); 914extern struct buffer_head * ufs_bread (struct inode *, unsigned, int, int *);
915extern int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create);
916 916
917/* namei.c */ 917/* namei.c */
918extern struct file_operations ufs_dir_operations; 918extern struct file_operations ufs_dir_operations;
diff --git a/include/linux/ufs_fs_sb.h b/include/linux/ufs_fs_sb.h
index c1be4c226486..8ff13c160f3d 100644
--- a/include/linux/ufs_fs_sb.h
+++ b/include/linux/ufs_fs_sb.h
@@ -25,7 +25,7 @@ struct ufs_csum;
25 25
26struct ufs_sb_info { 26struct ufs_sb_info {
27 struct ufs_sb_private_info * s_uspi; 27 struct ufs_sb_private_info * s_uspi;
28 struct ufs_csum * s_csp[UFS_MAXCSBUFS]; 28 struct ufs_csum * s_csp;
29 unsigned s_bytesex; 29 unsigned s_bytesex;
30 unsigned s_flags; 30 unsigned s_flags;
31 struct buffer_head ** s_ucg; 31 struct buffer_head ** s_ucg;
diff --git a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h
index ee21e6bf3867..a2aacfc7af2f 100644
--- a/include/linux/usb_ch9.h
+++ b/include/linux/usb_ch9.h
@@ -535,9 +535,11 @@ enum usb_device_state {
535 */ 535 */
536 USB_STATE_NOTATTACHED = 0, 536 USB_STATE_NOTATTACHED = 0,
537 537
538 /* the chapter 9 device states */ 538 /* chapter 9 and authentication (wireless) device states */
539 USB_STATE_ATTACHED, 539 USB_STATE_ATTACHED,
540 USB_STATE_POWERED, 540 USB_STATE_POWERED, /* wired */
541 USB_STATE_UNAUTHENTICATED, /* auth */
542 USB_STATE_RECONNECTING, /* auth */
541 USB_STATE_DEFAULT, /* limited function */ 543 USB_STATE_DEFAULT, /* limited function */
542 USB_STATE_ADDRESS, 544 USB_STATE_ADDRESS,
543 USB_STATE_CONFIGURED, /* most functions */ 545 USB_STATE_CONFIGURED, /* most functions */
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index ce40675324bd..6f6c69777648 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -315,6 +315,7 @@ struct v4l2_pix_format
315#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ 315#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */
316#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1') /* pwc older webcam */ 316#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1') /* pwc older webcam */
317#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2') /* pwc newer webcam */ 317#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2') /* pwc newer webcam */
318#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E','6','2','5') /* ET61X251 compression */
318 319
319/* 320/*
320 * F O R M A T E N U M E R A T I O N 321 * F O R M A T E N U M E R A T I O N
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index 67856eb93b43..dac43b15a5b0 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -88,12 +88,6 @@ extern struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX];
88extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); 88extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto);
89extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto); 89extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto);
90 90
91static inline struct nf_conntrack_l3proto *
92__nf_ct_l3proto_find(u_int16_t l3proto)
93{
94 return nf_ct_l3protos[l3proto];
95}
96
97extern struct nf_conntrack_l3proto * 91extern struct nf_conntrack_l3proto *
98nf_ct_l3proto_find_get(u_int16_t l3proto); 92nf_ct_l3proto_find_get(u_int16_t l3proto);
99 93
@@ -103,4 +97,13 @@ extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p);
103extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4; 97extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;
104extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6; 98extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6;
105extern struct nf_conntrack_l3proto nf_conntrack_generic_l3proto; 99extern struct nf_conntrack_l3proto nf_conntrack_generic_l3proto;
100
101static inline struct nf_conntrack_l3proto *
102__nf_ct_l3proto_find(u_int16_t l3proto)
103{
104 if (unlikely(l3proto >= AF_MAX))
105 return &nf_conntrack_generic_l3proto;
106 return nf_ct_l3protos[l3proto];
107}
108
106#endif /*_NF_CONNTRACK_L3PROTO_H*/ 109#endif /*_NF_CONNTRACK_L3PROTO_H*/
diff --git a/include/net/route.h b/include/net/route.h
index e3e5436f8017..9c04f15090d2 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -170,8 +170,8 @@ static inline int ip_route_connect(struct rtable **rp, u32 dst,
170 return ip_route_output_flow(rp, &fl, sk, 0); 170 return ip_route_output_flow(rp, &fl, sk, 0);
171} 171}
172 172
173static inline int ip_route_newports(struct rtable **rp, u16 sport, u16 dport, 173static inline int ip_route_newports(struct rtable **rp, u8 protocol,
174 struct sock *sk) 174 u16 sport, u16 dport, struct sock *sk)
175{ 175{
176 if (sport != (*rp)->fl.fl_ip_sport || 176 if (sport != (*rp)->fl.fl_ip_sport ||
177 dport != (*rp)->fl.fl_ip_dport) { 177 dport != (*rp)->fl.fl_ip_dport) {
@@ -180,6 +180,7 @@ static inline int ip_route_newports(struct rtable **rp, u16 sport, u16 dport,
180 memcpy(&fl, &(*rp)->fl, sizeof(fl)); 180 memcpy(&fl, &(*rp)->fl, sizeof(fl));
181 fl.fl_ip_sport = sport; 181 fl.fl_ip_sport = sport;
182 fl.fl_ip_dport = dport; 182 fl.fl_ip_dport = dport;
183 fl.proto = protocol;
183 ip_rt_put(*rp); 184 ip_rt_put(*rp);
184 *rp = NULL; 185 *rp = NULL;
185 return ip_route_output_flow(rp, &fl, sk, 0); 186 return ip_route_output_flow(rp, &fl, sk, 0);
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 8c522ae031bb..072f407848a6 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -700,7 +700,7 @@ struct sctp_chunk {
700 __u8 ecn_ce_done; /* Have we processed the ECN CE bit? */ 700 __u8 ecn_ce_done; /* Have we processed the ECN CE bit? */
701 __u8 pdiscard; /* Discard the whole packet now? */ 701 __u8 pdiscard; /* Discard the whole packet now? */
702 __u8 tsn_gap_acked; /* Is this chunk acked by a GAP ACK? */ 702 __u8 tsn_gap_acked; /* Is this chunk acked by a GAP ACK? */
703 __u8 fast_retransmit; /* Is this chunk fast retransmitted? */ 703 __s8 fast_retransmit; /* Is this chunk fast retransmitted? */
704 __u8 tsn_missing_report; /* Data chunk missing counter. */ 704 __u8 tsn_missing_report; /* Data chunk missing counter. */
705}; 705};
706 706
diff --git a/include/net/sock.h b/include/net/sock.h
index 1806e5b61419..30758035d616 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1354,12 +1354,12 @@ extern int sock_get_timestamp(struct sock *, struct timeval __user *);
1354 * Enable debug/info messages 1354 * Enable debug/info messages
1355 */ 1355 */
1356 1356
1357#if 0 1357#ifdef CONFIG_NETDEBUG
1358#define NETDEBUG(fmt, args...) do { } while (0)
1359#define LIMIT_NETDEBUG(fmt, args...) do { } while(0)
1360#else
1361#define NETDEBUG(fmt, args...) printk(fmt,##args) 1358#define NETDEBUG(fmt, args...) printk(fmt,##args)
1362#define LIMIT_NETDEBUG(fmt, args...) do { if (net_ratelimit()) printk(fmt,##args); } while(0) 1359#define LIMIT_NETDEBUG(fmt, args...) do { if (net_ratelimit()) printk(fmt,##args); } while(0)
1360#else
1361#define NETDEBUG(fmt, args...) do { } while (0)
1362#define LIMIT_NETDEBUG(fmt, args...) do { } while(0)
1363#endif 1363#endif
1364 1364
1365/* 1365/*
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index e94ca4d36035..290e3b4d2aec 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -275,7 +275,7 @@ extern int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
275 int data_direction, void *buffer, unsigned bufflen, 275 int data_direction, void *buffer, unsigned bufflen,
276 struct scsi_sense_hdr *, int timeout, int retries); 276 struct scsi_sense_hdr *, int timeout, int retries);
277extern int scsi_execute_async(struct scsi_device *sdev, 277extern int scsi_execute_async(struct scsi_device *sdev,
278 const unsigned char *cmd, int data_direction, 278 const unsigned char *cmd, int cmd_len, int data_direction,
279 void *buffer, unsigned bufflen, int use_sg, 279 void *buffer, unsigned bufflen, int use_sg,
280 int timeout, int retries, void *privdata, 280 int timeout, int retries, void *privdata,
281 void (*done)(void *, char *, int, int), 281 void (*done)(void *, char *, int, int),
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 467274a764d1..827992949c4b 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -554,7 +554,6 @@ struct Scsi_Host {
554 /* 554 /*
555 * ordered write support 555 * ordered write support
556 */ 556 */
557 unsigned ordered_flush:1;
558 unsigned ordered_tag:1; 557 unsigned ordered_tag:1;
559 558
560 /* 559 /*
diff --git a/init/Kconfig b/init/Kconfig
index b9923b1434a2..8b7abae87bf9 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -31,19 +31,8 @@ config EXPERIMENTAL
31 you say Y here, you will be offered the choice of using features or 31 you say Y here, you will be offered the choice of using features or
32 drivers that are currently considered to be in the alpha-test phase. 32 drivers that are currently considered to be in the alpha-test phase.
33 33
34config CLEAN_COMPILE
35 bool "Select only drivers expected to compile cleanly" if EXPERIMENTAL
36 default y
37 help
38 Select this option if you don't even want to see the option
39 to configure known-broken drivers.
40
41 If unsure, say Y
42
43config BROKEN 34config BROKEN
44 bool 35 bool
45 depends on !CLEAN_COMPILE
46 default y
47 36
48config BROKEN_ON_SMP 37config BROKEN_ON_SMP
49 bool 38 bool
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index fe2f71f92ae0..ba42b0a76961 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -641,7 +641,7 @@ static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask)
641 * task has been modifying its cpuset. 641 * task has been modifying its cpuset.
642 */ 642 */
643 643
644void cpuset_update_task_memory_state() 644void cpuset_update_task_memory_state(void)
645{ 645{
646 int my_cpusets_mem_gen; 646 int my_cpusets_mem_gen;
647 struct task_struct *tsk = current; 647 struct task_struct *tsk = current;
diff --git a/kernel/fork.c b/kernel/fork.c
index 4ae8cfc1c89c..7f0ab5ee948c 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -802,7 +802,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
802 init_sigpending(&sig->shared_pending); 802 init_sigpending(&sig->shared_pending);
803 INIT_LIST_HEAD(&sig->posix_timers); 803 INIT_LIST_HEAD(&sig->posix_timers);
804 804
805 hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC); 805 hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL);
806 sig->it_real_incr.tv64 = 0; 806 sig->it_real_incr.tv64 = 0;
807 sig->real_timer.function = it_real_fn; 807 sig->real_timer.function = it_real_fn;
808 sig->real_timer.data = tsk; 808 sig->real_timer.data = tsk;
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index f1c4155b49ac..2b6e1757aedd 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -21,6 +21,12 @@
21 * Credits: 21 * Credits:
22 * based on kernel/timer.c 22 * based on kernel/timer.c
23 * 23 *
24 * Help, testing, suggestions, bugfixes, improvements were
25 * provided by:
26 *
27 * George Anzinger, Andrew Morton, Steven Rostedt, Roman Zippel
28 * et. al.
29 *
24 * For licencing details see kernel-base/COPYING 30 * For licencing details see kernel-base/COPYING
25 */ 31 */
26 32
@@ -66,6 +72,12 @@ EXPORT_SYMBOL_GPL(ktime_get_real);
66 72
67/* 73/*
68 * The timer bases: 74 * The timer bases:
75 *
76 * Note: If we want to add new timer bases, we have to skip the two
77 * clock ids captured by the cpu-timers. We do this by holding empty
78 * entries rather than doing math adjustment of the clock ids.
79 * This ensures that we capture erroneous accesses to these clock ids
80 * rather than moving them into the range of valid clock id's.
69 */ 81 */
70 82
71#define MAX_HRTIMER_BASES 2 83#define MAX_HRTIMER_BASES 2
@@ -483,29 +495,25 @@ ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
483} 495}
484 496
485/** 497/**
486 * hrtimer_rebase - rebase an initialized hrtimer to a different base 498 * hrtimer_init - initialize a timer to the given clock
487 * 499 *
488 * @timer: the timer to be rebased 500 * @timer: the timer to be initialized
489 * @clock_id: the clock to be used 501 * @clock_id: the clock to be used
502 * @mode: timer mode abs/rel
490 */ 503 */
491void hrtimer_rebase(struct hrtimer *timer, const clockid_t clock_id) 504void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
505 enum hrtimer_mode mode)
492{ 506{
493 struct hrtimer_base *bases; 507 struct hrtimer_base *bases;
494 508
509 memset(timer, 0, sizeof(struct hrtimer));
510
495 bases = per_cpu(hrtimer_bases, raw_smp_processor_id()); 511 bases = per_cpu(hrtimer_bases, raw_smp_processor_id());
496 timer->base = &bases[clock_id];
497}
498 512
499/** 513 if (clock_id == CLOCK_REALTIME && mode != HRTIMER_ABS)
500 * hrtimer_init - initialize a timer to the given clock 514 clock_id = CLOCK_MONOTONIC;
501 * 515
502 * @timer: the timer to be initialized 516 timer->base = &bases[clock_id];
503 * @clock_id: the clock to be used
504 */
505void hrtimer_init(struct hrtimer *timer, const clockid_t clock_id)
506{
507 memset(timer, 0, sizeof(struct hrtimer));
508 hrtimer_rebase(timer, clock_id);
509} 517}
510 518
511/** 519/**
@@ -550,6 +558,7 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base)
550 fn = timer->function; 558 fn = timer->function;
551 data = timer->data; 559 data = timer->data;
552 set_curr_timer(base, timer); 560 set_curr_timer(base, timer);
561 timer->state = HRTIMER_RUNNING;
553 __remove_hrtimer(timer, base); 562 __remove_hrtimer(timer, base);
554 spin_unlock_irq(&base->lock); 563 spin_unlock_irq(&base->lock);
555 564
@@ -565,6 +574,10 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base)
565 574
566 spin_lock_irq(&base->lock); 575 spin_lock_irq(&base->lock);
567 576
577 /* Another CPU has added back the timer */
578 if (timer->state != HRTIMER_RUNNING)
579 continue;
580
568 if (restart == HRTIMER_RESTART) 581 if (restart == HRTIMER_RESTART)
569 enqueue_hrtimer(timer, base); 582 enqueue_hrtimer(timer, base);
570 else 583 else
@@ -638,8 +651,7 @@ schedule_hrtimer_interruptible(struct hrtimer *timer,
638 return schedule_hrtimer(timer, mode); 651 return schedule_hrtimer(timer, mode);
639} 652}
640 653
641static long __sched 654static long __sched nanosleep_restart(struct restart_block *restart)
642nanosleep_restart(struct restart_block *restart, clockid_t clockid)
643{ 655{
644 struct timespec __user *rmtp; 656 struct timespec __user *rmtp;
645 struct timespec tu; 657 struct timespec tu;
@@ -649,7 +661,7 @@ nanosleep_restart(struct restart_block *restart, clockid_t clockid)
649 661
650 restart->fn = do_no_restart_syscall; 662 restart->fn = do_no_restart_syscall;
651 663
652 hrtimer_init(&timer, clockid); 664 hrtimer_init(&timer, (clockid_t) restart->arg3, HRTIMER_ABS);
653 665
654 timer.expires.tv64 = ((u64)restart->arg1 << 32) | (u64) restart->arg0; 666 timer.expires.tv64 = ((u64)restart->arg1 << 32) | (u64) restart->arg0;
655 667
@@ -669,16 +681,6 @@ nanosleep_restart(struct restart_block *restart, clockid_t clockid)
669 return -ERESTART_RESTARTBLOCK; 681 return -ERESTART_RESTARTBLOCK;
670} 682}
671 683
672static long __sched nanosleep_restart_mono(struct restart_block *restart)
673{
674 return nanosleep_restart(restart, CLOCK_MONOTONIC);
675}
676
677static long __sched nanosleep_restart_real(struct restart_block *restart)
678{
679 return nanosleep_restart(restart, CLOCK_REALTIME);
680}
681
682long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, 684long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
683 const enum hrtimer_mode mode, const clockid_t clockid) 685 const enum hrtimer_mode mode, const clockid_t clockid)
684{ 686{
@@ -687,7 +689,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
687 struct timespec tu; 689 struct timespec tu;
688 ktime_t rem; 690 ktime_t rem;
689 691
690 hrtimer_init(&timer, clockid); 692 hrtimer_init(&timer, clockid, mode);
691 693
692 timer.expires = timespec_to_ktime(*rqtp); 694 timer.expires = timespec_to_ktime(*rqtp);
693 695
@@ -695,7 +697,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
695 if (rem.tv64 <= 0) 697 if (rem.tv64 <= 0)
696 return 0; 698 return 0;
697 699
698 /* Absolute timers do not update the rmtp value: */ 700 /* Absolute timers do not update the rmtp value and restart: */
699 if (mode == HRTIMER_ABS) 701 if (mode == HRTIMER_ABS)
700 return -ERESTARTNOHAND; 702 return -ERESTARTNOHAND;
701 703
@@ -705,11 +707,11 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
705 return -EFAULT; 707 return -EFAULT;
706 708
707 restart = &current_thread_info()->restart_block; 709 restart = &current_thread_info()->restart_block;
708 restart->fn = (clockid == CLOCK_MONOTONIC) ? 710 restart->fn = nanosleep_restart;
709 nanosleep_restart_mono : nanosleep_restart_real;
710 restart->arg0 = timer.expires.tv64 & 0xFFFFFFFF; 711 restart->arg0 = timer.expires.tv64 & 0xFFFFFFFF;
711 restart->arg1 = timer.expires.tv64 >> 32; 712 restart->arg1 = timer.expires.tv64 >> 32;
712 restart->arg2 = (unsigned long) rmtp; 713 restart->arg2 = (unsigned long) rmtp;
714 restart->arg3 = (unsigned long) timer.base->index;
713 715
714 return -ERESTART_RESTARTBLOCK; 716 return -ERESTART_RESTARTBLOCK;
715} 717}
@@ -736,10 +738,8 @@ static void __devinit init_hrtimers_cpu(int cpu)
736 struct hrtimer_base *base = per_cpu(hrtimer_bases, cpu); 738 struct hrtimer_base *base = per_cpu(hrtimer_bases, cpu);
737 int i; 739 int i;
738 740
739 for (i = 0; i < MAX_HRTIMER_BASES; i++) { 741 for (i = 0; i < MAX_HRTIMER_BASES; i++, base++)
740 spin_lock_init(&base->lock); 742 spin_lock_init(&base->lock);
741 base++;
742 }
743} 743}
744 744
745#ifdef CONFIG_HOTPLUG_CPU 745#ifdef CONFIG_HOTPLUG_CPU
diff --git a/kernel/intermodule.c b/kernel/intermodule.c
index 0cbe633420fb..55b1e5b85db9 100644
--- a/kernel/intermodule.c
+++ b/kernel/intermodule.c
@@ -179,3 +179,6 @@ EXPORT_SYMBOL(inter_module_register);
179EXPORT_SYMBOL(inter_module_unregister); 179EXPORT_SYMBOL(inter_module_unregister);
180EXPORT_SYMBOL(inter_module_get_request); 180EXPORT_SYMBOL(inter_module_get_request);
181EXPORT_SYMBOL(inter_module_put); 181EXPORT_SYMBOL(inter_module_put);
182
183MODULE_LICENSE("GPL");
184
diff --git a/kernel/itimer.c b/kernel/itimer.c
index c2c05c4ff28d..379be2f8c84c 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -49,9 +49,11 @@ int do_getitimer(int which, struct itimerval *value)
49 49
50 switch (which) { 50 switch (which) {
51 case ITIMER_REAL: 51 case ITIMER_REAL:
52 spin_lock_irq(&tsk->sighand->siglock);
52 value->it_value = itimer_get_remtime(&tsk->signal->real_timer); 53 value->it_value = itimer_get_remtime(&tsk->signal->real_timer);
53 value->it_interval = 54 value->it_interval =
54 ktime_to_timeval(tsk->signal->it_real_incr); 55 ktime_to_timeval(tsk->signal->it_real_incr);
56 spin_unlock_irq(&tsk->sighand->siglock);
55 break; 57 break;
56 case ITIMER_VIRTUAL: 58 case ITIMER_VIRTUAL:
57 read_lock(&tasklist_lock); 59 read_lock(&tasklist_lock);
@@ -150,18 +152,25 @@ int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
150 152
151 switch (which) { 153 switch (which) {
152 case ITIMER_REAL: 154 case ITIMER_REAL:
155again:
156 spin_lock_irq(&tsk->sighand->siglock);
153 timer = &tsk->signal->real_timer; 157 timer = &tsk->signal->real_timer;
154 hrtimer_cancel(timer);
155 if (ovalue) { 158 if (ovalue) {
156 ovalue->it_value = itimer_get_remtime(timer); 159 ovalue->it_value = itimer_get_remtime(timer);
157 ovalue->it_interval 160 ovalue->it_interval
158 = ktime_to_timeval(tsk->signal->it_real_incr); 161 = ktime_to_timeval(tsk->signal->it_real_incr);
159 } 162 }
163 /* We are sharing ->siglock with it_real_fn() */
164 if (hrtimer_try_to_cancel(timer) < 0) {
165 spin_unlock_irq(&tsk->sighand->siglock);
166 goto again;
167 }
160 tsk->signal->it_real_incr = 168 tsk->signal->it_real_incr =
161 timeval_to_ktime(value->it_interval); 169 timeval_to_ktime(value->it_interval);
162 expires = timeval_to_ktime(value->it_value); 170 expires = timeval_to_ktime(value->it_value);
163 if (expires.tv64 != 0) 171 if (expires.tv64 != 0)
164 hrtimer_start(timer, expires, HRTIMER_REL); 172 hrtimer_start(timer, expires, HRTIMER_REL);
173 spin_unlock_irq(&tsk->sighand->siglock);
165 break; 174 break;
166 case ITIMER_VIRTUAL: 175 case ITIMER_VIRTUAL:
167 nval = timeval_to_cputime(&value->it_value); 176 nval = timeval_to_cputime(&value->it_value);
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 3ea6325228da..fef1af8a73ce 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -344,23 +344,6 @@ void __kprobes kprobe_flush_task(struct task_struct *tk)
344 spin_unlock_irqrestore(&kretprobe_lock, flags); 344 spin_unlock_irqrestore(&kretprobe_lock, flags);
345} 345}
346 346
347/*
348 * This kprobe pre_handler is registered with every kretprobe. When probe
349 * hits it will set up the return probe.
350 */
351static int __kprobes pre_handler_kretprobe(struct kprobe *p,
352 struct pt_regs *regs)
353{
354 struct kretprobe *rp = container_of(p, struct kretprobe, kp);
355 unsigned long flags = 0;
356
357 /*TODO: consider to only swap the RA after the last pre_handler fired */
358 spin_lock_irqsave(&kretprobe_lock, flags);
359 arch_prepare_kretprobe(rp, regs);
360 spin_unlock_irqrestore(&kretprobe_lock, flags);
361 return 0;
362}
363
364static inline void free_rp_inst(struct kretprobe *rp) 347static inline void free_rp_inst(struct kretprobe *rp)
365{ 348{
366 struct kretprobe_instance *ri; 349 struct kretprobe_instance *ri;
@@ -578,6 +561,23 @@ void __kprobes unregister_jprobe(struct jprobe *jp)
578 561
579#ifdef ARCH_SUPPORTS_KRETPROBES 562#ifdef ARCH_SUPPORTS_KRETPROBES
580 563
564/*
565 * This kprobe pre_handler is registered with every kretprobe. When probe
566 * hits it will set up the return probe.
567 */
568static int __kprobes pre_handler_kretprobe(struct kprobe *p,
569 struct pt_regs *regs)
570{
571 struct kretprobe *rp = container_of(p, struct kretprobe, kp);
572 unsigned long flags = 0;
573
574 /*TODO: consider to only swap the RA after the last pre_handler fired */
575 spin_lock_irqsave(&kretprobe_lock, flags);
576 arch_prepare_kretprobe(rp, regs);
577 spin_unlock_irqrestore(&kretprobe_lock, flags);
578 return 0;
579}
580
581int __kprobes register_kretprobe(struct kretprobe *rp) 581int __kprobes register_kretprobe(struct kretprobe *rp)
582{ 582{
583 int ret = 0; 583 int ret = 0;
@@ -631,12 +631,12 @@ void __kprobes unregister_kretprobe(struct kretprobe *rp)
631 unregister_kprobe(&rp->kp); 631 unregister_kprobe(&rp->kp);
632 /* No race here */ 632 /* No race here */
633 spin_lock_irqsave(&kretprobe_lock, flags); 633 spin_lock_irqsave(&kretprobe_lock, flags);
634 free_rp_inst(rp);
635 while ((ri = get_used_rp_inst(rp)) != NULL) { 634 while ((ri = get_used_rp_inst(rp)) != NULL) {
636 ri->rp = NULL; 635 ri->rp = NULL;
637 hlist_del(&ri->uflist); 636 hlist_del(&ri->uflist);
638 } 637 }
639 spin_unlock_irqrestore(&kretprobe_lock, flags); 638 spin_unlock_irqrestore(&kretprobe_lock, flags);
639 free_rp_inst(rp);
640} 640}
641 641
642static int __init init_kprobes(void) 642static int __init init_kprobes(void)
diff --git a/kernel/module.c b/kernel/module.c
index 618ed6e23ecc..e058aedf6b93 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2092,7 +2092,8 @@ static unsigned long mod_find_symname(struct module *mod, const char *name)
2092 unsigned int i; 2092 unsigned int i;
2093 2093
2094 for (i = 0; i < mod->num_symtab; i++) 2094 for (i = 0; i < mod->num_symtab; i++)
2095 if (strcmp(name, mod->strtab+mod->symtab[i].st_name) == 0) 2095 if (strcmp(name, mod->strtab+mod->symtab[i].st_name) == 0 &&
2096 mod->symtab[i].st_info != 'U')
2096 return mod->symtab[i].st_value; 2097 return mod->symtab[i].st_value;
2097 return 0; 2098 return 0;
2098} 2099}
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 197208b3aa2a..216f574b5ffb 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -194,9 +194,7 @@ static inline int common_clock_set(const clockid_t which_clock,
194 194
195static int common_timer_create(struct k_itimer *new_timer) 195static int common_timer_create(struct k_itimer *new_timer)
196{ 196{
197 hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock); 197 hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
198 new_timer->it.real.timer.data = new_timer;
199 new_timer->it.real.timer.function = posix_timer_fn;
200 return 0; 198 return 0;
201} 199}
202 200
@@ -290,7 +288,8 @@ void do_schedule_next_timer(struct siginfo *info)
290 info->si_overrun = timr->it_overrun_last; 288 info->si_overrun = timr->it_overrun_last;
291 } 289 }
292 290
293 unlock_timer(timr, flags); 291 if (timr)
292 unlock_timer(timr, flags);
294} 293}
295 294
296int posix_timer_event(struct k_itimer *timr,int si_private) 295int posix_timer_event(struct k_itimer *timr,int si_private)
@@ -692,6 +691,7 @@ common_timer_set(struct k_itimer *timr, int flags,
692 struct itimerspec *new_setting, struct itimerspec *old_setting) 691 struct itimerspec *new_setting, struct itimerspec *old_setting)
693{ 692{
694 struct hrtimer *timer = &timr->it.real.timer; 693 struct hrtimer *timer = &timr->it.real.timer;
694 enum hrtimer_mode mode;
695 695
696 if (old_setting) 696 if (old_setting)
697 common_timer_get(timr, old_setting); 697 common_timer_get(timr, old_setting);
@@ -713,14 +713,10 @@ common_timer_set(struct k_itimer *timr, int flags,
713 if (!new_setting->it_value.tv_sec && !new_setting->it_value.tv_nsec) 713 if (!new_setting->it_value.tv_sec && !new_setting->it_value.tv_nsec)
714 return 0; 714 return 0;
715 715
716 /* Posix madness. Only absolute CLOCK_REALTIME timers 716 mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL;
717 * are affected by clock sets. So we must reiniatilize 717 hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
718 * the timer. 718 timr->it.real.timer.data = timr;
719 */ 719 timr->it.real.timer.function = posix_timer_fn;
720 if (timr->it_clock == CLOCK_REALTIME && (flags & TIMER_ABSTIME))
721 hrtimer_rebase(timer, CLOCK_REALTIME);
722 else
723 hrtimer_rebase(timer, CLOCK_MONOTONIC);
724 720
725 timer->expires = timespec_to_ktime(new_setting->it_value); 721 timer->expires = timespec_to_ktime(new_setting->it_value);
726 722
@@ -728,11 +724,15 @@ common_timer_set(struct k_itimer *timr, int flags,
728 timr->it.real.interval = timespec_to_ktime(new_setting->it_interval); 724 timr->it.real.interval = timespec_to_ktime(new_setting->it_interval);
729 725
730 /* SIGEV_NONE timers are not queued ! See common_timer_get */ 726 /* SIGEV_NONE timers are not queued ! See common_timer_get */
731 if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) 727 if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) {
728 /* Setup correct expiry time for relative timers */
729 if (mode == HRTIMER_REL)
730 timer->expires = ktime_add(timer->expires,
731 timer->base->get_time());
732 return 0; 732 return 0;
733 }
733 734
734 hrtimer_start(timer, timer->expires, (flags & TIMER_ABSTIME) ? 735 hrtimer_start(timer, timer->expires, mode);
735 HRTIMER_ABS : HRTIMER_REL);
736 return 0; 736 return 0;
737} 737}
738 738
@@ -875,12 +875,6 @@ int do_posix_clock_nosettime(const clockid_t clockid, struct timespec *tp)
875} 875}
876EXPORT_SYMBOL_GPL(do_posix_clock_nosettime); 876EXPORT_SYMBOL_GPL(do_posix_clock_nosettime);
877 877
878int do_posix_clock_notimer_create(struct k_itimer *timer)
879{
880 return -EINVAL;
881}
882EXPORT_SYMBOL_GPL(do_posix_clock_notimer_create);
883
884int do_posix_clock_nonanosleep(const clockid_t clock, int flags, 878int do_posix_clock_nonanosleep(const clockid_t clock, int flags,
885 struct timespec *t, struct timespec __user *r) 879 struct timespec *t, struct timespec __user *r)
886{ 880{
@@ -947,21 +941,8 @@ sys_clock_getres(const clockid_t which_clock, struct timespec __user *tp)
947static int common_nsleep(const clockid_t which_clock, int flags, 941static int common_nsleep(const clockid_t which_clock, int flags,
948 struct timespec *tsave, struct timespec __user *rmtp) 942 struct timespec *tsave, struct timespec __user *rmtp)
949{ 943{
950 int mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL; 944 return hrtimer_nanosleep(tsave, rmtp, flags & TIMER_ABSTIME ?
951 int clockid = which_clock; 945 HRTIMER_ABS : HRTIMER_REL, which_clock);
952
953 switch (which_clock) {
954 case CLOCK_REALTIME:
955 /* Posix madness. Only absolute timers on clock realtime
956 are affected by clock set. */
957 if (mode != HRTIMER_ABS)
958 clockid = CLOCK_MONOTONIC;
959 case CLOCK_MONOTONIC:
960 break;
961 default:
962 return -EINVAL;
963 }
964 return hrtimer_nanosleep(tsave, rmtp, mode, clockid);
965} 946}
966 947
967asmlinkage long 948asmlinkage long
diff --git a/kernel/power/console.c b/kernel/power/console.c
index 7ff375e7c95f..579d239d129f 100644
--- a/kernel/power/console.c
+++ b/kernel/power/console.c
@@ -9,18 +9,11 @@
9#include <linux/console.h> 9#include <linux/console.h>
10#include "power.h" 10#include "power.h"
11 11
12static int new_loglevel = 10;
13static int orig_loglevel;
14#ifdef SUSPEND_CONSOLE 12#ifdef SUSPEND_CONSOLE
15static int orig_fgconsole, orig_kmsg; 13static int orig_fgconsole, orig_kmsg;
16#endif
17 14
18int pm_prepare_console(void) 15int pm_prepare_console(void)
19{ 16{
20 orig_loglevel = console_loglevel;
21 console_loglevel = new_loglevel;
22
23#ifdef SUSPEND_CONSOLE
24 acquire_console_sem(); 17 acquire_console_sem();
25 18
26 orig_fgconsole = fg_console; 19 orig_fgconsole = fg_console;
@@ -41,18 +34,15 @@ int pm_prepare_console(void)
41 } 34 }
42 orig_kmsg = kmsg_redirect; 35 orig_kmsg = kmsg_redirect;
43 kmsg_redirect = SUSPEND_CONSOLE; 36 kmsg_redirect = SUSPEND_CONSOLE;
44#endif
45 return 0; 37 return 0;
46} 38}
47 39
48void pm_restore_console(void) 40void pm_restore_console(void)
49{ 41{
50 console_loglevel = orig_loglevel;
51#ifdef SUSPEND_CONSOLE
52 acquire_console_sem(); 42 acquire_console_sem();
53 set_console(orig_fgconsole); 43 set_console(orig_fgconsole);
54 release_console_sem(); 44 release_console_sem();
55 kmsg_redirect = orig_kmsg; 45 kmsg_redirect = orig_kmsg;
56#endif
57 return; 46 return;
58} 47}
48#endif
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index e24446f8d8cd..0b43847dc980 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -53,7 +53,7 @@ static void power_down(suspend_disk_method_t mode)
53 53
54 switch(mode) { 54 switch(mode) {
55 case PM_DISK_PLATFORM: 55 case PM_DISK_PLATFORM:
56 kernel_power_off_prepare(); 56 kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
57 error = pm_ops->enter(PM_SUSPEND_DISK); 57 error = pm_ops->enter(PM_SUSPEND_DISK);
58 break; 58 break;
59 case PM_DISK_SHUTDOWN: 59 case PM_DISK_SHUTDOWN:
@@ -95,13 +95,6 @@ static int prepare_processes(void)
95 goto thaw; 95 goto thaw;
96 } 96 }
97 97
98 if (pm_disk_mode == PM_DISK_PLATFORM) {
99 if (pm_ops && pm_ops->prepare) {
100 if ((error = pm_ops->prepare(PM_SUSPEND_DISK)))
101 goto thaw;
102 }
103 }
104
105 /* Free memory before shutting down devices. */ 98 /* Free memory before shutting down devices. */
106 if (!(error = swsusp_shrink_memory())) 99 if (!(error = swsusp_shrink_memory()))
107 return 0; 100 return 0;
@@ -367,14 +360,14 @@ power_attr(resume);
367 360
368static ssize_t image_size_show(struct subsystem * subsys, char *buf) 361static ssize_t image_size_show(struct subsystem * subsys, char *buf)
369{ 362{
370 return sprintf(buf, "%u\n", image_size); 363 return sprintf(buf, "%lu\n", image_size);
371} 364}
372 365
373static ssize_t image_size_store(struct subsystem * subsys, const char * buf, size_t n) 366static ssize_t image_size_store(struct subsystem * subsys, const char * buf, size_t n)
374{ 367{
375 unsigned int size; 368 unsigned long size;
376 369
377 if (sscanf(buf, "%u", &size) == 1) { 370 if (sscanf(buf, "%lu", &size) == 1) {
378 image_size = size; 371 image_size = size;
379 return n; 372 return n;
380 } 373 }
diff --git a/kernel/power/main.c b/kernel/power/main.c
index d253f3ae2fa5..9cb235cba4a9 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -133,10 +133,10 @@ static int suspend_enter(suspend_state_t state)
133static void suspend_finish(suspend_state_t state) 133static void suspend_finish(suspend_state_t state)
134{ 134{
135 device_resume(); 135 device_resume();
136 if (pm_ops && pm_ops->finish)
137 pm_ops->finish(state);
138 thaw_processes(); 136 thaw_processes();
139 enable_nonboot_cpus(); 137 enable_nonboot_cpus();
138 if (pm_ops && pm_ops->finish)
139 pm_ops->finish(state);
140 pm_restore_console(); 140 pm_restore_console();
141} 141}
142 142
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 7e8492fd1423..d8f0d1a76bae 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -42,8 +42,13 @@ static struct subsys_attribute _name##_attr = { \
42 42
43extern struct subsystem power_subsys; 43extern struct subsystem power_subsys;
44 44
45#ifdef SUSPEND_CONSOLE
45extern int pm_prepare_console(void); 46extern int pm_prepare_console(void);
46extern void pm_restore_console(void); 47extern void pm_restore_console(void);
48#else
49static int pm_prepare_console(void) { return 0; }
50static void pm_restore_console(void) {}
51#endif
47 52
48/* References to section boundaries */ 53/* References to section boundaries */
49extern const void __nosave_begin, __nosave_end; 54extern const void __nosave_begin, __nosave_end;
@@ -51,8 +56,8 @@ extern const void __nosave_begin, __nosave_end;
51extern unsigned int nr_copy_pages; 56extern unsigned int nr_copy_pages;
52extern struct pbe *pagedir_nosave; 57extern struct pbe *pagedir_nosave;
53 58
54/* Preferred image size in MB (default 500) */ 59/* Preferred image size in bytes (default 500 MB) */
55extern unsigned int image_size; 60extern unsigned long image_size;
56 61
57extern asmlinkage int swsusp_arch_suspend(void); 62extern asmlinkage int swsusp_arch_suspend(void);
58extern asmlinkage int swsusp_arch_resume(void); 63extern asmlinkage int swsusp_arch_resume(void);
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 55a18d26abed..59c91c148e82 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -70,12 +70,12 @@
70#include "power.h" 70#include "power.h"
71 71
72/* 72/*
73 * Preferred image size in MB (tunable via /sys/power/image_size). 73 * Preferred image size in bytes (tunable via /sys/power/image_size).
74 * When it is set to N, swsusp will do its best to ensure the image 74 * When it is set to N, swsusp will do its best to ensure the image
75 * size will not exceed N MB, but if that is impossible, it will 75 * size will not exceed N bytes, but if that is impossible, it will
76 * try to create the smallest image possible. 76 * try to create the smallest image possible.
77 */ 77 */
78unsigned int image_size = 500; 78unsigned long image_size = 500 * 1024 * 1024;
79 79
80#ifdef CONFIG_HIGHMEM 80#ifdef CONFIG_HIGHMEM
81unsigned int count_highmem_pages(void); 81unsigned int count_highmem_pages(void);
@@ -590,7 +590,7 @@ int swsusp_shrink_memory(void)
590 if (!tmp) 590 if (!tmp)
591 return -ENOMEM; 591 return -ENOMEM;
592 pages += tmp; 592 pages += tmp;
593 } else if (size > (image_size * 1024 * 1024) / PAGE_SIZE) { 593 } else if (size > image_size / PAGE_SIZE) {
594 tmp = shrink_all_memory(SHRINK_BITE); 594 tmp = shrink_all_memory(SHRINK_BITE);
595 pages += tmp; 595 pages += tmp;
596 } 596 }
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index 773219907dd8..7712912dbc84 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -114,16 +114,16 @@ rcu_torture_alloc(void)
114{ 114{
115 struct list_head *p; 115 struct list_head *p;
116 116
117 spin_lock(&rcu_torture_lock); 117 spin_lock_bh(&rcu_torture_lock);
118 if (list_empty(&rcu_torture_freelist)) { 118 if (list_empty(&rcu_torture_freelist)) {
119 atomic_inc(&n_rcu_torture_alloc_fail); 119 atomic_inc(&n_rcu_torture_alloc_fail);
120 spin_unlock(&rcu_torture_lock); 120 spin_unlock_bh(&rcu_torture_lock);
121 return NULL; 121 return NULL;
122 } 122 }
123 atomic_inc(&n_rcu_torture_alloc); 123 atomic_inc(&n_rcu_torture_alloc);
124 p = rcu_torture_freelist.next; 124 p = rcu_torture_freelist.next;
125 list_del_init(p); 125 list_del_init(p);
126 spin_unlock(&rcu_torture_lock); 126 spin_unlock_bh(&rcu_torture_lock);
127 return container_of(p, struct rcu_torture, rtort_free); 127 return container_of(p, struct rcu_torture, rtort_free);
128} 128}
129 129
@@ -134,9 +134,9 @@ static void
134rcu_torture_free(struct rcu_torture *p) 134rcu_torture_free(struct rcu_torture *p)
135{ 135{
136 atomic_inc(&n_rcu_torture_free); 136 atomic_inc(&n_rcu_torture_free);
137 spin_lock(&rcu_torture_lock); 137 spin_lock_bh(&rcu_torture_lock);
138 list_add_tail(&p->rtort_free, &rcu_torture_freelist); 138 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
139 spin_unlock(&rcu_torture_lock); 139 spin_unlock_bh(&rcu_torture_lock);
140} 140}
141 141
142static void 142static void
diff --git a/kernel/sched.c b/kernel/sched.c
index 3ee2ae45125f..bc38804e40dd 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4031,7 +4031,7 @@ long sched_getaffinity(pid_t pid, cpumask_t *mask)
4031 goto out_unlock; 4031 goto out_unlock;
4032 4032
4033 retval = 0; 4033 retval = 0;
4034 cpus_and(*mask, p->cpus_allowed, cpu_possible_map); 4034 cpus_and(*mask, p->cpus_allowed, cpu_online_map);
4035 4035
4036out_unlock: 4036out_unlock:
4037 read_unlock(&tasklist_lock); 4037 read_unlock(&tasklist_lock);
@@ -5141,7 +5141,7 @@ static void init_sched_build_groups(struct sched_group groups[], cpumask_t span,
5141#define SEARCH_SCOPE 2 5141#define SEARCH_SCOPE 2
5142#define MIN_CACHE_SIZE (64*1024U) 5142#define MIN_CACHE_SIZE (64*1024U)
5143#define DEFAULT_CACHE_SIZE (5*1024*1024U) 5143#define DEFAULT_CACHE_SIZE (5*1024*1024U)
5144#define ITERATIONS 2 5144#define ITERATIONS 1
5145#define SIZE_THRESH 130 5145#define SIZE_THRESH 130
5146#define COST_THRESH 130 5146#define COST_THRESH 130
5147 5147
@@ -5480,9 +5480,9 @@ static unsigned long long measure_migration_cost(int cpu1, int cpu2)
5480 break; 5480 break;
5481 } 5481 }
5482 /* 5482 /*
5483 * Increase the cachesize in 5% steps: 5483 * Increase the cachesize in 10% steps:
5484 */ 5484 */
5485 size = size * 20 / 19; 5485 size = size * 10 / 9;
5486 } 5486 }
5487 5487
5488 if (migration_debug) 5488 if (migration_debug)
@@ -5551,13 +5551,15 @@ static void calibrate_migration_costs(const cpumask_t *cpu_map)
5551 -1 5551 -1
5552#endif 5552#endif
5553 ); 5553 );
5554 printk("migration_cost="); 5554 if (system_state == SYSTEM_BOOTING) {
5555 for (distance = 0; distance <= max_distance; distance++) { 5555 printk("migration_cost=");
5556 if (distance) 5556 for (distance = 0; distance <= max_distance; distance++) {
5557 printk(","); 5557 if (distance)
5558 printk("%ld", (long)migration_cost[distance] / 1000); 5558 printk(",");
5559 printk("%ld", (long)migration_cost[distance] / 1000);
5560 }
5561 printk("\n");
5559 } 5562 }
5560 printk("\n");
5561 j1 = jiffies; 5563 j1 = jiffies;
5562 if (migration_debug) 5564 if (migration_debug)
5563 printk("migration: %ld seconds\n", (j1-j0)/HZ); 5565 printk("migration: %ld seconds\n", (j1-j0)/HZ);
@@ -6109,7 +6111,7 @@ void __init sched_init(void)
6109 runqueue_t *rq; 6111 runqueue_t *rq;
6110 int i, j, k; 6112 int i, j, k;
6111 6113
6112 for (i = 0; i < NR_CPUS; i++) { 6114 for_each_cpu(i) {
6113 prio_array_t *array; 6115 prio_array_t *array;
6114 6116
6115 rq = cpu_rq(i); 6117 rq = cpu_rq(i);
diff --git a/kernel/signal.c b/kernel/signal.c
index d3efafd8109a..b373fc2420da 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -283,7 +283,7 @@ static struct sigqueue *__sigqueue_alloc(struct task_struct *t, gfp_t flags,
283 return(q); 283 return(q);
284} 284}
285 285
286static inline void __sigqueue_free(struct sigqueue *q) 286static void __sigqueue_free(struct sigqueue *q)
287{ 287{
288 if (q->flags & SIGQUEUE_PREALLOC) 288 if (q->flags & SIGQUEUE_PREALLOC)
289 return; 289 return;
diff --git a/kernel/sys.c b/kernel/sys.c
index d09cac23fdfd..0929c698affc 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -440,23 +440,25 @@ void kernel_kexec(void)
440} 440}
441EXPORT_SYMBOL_GPL(kernel_kexec); 441EXPORT_SYMBOL_GPL(kernel_kexec);
442 442
443void kernel_shutdown_prepare(enum system_states state)
444{
445 notifier_call_chain(&reboot_notifier_list,
446 (state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL);
447 system_state = state;
448 device_shutdown();
449}
443/** 450/**
444 * kernel_halt - halt the system 451 * kernel_halt - halt the system
445 * 452 *
446 * Shutdown everything and perform a clean system halt. 453 * Shutdown everything and perform a clean system halt.
447 */ 454 */
448void kernel_halt_prepare(void)
449{
450 notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
451 system_state = SYSTEM_HALT;
452 device_shutdown();
453}
454void kernel_halt(void) 455void kernel_halt(void)
455{ 456{
456 kernel_halt_prepare(); 457 kernel_shutdown_prepare(SYSTEM_HALT);
457 printk(KERN_EMERG "System halted.\n"); 458 printk(KERN_EMERG "System halted.\n");
458 machine_halt(); 459 machine_halt();
459} 460}
461
460EXPORT_SYMBOL_GPL(kernel_halt); 462EXPORT_SYMBOL_GPL(kernel_halt);
461 463
462/** 464/**
@@ -464,20 +466,13 @@ EXPORT_SYMBOL_GPL(kernel_halt);
464 * 466 *
465 * Shutdown everything and perform a clean system power_off. 467 * Shutdown everything and perform a clean system power_off.
466 */ 468 */
467void kernel_power_off_prepare(void)
468{
469 notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
470 system_state = SYSTEM_POWER_OFF;
471 device_shutdown();
472}
473void kernel_power_off(void) 469void kernel_power_off(void)
474{ 470{
475 kernel_power_off_prepare(); 471 kernel_shutdown_prepare(SYSTEM_POWER_OFF);
476 printk(KERN_EMERG "Power down.\n"); 472 printk(KERN_EMERG "Power down.\n");
477 machine_power_off(); 473 machine_power_off();
478} 474}
479EXPORT_SYMBOL_GPL(kernel_power_off); 475EXPORT_SYMBOL_GPL(kernel_power_off);
480
481/* 476/*
482 * Reboot system call: for obvious reasons only root may call it, 477 * Reboot system call: for obvious reasons only root may call it,
483 * and even root needs to set up some magic numbers in the registers 478 * and even root needs to set up some magic numbers in the registers
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index cb99a42f8b37..71dd6f62efec 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -878,7 +878,17 @@ static ctl_table vm_table[] = {
878 .maxlen = sizeof(zone_reclaim_mode), 878 .maxlen = sizeof(zone_reclaim_mode),
879 .mode = 0644, 879 .mode = 0644,
880 .proc_handler = &proc_dointvec, 880 .proc_handler = &proc_dointvec,
881 .strategy = &zero, 881 .strategy = &sysctl_intvec,
882 .extra1 = &zero,
883 },
884 {
885 .ctl_name = VM_ZONE_RECLAIM_INTERVAL,
886 .procname = "zone_reclaim_interval",
887 .data = &zone_reclaim_interval,
888 .maxlen = sizeof(zone_reclaim_interval),
889 .mode = 0644,
890 .proc_handler = &proc_dointvec_jiffies,
891 .strategy = &sysctl_jiffies,
882 }, 892 },
883#endif 893#endif
884 { .ctl_name = 0 } 894 { .ctl_name = 0 }
diff --git a/kernel/time.c b/kernel/time.c
index 7477b1d2079e..804539165d8b 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -155,7 +155,7 @@ int do_sys_settimeofday(struct timespec *tv, struct timezone *tz)
155 static int firsttime = 1; 155 static int firsttime = 1;
156 int error = 0; 156 int error = 0;
157 157
158 if (!timespec_valid(tv)) 158 if (tv && !timespec_valid(tv))
159 return -EINVAL; 159 return -EINVAL;
160 160
161 error = security_settime(tv, tz); 161 error = security_settime(tv, tz);
@@ -637,15 +637,16 @@ void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec)
637 * 637 *
638 * Returns the timespec representation of the nsec parameter. 638 * Returns the timespec representation of the nsec parameter.
639 */ 639 */
640inline struct timespec ns_to_timespec(const nsec_t nsec) 640struct timespec ns_to_timespec(const nsec_t nsec)
641{ 641{
642 struct timespec ts; 642 struct timespec ts;
643 643
644 if (nsec) 644 if (!nsec)
645 ts.tv_sec = div_long_long_rem_signed(nsec, NSEC_PER_SEC, 645 return (struct timespec) {0, 0};
646 &ts.tv_nsec); 646
647 else 647 ts.tv_sec = div_long_long_rem_signed(nsec, NSEC_PER_SEC, &ts.tv_nsec);
648 ts.tv_sec = ts.tv_nsec = 0; 648 if (unlikely(nsec < 0))
649 set_normalized_timespec(&ts, ts.tv_sec, ts.tv_nsec);
649 650
650 return ts; 651 return ts;
651} 652}
diff --git a/kernel/user.c b/kernel/user.c
index 89e562feb1b1..d9deae43a9ab 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -13,6 +13,7 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/bitops.h> 14#include <linux/bitops.h>
15#include <linux/key.h> 15#include <linux/key.h>
16#include <linux/interrupt.h>
16 17
17/* 18/*
18 * UID task count cache, to get fast user lookup in "alloc_uid" 19 * UID task count cache, to get fast user lookup in "alloc_uid"
@@ -27,6 +28,16 @@
27 28
28static kmem_cache_t *uid_cachep; 29static kmem_cache_t *uid_cachep;
29static struct list_head uidhash_table[UIDHASH_SZ]; 30static struct list_head uidhash_table[UIDHASH_SZ];
31
32/*
33 * The uidhash_lock is mostly taken from process context, but it is
34 * occasionally also taken from softirq/tasklet context, when
35 * task-structs get RCU-freed. Hence all locking must be softirq-safe.
36 * But free_uid() is also called with local interrupts disabled, and running
37 * local_bh_enable() with local interrupts disabled is an error - we'll run
38 * softirq callbacks, and they can unconditionally enable interrupts, and
39 * the caller of free_uid() didn't expect that..
40 */
30static DEFINE_SPINLOCK(uidhash_lock); 41static DEFINE_SPINLOCK(uidhash_lock);
31 42
32struct user_struct root_user = { 43struct user_struct root_user = {
@@ -82,15 +93,19 @@ static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *has
82struct user_struct *find_user(uid_t uid) 93struct user_struct *find_user(uid_t uid)
83{ 94{
84 struct user_struct *ret; 95 struct user_struct *ret;
96 unsigned long flags;
85 97
86 spin_lock(&uidhash_lock); 98 spin_lock_irqsave(&uidhash_lock, flags);
87 ret = uid_hash_find(uid, uidhashentry(uid)); 99 ret = uid_hash_find(uid, uidhashentry(uid));
88 spin_unlock(&uidhash_lock); 100 spin_unlock_irqrestore(&uidhash_lock, flags);
89 return ret; 101 return ret;
90} 102}
91 103
92void free_uid(struct user_struct *up) 104void free_uid(struct user_struct *up)
93{ 105{
106 unsigned long flags;
107
108 local_irq_save(flags);
94 if (up && atomic_dec_and_lock(&up->__count, &uidhash_lock)) { 109 if (up && atomic_dec_and_lock(&up->__count, &uidhash_lock)) {
95 uid_hash_remove(up); 110 uid_hash_remove(up);
96 key_put(up->uid_keyring); 111 key_put(up->uid_keyring);
@@ -98,6 +113,7 @@ void free_uid(struct user_struct *up)
98 kmem_cache_free(uid_cachep, up); 113 kmem_cache_free(uid_cachep, up);
99 spin_unlock(&uidhash_lock); 114 spin_unlock(&uidhash_lock);
100 } 115 }
116 local_irq_restore(flags);
101} 117}
102 118
103struct user_struct * alloc_uid(uid_t uid) 119struct user_struct * alloc_uid(uid_t uid)
@@ -105,9 +121,9 @@ struct user_struct * alloc_uid(uid_t uid)
105 struct list_head *hashent = uidhashentry(uid); 121 struct list_head *hashent = uidhashentry(uid);
106 struct user_struct *up; 122 struct user_struct *up;
107 123
108 spin_lock(&uidhash_lock); 124 spin_lock_irq(&uidhash_lock);
109 up = uid_hash_find(uid, hashent); 125 up = uid_hash_find(uid, hashent);
110 spin_unlock(&uidhash_lock); 126 spin_unlock_irq(&uidhash_lock);
111 127
112 if (!up) { 128 if (!up) {
113 struct user_struct *new; 129 struct user_struct *new;
@@ -137,7 +153,7 @@ struct user_struct * alloc_uid(uid_t uid)
137 * Before adding this, check whether we raced 153 * Before adding this, check whether we raced
138 * on adding the same user already.. 154 * on adding the same user already..
139 */ 155 */
140 spin_lock(&uidhash_lock); 156 spin_lock_irq(&uidhash_lock);
141 up = uid_hash_find(uid, hashent); 157 up = uid_hash_find(uid, hashent);
142 if (up) { 158 if (up) {
143 key_put(new->uid_keyring); 159 key_put(new->uid_keyring);
@@ -147,7 +163,7 @@ struct user_struct * alloc_uid(uid_t uid)
147 uid_hash_insert(new, hashent); 163 uid_hash_insert(new, hashent);
148 up = new; 164 up = new;
149 } 165 }
150 spin_unlock(&uidhash_lock); 166 spin_unlock_irq(&uidhash_lock);
151 167
152 } 168 }
153 return up; 169 return up;
@@ -183,9 +199,9 @@ static int __init uid_cache_init(void)
183 INIT_LIST_HEAD(uidhash_table + n); 199 INIT_LIST_HEAD(uidhash_table + n);
184 200
185 /* Insert the root user immediately (init already runs as root) */ 201 /* Insert the root user immediately (init already runs as root) */
186 spin_lock(&uidhash_lock); 202 spin_lock_irq(&uidhash_lock);
187 uid_hash_insert(&root_user, uidhashentry(0)); 203 uid_hash_insert(&root_user, uidhashentry(0));
188 spin_unlock(&uidhash_lock); 204 spin_unlock_irq(&uidhash_lock);
189 205
190 return 0; 206 return 0;
191} 207}
diff --git a/lib/Makefile b/lib/Makefile
index 8535f4d7d1c3..648b2c1242fd 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -9,7 +9,7 @@ lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
9 9
10lib-y += kobject.o kref.o kobject_uevent.o klist.o 10lib-y += kobject.o kref.o kobject_uevent.o klist.o
11 11
12obj-y += sort.o parser.o halfmd4.o 12obj-y += sort.o parser.o halfmd4.o iomap_copy.o
13 13
14ifeq ($(CONFIG_DEBUG_KOBJECT),y) 14ifeq ($(CONFIG_DEBUG_KOBJECT),y)
15CFLAGS_kobject.o += -DDEBUG 15CFLAGS_kobject.o += -DDEBUG
diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c
index a5d2cdc5684c..fd355a99327c 100644
--- a/lib/int_sqrt.c
+++ b/lib/int_sqrt.c
@@ -15,7 +15,7 @@ unsigned long int_sqrt(unsigned long x)
15 op = x; 15 op = x;
16 res = 0; 16 res = 0;
17 17
18 one = 1 << 30; 18 one = 1UL << (BITS_PER_LONG - 2);
19 while (one > op) 19 while (one > op)
20 one >>= 2; 20 one >>= 2;
21 21
diff --git a/lib/iomap_copy.c b/lib/iomap_copy.c
new file mode 100644
index 000000000000..a6b1e271d53c
--- /dev/null
+++ b/lib/iomap_copy.c
@@ -0,0 +1,42 @@
1/*
2 * Copyright 2006 PathScale, Inc. All Rights Reserved.
3 *
4 * This file is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18#include <linux/io.h>
19#include <linux/module.h>
20
21/**
22 * __iowrite32_copy - copy data to MMIO space, in 32-bit units
23 * @to: destination, in MMIO space (must be 32-bit aligned)
24 * @from: source (must be 32-bit aligned)
25 * @count: number of 32-bit quantities to copy
26 *
27 * Copy data from kernel space to MMIO space, in units of 32 bits at a
28 * time. Order of access is not guaranteed, nor is a memory barrier
29 * performed afterwards.
30 */
31void __attribute__((weak)) __iowrite32_copy(void __iomem *to,
32 const void *from,
33 size_t count)
34{
35 u32 __iomem *dst = to;
36 const u32 *src = from;
37 const u32 *end = src + count;
38
39 while (src < end)
40 __raw_writel(*src++, dst++);
41}
42EXPORT_SYMBOL_GPL(__iowrite32_copy);
diff --git a/lib/ts_bm.c b/lib/ts_bm.c
index 8a8b3a16133e..c4c1ac5fbd1a 100644
--- a/lib/ts_bm.c
+++ b/lib/ts_bm.c
@@ -94,10 +94,28 @@ next: bs = bm->bad_shift[text[shift-i]];
94 return UINT_MAX; 94 return UINT_MAX;
95} 95}
96 96
97static int subpattern(u8 *pattern, int i, int j, int g)
98{
99 int x = i+g-1, y = j+g-1, ret = 0;
100
101 while(pattern[x--] == pattern[y--]) {
102 if (y < 0) {
103 ret = 1;
104 break;
105 }
106 if (--g == 0) {
107 ret = pattern[i-1] != pattern[j-1];
108 break;
109 }
110 }
111
112 return ret;
113}
114
97static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern, 115static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern,
98 unsigned int len) 116 unsigned int len)
99{ 117{
100 int i, j, ended, l[ASIZE]; 118 int i, j, g;
101 119
102 for (i = 0; i < ASIZE; i++) 120 for (i = 0; i < ASIZE; i++)
103 bm->bad_shift[i] = len; 121 bm->bad_shift[i] = len;
@@ -106,23 +124,15 @@ static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern,
106 124
107 /* Compute the good shift array, used to match reocurrences 125 /* Compute the good shift array, used to match reocurrences
108 * of a subpattern */ 126 * of a subpattern */
109 for (i = 1; i < bm->patlen; i++) {
110 for (j = 0; j < bm->patlen && bm->pattern[bm->patlen - 1 - j]
111 == bm->pattern[bm->patlen - 1 - i - j]; j++);
112 l[i] = j;
113 }
114
115 bm->good_shift[0] = 1; 127 bm->good_shift[0] = 1;
116 for (i = 1; i < bm->patlen; i++) 128 for (i = 1; i < bm->patlen; i++)
117 bm->good_shift[i] = bm->patlen; 129 bm->good_shift[i] = bm->patlen;
118 for (i = bm->patlen - 1; i > 0; i--) 130 for (i = bm->patlen-1, g = 1; i > 0; g++, i--) {
119 bm->good_shift[l[i]] = i; 131 for (j = i-1; j >= 1-g ; j--)
120 ended = 0; 132 if (subpattern(bm->pattern, i, j, g)) {
121 for (i = 0; i < bm->patlen; i++) { 133 bm->good_shift[g] = bm->patlen-j-g;
122 if (l[i] == bm->patlen - 1 - i) 134 break;
123 ended = i; 135 }
124 if (ended)
125 bm->good_shift[i] = ended;
126 } 136 }
127} 137}
128 138
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index b21d78c941b5..ceb3ebb3c399 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -444,6 +444,15 @@ retry:
444 page = alloc_huge_page(vma, address); 444 page = alloc_huge_page(vma, address);
445 if (!page) { 445 if (!page) {
446 hugetlb_put_quota(mapping); 446 hugetlb_put_quota(mapping);
447 /*
448 * No huge pages available. So this is an OOM
449 * condition but we do not want to trigger the OOM
450 * killer, so we return VM_FAULT_SIGBUS.
451 *
452 * A program using hugepages may fault with Bus Error
453 * because no huge pages are available in the cpuset, per
454 * memory policy or because all are in use!
455 */
447 goto out; 456 goto out;
448 } 457 }
449 458
diff --git a/mm/memory.c b/mm/memory.c
index 7a11ddd5060f..2bee1f21aa8a 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1871,6 +1871,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
1871 goto out; 1871 goto out;
1872 1872
1873 entry = pte_to_swp_entry(orig_pte); 1873 entry = pte_to_swp_entry(orig_pte);
1874again:
1874 page = lookup_swap_cache(entry); 1875 page = lookup_swap_cache(entry);
1875 if (!page) { 1876 if (!page) {
1876 swapin_readahead(entry, address, vma); 1877 swapin_readahead(entry, address, vma);
@@ -1894,6 +1895,12 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
1894 1895
1895 mark_page_accessed(page); 1896 mark_page_accessed(page);
1896 lock_page(page); 1897 lock_page(page);
1898 if (!PageSwapCache(page)) {
1899 /* Page migration has occured */
1900 unlock_page(page);
1901 page_cache_release(page);
1902 goto again;
1903 }
1897 1904
1898 /* 1905 /*
1899 * Back out if somebody else already faulted in this pte. 1906 * Back out if somebody else already faulted in this pte.
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 73790188b0eb..3bd7fb7e4b75 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -95,6 +95,9 @@
95#define MPOL_MF_INVERT (MPOL_MF_INTERNAL << 1) /* Invert check for nodemask */ 95#define MPOL_MF_INVERT (MPOL_MF_INTERNAL << 1) /* Invert check for nodemask */
96#define MPOL_MF_STATS (MPOL_MF_INTERNAL << 2) /* Gather statistics */ 96#define MPOL_MF_STATS (MPOL_MF_INTERNAL << 2) /* Gather statistics */
97 97
98/* The number of pages to migrate per call to migrate_pages() */
99#define MIGRATE_CHUNK_SIZE 256
100
98static kmem_cache_t *policy_cache; 101static kmem_cache_t *policy_cache;
99static kmem_cache_t *sn_cache; 102static kmem_cache_t *sn_cache;
100 103
@@ -543,24 +546,91 @@ static void migrate_page_add(struct page *page, struct list_head *pagelist,
543 } 546 }
544} 547}
545 548
546static int swap_pages(struct list_head *pagelist) 549/*
550 * Migrate the list 'pagelist' of pages to a certain destination.
551 *
552 * Specify destination with either non-NULL vma or dest_node >= 0
553 * Return the number of pages not migrated or error code
554 */
555static int migrate_pages_to(struct list_head *pagelist,
556 struct vm_area_struct *vma, int dest)
547{ 557{
558 LIST_HEAD(newlist);
548 LIST_HEAD(moved); 559 LIST_HEAD(moved);
549 LIST_HEAD(failed); 560 LIST_HEAD(failed);
550 int n; 561 int err = 0;
562 int nr_pages;
563 struct page *page;
564 struct list_head *p;
551 565
552 n = migrate_pages(pagelist, NULL, &moved, &failed); 566redo:
553 putback_lru_pages(&failed); 567 nr_pages = 0;
554 putback_lru_pages(&moved); 568 list_for_each(p, pagelist) {
569 if (vma)
570 page = alloc_page_vma(GFP_HIGHUSER, vma, vma->vm_start);
571 else
572 page = alloc_pages_node(dest, GFP_HIGHUSER, 0);
555 573
556 return n; 574 if (!page) {
575 err = -ENOMEM;
576 goto out;
577 }
578 list_add(&page->lru, &newlist);
579 nr_pages++;
580 if (nr_pages > MIGRATE_CHUNK_SIZE);
581 break;
582 }
583 err = migrate_pages(pagelist, &newlist, &moved, &failed);
584
585 putback_lru_pages(&moved); /* Call release pages instead ?? */
586
587 if (err >= 0 && list_empty(&newlist) && !list_empty(pagelist))
588 goto redo;
589out:
590 /* Return leftover allocated pages */
591 while (!list_empty(&newlist)) {
592 page = list_entry(newlist.next, struct page, lru);
593 list_del(&page->lru);
594 __free_page(page);
595 }
596 list_splice(&failed, pagelist);
597 if (err < 0)
598 return err;
599
600 /* Calculate number of leftover pages */
601 nr_pages = 0;
602 list_for_each(p, pagelist)
603 nr_pages++;
604 return nr_pages;
557} 605}
558 606
559/* 607/*
560 * For now migrate_pages simply swaps out the pages from nodes that are in 608 * Migrate pages from one node to a target node.
561 * the source set but not in the target set. In the future, we would 609 * Returns error or the number of pages not migrated.
562 * want a function that moves pages between the two nodesets in such 610 */
563 * a way as to preserve the physical layout as much as possible. 611int migrate_to_node(struct mm_struct *mm, int source, int dest, int flags)
612{
613 nodemask_t nmask;
614 LIST_HEAD(pagelist);
615 int err = 0;
616
617 nodes_clear(nmask);
618 node_set(source, nmask);
619
620 check_range(mm, mm->mmap->vm_start, TASK_SIZE, &nmask,
621 flags | MPOL_MF_DISCONTIG_OK, &pagelist);
622
623 if (!list_empty(&pagelist)) {
624 err = migrate_pages_to(&pagelist, NULL, dest);
625 if (!list_empty(&pagelist))
626 putback_lru_pages(&pagelist);
627 }
628 return err;
629}
630
631/*
632 * Move pages between the two nodesets so as to preserve the physical
633 * layout as much as possible.
564 * 634 *
565 * Returns the number of page that could not be moved. 635 * Returns the number of page that could not be moved.
566 */ 636 */
@@ -568,22 +638,76 @@ int do_migrate_pages(struct mm_struct *mm,
568 const nodemask_t *from_nodes, const nodemask_t *to_nodes, int flags) 638 const nodemask_t *from_nodes, const nodemask_t *to_nodes, int flags)
569{ 639{
570 LIST_HEAD(pagelist); 640 LIST_HEAD(pagelist);
571 int count = 0; 641 int busy = 0;
572 nodemask_t nodes; 642 int err = 0;
643 nodemask_t tmp;
573 644
574 nodes_andnot(nodes, *from_nodes, *to_nodes); 645 down_read(&mm->mmap_sem);
575 646
576 down_read(&mm->mmap_sem); 647/*
577 check_range(mm, mm->mmap->vm_start, TASK_SIZE, &nodes, 648 * Find a 'source' bit set in 'tmp' whose corresponding 'dest'
578 flags | MPOL_MF_DISCONTIG_OK, &pagelist); 649 * bit in 'to' is not also set in 'tmp'. Clear the found 'source'
650 * bit in 'tmp', and return that <source, dest> pair for migration.
651 * The pair of nodemasks 'to' and 'from' define the map.
652 *
653 * If no pair of bits is found that way, fallback to picking some
654 * pair of 'source' and 'dest' bits that are not the same. If the
655 * 'source' and 'dest' bits are the same, this represents a node
656 * that will be migrating to itself, so no pages need move.
657 *
658 * If no bits are left in 'tmp', or if all remaining bits left
659 * in 'tmp' correspond to the same bit in 'to', return false
660 * (nothing left to migrate).
661 *
662 * This lets us pick a pair of nodes to migrate between, such that
663 * if possible the dest node is not already occupied by some other
664 * source node, minimizing the risk of overloading the memory on a
665 * node that would happen if we migrated incoming memory to a node
666 * before migrating outgoing memory source that same node.
667 *
668 * A single scan of tmp is sufficient. As we go, we remember the
669 * most recent <s, d> pair that moved (s != d). If we find a pair
670 * that not only moved, but what's better, moved to an empty slot
671 * (d is not set in tmp), then we break out then, with that pair.
672 * Otherwise when we finish scannng from_tmp, we at least have the
673 * most recent <s, d> pair that moved. If we get all the way through
674 * the scan of tmp without finding any node that moved, much less
675 * moved to an empty node, then there is nothing left worth migrating.
676 */
579 677
580 if (!list_empty(&pagelist)) { 678 tmp = *from_nodes;
581 count = swap_pages(&pagelist); 679 while (!nodes_empty(tmp)) {
582 putback_lru_pages(&pagelist); 680 int s,d;
681 int source = -1;
682 int dest = 0;
683
684 for_each_node_mask(s, tmp) {
685 d = node_remap(s, *from_nodes, *to_nodes);
686 if (s == d)
687 continue;
688
689 source = s; /* Node moved. Memorize */
690 dest = d;
691
692 /* dest not in remaining from nodes? */
693 if (!node_isset(dest, tmp))
694 break;
695 }
696 if (source == -1)
697 break;
698
699 node_clear(source, tmp);
700 err = migrate_to_node(mm, source, dest, flags);
701 if (err > 0)
702 busy += err;
703 if (err < 0)
704 break;
583 } 705 }
584 706
585 up_read(&mm->mmap_sem); 707 up_read(&mm->mmap_sem);
586 return count; 708 if (err < 0)
709 return err;
710 return busy;
587} 711}
588 712
589long do_mbind(unsigned long start, unsigned long len, 713long do_mbind(unsigned long start, unsigned long len,
@@ -643,8 +767,9 @@ long do_mbind(unsigned long start, unsigned long len,
643 int nr_failed = 0; 767 int nr_failed = 0;
644 768
645 err = mbind_range(vma, start, end, new); 769 err = mbind_range(vma, start, end, new);
770
646 if (!list_empty(&pagelist)) 771 if (!list_empty(&pagelist))
647 nr_failed = swap_pages(&pagelist); 772 nr_failed = migrate_pages_to(&pagelist, vma, -1);
648 773
649 if (!err && nr_failed && (flags & MPOL_MF_STRICT)) 774 if (!err && nr_failed && (flags & MPOL_MF_STRICT))
650 err = -EIO; 775 err = -EIO;
@@ -1034,6 +1159,7 @@ static inline unsigned interleave_nid(struct mempolicy *pol,
1034 return interleave_nodes(pol); 1159 return interleave_nodes(pol);
1035} 1160}
1036 1161
1162#ifdef CONFIG_HUGETLBFS
1037/* Return a zonelist suitable for a huge page allocation. */ 1163/* Return a zonelist suitable for a huge page allocation. */
1038struct zonelist *huge_zonelist(struct vm_area_struct *vma, unsigned long addr) 1164struct zonelist *huge_zonelist(struct vm_area_struct *vma, unsigned long addr)
1039{ 1165{
@@ -1047,6 +1173,7 @@ struct zonelist *huge_zonelist(struct vm_area_struct *vma, unsigned long addr)
1047 } 1173 }
1048 return zonelist_policy(GFP_HIGHUSER, pol); 1174 return zonelist_policy(GFP_HIGHUSER, pol);
1049} 1175}
1176#endif
1050 1177
1051/* Allocate a page in interleaved policy. 1178/* Allocate a page in interleaved policy.
1052 Own path because it needs to do special accounting. */ 1179 Own path because it needs to do special accounting. */
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 14bd4ec79597..b05ab8f2a562 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -271,6 +271,7 @@ void out_of_memory(gfp_t gfp_mask, int order)
271 if (printk_ratelimit()) { 271 if (printk_ratelimit()) {
272 printk("oom-killer: gfp_mask=0x%x, order=%d\n", 272 printk("oom-killer: gfp_mask=0x%x, order=%d\n",
273 gfp_mask, order); 273 gfp_mask, order);
274 dump_stack();
274 show_mem(); 275 show_mem();
275 } 276 }
276 277
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index df54e2fc8ee0..dde04ff4be31 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1213,18 +1213,21 @@ static void __get_page_state(struct page_state *ret, int nr, cpumask_t *cpumask)
1213{ 1213{
1214 int cpu = 0; 1214 int cpu = 0;
1215 1215
1216 memset(ret, 0, sizeof(*ret)); 1216 memset(ret, 0, nr * sizeof(unsigned long));
1217 cpus_and(*cpumask, *cpumask, cpu_online_map); 1217 cpus_and(*cpumask, *cpumask, cpu_online_map);
1218 1218
1219 cpu = first_cpu(*cpumask); 1219 cpu = first_cpu(*cpumask);
1220 while (cpu < NR_CPUS) { 1220 while (cpu < NR_CPUS) {
1221 unsigned long *in, *out, off; 1221 unsigned long *in, *out, off;
1222 1222
1223 if (!cpu_isset(cpu, *cpumask))
1224 continue;
1225
1223 in = (unsigned long *)&per_cpu(page_states, cpu); 1226 in = (unsigned long *)&per_cpu(page_states, cpu);
1224 1227
1225 cpu = next_cpu(cpu, *cpumask); 1228 cpu = next_cpu(cpu, *cpumask);
1226 1229
1227 if (cpu < NR_CPUS) 1230 if (likely(cpu < NR_CPUS))
1228 prefetch(&per_cpu(page_states, cpu)); 1231 prefetch(&per_cpu(page_states, cpu));
1229 1232
1230 out = (unsigned long *)ret; 1233 out = (unsigned long *)ret;
@@ -1799,7 +1802,7 @@ void zonetable_add(struct zone *zone, int nid, int zid, unsigned long pfn,
1799 memmap_init_zone((size), (nid), (zone), (start_pfn)) 1802 memmap_init_zone((size), (nid), (zone), (start_pfn))
1800#endif 1803#endif
1801 1804
1802static int __meminit zone_batchsize(struct zone *zone) 1805static int __cpuinit zone_batchsize(struct zone *zone)
1803{ 1806{
1804 int batch; 1807 int batch;
1805 1808
@@ -1886,14 +1889,13 @@ static void setup_pagelist_highmark(struct per_cpu_pageset *p,
1886 * not check if the processor is online before following the pageset pointer. 1889 * not check if the processor is online before following the pageset pointer.
1887 * Other parts of the kernel may not check if the zone is available. 1890 * Other parts of the kernel may not check if the zone is available.
1888 */ 1891 */
1889static struct per_cpu_pageset 1892static struct per_cpu_pageset boot_pageset[NR_CPUS];
1890 boot_pageset[NR_CPUS];
1891 1893
1892/* 1894/*
1893 * Dynamically allocate memory for the 1895 * Dynamically allocate memory for the
1894 * per cpu pageset array in struct zone. 1896 * per cpu pageset array in struct zone.
1895 */ 1897 */
1896static int __meminit process_zones(int cpu) 1898static int __cpuinit process_zones(int cpu)
1897{ 1899{
1898 struct zone *zone, *dzone; 1900 struct zone *zone, *dzone;
1899 1901
@@ -1934,7 +1936,7 @@ static inline void free_zone_pagesets(int cpu)
1934 } 1936 }
1935} 1937}
1936 1938
1937static int __meminit pageset_cpuup_callback(struct notifier_block *nfb, 1939static int __cpuinit pageset_cpuup_callback(struct notifier_block *nfb,
1938 unsigned long action, 1940 unsigned long action,
1939 void *hcpu) 1941 void *hcpu)
1940{ 1942{
diff --git a/mm/rmap.c b/mm/rmap.c
index d85a99d28c03..df2c41c2a9a2 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -52,6 +52,7 @@
52#include <linux/init.h> 52#include <linux/init.h>
53#include <linux/rmap.h> 53#include <linux/rmap.h>
54#include <linux/rcupdate.h> 54#include <linux/rcupdate.h>
55#include <linux/module.h>
55 56
56#include <asm/tlbflush.h> 57#include <asm/tlbflush.h>
57 58
@@ -205,6 +206,36 @@ out:
205 return anon_vma; 206 return anon_vma;
206} 207}
207 208
209#ifdef CONFIG_MIGRATION
210/*
211 * Remove an anonymous page from swap replacing the swap pte's
212 * through real pte's pointing to valid pages and then releasing
213 * the page from the swap cache.
214 *
215 * Must hold page lock on page.
216 */
217void remove_from_swap(struct page *page)
218{
219 struct anon_vma *anon_vma;
220 struct vm_area_struct *vma;
221
222 if (!PageAnon(page) || !PageSwapCache(page))
223 return;
224
225 anon_vma = page_lock_anon_vma(page);
226 if (!anon_vma)
227 return;
228
229 list_for_each_entry(vma, &anon_vma->head, anon_vma_node)
230 remove_vma_swap(vma, page);
231
232 spin_unlock(&anon_vma->lock);
233
234 delete_from_swap_cache(page);
235}
236EXPORT_SYMBOL(remove_from_swap);
237#endif
238
208/* 239/*
209 * At what user virtual address is page expected in vma? 240 * At what user virtual address is page expected in vma?
210 */ 241 */
@@ -541,7 +572,8 @@ void page_remove_rmap(struct page *page)
541 * Subfunctions of try_to_unmap: try_to_unmap_one called 572 * Subfunctions of try_to_unmap: try_to_unmap_one called
542 * repeatedly from either try_to_unmap_anon or try_to_unmap_file. 573 * repeatedly from either try_to_unmap_anon or try_to_unmap_file.
543 */ 574 */
544static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma) 575static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
576 int ignore_refs)
545{ 577{
546 struct mm_struct *mm = vma->vm_mm; 578 struct mm_struct *mm = vma->vm_mm;
547 unsigned long address; 579 unsigned long address;
@@ -564,7 +596,8 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
564 * skipped over this mm) then we should reactivate it. 596 * skipped over this mm) then we should reactivate it.
565 */ 597 */
566 if ((vma->vm_flags & VM_LOCKED) || 598 if ((vma->vm_flags & VM_LOCKED) ||
567 ptep_clear_flush_young(vma, address, pte)) { 599 (ptep_clear_flush_young(vma, address, pte)
600 && !ignore_refs)) {
568 ret = SWAP_FAIL; 601 ret = SWAP_FAIL;
569 goto out_unmap; 602 goto out_unmap;
570 } 603 }
@@ -698,7 +731,7 @@ static void try_to_unmap_cluster(unsigned long cursor,
698 pte_unmap_unlock(pte - 1, ptl); 731 pte_unmap_unlock(pte - 1, ptl);
699} 732}
700 733
701static int try_to_unmap_anon(struct page *page) 734static int try_to_unmap_anon(struct page *page, int ignore_refs)
702{ 735{
703 struct anon_vma *anon_vma; 736 struct anon_vma *anon_vma;
704 struct vm_area_struct *vma; 737 struct vm_area_struct *vma;
@@ -709,7 +742,7 @@ static int try_to_unmap_anon(struct page *page)
709 return ret; 742 return ret;
710 743
711 list_for_each_entry(vma, &anon_vma->head, anon_vma_node) { 744 list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
712 ret = try_to_unmap_one(page, vma); 745 ret = try_to_unmap_one(page, vma, ignore_refs);
713 if (ret == SWAP_FAIL || !page_mapped(page)) 746 if (ret == SWAP_FAIL || !page_mapped(page))
714 break; 747 break;
715 } 748 }
@@ -726,7 +759,7 @@ static int try_to_unmap_anon(struct page *page)
726 * 759 *
727 * This function is only called from try_to_unmap for object-based pages. 760 * This function is only called from try_to_unmap for object-based pages.
728 */ 761 */
729static int try_to_unmap_file(struct page *page) 762static int try_to_unmap_file(struct page *page, int ignore_refs)
730{ 763{
731 struct address_space *mapping = page->mapping; 764 struct address_space *mapping = page->mapping;
732 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); 765 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
@@ -740,7 +773,7 @@ static int try_to_unmap_file(struct page *page)
740 773
741 spin_lock(&mapping->i_mmap_lock); 774 spin_lock(&mapping->i_mmap_lock);
742 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) { 775 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
743 ret = try_to_unmap_one(page, vma); 776 ret = try_to_unmap_one(page, vma, ignore_refs);
744 if (ret == SWAP_FAIL || !page_mapped(page)) 777 if (ret == SWAP_FAIL || !page_mapped(page))
745 goto out; 778 goto out;
746 } 779 }
@@ -825,16 +858,16 @@ out:
825 * SWAP_AGAIN - we missed a mapping, try again later 858 * SWAP_AGAIN - we missed a mapping, try again later
826 * SWAP_FAIL - the page is unswappable 859 * SWAP_FAIL - the page is unswappable
827 */ 860 */
828int try_to_unmap(struct page *page) 861int try_to_unmap(struct page *page, int ignore_refs)
829{ 862{
830 int ret; 863 int ret;
831 864
832 BUG_ON(!PageLocked(page)); 865 BUG_ON(!PageLocked(page));
833 866
834 if (PageAnon(page)) 867 if (PageAnon(page))
835 ret = try_to_unmap_anon(page); 868 ret = try_to_unmap_anon(page, ignore_refs);
836 else 869 else
837 ret = try_to_unmap_file(page); 870 ret = try_to_unmap_file(page, ignore_refs);
838 871
839 if (!page_mapped(page)) 872 if (!page_mapped(page))
840 ret = SWAP_SUCCESS; 873 ret = SWAP_SUCCESS;
diff --git a/mm/shmem.c b/mm/shmem.c
index ce501bce1c2e..f7ac7b812f92 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1028,6 +1028,14 @@ repeat:
1028 page_cache_release(swappage); 1028 page_cache_release(swappage);
1029 goto repeat; 1029 goto repeat;
1030 } 1030 }
1031 if (!PageSwapCache(swappage)) {
1032 /* Page migration has occured */
1033 shmem_swp_unmap(entry);
1034 spin_unlock(&info->lock);
1035 unlock_page(swappage);
1036 page_cache_release(swappage);
1037 goto repeat;
1038 }
1031 if (PageWriteback(swappage)) { 1039 if (PageWriteback(swappage)) {
1032 shmem_swp_unmap(entry); 1040 shmem_swp_unmap(entry);
1033 spin_unlock(&info->lock); 1041 spin_unlock(&info->lock);
diff --git a/mm/slab.c b/mm/slab.c
index 6f8495e2185b..d66c2b0d9715 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -55,7 +55,7 @@
55 * 55 *
56 * SMP synchronization: 56 * SMP synchronization:
57 * constructors and destructors are called without any locking. 57 * constructors and destructors are called without any locking.
58 * Several members in kmem_cache_t and struct slab never change, they 58 * Several members in struct kmem_cache and struct slab never change, they
59 * are accessed without any locking. 59 * are accessed without any locking.
60 * The per-cpu arrays are never accessed from the wrong cpu, no locking, 60 * The per-cpu arrays are never accessed from the wrong cpu, no locking,
61 * and local interrupts are disabled so slab code is preempt-safe. 61 * and local interrupts are disabled so slab code is preempt-safe.
@@ -244,7 +244,7 @@ struct slab {
244 */ 244 */
245struct slab_rcu { 245struct slab_rcu {
246 struct rcu_head head; 246 struct rcu_head head;
247 kmem_cache_t *cachep; 247 struct kmem_cache *cachep;
248 void *addr; 248 void *addr;
249}; 249};
250 250
@@ -294,6 +294,7 @@ struct kmem_list3 {
294 unsigned long next_reap; 294 unsigned long next_reap;
295 int free_touched; 295 int free_touched;
296 unsigned int free_limit; 296 unsigned int free_limit;
297 unsigned int colour_next; /* Per-node cache coloring */
297 spinlock_t list_lock; 298 spinlock_t list_lock;
298 struct array_cache *shared; /* shared per node */ 299 struct array_cache *shared; /* shared per node */
299 struct array_cache **alien; /* on other nodes */ 300 struct array_cache **alien; /* on other nodes */
@@ -316,6 +317,8 @@ struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
316 */ 317 */
317static __always_inline int index_of(const size_t size) 318static __always_inline int index_of(const size_t size)
318{ 319{
320 extern void __bad_size(void);
321
319 if (__builtin_constant_p(size)) { 322 if (__builtin_constant_p(size)) {
320 int i = 0; 323 int i = 0;
321 324
@@ -326,25 +329,23 @@ static __always_inline int index_of(const size_t size)
326 i++; 329 i++;
327#include "linux/kmalloc_sizes.h" 330#include "linux/kmalloc_sizes.h"
328#undef CACHE 331#undef CACHE
329 { 332 __bad_size();
330 extern void __bad_size(void);
331 __bad_size();
332 }
333 } else 333 } else
334 BUG(); 334 __bad_size();
335 return 0; 335 return 0;
336} 336}
337 337
338#define INDEX_AC index_of(sizeof(struct arraycache_init)) 338#define INDEX_AC index_of(sizeof(struct arraycache_init))
339#define INDEX_L3 index_of(sizeof(struct kmem_list3)) 339#define INDEX_L3 index_of(sizeof(struct kmem_list3))
340 340
341static inline void kmem_list3_init(struct kmem_list3 *parent) 341static void kmem_list3_init(struct kmem_list3 *parent)
342{ 342{
343 INIT_LIST_HEAD(&parent->slabs_full); 343 INIT_LIST_HEAD(&parent->slabs_full);
344 INIT_LIST_HEAD(&parent->slabs_partial); 344 INIT_LIST_HEAD(&parent->slabs_partial);
345 INIT_LIST_HEAD(&parent->slabs_free); 345 INIT_LIST_HEAD(&parent->slabs_free);
346 parent->shared = NULL; 346 parent->shared = NULL;
347 parent->alien = NULL; 347 parent->alien = NULL;
348 parent->colour_next = 0;
348 spin_lock_init(&parent->list_lock); 349 spin_lock_init(&parent->list_lock);
349 parent->free_objects = 0; 350 parent->free_objects = 0;
350 parent->free_touched = 0; 351 parent->free_touched = 0;
@@ -364,7 +365,7 @@ static inline void kmem_list3_init(struct kmem_list3 *parent)
364 } while (0) 365 } while (0)
365 366
366/* 367/*
367 * kmem_cache_t 368 * struct kmem_cache
368 * 369 *
369 * manages a cache. 370 * manages a cache.
370 */ 371 */
@@ -375,7 +376,7 @@ struct kmem_cache {
375 unsigned int batchcount; 376 unsigned int batchcount;
376 unsigned int limit; 377 unsigned int limit;
377 unsigned int shared; 378 unsigned int shared;
378 unsigned int objsize; 379 unsigned int buffer_size;
379/* 2) touched by every alloc & free from the backend */ 380/* 2) touched by every alloc & free from the backend */
380 struct kmem_list3 *nodelists[MAX_NUMNODES]; 381 struct kmem_list3 *nodelists[MAX_NUMNODES];
381 unsigned int flags; /* constant flags */ 382 unsigned int flags; /* constant flags */
@@ -391,16 +392,15 @@ struct kmem_cache {
391 392
392 size_t colour; /* cache colouring range */ 393 size_t colour; /* cache colouring range */
393 unsigned int colour_off; /* colour offset */ 394 unsigned int colour_off; /* colour offset */
394 unsigned int colour_next; /* cache colouring */ 395 struct kmem_cache *slabp_cache;
395 kmem_cache_t *slabp_cache;
396 unsigned int slab_size; 396 unsigned int slab_size;
397 unsigned int dflags; /* dynamic flags */ 397 unsigned int dflags; /* dynamic flags */
398 398
399 /* constructor func */ 399 /* constructor func */
400 void (*ctor) (void *, kmem_cache_t *, unsigned long); 400 void (*ctor) (void *, struct kmem_cache *, unsigned long);
401 401
402 /* de-constructor func */ 402 /* de-constructor func */
403 void (*dtor) (void *, kmem_cache_t *, unsigned long); 403 void (*dtor) (void *, struct kmem_cache *, unsigned long);
404 404
405/* 4) cache creation/removal */ 405/* 4) cache creation/removal */
406 const char *name; 406 const char *name;
@@ -423,8 +423,14 @@ struct kmem_cache {
423 atomic_t freemiss; 423 atomic_t freemiss;
424#endif 424#endif
425#if DEBUG 425#if DEBUG
426 int dbghead; 426 /*
427 int reallen; 427 * If debugging is enabled, then the allocator can add additional
428 * fields and/or padding to every object. buffer_size contains the total
429 * object size including these internal fields, the following two
430 * variables contain the offset to the user object and its size.
431 */
432 int obj_offset;
433 int obj_size;
428#endif 434#endif
429}; 435};
430 436
@@ -495,50 +501,50 @@ struct kmem_cache {
495 501
496/* memory layout of objects: 502/* memory layout of objects:
497 * 0 : objp 503 * 0 : objp
498 * 0 .. cachep->dbghead - BYTES_PER_WORD - 1: padding. This ensures that 504 * 0 .. cachep->obj_offset - BYTES_PER_WORD - 1: padding. This ensures that
499 * the end of an object is aligned with the end of the real 505 * the end of an object is aligned with the end of the real
500 * allocation. Catches writes behind the end of the allocation. 506 * allocation. Catches writes behind the end of the allocation.
501 * cachep->dbghead - BYTES_PER_WORD .. cachep->dbghead - 1: 507 * cachep->obj_offset - BYTES_PER_WORD .. cachep->obj_offset - 1:
502 * redzone word. 508 * redzone word.
503 * cachep->dbghead: The real object. 509 * cachep->obj_offset: The real object.
504 * cachep->objsize - 2* BYTES_PER_WORD: redzone word [BYTES_PER_WORD long] 510 * cachep->buffer_size - 2* BYTES_PER_WORD: redzone word [BYTES_PER_WORD long]
505 * cachep->objsize - 1* BYTES_PER_WORD: last caller address [BYTES_PER_WORD long] 511 * cachep->buffer_size - 1* BYTES_PER_WORD: last caller address [BYTES_PER_WORD long]
506 */ 512 */
507static int obj_dbghead(kmem_cache_t *cachep) 513static int obj_offset(struct kmem_cache *cachep)
508{ 514{
509 return cachep->dbghead; 515 return cachep->obj_offset;
510} 516}
511 517
512static int obj_reallen(kmem_cache_t *cachep) 518static int obj_size(struct kmem_cache *cachep)
513{ 519{
514 return cachep->reallen; 520 return cachep->obj_size;
515} 521}
516 522
517static unsigned long *dbg_redzone1(kmem_cache_t *cachep, void *objp) 523static unsigned long *dbg_redzone1(struct kmem_cache *cachep, void *objp)
518{ 524{
519 BUG_ON(!(cachep->flags & SLAB_RED_ZONE)); 525 BUG_ON(!(cachep->flags & SLAB_RED_ZONE));
520 return (unsigned long*) (objp+obj_dbghead(cachep)-BYTES_PER_WORD); 526 return (unsigned long*) (objp+obj_offset(cachep)-BYTES_PER_WORD);
521} 527}
522 528
523static unsigned long *dbg_redzone2(kmem_cache_t *cachep, void *objp) 529static unsigned long *dbg_redzone2(struct kmem_cache *cachep, void *objp)
524{ 530{
525 BUG_ON(!(cachep->flags & SLAB_RED_ZONE)); 531 BUG_ON(!(cachep->flags & SLAB_RED_ZONE));
526 if (cachep->flags & SLAB_STORE_USER) 532 if (cachep->flags & SLAB_STORE_USER)
527 return (unsigned long *)(objp + cachep->objsize - 533 return (unsigned long *)(objp + cachep->buffer_size -
528 2 * BYTES_PER_WORD); 534 2 * BYTES_PER_WORD);
529 return (unsigned long *)(objp + cachep->objsize - BYTES_PER_WORD); 535 return (unsigned long *)(objp + cachep->buffer_size - BYTES_PER_WORD);
530} 536}
531 537
532static void **dbg_userword(kmem_cache_t *cachep, void *objp) 538static void **dbg_userword(struct kmem_cache *cachep, void *objp)
533{ 539{
534 BUG_ON(!(cachep->flags & SLAB_STORE_USER)); 540 BUG_ON(!(cachep->flags & SLAB_STORE_USER));
535 return (void **)(objp + cachep->objsize - BYTES_PER_WORD); 541 return (void **)(objp + cachep->buffer_size - BYTES_PER_WORD);
536} 542}
537 543
538#else 544#else
539 545
540#define obj_dbghead(x) 0 546#define obj_offset(x) 0
541#define obj_reallen(cachep) (cachep->objsize) 547#define obj_size(cachep) (cachep->buffer_size)
542#define dbg_redzone1(cachep, objp) ({BUG(); (unsigned long *)NULL;}) 548#define dbg_redzone1(cachep, objp) ({BUG(); (unsigned long *)NULL;})
543#define dbg_redzone2(cachep, objp) ({BUG(); (unsigned long *)NULL;}) 549#define dbg_redzone2(cachep, objp) ({BUG(); (unsigned long *)NULL;})
544#define dbg_userword(cachep, objp) ({BUG(); (void **)NULL;}) 550#define dbg_userword(cachep, objp) ({BUG(); (void **)NULL;})
@@ -591,6 +597,18 @@ static inline struct slab *page_get_slab(struct page *page)
591 return (struct slab *)page->lru.prev; 597 return (struct slab *)page->lru.prev;
592} 598}
593 599
600static inline struct kmem_cache *virt_to_cache(const void *obj)
601{
602 struct page *page = virt_to_page(obj);
603 return page_get_cache(page);
604}
605
606static inline struct slab *virt_to_slab(const void *obj)
607{
608 struct page *page = virt_to_page(obj);
609 return page_get_slab(page);
610}
611
594/* These are the default caches for kmalloc. Custom caches can have other sizes. */ 612/* These are the default caches for kmalloc. Custom caches can have other sizes. */
595struct cache_sizes malloc_sizes[] = { 613struct cache_sizes malloc_sizes[] = {
596#define CACHE(x) { .cs_size = (x) }, 614#define CACHE(x) { .cs_size = (x) },
@@ -619,16 +637,16 @@ static struct arraycache_init initarray_generic =
619 { {0, BOOT_CPUCACHE_ENTRIES, 1, 0} }; 637 { {0, BOOT_CPUCACHE_ENTRIES, 1, 0} };
620 638
621/* internal cache of cache description objs */ 639/* internal cache of cache description objs */
622static kmem_cache_t cache_cache = { 640static struct kmem_cache cache_cache = {
623 .batchcount = 1, 641 .batchcount = 1,
624 .limit = BOOT_CPUCACHE_ENTRIES, 642 .limit = BOOT_CPUCACHE_ENTRIES,
625 .shared = 1, 643 .shared = 1,
626 .objsize = sizeof(kmem_cache_t), 644 .buffer_size = sizeof(struct kmem_cache),
627 .flags = SLAB_NO_REAP, 645 .flags = SLAB_NO_REAP,
628 .spinlock = SPIN_LOCK_UNLOCKED, 646 .spinlock = SPIN_LOCK_UNLOCKED,
629 .name = "kmem_cache", 647 .name = "kmem_cache",
630#if DEBUG 648#if DEBUG
631 .reallen = sizeof(kmem_cache_t), 649 .obj_size = sizeof(struct kmem_cache),
632#endif 650#endif
633}; 651};
634 652
@@ -657,17 +675,17 @@ static enum {
657 675
658static DEFINE_PER_CPU(struct work_struct, reap_work); 676static DEFINE_PER_CPU(struct work_struct, reap_work);
659 677
660static void free_block(kmem_cache_t *cachep, void **objpp, int len, int node); 678static void free_block(struct kmem_cache *cachep, void **objpp, int len, int node);
661static void enable_cpucache(kmem_cache_t *cachep); 679static void enable_cpucache(struct kmem_cache *cachep);
662static void cache_reap(void *unused); 680static void cache_reap(void *unused);
663static int __node_shrink(kmem_cache_t *cachep, int node); 681static int __node_shrink(struct kmem_cache *cachep, int node);
664 682
665static inline struct array_cache *ac_data(kmem_cache_t *cachep) 683static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep)
666{ 684{
667 return cachep->array[smp_processor_id()]; 685 return cachep->array[smp_processor_id()];
668} 686}
669 687
670static inline kmem_cache_t *__find_general_cachep(size_t size, gfp_t gfpflags) 688static inline struct kmem_cache *__find_general_cachep(size_t size, gfp_t gfpflags)
671{ 689{
672 struct cache_sizes *csizep = malloc_sizes; 690 struct cache_sizes *csizep = malloc_sizes;
673 691
@@ -691,43 +709,80 @@ static inline kmem_cache_t *__find_general_cachep(size_t size, gfp_t gfpflags)
691 return csizep->cs_cachep; 709 return csizep->cs_cachep;
692} 710}
693 711
694kmem_cache_t *kmem_find_general_cachep(size_t size, gfp_t gfpflags) 712struct kmem_cache *kmem_find_general_cachep(size_t size, gfp_t gfpflags)
695{ 713{
696 return __find_general_cachep(size, gfpflags); 714 return __find_general_cachep(size, gfpflags);
697} 715}
698EXPORT_SYMBOL(kmem_find_general_cachep); 716EXPORT_SYMBOL(kmem_find_general_cachep);
699 717
700/* Cal the num objs, wastage, and bytes left over for a given slab size. */ 718static size_t slab_mgmt_size(size_t nr_objs, size_t align)
701static void cache_estimate(unsigned long gfporder, size_t size, size_t align,
702 int flags, size_t *left_over, unsigned int *num)
703{ 719{
704 int i; 720 return ALIGN(sizeof(struct slab)+nr_objs*sizeof(kmem_bufctl_t), align);
705 size_t wastage = PAGE_SIZE << gfporder; 721}
706 size_t extra = 0;
707 size_t base = 0;
708 722
709 if (!(flags & CFLGS_OFF_SLAB)) { 723/* Calculate the number of objects and left-over bytes for a given
710 base = sizeof(struct slab); 724 buffer size. */
711 extra = sizeof(kmem_bufctl_t); 725static void cache_estimate(unsigned long gfporder, size_t buffer_size,
712 } 726 size_t align, int flags, size_t *left_over,
713 i = 0; 727 unsigned int *num)
714 while (i * size + ALIGN(base + i * extra, align) <= wastage) 728{
715 i++; 729 int nr_objs;
716 if (i > 0) 730 size_t mgmt_size;
717 i--; 731 size_t slab_size = PAGE_SIZE << gfporder;
732
733 /*
734 * The slab management structure can be either off the slab or
735 * on it. For the latter case, the memory allocated for a
736 * slab is used for:
737 *
738 * - The struct slab
739 * - One kmem_bufctl_t for each object
740 * - Padding to respect alignment of @align
741 * - @buffer_size bytes for each object
742 *
743 * If the slab management structure is off the slab, then the
744 * alignment will already be calculated into the size. Because
745 * the slabs are all pages aligned, the objects will be at the
746 * correct alignment when allocated.
747 */
748 if (flags & CFLGS_OFF_SLAB) {
749 mgmt_size = 0;
750 nr_objs = slab_size / buffer_size;
751
752 if (nr_objs > SLAB_LIMIT)
753 nr_objs = SLAB_LIMIT;
754 } else {
755 /*
756 * Ignore padding for the initial guess. The padding
757 * is at most @align-1 bytes, and @buffer_size is at
758 * least @align. In the worst case, this result will
759 * be one greater than the number of objects that fit
760 * into the memory allocation when taking the padding
761 * into account.
762 */
763 nr_objs = (slab_size - sizeof(struct slab)) /
764 (buffer_size + sizeof(kmem_bufctl_t));
765
766 /*
767 * This calculated number will be either the right
768 * amount, or one greater than what we want.
769 */
770 if (slab_mgmt_size(nr_objs, align) + nr_objs*buffer_size
771 > slab_size)
772 nr_objs--;
718 773
719 if (i > SLAB_LIMIT) 774 if (nr_objs > SLAB_LIMIT)
720 i = SLAB_LIMIT; 775 nr_objs = SLAB_LIMIT;
721 776
722 *num = i; 777 mgmt_size = slab_mgmt_size(nr_objs, align);
723 wastage -= i * size; 778 }
724 wastage -= ALIGN(base + i * extra, align); 779 *num = nr_objs;
725 *left_over = wastage; 780 *left_over = slab_size - nr_objs*buffer_size - mgmt_size;
726} 781}
727 782
728#define slab_error(cachep, msg) __slab_error(__FUNCTION__, cachep, msg) 783#define slab_error(cachep, msg) __slab_error(__FUNCTION__, cachep, msg)
729 784
730static void __slab_error(const char *function, kmem_cache_t *cachep, char *msg) 785static void __slab_error(const char *function, struct kmem_cache *cachep, char *msg)
731{ 786{
732 printk(KERN_ERR "slab error in %s(): cache `%s': %s\n", 787 printk(KERN_ERR "slab error in %s(): cache `%s': %s\n",
733 function, cachep->name, msg); 788 function, cachep->name, msg);
@@ -774,9 +829,9 @@ static struct array_cache *alloc_arraycache(int node, int entries,
774} 829}
775 830
776#ifdef CONFIG_NUMA 831#ifdef CONFIG_NUMA
777static void *__cache_alloc_node(kmem_cache_t *, gfp_t, int); 832static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int);
778 833
779static inline struct array_cache **alloc_alien_cache(int node, int limit) 834static struct array_cache **alloc_alien_cache(int node, int limit)
780{ 835{
781 struct array_cache **ac_ptr; 836 struct array_cache **ac_ptr;
782 int memsize = sizeof(void *) * MAX_NUMNODES; 837 int memsize = sizeof(void *) * MAX_NUMNODES;
@@ -803,7 +858,7 @@ static inline struct array_cache **alloc_alien_cache(int node, int limit)
803 return ac_ptr; 858 return ac_ptr;
804} 859}
805 860
806static inline void free_alien_cache(struct array_cache **ac_ptr) 861static void free_alien_cache(struct array_cache **ac_ptr)
807{ 862{
808 int i; 863 int i;
809 864
@@ -816,8 +871,8 @@ static inline void free_alien_cache(struct array_cache **ac_ptr)
816 kfree(ac_ptr); 871 kfree(ac_ptr);
817} 872}
818 873
819static inline void __drain_alien_cache(kmem_cache_t *cachep, 874static void __drain_alien_cache(struct kmem_cache *cachep,
820 struct array_cache *ac, int node) 875 struct array_cache *ac, int node)
821{ 876{
822 struct kmem_list3 *rl3 = cachep->nodelists[node]; 877 struct kmem_list3 *rl3 = cachep->nodelists[node];
823 878
@@ -829,14 +884,14 @@ static inline void __drain_alien_cache(kmem_cache_t *cachep,
829 } 884 }
830} 885}
831 886
832static void drain_alien_cache(kmem_cache_t *cachep, struct kmem_list3 *l3) 887static void drain_alien_cache(struct kmem_cache *cachep, struct array_cache **alien)
833{ 888{
834 int i = 0; 889 int i = 0;
835 struct array_cache *ac; 890 struct array_cache *ac;
836 unsigned long flags; 891 unsigned long flags;
837 892
838 for_each_online_node(i) { 893 for_each_online_node(i) {
839 ac = l3->alien[i]; 894 ac = alien[i];
840 if (ac) { 895 if (ac) {
841 spin_lock_irqsave(&ac->lock, flags); 896 spin_lock_irqsave(&ac->lock, flags);
842 __drain_alien_cache(cachep, ac, i); 897 __drain_alien_cache(cachep, ac, i);
@@ -845,16 +900,25 @@ static void drain_alien_cache(kmem_cache_t *cachep, struct kmem_list3 *l3)
845 } 900 }
846} 901}
847#else 902#else
848#define alloc_alien_cache(node, limit) do { } while (0) 903
849#define free_alien_cache(ac_ptr) do { } while (0) 904#define drain_alien_cache(cachep, alien) do { } while (0)
850#define drain_alien_cache(cachep, l3) do { } while (0) 905
906static inline struct array_cache **alloc_alien_cache(int node, int limit)
907{
908 return (struct array_cache **) 0x01020304ul;
909}
910
911static inline void free_alien_cache(struct array_cache **ac_ptr)
912{
913}
914
851#endif 915#endif
852 916
853static int __devinit cpuup_callback(struct notifier_block *nfb, 917static int __devinit cpuup_callback(struct notifier_block *nfb,
854 unsigned long action, void *hcpu) 918 unsigned long action, void *hcpu)
855{ 919{
856 long cpu = (long)hcpu; 920 long cpu = (long)hcpu;
857 kmem_cache_t *cachep; 921 struct kmem_cache *cachep;
858 struct kmem_list3 *l3 = NULL; 922 struct kmem_list3 *l3 = NULL;
859 int node = cpu_to_node(cpu); 923 int node = cpu_to_node(cpu);
860 int memsize = sizeof(struct kmem_list3); 924 int memsize = sizeof(struct kmem_list3);
@@ -881,6 +945,11 @@ static int __devinit cpuup_callback(struct notifier_block *nfb,
881 l3->next_reap = jiffies + REAPTIMEOUT_LIST3 + 945 l3->next_reap = jiffies + REAPTIMEOUT_LIST3 +
882 ((unsigned long)cachep) % REAPTIMEOUT_LIST3; 946 ((unsigned long)cachep) % REAPTIMEOUT_LIST3;
883 947
948 /*
949 * The l3s don't come and go as CPUs come and
950 * go. cache_chain_mutex is sufficient
951 * protection here.
952 */
884 cachep->nodelists[node] = l3; 953 cachep->nodelists[node] = l3;
885 } 954 }
886 955
@@ -895,26 +964,46 @@ static int __devinit cpuup_callback(struct notifier_block *nfb,
895 & array cache's */ 964 & array cache's */
896 list_for_each_entry(cachep, &cache_chain, next) { 965 list_for_each_entry(cachep, &cache_chain, next) {
897 struct array_cache *nc; 966 struct array_cache *nc;
967 struct array_cache *shared;
968 struct array_cache **alien;
898 969
899 nc = alloc_arraycache(node, cachep->limit, 970 nc = alloc_arraycache(node, cachep->limit,
900 cachep->batchcount); 971 cachep->batchcount);
901 if (!nc) 972 if (!nc)
902 goto bad; 973 goto bad;
974 shared = alloc_arraycache(node,
975 cachep->shared * cachep->batchcount,
976 0xbaadf00d);
977 if (!shared)
978 goto bad;
979
980 alien = alloc_alien_cache(node, cachep->limit);
981 if (!alien)
982 goto bad;
903 cachep->array[cpu] = nc; 983 cachep->array[cpu] = nc;
904 984
905 l3 = cachep->nodelists[node]; 985 l3 = cachep->nodelists[node];
906 BUG_ON(!l3); 986 BUG_ON(!l3);
907 if (!l3->shared) {
908 if (!(nc = alloc_arraycache(node,
909 cachep->shared *
910 cachep->batchcount,
911 0xbaadf00d)))
912 goto bad;
913 987
914 /* we are serialised from CPU_DEAD or 988 spin_lock_irq(&l3->list_lock);
915 CPU_UP_CANCELLED by the cpucontrol lock */ 989 if (!l3->shared) {
916 l3->shared = nc; 990 /*
991 * We are serialised from CPU_DEAD or
992 * CPU_UP_CANCELLED by the cpucontrol lock
993 */
994 l3->shared = shared;
995 shared = NULL;
996 }
997#ifdef CONFIG_NUMA
998 if (!l3->alien) {
999 l3->alien = alien;
1000 alien = NULL;
917 } 1001 }
1002#endif
1003 spin_unlock_irq(&l3->list_lock);
1004
1005 kfree(shared);
1006 free_alien_cache(alien);
918 } 1007 }
919 mutex_unlock(&cache_chain_mutex); 1008 mutex_unlock(&cache_chain_mutex);
920 break; 1009 break;
@@ -923,25 +1012,34 @@ static int __devinit cpuup_callback(struct notifier_block *nfb,
923 break; 1012 break;
924#ifdef CONFIG_HOTPLUG_CPU 1013#ifdef CONFIG_HOTPLUG_CPU
925 case CPU_DEAD: 1014 case CPU_DEAD:
1015 /*
1016 * Even if all the cpus of a node are down, we don't free the
1017 * kmem_list3 of any cache. This to avoid a race between
1018 * cpu_down, and a kmalloc allocation from another cpu for
1019 * memory from the node of the cpu going down. The list3
1020 * structure is usually allocated from kmem_cache_create() and
1021 * gets destroyed at kmem_cache_destroy().
1022 */
926 /* fall thru */ 1023 /* fall thru */
927 case CPU_UP_CANCELED: 1024 case CPU_UP_CANCELED:
928 mutex_lock(&cache_chain_mutex); 1025 mutex_lock(&cache_chain_mutex);
929 1026
930 list_for_each_entry(cachep, &cache_chain, next) { 1027 list_for_each_entry(cachep, &cache_chain, next) {
931 struct array_cache *nc; 1028 struct array_cache *nc;
1029 struct array_cache *shared;
1030 struct array_cache **alien;
932 cpumask_t mask; 1031 cpumask_t mask;
933 1032
934 mask = node_to_cpumask(node); 1033 mask = node_to_cpumask(node);
935 spin_lock_irq(&cachep->spinlock);
936 /* cpu is dead; no one can alloc from it. */ 1034 /* cpu is dead; no one can alloc from it. */
937 nc = cachep->array[cpu]; 1035 nc = cachep->array[cpu];
938 cachep->array[cpu] = NULL; 1036 cachep->array[cpu] = NULL;
939 l3 = cachep->nodelists[node]; 1037 l3 = cachep->nodelists[node];
940 1038
941 if (!l3) 1039 if (!l3)
942 goto unlock_cache; 1040 goto free_array_cache;
943 1041
944 spin_lock(&l3->list_lock); 1042 spin_lock_irq(&l3->list_lock);
945 1043
946 /* Free limit for this kmem_list3 */ 1044 /* Free limit for this kmem_list3 */
947 l3->free_limit -= cachep->batchcount; 1045 l3->free_limit -= cachep->batchcount;
@@ -949,34 +1047,44 @@ static int __devinit cpuup_callback(struct notifier_block *nfb,
949 free_block(cachep, nc->entry, nc->avail, node); 1047 free_block(cachep, nc->entry, nc->avail, node);
950 1048
951 if (!cpus_empty(mask)) { 1049 if (!cpus_empty(mask)) {
952 spin_unlock(&l3->list_lock); 1050 spin_unlock_irq(&l3->list_lock);
953 goto unlock_cache; 1051 goto free_array_cache;
954 } 1052 }
955 1053
956 if (l3->shared) { 1054 shared = l3->shared;
1055 if (shared) {
957 free_block(cachep, l3->shared->entry, 1056 free_block(cachep, l3->shared->entry,
958 l3->shared->avail, node); 1057 l3->shared->avail, node);
959 kfree(l3->shared);
960 l3->shared = NULL; 1058 l3->shared = NULL;
961 } 1059 }
962 if (l3->alien) {
963 drain_alien_cache(cachep, l3);
964 free_alien_cache(l3->alien);
965 l3->alien = NULL;
966 }
967 1060
968 /* free slabs belonging to this node */ 1061 alien = l3->alien;
969 if (__node_shrink(cachep, node)) { 1062 l3->alien = NULL;
970 cachep->nodelists[node] = NULL; 1063
971 spin_unlock(&l3->list_lock); 1064 spin_unlock_irq(&l3->list_lock);
972 kfree(l3); 1065
973 } else { 1066 kfree(shared);
974 spin_unlock(&l3->list_lock); 1067 if (alien) {
1068 drain_alien_cache(cachep, alien);
1069 free_alien_cache(alien);
975 } 1070 }
976 unlock_cache: 1071free_array_cache:
977 spin_unlock_irq(&cachep->spinlock);
978 kfree(nc); 1072 kfree(nc);
979 } 1073 }
1074 /*
1075 * In the previous loop, all the objects were freed to
1076 * the respective cache's slabs, now we can go ahead and
1077 * shrink each nodelist to its limit.
1078 */
1079 list_for_each_entry(cachep, &cache_chain, next) {
1080 l3 = cachep->nodelists[node];
1081 if (!l3)
1082 continue;
1083 spin_lock_irq(&l3->list_lock);
1084 /* free slabs belonging to this node */
1085 __node_shrink(cachep, node);
1086 spin_unlock_irq(&l3->list_lock);
1087 }
980 mutex_unlock(&cache_chain_mutex); 1088 mutex_unlock(&cache_chain_mutex);
981 break; 1089 break;
982#endif 1090#endif
@@ -992,7 +1100,7 @@ static struct notifier_block cpucache_notifier = { &cpuup_callback, NULL, 0 };
992/* 1100/*
993 * swap the static kmem_list3 with kmalloced memory 1101 * swap the static kmem_list3 with kmalloced memory
994 */ 1102 */
995static void init_list(kmem_cache_t *cachep, struct kmem_list3 *list, int nodeid) 1103static void init_list(struct kmem_cache *cachep, struct kmem_list3 *list, int nodeid)
996{ 1104{
997 struct kmem_list3 *ptr; 1105 struct kmem_list3 *ptr;
998 1106
@@ -1032,14 +1140,14 @@ void __init kmem_cache_init(void)
1032 1140
1033 /* Bootstrap is tricky, because several objects are allocated 1141 /* Bootstrap is tricky, because several objects are allocated
1034 * from caches that do not exist yet: 1142 * from caches that do not exist yet:
1035 * 1) initialize the cache_cache cache: it contains the kmem_cache_t 1143 * 1) initialize the cache_cache cache: it contains the struct kmem_cache
1036 * structures of all caches, except cache_cache itself: cache_cache 1144 * structures of all caches, except cache_cache itself: cache_cache
1037 * is statically allocated. 1145 * is statically allocated.
1038 * Initially an __init data area is used for the head array and the 1146 * Initially an __init data area is used for the head array and the
1039 * kmem_list3 structures, it's replaced with a kmalloc allocated 1147 * kmem_list3 structures, it's replaced with a kmalloc allocated
1040 * array at the end of the bootstrap. 1148 * array at the end of the bootstrap.
1041 * 2) Create the first kmalloc cache. 1149 * 2) Create the first kmalloc cache.
1042 * The kmem_cache_t for the new cache is allocated normally. 1150 * The struct kmem_cache for the new cache is allocated normally.
1043 * An __init data area is used for the head array. 1151 * An __init data area is used for the head array.
1044 * 3) Create the remaining kmalloc caches, with minimally sized 1152 * 3) Create the remaining kmalloc caches, with minimally sized
1045 * head arrays. 1153 * head arrays.
@@ -1057,15 +1165,14 @@ void __init kmem_cache_init(void)
1057 cache_cache.array[smp_processor_id()] = &initarray_cache.cache; 1165 cache_cache.array[smp_processor_id()] = &initarray_cache.cache;
1058 cache_cache.nodelists[numa_node_id()] = &initkmem_list3[CACHE_CACHE]; 1166 cache_cache.nodelists[numa_node_id()] = &initkmem_list3[CACHE_CACHE];
1059 1167
1060 cache_cache.objsize = ALIGN(cache_cache.objsize, cache_line_size()); 1168 cache_cache.buffer_size = ALIGN(cache_cache.buffer_size, cache_line_size());
1061 1169
1062 cache_estimate(0, cache_cache.objsize, cache_line_size(), 0, 1170 cache_estimate(0, cache_cache.buffer_size, cache_line_size(), 0,
1063 &left_over, &cache_cache.num); 1171 &left_over, &cache_cache.num);
1064 if (!cache_cache.num) 1172 if (!cache_cache.num)
1065 BUG(); 1173 BUG();
1066 1174
1067 cache_cache.colour = left_over / cache_cache.colour_off; 1175 cache_cache.colour = left_over / cache_cache.colour_off;
1068 cache_cache.colour_next = 0;
1069 cache_cache.slab_size = ALIGN(cache_cache.num * sizeof(kmem_bufctl_t) + 1176 cache_cache.slab_size = ALIGN(cache_cache.num * sizeof(kmem_bufctl_t) +
1070 sizeof(struct slab), cache_line_size()); 1177 sizeof(struct slab), cache_line_size());
1071 1178
@@ -1132,8 +1239,8 @@ void __init kmem_cache_init(void)
1132 ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); 1239 ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL);
1133 1240
1134 local_irq_disable(); 1241 local_irq_disable();
1135 BUG_ON(ac_data(&cache_cache) != &initarray_cache.cache); 1242 BUG_ON(cpu_cache_get(&cache_cache) != &initarray_cache.cache);
1136 memcpy(ptr, ac_data(&cache_cache), 1243 memcpy(ptr, cpu_cache_get(&cache_cache),
1137 sizeof(struct arraycache_init)); 1244 sizeof(struct arraycache_init));
1138 cache_cache.array[smp_processor_id()] = ptr; 1245 cache_cache.array[smp_processor_id()] = ptr;
1139 local_irq_enable(); 1246 local_irq_enable();
@@ -1141,9 +1248,9 @@ void __init kmem_cache_init(void)
1141 ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL); 1248 ptr = kmalloc(sizeof(struct arraycache_init), GFP_KERNEL);
1142 1249
1143 local_irq_disable(); 1250 local_irq_disable();
1144 BUG_ON(ac_data(malloc_sizes[INDEX_AC].cs_cachep) 1251 BUG_ON(cpu_cache_get(malloc_sizes[INDEX_AC].cs_cachep)
1145 != &initarray_generic.cache); 1252 != &initarray_generic.cache);
1146 memcpy(ptr, ac_data(malloc_sizes[INDEX_AC].cs_cachep), 1253 memcpy(ptr, cpu_cache_get(malloc_sizes[INDEX_AC].cs_cachep),
1147 sizeof(struct arraycache_init)); 1254 sizeof(struct arraycache_init));
1148 malloc_sizes[INDEX_AC].cs_cachep->array[smp_processor_id()] = 1255 malloc_sizes[INDEX_AC].cs_cachep->array[smp_processor_id()] =
1149 ptr; 1256 ptr;
@@ -1170,7 +1277,7 @@ void __init kmem_cache_init(void)
1170 1277
1171 /* 6) resize the head arrays to their final sizes */ 1278 /* 6) resize the head arrays to their final sizes */
1172 { 1279 {
1173 kmem_cache_t *cachep; 1280 struct kmem_cache *cachep;
1174 mutex_lock(&cache_chain_mutex); 1281 mutex_lock(&cache_chain_mutex);
1175 list_for_each_entry(cachep, &cache_chain, next) 1282 list_for_each_entry(cachep, &cache_chain, next)
1176 enable_cpucache(cachep); 1283 enable_cpucache(cachep);
@@ -1181,7 +1288,7 @@ void __init kmem_cache_init(void)
1181 g_cpucache_up = FULL; 1288 g_cpucache_up = FULL;
1182 1289
1183 /* Register a cpu startup notifier callback 1290 /* Register a cpu startup notifier callback
1184 * that initializes ac_data for all new cpus 1291 * that initializes cpu_cache_get for all new cpus
1185 */ 1292 */
1186 register_cpu_notifier(&cpucache_notifier); 1293 register_cpu_notifier(&cpucache_notifier);
1187 1294
@@ -1213,7 +1320,7 @@ __initcall(cpucache_init);
1213 * did not request dmaable memory, we might get it, but that 1320 * did not request dmaable memory, we might get it, but that
1214 * would be relatively rare and ignorable. 1321 * would be relatively rare and ignorable.
1215 */ 1322 */
1216static void *kmem_getpages(kmem_cache_t *cachep, gfp_t flags, int nodeid) 1323static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid)
1217{ 1324{
1218 struct page *page; 1325 struct page *page;
1219 void *addr; 1326 void *addr;
@@ -1239,7 +1346,7 @@ static void *kmem_getpages(kmem_cache_t *cachep, gfp_t flags, int nodeid)
1239/* 1346/*
1240 * Interface to system's page release. 1347 * Interface to system's page release.
1241 */ 1348 */
1242static void kmem_freepages(kmem_cache_t *cachep, void *addr) 1349static void kmem_freepages(struct kmem_cache *cachep, void *addr)
1243{ 1350{
1244 unsigned long i = (1 << cachep->gfporder); 1351 unsigned long i = (1 << cachep->gfporder);
1245 struct page *page = virt_to_page(addr); 1352 struct page *page = virt_to_page(addr);
@@ -1261,7 +1368,7 @@ static void kmem_freepages(kmem_cache_t *cachep, void *addr)
1261static void kmem_rcu_free(struct rcu_head *head) 1368static void kmem_rcu_free(struct rcu_head *head)
1262{ 1369{
1263 struct slab_rcu *slab_rcu = (struct slab_rcu *)head; 1370 struct slab_rcu *slab_rcu = (struct slab_rcu *)head;
1264 kmem_cache_t *cachep = slab_rcu->cachep; 1371 struct kmem_cache *cachep = slab_rcu->cachep;
1265 1372
1266 kmem_freepages(cachep, slab_rcu->addr); 1373 kmem_freepages(cachep, slab_rcu->addr);
1267 if (OFF_SLAB(cachep)) 1374 if (OFF_SLAB(cachep))
@@ -1271,12 +1378,12 @@ static void kmem_rcu_free(struct rcu_head *head)
1271#if DEBUG 1378#if DEBUG
1272 1379
1273#ifdef CONFIG_DEBUG_PAGEALLOC 1380#ifdef CONFIG_DEBUG_PAGEALLOC
1274static void store_stackinfo(kmem_cache_t *cachep, unsigned long *addr, 1381static void store_stackinfo(struct kmem_cache *cachep, unsigned long *addr,
1275 unsigned long caller) 1382 unsigned long caller)
1276{ 1383{
1277 int size = obj_reallen(cachep); 1384 int size = obj_size(cachep);
1278 1385
1279 addr = (unsigned long *)&((char *)addr)[obj_dbghead(cachep)]; 1386 addr = (unsigned long *)&((char *)addr)[obj_offset(cachep)];
1280 1387
1281 if (size < 5 * sizeof(unsigned long)) 1388 if (size < 5 * sizeof(unsigned long))
1282 return; 1389 return;
@@ -1304,10 +1411,10 @@ static void store_stackinfo(kmem_cache_t *cachep, unsigned long *addr,
1304} 1411}
1305#endif 1412#endif
1306 1413
1307static void poison_obj(kmem_cache_t *cachep, void *addr, unsigned char val) 1414static void poison_obj(struct kmem_cache *cachep, void *addr, unsigned char val)
1308{ 1415{
1309 int size = obj_reallen(cachep); 1416 int size = obj_size(cachep);
1310 addr = &((char *)addr)[obj_dbghead(cachep)]; 1417 addr = &((char *)addr)[obj_offset(cachep)];
1311 1418
1312 memset(addr, val, size); 1419 memset(addr, val, size);
1313 *(unsigned char *)(addr + size - 1) = POISON_END; 1420 *(unsigned char *)(addr + size - 1) = POISON_END;
@@ -1326,7 +1433,7 @@ static void dump_line(char *data, int offset, int limit)
1326 1433
1327#if DEBUG 1434#if DEBUG
1328 1435
1329static void print_objinfo(kmem_cache_t *cachep, void *objp, int lines) 1436static void print_objinfo(struct kmem_cache *cachep, void *objp, int lines)
1330{ 1437{
1331 int i, size; 1438 int i, size;
1332 char *realobj; 1439 char *realobj;
@@ -1344,8 +1451,8 @@ static void print_objinfo(kmem_cache_t *cachep, void *objp, int lines)
1344 (unsigned long)*dbg_userword(cachep, objp)); 1451 (unsigned long)*dbg_userword(cachep, objp));
1345 printk("\n"); 1452 printk("\n");
1346 } 1453 }
1347 realobj = (char *)objp + obj_dbghead(cachep); 1454 realobj = (char *)objp + obj_offset(cachep);
1348 size = obj_reallen(cachep); 1455 size = obj_size(cachep);
1349 for (i = 0; i < size && lines; i += 16, lines--) { 1456 for (i = 0; i < size && lines; i += 16, lines--) {
1350 int limit; 1457 int limit;
1351 limit = 16; 1458 limit = 16;
@@ -1355,14 +1462,14 @@ static void print_objinfo(kmem_cache_t *cachep, void *objp, int lines)
1355 } 1462 }
1356} 1463}
1357 1464
1358static void check_poison_obj(kmem_cache_t *cachep, void *objp) 1465static void check_poison_obj(struct kmem_cache *cachep, void *objp)
1359{ 1466{
1360 char *realobj; 1467 char *realobj;
1361 int size, i; 1468 int size, i;
1362 int lines = 0; 1469 int lines = 0;
1363 1470
1364 realobj = (char *)objp + obj_dbghead(cachep); 1471 realobj = (char *)objp + obj_offset(cachep);
1365 size = obj_reallen(cachep); 1472 size = obj_size(cachep);
1366 1473
1367 for (i = 0; i < size; i++) { 1474 for (i = 0; i < size; i++) {
1368 char exp = POISON_FREE; 1475 char exp = POISON_FREE;
@@ -1395,20 +1502,20 @@ static void check_poison_obj(kmem_cache_t *cachep, void *objp)
1395 /* Print some data about the neighboring objects, if they 1502 /* Print some data about the neighboring objects, if they
1396 * exist: 1503 * exist:
1397 */ 1504 */
1398 struct slab *slabp = page_get_slab(virt_to_page(objp)); 1505 struct slab *slabp = virt_to_slab(objp);
1399 int objnr; 1506 int objnr;
1400 1507
1401 objnr = (objp - slabp->s_mem) / cachep->objsize; 1508 objnr = (unsigned)(objp - slabp->s_mem) / cachep->buffer_size;
1402 if (objnr) { 1509 if (objnr) {
1403 objp = slabp->s_mem + (objnr - 1) * cachep->objsize; 1510 objp = slabp->s_mem + (objnr - 1) * cachep->buffer_size;
1404 realobj = (char *)objp + obj_dbghead(cachep); 1511 realobj = (char *)objp + obj_offset(cachep);
1405 printk(KERN_ERR "Prev obj: start=%p, len=%d\n", 1512 printk(KERN_ERR "Prev obj: start=%p, len=%d\n",
1406 realobj, size); 1513 realobj, size);
1407 print_objinfo(cachep, objp, 2); 1514 print_objinfo(cachep, objp, 2);
1408 } 1515 }
1409 if (objnr + 1 < cachep->num) { 1516 if (objnr + 1 < cachep->num) {
1410 objp = slabp->s_mem + (objnr + 1) * cachep->objsize; 1517 objp = slabp->s_mem + (objnr + 1) * cachep->buffer_size;
1411 realobj = (char *)objp + obj_dbghead(cachep); 1518 realobj = (char *)objp + obj_offset(cachep);
1412 printk(KERN_ERR "Next obj: start=%p, len=%d\n", 1519 printk(KERN_ERR "Next obj: start=%p, len=%d\n",
1413 realobj, size); 1520 realobj, size);
1414 print_objinfo(cachep, objp, 2); 1521 print_objinfo(cachep, objp, 2);
@@ -1417,25 +1524,23 @@ static void check_poison_obj(kmem_cache_t *cachep, void *objp)
1417} 1524}
1418#endif 1525#endif
1419 1526
1420/* Destroy all the objs in a slab, and release the mem back to the system. 1527#if DEBUG
1421 * Before calling the slab must have been unlinked from the cache. 1528/**
1422 * The cache-lock is not held/needed. 1529 * slab_destroy_objs - call the registered destructor for each object in
1530 * a slab that is to be destroyed.
1423 */ 1531 */
1424static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp) 1532static void slab_destroy_objs(struct kmem_cache *cachep, struct slab *slabp)
1425{ 1533{
1426 void *addr = slabp->s_mem - slabp->colouroff;
1427
1428#if DEBUG
1429 int i; 1534 int i;
1430 for (i = 0; i < cachep->num; i++) { 1535 for (i = 0; i < cachep->num; i++) {
1431 void *objp = slabp->s_mem + cachep->objsize * i; 1536 void *objp = slabp->s_mem + cachep->buffer_size * i;
1432 1537
1433 if (cachep->flags & SLAB_POISON) { 1538 if (cachep->flags & SLAB_POISON) {
1434#ifdef CONFIG_DEBUG_PAGEALLOC 1539#ifdef CONFIG_DEBUG_PAGEALLOC
1435 if ((cachep->objsize % PAGE_SIZE) == 0 1540 if ((cachep->buffer_size % PAGE_SIZE) == 0
1436 && OFF_SLAB(cachep)) 1541 && OFF_SLAB(cachep))
1437 kernel_map_pages(virt_to_page(objp), 1542 kernel_map_pages(virt_to_page(objp),
1438 cachep->objsize / PAGE_SIZE, 1543 cachep->buffer_size / PAGE_SIZE,
1439 1); 1544 1);
1440 else 1545 else
1441 check_poison_obj(cachep, objp); 1546 check_poison_obj(cachep, objp);
@@ -1452,18 +1557,32 @@ static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp)
1452 "was overwritten"); 1557 "was overwritten");
1453 } 1558 }
1454 if (cachep->dtor && !(cachep->flags & SLAB_POISON)) 1559 if (cachep->dtor && !(cachep->flags & SLAB_POISON))
1455 (cachep->dtor) (objp + obj_dbghead(cachep), cachep, 0); 1560 (cachep->dtor) (objp + obj_offset(cachep), cachep, 0);
1456 } 1561 }
1562}
1457#else 1563#else
1564static void slab_destroy_objs(struct kmem_cache *cachep, struct slab *slabp)
1565{
1458 if (cachep->dtor) { 1566 if (cachep->dtor) {
1459 int i; 1567 int i;
1460 for (i = 0; i < cachep->num; i++) { 1568 for (i = 0; i < cachep->num; i++) {
1461 void *objp = slabp->s_mem + cachep->objsize * i; 1569 void *objp = slabp->s_mem + cachep->buffer_size * i;
1462 (cachep->dtor) (objp, cachep, 0); 1570 (cachep->dtor) (objp, cachep, 0);
1463 } 1571 }
1464 } 1572 }
1573}
1465#endif 1574#endif
1466 1575
1576/**
1577 * Destroy all the objs in a slab, and release the mem back to the system.
1578 * Before calling the slab must have been unlinked from the cache.
1579 * The cache-lock is not held/needed.
1580 */
1581static void slab_destroy(struct kmem_cache *cachep, struct slab *slabp)
1582{
1583 void *addr = slabp->s_mem - slabp->colouroff;
1584
1585 slab_destroy_objs(cachep, slabp);
1467 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) { 1586 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) {
1468 struct slab_rcu *slab_rcu; 1587 struct slab_rcu *slab_rcu;
1469 1588
@@ -1478,9 +1597,9 @@ static void slab_destroy(kmem_cache_t *cachep, struct slab *slabp)
1478 } 1597 }
1479} 1598}
1480 1599
1481/* For setting up all the kmem_list3s for cache whose objsize is same 1600/* For setting up all the kmem_list3s for cache whose buffer_size is same
1482 as size of kmem_list3. */ 1601 as size of kmem_list3. */
1483static inline void set_up_list3s(kmem_cache_t *cachep, int index) 1602static void set_up_list3s(struct kmem_cache *cachep, int index)
1484{ 1603{
1485 int node; 1604 int node;
1486 1605
@@ -1493,15 +1612,20 @@ static inline void set_up_list3s(kmem_cache_t *cachep, int index)
1493} 1612}
1494 1613
1495/** 1614/**
1496 * calculate_slab_order - calculate size (page order) of slabs and the number 1615 * calculate_slab_order - calculate size (page order) of slabs
1497 * of objects per slab. 1616 * @cachep: pointer to the cache that is being created
1617 * @size: size of objects to be created in this cache.
1618 * @align: required alignment for the objects.
1619 * @flags: slab allocation flags
1620 *
1621 * Also calculates the number of objects per slab.
1498 * 1622 *
1499 * This could be made much more intelligent. For now, try to avoid using 1623 * This could be made much more intelligent. For now, try to avoid using
1500 * high order pages for slabs. When the gfp() functions are more friendly 1624 * high order pages for slabs. When the gfp() functions are more friendly
1501 * towards high-order requests, this should be changed. 1625 * towards high-order requests, this should be changed.
1502 */ 1626 */
1503static inline size_t calculate_slab_order(kmem_cache_t *cachep, size_t size, 1627static inline size_t calculate_slab_order(struct kmem_cache *cachep,
1504 size_t align, gfp_t flags) 1628 size_t size, size_t align, unsigned long flags)
1505{ 1629{
1506 size_t left_over = 0; 1630 size_t left_over = 0;
1507 1631
@@ -1572,13 +1696,13 @@ static inline size_t calculate_slab_order(kmem_cache_t *cachep, size_t size,
1572 * cacheline. This can be beneficial if you're counting cycles as closely 1696 * cacheline. This can be beneficial if you're counting cycles as closely
1573 * as davem. 1697 * as davem.
1574 */ 1698 */
1575kmem_cache_t * 1699struct kmem_cache *
1576kmem_cache_create (const char *name, size_t size, size_t align, 1700kmem_cache_create (const char *name, size_t size, size_t align,
1577 unsigned long flags, void (*ctor)(void*, kmem_cache_t *, unsigned long), 1701 unsigned long flags, void (*ctor)(void*, struct kmem_cache *, unsigned long),
1578 void (*dtor)(void*, kmem_cache_t *, unsigned long)) 1702 void (*dtor)(void*, struct kmem_cache *, unsigned long))
1579{ 1703{
1580 size_t left_over, slab_size, ralign; 1704 size_t left_over, slab_size, ralign;
1581 kmem_cache_t *cachep = NULL; 1705 struct kmem_cache *cachep = NULL;
1582 struct list_head *p; 1706 struct list_head *p;
1583 1707
1584 /* 1708 /*
@@ -1596,7 +1720,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
1596 mutex_lock(&cache_chain_mutex); 1720 mutex_lock(&cache_chain_mutex);
1597 1721
1598 list_for_each(p, &cache_chain) { 1722 list_for_each(p, &cache_chain) {
1599 kmem_cache_t *pc = list_entry(p, kmem_cache_t, next); 1723 struct kmem_cache *pc = list_entry(p, struct kmem_cache, next);
1600 mm_segment_t old_fs = get_fs(); 1724 mm_segment_t old_fs = get_fs();
1601 char tmp; 1725 char tmp;
1602 int res; 1726 int res;
@@ -1611,7 +1735,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
1611 set_fs(old_fs); 1735 set_fs(old_fs);
1612 if (res) { 1736 if (res) {
1613 printk("SLAB: cache with size %d has lost its name\n", 1737 printk("SLAB: cache with size %d has lost its name\n",
1614 pc->objsize); 1738 pc->buffer_size);
1615 continue; 1739 continue;
1616 } 1740 }
1617 1741
@@ -1696,20 +1820,20 @@ kmem_cache_create (const char *name, size_t size, size_t align,
1696 align = ralign; 1820 align = ralign;
1697 1821
1698 /* Get cache's description obj. */ 1822 /* Get cache's description obj. */
1699 cachep = (kmem_cache_t *) kmem_cache_alloc(&cache_cache, SLAB_KERNEL); 1823 cachep = kmem_cache_alloc(&cache_cache, SLAB_KERNEL);
1700 if (!cachep) 1824 if (!cachep)
1701 goto oops; 1825 goto oops;
1702 memset(cachep, 0, sizeof(kmem_cache_t)); 1826 memset(cachep, 0, sizeof(struct kmem_cache));
1703 1827
1704#if DEBUG 1828#if DEBUG
1705 cachep->reallen = size; 1829 cachep->obj_size = size;
1706 1830
1707 if (flags & SLAB_RED_ZONE) { 1831 if (flags & SLAB_RED_ZONE) {
1708 /* redzoning only works with word aligned caches */ 1832 /* redzoning only works with word aligned caches */
1709 align = BYTES_PER_WORD; 1833 align = BYTES_PER_WORD;
1710 1834
1711 /* add space for red zone words */ 1835 /* add space for red zone words */
1712 cachep->dbghead += BYTES_PER_WORD; 1836 cachep->obj_offset += BYTES_PER_WORD;
1713 size += 2 * BYTES_PER_WORD; 1837 size += 2 * BYTES_PER_WORD;
1714 } 1838 }
1715 if (flags & SLAB_STORE_USER) { 1839 if (flags & SLAB_STORE_USER) {
@@ -1722,8 +1846,8 @@ kmem_cache_create (const char *name, size_t size, size_t align,
1722 } 1846 }
1723#if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC) 1847#if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC)
1724 if (size >= malloc_sizes[INDEX_L3 + 1].cs_size 1848 if (size >= malloc_sizes[INDEX_L3 + 1].cs_size
1725 && cachep->reallen > cache_line_size() && size < PAGE_SIZE) { 1849 && cachep->obj_size > cache_line_size() && size < PAGE_SIZE) {
1726 cachep->dbghead += PAGE_SIZE - size; 1850 cachep->obj_offset += PAGE_SIZE - size;
1727 size = PAGE_SIZE; 1851 size = PAGE_SIZE;
1728 } 1852 }
1729#endif 1853#endif
@@ -1786,7 +1910,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
1786 if (flags & SLAB_CACHE_DMA) 1910 if (flags & SLAB_CACHE_DMA)
1787 cachep->gfpflags |= GFP_DMA; 1911 cachep->gfpflags |= GFP_DMA;
1788 spin_lock_init(&cachep->spinlock); 1912 spin_lock_init(&cachep->spinlock);
1789 cachep->objsize = size; 1913 cachep->buffer_size = size;
1790 1914
1791 if (flags & CFLGS_OFF_SLAB) 1915 if (flags & CFLGS_OFF_SLAB)
1792 cachep->slabp_cache = kmem_find_general_cachep(slab_size, 0u); 1916 cachep->slabp_cache = kmem_find_general_cachep(slab_size, 0u);
@@ -1843,11 +1967,11 @@ kmem_cache_create (const char *name, size_t size, size_t align,
1843 jiffies + REAPTIMEOUT_LIST3 + 1967 jiffies + REAPTIMEOUT_LIST3 +
1844 ((unsigned long)cachep) % REAPTIMEOUT_LIST3; 1968 ((unsigned long)cachep) % REAPTIMEOUT_LIST3;
1845 1969
1846 BUG_ON(!ac_data(cachep)); 1970 BUG_ON(!cpu_cache_get(cachep));
1847 ac_data(cachep)->avail = 0; 1971 cpu_cache_get(cachep)->avail = 0;
1848 ac_data(cachep)->limit = BOOT_CPUCACHE_ENTRIES; 1972 cpu_cache_get(cachep)->limit = BOOT_CPUCACHE_ENTRIES;
1849 ac_data(cachep)->batchcount = 1; 1973 cpu_cache_get(cachep)->batchcount = 1;
1850 ac_data(cachep)->touched = 0; 1974 cpu_cache_get(cachep)->touched = 0;
1851 cachep->batchcount = 1; 1975 cachep->batchcount = 1;
1852 cachep->limit = BOOT_CPUCACHE_ENTRIES; 1976 cachep->limit = BOOT_CPUCACHE_ENTRIES;
1853 } 1977 }
@@ -1875,7 +1999,7 @@ static void check_irq_on(void)
1875 BUG_ON(irqs_disabled()); 1999 BUG_ON(irqs_disabled());
1876} 2000}
1877 2001
1878static void check_spinlock_acquired(kmem_cache_t *cachep) 2002static void check_spinlock_acquired(struct kmem_cache *cachep)
1879{ 2003{
1880#ifdef CONFIG_SMP 2004#ifdef CONFIG_SMP
1881 check_irq_off(); 2005 check_irq_off();
@@ -1883,7 +2007,7 @@ static void check_spinlock_acquired(kmem_cache_t *cachep)
1883#endif 2007#endif
1884} 2008}
1885 2009
1886static inline void check_spinlock_acquired_node(kmem_cache_t *cachep, int node) 2010static void check_spinlock_acquired_node(struct kmem_cache *cachep, int node)
1887{ 2011{
1888#ifdef CONFIG_SMP 2012#ifdef CONFIG_SMP
1889 check_irq_off(); 2013 check_irq_off();
@@ -1916,45 +2040,43 @@ static void smp_call_function_all_cpus(void (*func)(void *arg), void *arg)
1916 preempt_enable(); 2040 preempt_enable();
1917} 2041}
1918 2042
1919static void drain_array_locked(kmem_cache_t *cachep, struct array_cache *ac, 2043static void drain_array_locked(struct kmem_cache *cachep, struct array_cache *ac,
1920 int force, int node); 2044 int force, int node);
1921 2045
1922static void do_drain(void *arg) 2046static void do_drain(void *arg)
1923{ 2047{
1924 kmem_cache_t *cachep = (kmem_cache_t *) arg; 2048 struct kmem_cache *cachep = (struct kmem_cache *) arg;
1925 struct array_cache *ac; 2049 struct array_cache *ac;
1926 int node = numa_node_id(); 2050 int node = numa_node_id();
1927 2051
1928 check_irq_off(); 2052 check_irq_off();
1929 ac = ac_data(cachep); 2053 ac = cpu_cache_get(cachep);
1930 spin_lock(&cachep->nodelists[node]->list_lock); 2054 spin_lock(&cachep->nodelists[node]->list_lock);
1931 free_block(cachep, ac->entry, ac->avail, node); 2055 free_block(cachep, ac->entry, ac->avail, node);
1932 spin_unlock(&cachep->nodelists[node]->list_lock); 2056 spin_unlock(&cachep->nodelists[node]->list_lock);
1933 ac->avail = 0; 2057 ac->avail = 0;
1934} 2058}
1935 2059
1936static void drain_cpu_caches(kmem_cache_t *cachep) 2060static void drain_cpu_caches(struct kmem_cache *cachep)
1937{ 2061{
1938 struct kmem_list3 *l3; 2062 struct kmem_list3 *l3;
1939 int node; 2063 int node;
1940 2064
1941 smp_call_function_all_cpus(do_drain, cachep); 2065 smp_call_function_all_cpus(do_drain, cachep);
1942 check_irq_on(); 2066 check_irq_on();
1943 spin_lock_irq(&cachep->spinlock);
1944 for_each_online_node(node) { 2067 for_each_online_node(node) {
1945 l3 = cachep->nodelists[node]; 2068 l3 = cachep->nodelists[node];
1946 if (l3) { 2069 if (l3) {
1947 spin_lock(&l3->list_lock); 2070 spin_lock_irq(&l3->list_lock);
1948 drain_array_locked(cachep, l3->shared, 1, node); 2071 drain_array_locked(cachep, l3->shared, 1, node);
1949 spin_unlock(&l3->list_lock); 2072 spin_unlock_irq(&l3->list_lock);
1950 if (l3->alien) 2073 if (l3->alien)
1951 drain_alien_cache(cachep, l3); 2074 drain_alien_cache(cachep, l3->alien);
1952 } 2075 }
1953 } 2076 }
1954 spin_unlock_irq(&cachep->spinlock);
1955} 2077}
1956 2078
1957static int __node_shrink(kmem_cache_t *cachep, int node) 2079static int __node_shrink(struct kmem_cache *cachep, int node)
1958{ 2080{
1959 struct slab *slabp; 2081 struct slab *slabp;
1960 struct kmem_list3 *l3 = cachep->nodelists[node]; 2082 struct kmem_list3 *l3 = cachep->nodelists[node];
@@ -1983,7 +2105,7 @@ static int __node_shrink(kmem_cache_t *cachep, int node)
1983 return ret; 2105 return ret;
1984} 2106}
1985 2107
1986static int __cache_shrink(kmem_cache_t *cachep) 2108static int __cache_shrink(struct kmem_cache *cachep)
1987{ 2109{
1988 int ret = 0, i = 0; 2110 int ret = 0, i = 0;
1989 struct kmem_list3 *l3; 2111 struct kmem_list3 *l3;
@@ -2009,7 +2131,7 @@ static int __cache_shrink(kmem_cache_t *cachep)
2009 * Releases as many slabs as possible for a cache. 2131 * Releases as many slabs as possible for a cache.
2010 * To help debugging, a zero exit status indicates all slabs were released. 2132 * To help debugging, a zero exit status indicates all slabs were released.
2011 */ 2133 */
2012int kmem_cache_shrink(kmem_cache_t *cachep) 2134int kmem_cache_shrink(struct kmem_cache *cachep)
2013{ 2135{
2014 if (!cachep || in_interrupt()) 2136 if (!cachep || in_interrupt())
2015 BUG(); 2137 BUG();
@@ -2022,7 +2144,7 @@ EXPORT_SYMBOL(kmem_cache_shrink);
2022 * kmem_cache_destroy - delete a cache 2144 * kmem_cache_destroy - delete a cache
2023 * @cachep: the cache to destroy 2145 * @cachep: the cache to destroy
2024 * 2146 *
2025 * Remove a kmem_cache_t object from the slab cache. 2147 * Remove a struct kmem_cache object from the slab cache.
2026 * Returns 0 on success. 2148 * Returns 0 on success.
2027 * 2149 *
2028 * It is expected this function will be called by a module when it is 2150 * It is expected this function will be called by a module when it is
@@ -2035,7 +2157,7 @@ EXPORT_SYMBOL(kmem_cache_shrink);
2035 * The caller must guarantee that noone will allocate memory from the cache 2157 * The caller must guarantee that noone will allocate memory from the cache
2036 * during the kmem_cache_destroy(). 2158 * during the kmem_cache_destroy().
2037 */ 2159 */
2038int kmem_cache_destroy(kmem_cache_t *cachep) 2160int kmem_cache_destroy(struct kmem_cache *cachep)
2039{ 2161{
2040 int i; 2162 int i;
2041 struct kmem_list3 *l3; 2163 struct kmem_list3 *l3;
@@ -2086,7 +2208,7 @@ int kmem_cache_destroy(kmem_cache_t *cachep)
2086EXPORT_SYMBOL(kmem_cache_destroy); 2208EXPORT_SYMBOL(kmem_cache_destroy);
2087 2209
2088/* Get the memory for a slab management obj. */ 2210/* Get the memory for a slab management obj. */
2089static struct slab *alloc_slabmgmt(kmem_cache_t *cachep, void *objp, 2211static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
2090 int colour_off, gfp_t local_flags) 2212 int colour_off, gfp_t local_flags)
2091{ 2213{
2092 struct slab *slabp; 2214 struct slab *slabp;
@@ -2112,13 +2234,13 @@ static inline kmem_bufctl_t *slab_bufctl(struct slab *slabp)
2112 return (kmem_bufctl_t *) (slabp + 1); 2234 return (kmem_bufctl_t *) (slabp + 1);
2113} 2235}
2114 2236
2115static void cache_init_objs(kmem_cache_t *cachep, 2237static void cache_init_objs(struct kmem_cache *cachep,
2116 struct slab *slabp, unsigned long ctor_flags) 2238 struct slab *slabp, unsigned long ctor_flags)
2117{ 2239{
2118 int i; 2240 int i;
2119 2241
2120 for (i = 0; i < cachep->num; i++) { 2242 for (i = 0; i < cachep->num; i++) {
2121 void *objp = slabp->s_mem + cachep->objsize * i; 2243 void *objp = slabp->s_mem + cachep->buffer_size * i;
2122#if DEBUG 2244#if DEBUG
2123 /* need to poison the objs? */ 2245 /* need to poison the objs? */
2124 if (cachep->flags & SLAB_POISON) 2246 if (cachep->flags & SLAB_POISON)
@@ -2136,7 +2258,7 @@ static void cache_init_objs(kmem_cache_t *cachep,
2136 * Otherwise, deadlock. They must also be threaded. 2258 * Otherwise, deadlock. They must also be threaded.
2137 */ 2259 */
2138 if (cachep->ctor && !(cachep->flags & SLAB_POISON)) 2260 if (cachep->ctor && !(cachep->flags & SLAB_POISON))
2139 cachep->ctor(objp + obj_dbghead(cachep), cachep, 2261 cachep->ctor(objp + obj_offset(cachep), cachep,
2140 ctor_flags); 2262 ctor_flags);
2141 2263
2142 if (cachep->flags & SLAB_RED_ZONE) { 2264 if (cachep->flags & SLAB_RED_ZONE) {
@@ -2147,10 +2269,10 @@ static void cache_init_objs(kmem_cache_t *cachep,
2147 slab_error(cachep, "constructor overwrote the" 2269 slab_error(cachep, "constructor overwrote the"
2148 " start of an object"); 2270 " start of an object");
2149 } 2271 }
2150 if ((cachep->objsize % PAGE_SIZE) == 0 && OFF_SLAB(cachep) 2272 if ((cachep->buffer_size % PAGE_SIZE) == 0 && OFF_SLAB(cachep)
2151 && cachep->flags & SLAB_POISON) 2273 && cachep->flags & SLAB_POISON)
2152 kernel_map_pages(virt_to_page(objp), 2274 kernel_map_pages(virt_to_page(objp),
2153 cachep->objsize / PAGE_SIZE, 0); 2275 cachep->buffer_size / PAGE_SIZE, 0);
2154#else 2276#else
2155 if (cachep->ctor) 2277 if (cachep->ctor)
2156 cachep->ctor(objp, cachep, ctor_flags); 2278 cachep->ctor(objp, cachep, ctor_flags);
@@ -2161,7 +2283,7 @@ static void cache_init_objs(kmem_cache_t *cachep,
2161 slabp->free = 0; 2283 slabp->free = 0;
2162} 2284}
2163 2285
2164static void kmem_flagcheck(kmem_cache_t *cachep, gfp_t flags) 2286static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags)
2165{ 2287{
2166 if (flags & SLAB_DMA) { 2288 if (flags & SLAB_DMA) {
2167 if (!(cachep->gfpflags & GFP_DMA)) 2289 if (!(cachep->gfpflags & GFP_DMA))
@@ -2172,7 +2294,43 @@ static void kmem_flagcheck(kmem_cache_t *cachep, gfp_t flags)
2172 } 2294 }
2173} 2295}
2174 2296
2175static void set_slab_attr(kmem_cache_t *cachep, struct slab *slabp, void *objp) 2297static void *slab_get_obj(struct kmem_cache *cachep, struct slab *slabp, int nodeid)
2298{
2299 void *objp = slabp->s_mem + (slabp->free * cachep->buffer_size);
2300 kmem_bufctl_t next;
2301
2302 slabp->inuse++;
2303 next = slab_bufctl(slabp)[slabp->free];
2304#if DEBUG
2305 slab_bufctl(slabp)[slabp->free] = BUFCTL_FREE;
2306 WARN_ON(slabp->nodeid != nodeid);
2307#endif
2308 slabp->free = next;
2309
2310 return objp;
2311}
2312
2313static void slab_put_obj(struct kmem_cache *cachep, struct slab *slabp, void *objp,
2314 int nodeid)
2315{
2316 unsigned int objnr = (unsigned)(objp-slabp->s_mem) / cachep->buffer_size;
2317
2318#if DEBUG
2319 /* Verify that the slab belongs to the intended node */
2320 WARN_ON(slabp->nodeid != nodeid);
2321
2322 if (slab_bufctl(slabp)[objnr] != BUFCTL_FREE) {
2323 printk(KERN_ERR "slab: double free detected in cache "
2324 "'%s', objp %p\n", cachep->name, objp);
2325 BUG();
2326 }
2327#endif
2328 slab_bufctl(slabp)[objnr] = slabp->free;
2329 slabp->free = objnr;
2330 slabp->inuse--;
2331}
2332
2333static void set_slab_attr(struct kmem_cache *cachep, struct slab *slabp, void *objp)
2176{ 2334{
2177 int i; 2335 int i;
2178 struct page *page; 2336 struct page *page;
@@ -2191,7 +2349,7 @@ static void set_slab_attr(kmem_cache_t *cachep, struct slab *slabp, void *objp)
2191 * Grow (by 1) the number of slabs within a cache. This is called by 2349 * Grow (by 1) the number of slabs within a cache. This is called by
2192 * kmem_cache_alloc() when there are no active objs left in a cache. 2350 * kmem_cache_alloc() when there are no active objs left in a cache.
2193 */ 2351 */
2194static int cache_grow(kmem_cache_t *cachep, gfp_t flags, int nodeid) 2352static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid)
2195{ 2353{
2196 struct slab *slabp; 2354 struct slab *slabp;
2197 void *objp; 2355 void *objp;
@@ -2217,20 +2375,20 @@ static int cache_grow(kmem_cache_t *cachep, gfp_t flags, int nodeid)
2217 */ 2375 */
2218 ctor_flags |= SLAB_CTOR_ATOMIC; 2376 ctor_flags |= SLAB_CTOR_ATOMIC;
2219 2377
2220 /* About to mess with non-constant members - lock. */ 2378 /* Take the l3 list lock to change the colour_next on this node */
2221 check_irq_off(); 2379 check_irq_off();
2222 spin_lock(&cachep->spinlock); 2380 l3 = cachep->nodelists[nodeid];
2381 spin_lock(&l3->list_lock);
2223 2382
2224 /* Get colour for the slab, and cal the next value. */ 2383 /* Get colour for the slab, and cal the next value. */
2225 offset = cachep->colour_next; 2384 offset = l3->colour_next;
2226 cachep->colour_next++; 2385 l3->colour_next++;
2227 if (cachep->colour_next >= cachep->colour) 2386 if (l3->colour_next >= cachep->colour)
2228 cachep->colour_next = 0; 2387 l3->colour_next = 0;
2229 offset *= cachep->colour_off; 2388 spin_unlock(&l3->list_lock);
2230 2389
2231 spin_unlock(&cachep->spinlock); 2390 offset *= cachep->colour_off;
2232 2391
2233 check_irq_off();
2234 if (local_flags & __GFP_WAIT) 2392 if (local_flags & __GFP_WAIT)
2235 local_irq_enable(); 2393 local_irq_enable();
2236 2394
@@ -2260,7 +2418,6 @@ static int cache_grow(kmem_cache_t *cachep, gfp_t flags, int nodeid)
2260 if (local_flags & __GFP_WAIT) 2418 if (local_flags & __GFP_WAIT)
2261 local_irq_disable(); 2419 local_irq_disable();
2262 check_irq_off(); 2420 check_irq_off();
2263 l3 = cachep->nodelists[nodeid];
2264 spin_lock(&l3->list_lock); 2421 spin_lock(&l3->list_lock);
2265 2422
2266 /* Make slab active. */ 2423 /* Make slab active. */
@@ -2302,14 +2459,14 @@ static void kfree_debugcheck(const void *objp)
2302 } 2459 }
2303} 2460}
2304 2461
2305static void *cache_free_debugcheck(kmem_cache_t *cachep, void *objp, 2462static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
2306 void *caller) 2463 void *caller)
2307{ 2464{
2308 struct page *page; 2465 struct page *page;
2309 unsigned int objnr; 2466 unsigned int objnr;
2310 struct slab *slabp; 2467 struct slab *slabp;
2311 2468
2312 objp -= obj_dbghead(cachep); 2469 objp -= obj_offset(cachep);
2313 kfree_debugcheck(objp); 2470 kfree_debugcheck(objp);
2314 page = virt_to_page(objp); 2471 page = virt_to_page(objp);
2315 2472
@@ -2341,31 +2498,31 @@ static void *cache_free_debugcheck(kmem_cache_t *cachep, void *objp,
2341 if (cachep->flags & SLAB_STORE_USER) 2498 if (cachep->flags & SLAB_STORE_USER)
2342 *dbg_userword(cachep, objp) = caller; 2499 *dbg_userword(cachep, objp) = caller;
2343 2500
2344 objnr = (objp - slabp->s_mem) / cachep->objsize; 2501 objnr = (unsigned)(objp - slabp->s_mem) / cachep->buffer_size;
2345 2502
2346 BUG_ON(objnr >= cachep->num); 2503 BUG_ON(objnr >= cachep->num);
2347 BUG_ON(objp != slabp->s_mem + objnr * cachep->objsize); 2504 BUG_ON(objp != slabp->s_mem + objnr * cachep->buffer_size);
2348 2505
2349 if (cachep->flags & SLAB_DEBUG_INITIAL) { 2506 if (cachep->flags & SLAB_DEBUG_INITIAL) {
2350 /* Need to call the slab's constructor so the 2507 /* Need to call the slab's constructor so the
2351 * caller can perform a verify of its state (debugging). 2508 * caller can perform a verify of its state (debugging).
2352 * Called without the cache-lock held. 2509 * Called without the cache-lock held.
2353 */ 2510 */
2354 cachep->ctor(objp + obj_dbghead(cachep), 2511 cachep->ctor(objp + obj_offset(cachep),
2355 cachep, SLAB_CTOR_CONSTRUCTOR | SLAB_CTOR_VERIFY); 2512 cachep, SLAB_CTOR_CONSTRUCTOR | SLAB_CTOR_VERIFY);
2356 } 2513 }
2357 if (cachep->flags & SLAB_POISON && cachep->dtor) { 2514 if (cachep->flags & SLAB_POISON && cachep->dtor) {
2358 /* we want to cache poison the object, 2515 /* we want to cache poison the object,
2359 * call the destruction callback 2516 * call the destruction callback
2360 */ 2517 */
2361 cachep->dtor(objp + obj_dbghead(cachep), cachep, 0); 2518 cachep->dtor(objp + obj_offset(cachep), cachep, 0);
2362 } 2519 }
2363 if (cachep->flags & SLAB_POISON) { 2520 if (cachep->flags & SLAB_POISON) {
2364#ifdef CONFIG_DEBUG_PAGEALLOC 2521#ifdef CONFIG_DEBUG_PAGEALLOC
2365 if ((cachep->objsize % PAGE_SIZE) == 0 && OFF_SLAB(cachep)) { 2522 if ((cachep->buffer_size % PAGE_SIZE) == 0 && OFF_SLAB(cachep)) {
2366 store_stackinfo(cachep, objp, (unsigned long)caller); 2523 store_stackinfo(cachep, objp, (unsigned long)caller);
2367 kernel_map_pages(virt_to_page(objp), 2524 kernel_map_pages(virt_to_page(objp),
2368 cachep->objsize / PAGE_SIZE, 0); 2525 cachep->buffer_size / PAGE_SIZE, 0);
2369 } else { 2526 } else {
2370 poison_obj(cachep, objp, POISON_FREE); 2527 poison_obj(cachep, objp, POISON_FREE);
2371 } 2528 }
@@ -2376,7 +2533,7 @@ static void *cache_free_debugcheck(kmem_cache_t *cachep, void *objp,
2376 return objp; 2533 return objp;
2377} 2534}
2378 2535
2379static void check_slabp(kmem_cache_t *cachep, struct slab *slabp) 2536static void check_slabp(struct kmem_cache *cachep, struct slab *slabp)
2380{ 2537{
2381 kmem_bufctl_t i; 2538 kmem_bufctl_t i;
2382 int entries = 0; 2539 int entries = 0;
@@ -2409,14 +2566,14 @@ static void check_slabp(kmem_cache_t *cachep, struct slab *slabp)
2409#define check_slabp(x,y) do { } while(0) 2566#define check_slabp(x,y) do { } while(0)
2410#endif 2567#endif
2411 2568
2412static void *cache_alloc_refill(kmem_cache_t *cachep, gfp_t flags) 2569static void *cache_alloc_refill(struct kmem_cache *cachep, gfp_t flags)
2413{ 2570{
2414 int batchcount; 2571 int batchcount;
2415 struct kmem_list3 *l3; 2572 struct kmem_list3 *l3;
2416 struct array_cache *ac; 2573 struct array_cache *ac;
2417 2574
2418 check_irq_off(); 2575 check_irq_off();
2419 ac = ac_data(cachep); 2576 ac = cpu_cache_get(cachep);
2420 retry: 2577 retry:
2421 batchcount = ac->batchcount; 2578 batchcount = ac->batchcount;
2422 if (!ac->touched && batchcount > BATCHREFILL_LIMIT) { 2579 if (!ac->touched && batchcount > BATCHREFILL_LIMIT) {
@@ -2461,22 +2618,12 @@ static void *cache_alloc_refill(kmem_cache_t *cachep, gfp_t flags)
2461 check_slabp(cachep, slabp); 2618 check_slabp(cachep, slabp);
2462 check_spinlock_acquired(cachep); 2619 check_spinlock_acquired(cachep);
2463 while (slabp->inuse < cachep->num && batchcount--) { 2620 while (slabp->inuse < cachep->num && batchcount--) {
2464 kmem_bufctl_t next;
2465 STATS_INC_ALLOCED(cachep); 2621 STATS_INC_ALLOCED(cachep);
2466 STATS_INC_ACTIVE(cachep); 2622 STATS_INC_ACTIVE(cachep);
2467 STATS_SET_HIGH(cachep); 2623 STATS_SET_HIGH(cachep);
2468 2624
2469 /* get obj pointer */ 2625 ac->entry[ac->avail++] = slab_get_obj(cachep, slabp,
2470 ac->entry[ac->avail++] = slabp->s_mem + 2626 numa_node_id());
2471 slabp->free * cachep->objsize;
2472
2473 slabp->inuse++;
2474 next = slab_bufctl(slabp)[slabp->free];
2475#if DEBUG
2476 slab_bufctl(slabp)[slabp->free] = BUFCTL_FREE;
2477 WARN_ON(numa_node_id() != slabp->nodeid);
2478#endif
2479 slabp->free = next;
2480 } 2627 }
2481 check_slabp(cachep, slabp); 2628 check_slabp(cachep, slabp);
2482 2629
@@ -2498,7 +2645,7 @@ static void *cache_alloc_refill(kmem_cache_t *cachep, gfp_t flags)
2498 x = cache_grow(cachep, flags, numa_node_id()); 2645 x = cache_grow(cachep, flags, numa_node_id());
2499 2646
2500 // cache_grow can reenable interrupts, then ac could change. 2647 // cache_grow can reenable interrupts, then ac could change.
2501 ac = ac_data(cachep); 2648 ac = cpu_cache_get(cachep);
2502 if (!x && ac->avail == 0) // no objects in sight? abort 2649 if (!x && ac->avail == 0) // no objects in sight? abort
2503 return NULL; 2650 return NULL;
2504 2651
@@ -2510,7 +2657,7 @@ static void *cache_alloc_refill(kmem_cache_t *cachep, gfp_t flags)
2510} 2657}
2511 2658
2512static inline void 2659static inline void
2513cache_alloc_debugcheck_before(kmem_cache_t *cachep, gfp_t flags) 2660cache_alloc_debugcheck_before(struct kmem_cache *cachep, gfp_t flags)
2514{ 2661{
2515 might_sleep_if(flags & __GFP_WAIT); 2662 might_sleep_if(flags & __GFP_WAIT);
2516#if DEBUG 2663#if DEBUG
@@ -2519,16 +2666,16 @@ cache_alloc_debugcheck_before(kmem_cache_t *cachep, gfp_t flags)
2519} 2666}
2520 2667
2521#if DEBUG 2668#if DEBUG
2522static void *cache_alloc_debugcheck_after(kmem_cache_t *cachep, gfp_t flags, 2669static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep, gfp_t flags,
2523 void *objp, void *caller) 2670 void *objp, void *caller)
2524{ 2671{
2525 if (!objp) 2672 if (!objp)
2526 return objp; 2673 return objp;
2527 if (cachep->flags & SLAB_POISON) { 2674 if (cachep->flags & SLAB_POISON) {
2528#ifdef CONFIG_DEBUG_PAGEALLOC 2675#ifdef CONFIG_DEBUG_PAGEALLOC
2529 if ((cachep->objsize % PAGE_SIZE) == 0 && OFF_SLAB(cachep)) 2676 if ((cachep->buffer_size % PAGE_SIZE) == 0 && OFF_SLAB(cachep))
2530 kernel_map_pages(virt_to_page(objp), 2677 kernel_map_pages(virt_to_page(objp),
2531 cachep->objsize / PAGE_SIZE, 1); 2678 cachep->buffer_size / PAGE_SIZE, 1);
2532 else 2679 else
2533 check_poison_obj(cachep, objp); 2680 check_poison_obj(cachep, objp);
2534#else 2681#else
@@ -2553,7 +2700,7 @@ static void *cache_alloc_debugcheck_after(kmem_cache_t *cachep, gfp_t flags,
2553 *dbg_redzone1(cachep, objp) = RED_ACTIVE; 2700 *dbg_redzone1(cachep, objp) = RED_ACTIVE;
2554 *dbg_redzone2(cachep, objp) = RED_ACTIVE; 2701 *dbg_redzone2(cachep, objp) = RED_ACTIVE;
2555 } 2702 }
2556 objp += obj_dbghead(cachep); 2703 objp += obj_offset(cachep);
2557 if (cachep->ctor && cachep->flags & SLAB_POISON) { 2704 if (cachep->ctor && cachep->flags & SLAB_POISON) {
2558 unsigned long ctor_flags = SLAB_CTOR_CONSTRUCTOR; 2705 unsigned long ctor_flags = SLAB_CTOR_CONSTRUCTOR;
2559 2706
@@ -2568,7 +2715,7 @@ static void *cache_alloc_debugcheck_after(kmem_cache_t *cachep, gfp_t flags,
2568#define cache_alloc_debugcheck_after(a,b,objp,d) (objp) 2715#define cache_alloc_debugcheck_after(a,b,objp,d) (objp)
2569#endif 2716#endif
2570 2717
2571static inline void *____cache_alloc(kmem_cache_t *cachep, gfp_t flags) 2718static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
2572{ 2719{
2573 void *objp; 2720 void *objp;
2574 struct array_cache *ac; 2721 struct array_cache *ac;
@@ -2583,7 +2730,7 @@ static inline void *____cache_alloc(kmem_cache_t *cachep, gfp_t flags)
2583#endif 2730#endif
2584 2731
2585 check_irq_off(); 2732 check_irq_off();
2586 ac = ac_data(cachep); 2733 ac = cpu_cache_get(cachep);
2587 if (likely(ac->avail)) { 2734 if (likely(ac->avail)) {
2588 STATS_INC_ALLOCHIT(cachep); 2735 STATS_INC_ALLOCHIT(cachep);
2589 ac->touched = 1; 2736 ac->touched = 1;
@@ -2595,7 +2742,8 @@ static inline void *____cache_alloc(kmem_cache_t *cachep, gfp_t flags)
2595 return objp; 2742 return objp;
2596} 2743}
2597 2744
2598static inline void *__cache_alloc(kmem_cache_t *cachep, gfp_t flags) 2745static __always_inline void *
2746__cache_alloc(struct kmem_cache *cachep, gfp_t flags, void *caller)
2599{ 2747{
2600 unsigned long save_flags; 2748 unsigned long save_flags;
2601 void *objp; 2749 void *objp;
@@ -2606,7 +2754,7 @@ static inline void *__cache_alloc(kmem_cache_t *cachep, gfp_t flags)
2606 objp = ____cache_alloc(cachep, flags); 2754 objp = ____cache_alloc(cachep, flags);
2607 local_irq_restore(save_flags); 2755 local_irq_restore(save_flags);
2608 objp = cache_alloc_debugcheck_after(cachep, flags, objp, 2756 objp = cache_alloc_debugcheck_after(cachep, flags, objp,
2609 __builtin_return_address(0)); 2757 caller);
2610 prefetchw(objp); 2758 prefetchw(objp);
2611 return objp; 2759 return objp;
2612} 2760}
@@ -2615,19 +2763,19 @@ static inline void *__cache_alloc(kmem_cache_t *cachep, gfp_t flags)
2615/* 2763/*
2616 * A interface to enable slab creation on nodeid 2764 * A interface to enable slab creation on nodeid
2617 */ 2765 */
2618static void *__cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int nodeid) 2766static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
2619{ 2767{
2620 struct list_head *entry; 2768 struct list_head *entry;
2621 struct slab *slabp; 2769 struct slab *slabp;
2622 struct kmem_list3 *l3; 2770 struct kmem_list3 *l3;
2623 void *obj; 2771 void *obj;
2624 kmem_bufctl_t next;
2625 int x; 2772 int x;
2626 2773
2627 l3 = cachep->nodelists[nodeid]; 2774 l3 = cachep->nodelists[nodeid];
2628 BUG_ON(!l3); 2775 BUG_ON(!l3);
2629 2776
2630 retry: 2777 retry:
2778 check_irq_off();
2631 spin_lock(&l3->list_lock); 2779 spin_lock(&l3->list_lock);
2632 entry = l3->slabs_partial.next; 2780 entry = l3->slabs_partial.next;
2633 if (entry == &l3->slabs_partial) { 2781 if (entry == &l3->slabs_partial) {
@@ -2647,14 +2795,7 @@ static void *__cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int nodeid)
2647 2795
2648 BUG_ON(slabp->inuse == cachep->num); 2796 BUG_ON(slabp->inuse == cachep->num);
2649 2797
2650 /* get obj pointer */ 2798 obj = slab_get_obj(cachep, slabp, nodeid);
2651 obj = slabp->s_mem + slabp->free * cachep->objsize;
2652 slabp->inuse++;
2653 next = slab_bufctl(slabp)[slabp->free];
2654#if DEBUG
2655 slab_bufctl(slabp)[slabp->free] = BUFCTL_FREE;
2656#endif
2657 slabp->free = next;
2658 check_slabp(cachep, slabp); 2799 check_slabp(cachep, slabp);
2659 l3->free_objects--; 2800 l3->free_objects--;
2660 /* move slabp to correct slabp list: */ 2801 /* move slabp to correct slabp list: */
@@ -2685,7 +2826,7 @@ static void *__cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int nodeid)
2685/* 2826/*
2686 * Caller needs to acquire correct kmem_list's list_lock 2827 * Caller needs to acquire correct kmem_list's list_lock
2687 */ 2828 */
2688static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects, 2829static void free_block(struct kmem_cache *cachep, void **objpp, int nr_objects,
2689 int node) 2830 int node)
2690{ 2831{
2691 int i; 2832 int i;
@@ -2694,29 +2835,14 @@ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects,
2694 for (i = 0; i < nr_objects; i++) { 2835 for (i = 0; i < nr_objects; i++) {
2695 void *objp = objpp[i]; 2836 void *objp = objpp[i];
2696 struct slab *slabp; 2837 struct slab *slabp;
2697 unsigned int objnr;
2698 2838
2699 slabp = page_get_slab(virt_to_page(objp)); 2839 slabp = virt_to_slab(objp);
2700 l3 = cachep->nodelists[node]; 2840 l3 = cachep->nodelists[node];
2701 list_del(&slabp->list); 2841 list_del(&slabp->list);
2702 objnr = (objp - slabp->s_mem) / cachep->objsize;
2703 check_spinlock_acquired_node(cachep, node); 2842 check_spinlock_acquired_node(cachep, node);
2704 check_slabp(cachep, slabp); 2843 check_slabp(cachep, slabp);
2705 2844 slab_put_obj(cachep, slabp, objp, node);
2706#if DEBUG
2707 /* Verify that the slab belongs to the intended node */
2708 WARN_ON(slabp->nodeid != node);
2709
2710 if (slab_bufctl(slabp)[objnr] != BUFCTL_FREE) {
2711 printk(KERN_ERR "slab: double free detected in cache "
2712 "'%s', objp %p\n", cachep->name, objp);
2713 BUG();
2714 }
2715#endif
2716 slab_bufctl(slabp)[objnr] = slabp->free;
2717 slabp->free = objnr;
2718 STATS_DEC_ACTIVE(cachep); 2845 STATS_DEC_ACTIVE(cachep);
2719 slabp->inuse--;
2720 l3->free_objects++; 2846 l3->free_objects++;
2721 check_slabp(cachep, slabp); 2847 check_slabp(cachep, slabp);
2722 2848
@@ -2738,7 +2864,7 @@ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects,
2738 } 2864 }
2739} 2865}
2740 2866
2741static void cache_flusharray(kmem_cache_t *cachep, struct array_cache *ac) 2867static void cache_flusharray(struct kmem_cache *cachep, struct array_cache *ac)
2742{ 2868{
2743 int batchcount; 2869 int batchcount;
2744 struct kmem_list3 *l3; 2870 struct kmem_list3 *l3;
@@ -2797,9 +2923,9 @@ static void cache_flusharray(kmem_cache_t *cachep, struct array_cache *ac)
2797 * 2923 *
2798 * Called with disabled ints. 2924 * Called with disabled ints.
2799 */ 2925 */
2800static inline void __cache_free(kmem_cache_t *cachep, void *objp) 2926static inline void __cache_free(struct kmem_cache *cachep, void *objp)
2801{ 2927{
2802 struct array_cache *ac = ac_data(cachep); 2928 struct array_cache *ac = cpu_cache_get(cachep);
2803 2929
2804 check_irq_off(); 2930 check_irq_off();
2805 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0)); 2931 objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
@@ -2810,7 +2936,7 @@ static inline void __cache_free(kmem_cache_t *cachep, void *objp)
2810#ifdef CONFIG_NUMA 2936#ifdef CONFIG_NUMA
2811 { 2937 {
2812 struct slab *slabp; 2938 struct slab *slabp;
2813 slabp = page_get_slab(virt_to_page(objp)); 2939 slabp = virt_to_slab(objp);
2814 if (unlikely(slabp->nodeid != numa_node_id())) { 2940 if (unlikely(slabp->nodeid != numa_node_id())) {
2815 struct array_cache *alien = NULL; 2941 struct array_cache *alien = NULL;
2816 int nodeid = slabp->nodeid; 2942 int nodeid = slabp->nodeid;
@@ -2856,9 +2982,9 @@ static inline void __cache_free(kmem_cache_t *cachep, void *objp)
2856 * Allocate an object from this cache. The flags are only relevant 2982 * Allocate an object from this cache. The flags are only relevant
2857 * if the cache has no available objects. 2983 * if the cache has no available objects.
2858 */ 2984 */
2859void *kmem_cache_alloc(kmem_cache_t *cachep, gfp_t flags) 2985void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
2860{ 2986{
2861 return __cache_alloc(cachep, flags); 2987 return __cache_alloc(cachep, flags, __builtin_return_address(0));
2862} 2988}
2863EXPORT_SYMBOL(kmem_cache_alloc); 2989EXPORT_SYMBOL(kmem_cache_alloc);
2864 2990
@@ -2876,12 +3002,12 @@ EXPORT_SYMBOL(kmem_cache_alloc);
2876 * 3002 *
2877 * Currently only used for dentry validation. 3003 * Currently only used for dentry validation.
2878 */ 3004 */
2879int fastcall kmem_ptr_validate(kmem_cache_t *cachep, void *ptr) 3005int fastcall kmem_ptr_validate(struct kmem_cache *cachep, void *ptr)
2880{ 3006{
2881 unsigned long addr = (unsigned long)ptr; 3007 unsigned long addr = (unsigned long)ptr;
2882 unsigned long min_addr = PAGE_OFFSET; 3008 unsigned long min_addr = PAGE_OFFSET;
2883 unsigned long align_mask = BYTES_PER_WORD - 1; 3009 unsigned long align_mask = BYTES_PER_WORD - 1;
2884 unsigned long size = cachep->objsize; 3010 unsigned long size = cachep->buffer_size;
2885 struct page *page; 3011 struct page *page;
2886 3012
2887 if (unlikely(addr < min_addr)) 3013 if (unlikely(addr < min_addr))
@@ -2917,32 +3043,23 @@ int fastcall kmem_ptr_validate(kmem_cache_t *cachep, void *ptr)
2917 * New and improved: it will now make sure that the object gets 3043 * New and improved: it will now make sure that the object gets
2918 * put on the correct node list so that there is no false sharing. 3044 * put on the correct node list so that there is no false sharing.
2919 */ 3045 */
2920void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int nodeid) 3046void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
2921{ 3047{
2922 unsigned long save_flags; 3048 unsigned long save_flags;
2923 void *ptr; 3049 void *ptr;
2924 3050
2925 if (nodeid == -1)
2926 return __cache_alloc(cachep, flags);
2927
2928 if (unlikely(!cachep->nodelists[nodeid])) {
2929 /* Fall back to __cache_alloc if we run into trouble */
2930 printk(KERN_WARNING
2931 "slab: not allocating in inactive node %d for cache %s\n",
2932 nodeid, cachep->name);
2933 return __cache_alloc(cachep, flags);
2934 }
2935
2936 cache_alloc_debugcheck_before(cachep, flags); 3051 cache_alloc_debugcheck_before(cachep, flags);
2937 local_irq_save(save_flags); 3052 local_irq_save(save_flags);
2938 if (nodeid == numa_node_id()) 3053
3054 if (nodeid == -1 || nodeid == numa_node_id() ||
3055 !cachep->nodelists[nodeid])
2939 ptr = ____cache_alloc(cachep, flags); 3056 ptr = ____cache_alloc(cachep, flags);
2940 else 3057 else
2941 ptr = __cache_alloc_node(cachep, flags, nodeid); 3058 ptr = __cache_alloc_node(cachep, flags, nodeid);
2942 local_irq_restore(save_flags); 3059 local_irq_restore(save_flags);
2943 ptr = 3060
2944 cache_alloc_debugcheck_after(cachep, flags, ptr, 3061 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr,
2945 __builtin_return_address(0)); 3062 __builtin_return_address(0));
2946 3063
2947 return ptr; 3064 return ptr;
2948} 3065}
@@ -2950,7 +3067,7 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
2950 3067
2951void *kmalloc_node(size_t size, gfp_t flags, int node) 3068void *kmalloc_node(size_t size, gfp_t flags, int node)
2952{ 3069{
2953 kmem_cache_t *cachep; 3070 struct kmem_cache *cachep;
2954 3071
2955 cachep = kmem_find_general_cachep(size, flags); 3072 cachep = kmem_find_general_cachep(size, flags);
2956 if (unlikely(cachep == NULL)) 3073 if (unlikely(cachep == NULL))
@@ -2981,9 +3098,10 @@ EXPORT_SYMBOL(kmalloc_node);
2981 * platforms. For example, on i386, it means that the memory must come 3098 * platforms. For example, on i386, it means that the memory must come
2982 * from the first 16MB. 3099 * from the first 16MB.
2983 */ 3100 */
2984void *__kmalloc(size_t size, gfp_t flags) 3101static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
3102 void *caller)
2985{ 3103{
2986 kmem_cache_t *cachep; 3104 struct kmem_cache *cachep;
2987 3105
2988 /* If you want to save a few bytes .text space: replace 3106 /* If you want to save a few bytes .text space: replace
2989 * __ with kmem_. 3107 * __ with kmem_.
@@ -2993,10 +3111,27 @@ void *__kmalloc(size_t size, gfp_t flags)
2993 cachep = __find_general_cachep(size, flags); 3111 cachep = __find_general_cachep(size, flags);
2994 if (unlikely(cachep == NULL)) 3112 if (unlikely(cachep == NULL))
2995 return NULL; 3113 return NULL;
2996 return __cache_alloc(cachep, flags); 3114 return __cache_alloc(cachep, flags, caller);
3115}
3116
3117#ifndef CONFIG_DEBUG_SLAB
3118
3119void *__kmalloc(size_t size, gfp_t flags)
3120{
3121 return __do_kmalloc(size, flags, NULL);
2997} 3122}
2998EXPORT_SYMBOL(__kmalloc); 3123EXPORT_SYMBOL(__kmalloc);
2999 3124
3125#else
3126
3127void *__kmalloc_track_caller(size_t size, gfp_t flags, void *caller)
3128{
3129 return __do_kmalloc(size, flags, caller);
3130}
3131EXPORT_SYMBOL(__kmalloc_track_caller);
3132
3133#endif
3134
3000#ifdef CONFIG_SMP 3135#ifdef CONFIG_SMP
3001/** 3136/**
3002 * __alloc_percpu - allocate one copy of the object for every present 3137 * __alloc_percpu - allocate one copy of the object for every present
@@ -3054,7 +3189,7 @@ EXPORT_SYMBOL(__alloc_percpu);
3054 * Free an object which was previously allocated from this 3189 * Free an object which was previously allocated from this
3055 * cache. 3190 * cache.
3056 */ 3191 */
3057void kmem_cache_free(kmem_cache_t *cachep, void *objp) 3192void kmem_cache_free(struct kmem_cache *cachep, void *objp)
3058{ 3193{
3059 unsigned long flags; 3194 unsigned long flags;
3060 3195
@@ -3075,15 +3210,15 @@ EXPORT_SYMBOL(kmem_cache_free);
3075 */ 3210 */
3076void kfree(const void *objp) 3211void kfree(const void *objp)
3077{ 3212{
3078 kmem_cache_t *c; 3213 struct kmem_cache *c;
3079 unsigned long flags; 3214 unsigned long flags;
3080 3215
3081 if (unlikely(!objp)) 3216 if (unlikely(!objp))
3082 return; 3217 return;
3083 local_irq_save(flags); 3218 local_irq_save(flags);
3084 kfree_debugcheck(objp); 3219 kfree_debugcheck(objp);
3085 c = page_get_cache(virt_to_page(objp)); 3220 c = virt_to_cache(objp);
3086 mutex_debug_check_no_locks_freed(objp, obj_reallen(c)); 3221 mutex_debug_check_no_locks_freed(objp, obj_size(c));
3087 __cache_free(c, (void *)objp); 3222 __cache_free(c, (void *)objp);
3088 local_irq_restore(flags); 3223 local_irq_restore(flags);
3089} 3224}
@@ -3112,13 +3247,13 @@ void free_percpu(const void *objp)
3112EXPORT_SYMBOL(free_percpu); 3247EXPORT_SYMBOL(free_percpu);
3113#endif 3248#endif
3114 3249
3115unsigned int kmem_cache_size(kmem_cache_t *cachep) 3250unsigned int kmem_cache_size(struct kmem_cache *cachep)
3116{ 3251{
3117 return obj_reallen(cachep); 3252 return obj_size(cachep);
3118} 3253}
3119EXPORT_SYMBOL(kmem_cache_size); 3254EXPORT_SYMBOL(kmem_cache_size);
3120 3255
3121const char *kmem_cache_name(kmem_cache_t *cachep) 3256const char *kmem_cache_name(struct kmem_cache *cachep)
3122{ 3257{
3123 return cachep->name; 3258 return cachep->name;
3124} 3259}
@@ -3127,7 +3262,7 @@ EXPORT_SYMBOL_GPL(kmem_cache_name);
3127/* 3262/*
3128 * This initializes kmem_list3 for all nodes. 3263 * This initializes kmem_list3 for all nodes.
3129 */ 3264 */
3130static int alloc_kmemlist(kmem_cache_t *cachep) 3265static int alloc_kmemlist(struct kmem_cache *cachep)
3131{ 3266{
3132 int node; 3267 int node;
3133 struct kmem_list3 *l3; 3268 struct kmem_list3 *l3;
@@ -3183,7 +3318,7 @@ static int alloc_kmemlist(kmem_cache_t *cachep)
3183} 3318}
3184 3319
3185struct ccupdate_struct { 3320struct ccupdate_struct {
3186 kmem_cache_t *cachep; 3321 struct kmem_cache *cachep;
3187 struct array_cache *new[NR_CPUS]; 3322 struct array_cache *new[NR_CPUS];
3188}; 3323};
3189 3324
@@ -3193,13 +3328,13 @@ static void do_ccupdate_local(void *info)
3193 struct array_cache *old; 3328 struct array_cache *old;
3194 3329
3195 check_irq_off(); 3330 check_irq_off();
3196 old = ac_data(new->cachep); 3331 old = cpu_cache_get(new->cachep);
3197 3332
3198 new->cachep->array[smp_processor_id()] = new->new[smp_processor_id()]; 3333 new->cachep->array[smp_processor_id()] = new->new[smp_processor_id()];
3199 new->new[smp_processor_id()] = old; 3334 new->new[smp_processor_id()] = old;
3200} 3335}
3201 3336
3202static int do_tune_cpucache(kmem_cache_t *cachep, int limit, int batchcount, 3337static int do_tune_cpucache(struct kmem_cache *cachep, int limit, int batchcount,
3203 int shared) 3338 int shared)
3204{ 3339{
3205 struct ccupdate_struct new; 3340 struct ccupdate_struct new;
@@ -3220,11 +3355,11 @@ static int do_tune_cpucache(kmem_cache_t *cachep, int limit, int batchcount,
3220 smp_call_function_all_cpus(do_ccupdate_local, (void *)&new); 3355 smp_call_function_all_cpus(do_ccupdate_local, (void *)&new);
3221 3356
3222 check_irq_on(); 3357 check_irq_on();
3223 spin_lock_irq(&cachep->spinlock); 3358 spin_lock(&cachep->spinlock);
3224 cachep->batchcount = batchcount; 3359 cachep->batchcount = batchcount;
3225 cachep->limit = limit; 3360 cachep->limit = limit;
3226 cachep->shared = shared; 3361 cachep->shared = shared;
3227 spin_unlock_irq(&cachep->spinlock); 3362 spin_unlock(&cachep->spinlock);
3228 3363
3229 for_each_online_cpu(i) { 3364 for_each_online_cpu(i) {
3230 struct array_cache *ccold = new.new[i]; 3365 struct array_cache *ccold = new.new[i];
@@ -3245,7 +3380,7 @@ static int do_tune_cpucache(kmem_cache_t *cachep, int limit, int batchcount,
3245 return 0; 3380 return 0;
3246} 3381}
3247 3382
3248static void enable_cpucache(kmem_cache_t *cachep) 3383static void enable_cpucache(struct kmem_cache *cachep)
3249{ 3384{
3250 int err; 3385 int err;
3251 int limit, shared; 3386 int limit, shared;
@@ -3258,13 +3393,13 @@ static void enable_cpucache(kmem_cache_t *cachep)
3258 * The numbers are guessed, we should auto-tune as described by 3393 * The numbers are guessed, we should auto-tune as described by
3259 * Bonwick. 3394 * Bonwick.
3260 */ 3395 */
3261 if (cachep->objsize > 131072) 3396 if (cachep->buffer_size > 131072)
3262 limit = 1; 3397 limit = 1;
3263 else if (cachep->objsize > PAGE_SIZE) 3398 else if (cachep->buffer_size > PAGE_SIZE)
3264 limit = 8; 3399 limit = 8;
3265 else if (cachep->objsize > 1024) 3400 else if (cachep->buffer_size > 1024)
3266 limit = 24; 3401 limit = 24;
3267 else if (cachep->objsize > 256) 3402 else if (cachep->buffer_size > 256)
3268 limit = 54; 3403 limit = 54;
3269 else 3404 else
3270 limit = 120; 3405 limit = 120;
@@ -3279,7 +3414,7 @@ static void enable_cpucache(kmem_cache_t *cachep)
3279 */ 3414 */
3280 shared = 0; 3415 shared = 0;
3281#ifdef CONFIG_SMP 3416#ifdef CONFIG_SMP
3282 if (cachep->objsize <= PAGE_SIZE) 3417 if (cachep->buffer_size <= PAGE_SIZE)
3283 shared = 8; 3418 shared = 8;
3284#endif 3419#endif
3285 3420
@@ -3297,7 +3432,7 @@ static void enable_cpucache(kmem_cache_t *cachep)
3297 cachep->name, -err); 3432 cachep->name, -err);
3298} 3433}
3299 3434
3300static void drain_array_locked(kmem_cache_t *cachep, struct array_cache *ac, 3435static void drain_array_locked(struct kmem_cache *cachep, struct array_cache *ac,
3301 int force, int node) 3436 int force, int node)
3302{ 3437{
3303 int tofree; 3438 int tofree;
@@ -3342,12 +3477,12 @@ static void cache_reap(void *unused)
3342 } 3477 }
3343 3478
3344 list_for_each(walk, &cache_chain) { 3479 list_for_each(walk, &cache_chain) {
3345 kmem_cache_t *searchp; 3480 struct kmem_cache *searchp;
3346 struct list_head *p; 3481 struct list_head *p;
3347 int tofree; 3482 int tofree;
3348 struct slab *slabp; 3483 struct slab *slabp;
3349 3484
3350 searchp = list_entry(walk, kmem_cache_t, next); 3485 searchp = list_entry(walk, struct kmem_cache, next);
3351 3486
3352 if (searchp->flags & SLAB_NO_REAP) 3487 if (searchp->flags & SLAB_NO_REAP)
3353 goto next; 3488 goto next;
@@ -3356,10 +3491,10 @@ static void cache_reap(void *unused)
3356 3491
3357 l3 = searchp->nodelists[numa_node_id()]; 3492 l3 = searchp->nodelists[numa_node_id()];
3358 if (l3->alien) 3493 if (l3->alien)
3359 drain_alien_cache(searchp, l3); 3494 drain_alien_cache(searchp, l3->alien);
3360 spin_lock_irq(&l3->list_lock); 3495 spin_lock_irq(&l3->list_lock);
3361 3496
3362 drain_array_locked(searchp, ac_data(searchp), 0, 3497 drain_array_locked(searchp, cpu_cache_get(searchp), 0,
3363 numa_node_id()); 3498 numa_node_id());
3364 3499
3365 if (time_after(l3->next_reap, jiffies)) 3500 if (time_after(l3->next_reap, jiffies))
@@ -3450,15 +3585,15 @@ static void *s_start(struct seq_file *m, loff_t *pos)
3450 if (p == &cache_chain) 3585 if (p == &cache_chain)
3451 return NULL; 3586 return NULL;
3452 } 3587 }
3453 return list_entry(p, kmem_cache_t, next); 3588 return list_entry(p, struct kmem_cache, next);
3454} 3589}
3455 3590
3456static void *s_next(struct seq_file *m, void *p, loff_t *pos) 3591static void *s_next(struct seq_file *m, void *p, loff_t *pos)
3457{ 3592{
3458 kmem_cache_t *cachep = p; 3593 struct kmem_cache *cachep = p;
3459 ++*pos; 3594 ++*pos;
3460 return cachep->next.next == &cache_chain ? NULL 3595 return cachep->next.next == &cache_chain ? NULL
3461 : list_entry(cachep->next.next, kmem_cache_t, next); 3596 : list_entry(cachep->next.next, struct kmem_cache, next);
3462} 3597}
3463 3598
3464static void s_stop(struct seq_file *m, void *p) 3599static void s_stop(struct seq_file *m, void *p)
@@ -3468,7 +3603,7 @@ static void s_stop(struct seq_file *m, void *p)
3468 3603
3469static int s_show(struct seq_file *m, void *p) 3604static int s_show(struct seq_file *m, void *p)
3470{ 3605{
3471 kmem_cache_t *cachep = p; 3606 struct kmem_cache *cachep = p;
3472 struct list_head *q; 3607 struct list_head *q;
3473 struct slab *slabp; 3608 struct slab *slabp;
3474 unsigned long active_objs; 3609 unsigned long active_objs;
@@ -3480,8 +3615,7 @@ static int s_show(struct seq_file *m, void *p)
3480 int node; 3615 int node;
3481 struct kmem_list3 *l3; 3616 struct kmem_list3 *l3;
3482 3617
3483 check_irq_on(); 3618 spin_lock(&cachep->spinlock);
3484 spin_lock_irq(&cachep->spinlock);
3485 active_objs = 0; 3619 active_objs = 0;
3486 num_slabs = 0; 3620 num_slabs = 0;
3487 for_each_online_node(node) { 3621 for_each_online_node(node) {
@@ -3489,7 +3623,8 @@ static int s_show(struct seq_file *m, void *p)
3489 if (!l3) 3623 if (!l3)
3490 continue; 3624 continue;
3491 3625
3492 spin_lock(&l3->list_lock); 3626 check_irq_on();
3627 spin_lock_irq(&l3->list_lock);
3493 3628
3494 list_for_each(q, &l3->slabs_full) { 3629 list_for_each(q, &l3->slabs_full) {
3495 slabp = list_entry(q, struct slab, list); 3630 slabp = list_entry(q, struct slab, list);
@@ -3514,9 +3649,10 @@ static int s_show(struct seq_file *m, void *p)
3514 num_slabs++; 3649 num_slabs++;
3515 } 3650 }
3516 free_objects += l3->free_objects; 3651 free_objects += l3->free_objects;
3517 shared_avail += l3->shared->avail; 3652 if (l3->shared)
3653 shared_avail += l3->shared->avail;
3518 3654
3519 spin_unlock(&l3->list_lock); 3655 spin_unlock_irq(&l3->list_lock);
3520 } 3656 }
3521 num_slabs += active_slabs; 3657 num_slabs += active_slabs;
3522 num_objs = num_slabs * cachep->num; 3658 num_objs = num_slabs * cachep->num;
@@ -3528,7 +3664,7 @@ static int s_show(struct seq_file *m, void *p)
3528 printk(KERN_ERR "slab: cache %s error: %s\n", name, error); 3664 printk(KERN_ERR "slab: cache %s error: %s\n", name, error);
3529 3665
3530 seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d", 3666 seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d",
3531 name, active_objs, num_objs, cachep->objsize, 3667 name, active_objs, num_objs, cachep->buffer_size,
3532 cachep->num, (1 << cachep->gfporder)); 3668 cachep->num, (1 << cachep->gfporder));
3533 seq_printf(m, " : tunables %4u %4u %4u", 3669 seq_printf(m, " : tunables %4u %4u %4u",
3534 cachep->limit, cachep->batchcount, cachep->shared); 3670 cachep->limit, cachep->batchcount, cachep->shared);
@@ -3560,7 +3696,7 @@ static int s_show(struct seq_file *m, void *p)
3560 } 3696 }
3561#endif 3697#endif
3562 seq_putc(m, '\n'); 3698 seq_putc(m, '\n');
3563 spin_unlock_irq(&cachep->spinlock); 3699 spin_unlock(&cachep->spinlock);
3564 return 0; 3700 return 0;
3565} 3701}
3566 3702
@@ -3618,7 +3754,8 @@ ssize_t slabinfo_write(struct file *file, const char __user * buffer,
3618 mutex_lock(&cache_chain_mutex); 3754 mutex_lock(&cache_chain_mutex);
3619 res = -EINVAL; 3755 res = -EINVAL;
3620 list_for_each(p, &cache_chain) { 3756 list_for_each(p, &cache_chain) {
3621 kmem_cache_t *cachep = list_entry(p, kmem_cache_t, next); 3757 struct kmem_cache *cachep = list_entry(p, struct kmem_cache,
3758 next);
3622 3759
3623 if (!strcmp(cachep->name, kbuf)) { 3760 if (!strcmp(cachep->name, kbuf)) {
3624 if (limit < 1 || 3761 if (limit < 1 ||
@@ -3656,5 +3793,5 @@ unsigned int ksize(const void *objp)
3656 if (unlikely(objp == NULL)) 3793 if (unlikely(objp == NULL))
3657 return 0; 3794 return 0;
3658 3795
3659 return obj_reallen(page_get_cache(virt_to_page(objp))); 3796 return obj_size(virt_to_cache(objp));
3660} 3797}
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 7b09ac503fec..db8a3d3e1636 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -27,6 +27,7 @@ static struct address_space_operations swap_aops = {
27 .writepage = swap_writepage, 27 .writepage = swap_writepage,
28 .sync_page = block_sync_page, 28 .sync_page = block_sync_page,
29 .set_page_dirty = __set_page_dirty_nobuffers, 29 .set_page_dirty = __set_page_dirty_nobuffers,
30 .migratepage = migrate_page,
30}; 31};
31 32
32static struct backing_dev_info swap_backing_dev_info = { 33static struct backing_dev_info swap_backing_dev_info = {
diff --git a/mm/swapfile.c b/mm/swapfile.c
index f1e69c30d203..1f9cf0d073b8 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -554,6 +554,15 @@ static int unuse_mm(struct mm_struct *mm,
554 return 0; 554 return 0;
555} 555}
556 556
557#ifdef CONFIG_MIGRATION
558int remove_vma_swap(struct vm_area_struct *vma, struct page *page)
559{
560 swp_entry_t entry = { .val = page_private(page) };
561
562 return unuse_vma(vma, entry, page);
563}
564#endif
565
557/* 566/*
558 * Scan swap_map from current position to next entry still in use. 567 * Scan swap_map from current position to next entry still in use.
559 * Recycle to start on reaching the end, returning 0 when empty. 568 * Recycle to start on reaching the end, returning 0 when empty.
@@ -646,6 +655,7 @@ static int try_to_unuse(unsigned int type)
646 */ 655 */
647 swap_map = &si->swap_map[i]; 656 swap_map = &si->swap_map[i];
648 entry = swp_entry(type, i); 657 entry = swp_entry(type, i);
658again:
649 page = read_swap_cache_async(entry, NULL, 0); 659 page = read_swap_cache_async(entry, NULL, 0);
650 if (!page) { 660 if (!page) {
651 /* 661 /*
@@ -680,6 +690,12 @@ static int try_to_unuse(unsigned int type)
680 wait_on_page_locked(page); 690 wait_on_page_locked(page);
681 wait_on_page_writeback(page); 691 wait_on_page_writeback(page);
682 lock_page(page); 692 lock_page(page);
693 if (!PageSwapCache(page)) {
694 /* Page migration has occured */
695 unlock_page(page);
696 page_cache_release(page);
697 goto again;
698 }
683 wait_on_page_writeback(page); 699 wait_on_page_writeback(page);
684 700
685 /* 701 /*
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 2e34b61a70c7..5a610804cd06 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -477,7 +477,13 @@ static int shrink_list(struct list_head *page_list, struct scan_control *sc)
477 * processes. Try to unmap it here. 477 * processes. Try to unmap it here.
478 */ 478 */
479 if (page_mapped(page) && mapping) { 479 if (page_mapped(page) && mapping) {
480 switch (try_to_unmap(page)) { 480 /*
481 * No unmapping if we do not swap
482 */
483 if (!sc->may_swap)
484 goto keep_locked;
485
486 switch (try_to_unmap(page, 0)) {
481 case SWAP_FAIL: 487 case SWAP_FAIL:
482 goto activate_locked; 488 goto activate_locked;
483 case SWAP_AGAIN: 489 case SWAP_AGAIN:
@@ -492,7 +498,7 @@ static int shrink_list(struct list_head *page_list, struct scan_control *sc)
492 goto keep_locked; 498 goto keep_locked;
493 if (!may_enter_fs) 499 if (!may_enter_fs)
494 goto keep_locked; 500 goto keep_locked;
495 if (laptop_mode && !sc->may_writepage) 501 if (!sc->may_writepage)
496 goto keep_locked; 502 goto keep_locked;
497 503
498 /* Page is dirty, try to write it out here */ 504 /* Page is dirty, try to write it out here */
@@ -609,6 +615,15 @@ int putback_lru_pages(struct list_head *l)
609} 615}
610 616
611/* 617/*
618 * Non migratable page
619 */
620int fail_migrate_page(struct page *newpage, struct page *page)
621{
622 return -EIO;
623}
624EXPORT_SYMBOL(fail_migrate_page);
625
626/*
612 * swapout a single page 627 * swapout a single page
613 * page is locked upon entry, unlocked on exit 628 * page is locked upon entry, unlocked on exit
614 */ 629 */
@@ -617,7 +632,7 @@ static int swap_page(struct page *page)
617 struct address_space *mapping = page_mapping(page); 632 struct address_space *mapping = page_mapping(page);
618 633
619 if (page_mapped(page) && mapping) 634 if (page_mapped(page) && mapping)
620 if (try_to_unmap(page) != SWAP_SUCCESS) 635 if (try_to_unmap(page, 0) != SWAP_SUCCESS)
621 goto unlock_retry; 636 goto unlock_retry;
622 637
623 if (PageDirty(page)) { 638 if (PageDirty(page)) {
@@ -653,6 +668,167 @@ unlock_retry:
653retry: 668retry:
654 return -EAGAIN; 669 return -EAGAIN;
655} 670}
671EXPORT_SYMBOL(swap_page);
672
673/*
674 * Page migration was first developed in the context of the memory hotplug
675 * project. The main authors of the migration code are:
676 *
677 * IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
678 * Hirokazu Takahashi <taka@valinux.co.jp>
679 * Dave Hansen <haveblue@us.ibm.com>
680 * Christoph Lameter <clameter@sgi.com>
681 */
682
683/*
684 * Remove references for a page and establish the new page with the correct
685 * basic settings to be able to stop accesses to the page.
686 */
687int migrate_page_remove_references(struct page *newpage,
688 struct page *page, int nr_refs)
689{
690 struct address_space *mapping = page_mapping(page);
691 struct page **radix_pointer;
692
693 /*
694 * Avoid doing any of the following work if the page count
695 * indicates that the page is in use or truncate has removed
696 * the page.
697 */
698 if (!mapping || page_mapcount(page) + nr_refs != page_count(page))
699 return 1;
700
701 /*
702 * Establish swap ptes for anonymous pages or destroy pte
703 * maps for files.
704 *
705 * In order to reestablish file backed mappings the fault handlers
706 * will take the radix tree_lock which may then be used to stop
707 * processses from accessing this page until the new page is ready.
708 *
709 * A process accessing via a swap pte (an anonymous page) will take a
710 * page_lock on the old page which will block the process until the
711 * migration attempt is complete. At that time the PageSwapCache bit
712 * will be examined. If the page was migrated then the PageSwapCache
713 * bit will be clear and the operation to retrieve the page will be
714 * retried which will find the new page in the radix tree. Then a new
715 * direct mapping may be generated based on the radix tree contents.
716 *
717 * If the page was not migrated then the PageSwapCache bit
718 * is still set and the operation may continue.
719 */
720 try_to_unmap(page, 1);
721
722 /*
723 * Give up if we were unable to remove all mappings.
724 */
725 if (page_mapcount(page))
726 return 1;
727
728 write_lock_irq(&mapping->tree_lock);
729
730 radix_pointer = (struct page **)radix_tree_lookup_slot(
731 &mapping->page_tree,
732 page_index(page));
733
734 if (!page_mapping(page) || page_count(page) != nr_refs ||
735 *radix_pointer != page) {
736 write_unlock_irq(&mapping->tree_lock);
737 return 1;
738 }
739
740 /*
741 * Now we know that no one else is looking at the page.
742 *
743 * Certain minimal information about a page must be available
744 * in order for other subsystems to properly handle the page if they
745 * find it through the radix tree update before we are finished
746 * copying the page.
747 */
748 get_page(newpage);
749 newpage->index = page->index;
750 newpage->mapping = page->mapping;
751 if (PageSwapCache(page)) {
752 SetPageSwapCache(newpage);
753 set_page_private(newpage, page_private(page));
754 }
755
756 *radix_pointer = newpage;
757 __put_page(page);
758 write_unlock_irq(&mapping->tree_lock);
759
760 return 0;
761}
762EXPORT_SYMBOL(migrate_page_remove_references);
763
764/*
765 * Copy the page to its new location
766 */
767void migrate_page_copy(struct page *newpage, struct page *page)
768{
769 copy_highpage(newpage, page);
770
771 if (PageError(page))
772 SetPageError(newpage);
773 if (PageReferenced(page))
774 SetPageReferenced(newpage);
775 if (PageUptodate(page))
776 SetPageUptodate(newpage);
777 if (PageActive(page))
778 SetPageActive(newpage);
779 if (PageChecked(page))
780 SetPageChecked(newpage);
781 if (PageMappedToDisk(page))
782 SetPageMappedToDisk(newpage);
783
784 if (PageDirty(page)) {
785 clear_page_dirty_for_io(page);
786 set_page_dirty(newpage);
787 }
788
789 ClearPageSwapCache(page);
790 ClearPageActive(page);
791 ClearPagePrivate(page);
792 set_page_private(page, 0);
793 page->mapping = NULL;
794
795 /*
796 * If any waiters have accumulated on the new page then
797 * wake them up.
798 */
799 if (PageWriteback(newpage))
800 end_page_writeback(newpage);
801}
802EXPORT_SYMBOL(migrate_page_copy);
803
804/*
805 * Common logic to directly migrate a single page suitable for
806 * pages that do not use PagePrivate.
807 *
808 * Pages are locked upon entry and exit.
809 */
810int migrate_page(struct page *newpage, struct page *page)
811{
812 BUG_ON(PageWriteback(page)); /* Writeback must be complete */
813
814 if (migrate_page_remove_references(newpage, page, 2))
815 return -EAGAIN;
816
817 migrate_page_copy(newpage, page);
818
819 /*
820 * Remove auxiliary swap entries and replace
821 * them with real ptes.
822 *
823 * Note that a real pte entry will allow processes that are not
824 * waiting on the page lock to use the new page via the page tables
825 * before the new page is unlocked.
826 */
827 remove_from_swap(newpage);
828 return 0;
829}
830EXPORT_SYMBOL(migrate_page);
831
656/* 832/*
657 * migrate_pages 833 * migrate_pages
658 * 834 *
@@ -666,11 +842,6 @@ retry:
666 * are movable anymore because t has become empty 842 * are movable anymore because t has become empty
667 * or no retryable pages exist anymore. 843 * or no retryable pages exist anymore.
668 * 844 *
669 * SIMPLIFIED VERSION: This implementation of migrate_pages
670 * is only swapping out pages and never touches the second
671 * list. The direct migration patchset
672 * extends this function to avoid the use of swap.
673 *
674 * Return: Number of pages not migrated when "to" ran empty. 845 * Return: Number of pages not migrated when "to" ran empty.
675 */ 846 */
676int migrate_pages(struct list_head *from, struct list_head *to, 847int migrate_pages(struct list_head *from, struct list_head *to,
@@ -691,6 +862,9 @@ redo:
691 retry = 0; 862 retry = 0;
692 863
693 list_for_each_entry_safe(page, page2, from, lru) { 864 list_for_each_entry_safe(page, page2, from, lru) {
865 struct page *newpage = NULL;
866 struct address_space *mapping;
867
694 cond_resched(); 868 cond_resched();
695 869
696 rc = 0; 870 rc = 0;
@@ -698,6 +872,9 @@ redo:
698 /* page was freed from under us. So we are done. */ 872 /* page was freed from under us. So we are done. */
699 goto next; 873 goto next;
700 874
875 if (to && list_empty(to))
876 break;
877
701 /* 878 /*
702 * Skip locked pages during the first two passes to give the 879 * Skip locked pages during the first two passes to give the
703 * functions holding the lock time to release the page. Later we 880 * functions holding the lock time to release the page. Later we
@@ -734,12 +911,69 @@ redo:
734 } 911 }
735 } 912 }
736 913
914 if (!to) {
915 rc = swap_page(page);
916 goto next;
917 }
918
919 newpage = lru_to_page(to);
920 lock_page(newpage);
921
737 /* 922 /*
738 * Page is properly locked and writeback is complete. 923 * Pages are properly locked and writeback is complete.
739 * Try to migrate the page. 924 * Try to migrate the page.
740 */ 925 */
741 rc = swap_page(page); 926 mapping = page_mapping(page);
742 goto next; 927 if (!mapping)
928 goto unlock_both;
929
930 if (mapping->a_ops->migratepage) {
931 rc = mapping->a_ops->migratepage(newpage, page);
932 goto unlock_both;
933 }
934
935 /*
936 * Trigger writeout if page is dirty
937 */
938 if (PageDirty(page)) {
939 switch (pageout(page, mapping)) {
940 case PAGE_KEEP:
941 case PAGE_ACTIVATE:
942 goto unlock_both;
943
944 case PAGE_SUCCESS:
945 unlock_page(newpage);
946 goto next;
947
948 case PAGE_CLEAN:
949 ; /* try to migrate the page below */
950 }
951 }
952 /*
953 * If we have no buffer or can release the buffer
954 * then do a simple migration.
955 */
956 if (!page_has_buffers(page) ||
957 try_to_release_page(page, GFP_KERNEL)) {
958 rc = migrate_page(newpage, page);
959 goto unlock_both;
960 }
961
962 /*
963 * On early passes with mapped pages simply
964 * retry. There may be a lock held for some
965 * buffers that may go away. Later
966 * swap them out.
967 */
968 if (pass > 4) {
969 unlock_page(newpage);
970 newpage = NULL;
971 rc = swap_page(page);
972 goto next;
973 }
974
975unlock_both:
976 unlock_page(newpage);
743 977
744unlock_page: 978unlock_page:
745 unlock_page(page); 979 unlock_page(page);
@@ -752,7 +986,10 @@ next:
752 list_move(&page->lru, failed); 986 list_move(&page->lru, failed);
753 nr_failed++; 987 nr_failed++;
754 } else { 988 } else {
755 /* Success */ 989 if (newpage) {
990 /* Successful migration. Return page to LRU */
991 move_to_lru(newpage);
992 }
756 list_move(&page->lru, moved); 993 list_move(&page->lru, moved);
757 } 994 }
758 } 995 }
@@ -1170,7 +1407,7 @@ int try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
1170 int i; 1407 int i;
1171 1408
1172 sc.gfp_mask = gfp_mask; 1409 sc.gfp_mask = gfp_mask;
1173 sc.may_writepage = 0; 1410 sc.may_writepage = !laptop_mode;
1174 sc.may_swap = 1; 1411 sc.may_swap = 1;
1175 1412
1176 inc_page_state(allocstall); 1413 inc_page_state(allocstall);
@@ -1273,7 +1510,7 @@ loop_again:
1273 total_scanned = 0; 1510 total_scanned = 0;
1274 total_reclaimed = 0; 1511 total_reclaimed = 0;
1275 sc.gfp_mask = GFP_KERNEL; 1512 sc.gfp_mask = GFP_KERNEL;
1276 sc.may_writepage = 0; 1513 sc.may_writepage = !laptop_mode;
1277 sc.may_swap = 1; 1514 sc.may_swap = 1;
1278 sc.nr_mapped = read_page_state(nr_mapped); 1515 sc.nr_mapped = read_page_state(nr_mapped);
1279 1516
@@ -1586,40 +1823,61 @@ module_init(kswapd_init)
1586 */ 1823 */
1587int zone_reclaim_mode __read_mostly; 1824int zone_reclaim_mode __read_mostly;
1588 1825
1826#define RECLAIM_OFF 0
1827#define RECLAIM_ZONE (1<<0) /* Run shrink_cache on the zone */
1828#define RECLAIM_WRITE (1<<1) /* Writeout pages during reclaim */
1829#define RECLAIM_SWAP (1<<2) /* Swap pages out during reclaim */
1830#define RECLAIM_SLAB (1<<3) /* Do a global slab shrink if the zone is out of memory */
1831
1589/* 1832/*
1590 * Mininum time between zone reclaim scans 1833 * Mininum time between zone reclaim scans
1591 */ 1834 */
1592#define ZONE_RECLAIM_INTERVAL HZ/2 1835int zone_reclaim_interval __read_mostly = 30*HZ;
1836
1837/*
1838 * Priority for ZONE_RECLAIM. This determines the fraction of pages
1839 * of a node considered for each zone_reclaim. 4 scans 1/16th of
1840 * a zone.
1841 */
1842#define ZONE_RECLAIM_PRIORITY 4
1843
1593/* 1844/*
1594 * Try to free up some pages from this zone through reclaim. 1845 * Try to free up some pages from this zone through reclaim.
1595 */ 1846 */
1596int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) 1847int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
1597{ 1848{
1598 int nr_pages = 1 << order; 1849 int nr_pages;
1599 struct task_struct *p = current; 1850 struct task_struct *p = current;
1600 struct reclaim_state reclaim_state; 1851 struct reclaim_state reclaim_state;
1601 struct scan_control sc = { 1852 struct scan_control sc;
1602 .gfp_mask = gfp_mask, 1853 cpumask_t mask;
1603 .may_writepage = 0, 1854 int node_id;
1604 .may_swap = 0, 1855
1605 .nr_mapped = read_page_state(nr_mapped), 1856 if (time_before(jiffies,
1606 .nr_scanned = 0, 1857 zone->last_unsuccessful_zone_reclaim + zone_reclaim_interval))
1607 .nr_reclaimed = 0, 1858 return 0;
1608 .priority = 0
1609 };
1610 1859
1611 if (!(gfp_mask & __GFP_WAIT) || 1860 if (!(gfp_mask & __GFP_WAIT) ||
1612 zone->zone_pgdat->node_id != numa_node_id() ||
1613 zone->all_unreclaimable || 1861 zone->all_unreclaimable ||
1614 atomic_read(&zone->reclaim_in_progress) > 0) 1862 atomic_read(&zone->reclaim_in_progress) > 0)
1615 return 0; 1863 return 0;
1616 1864
1617 if (time_before(jiffies, 1865 node_id = zone->zone_pgdat->node_id;
1618 zone->last_unsuccessful_zone_reclaim + ZONE_RECLAIM_INTERVAL)) 1866 mask = node_to_cpumask(node_id);
1619 return 0; 1867 if (!cpus_empty(mask) && node_id != numa_node_id())
1868 return 0;
1869
1870 sc.may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE);
1871 sc.may_swap = !!(zone_reclaim_mode & RECLAIM_SWAP);
1872 sc.nr_scanned = 0;
1873 sc.nr_reclaimed = 0;
1874 sc.priority = ZONE_RECLAIM_PRIORITY + 1;
1875 sc.nr_mapped = read_page_state(nr_mapped);
1876 sc.gfp_mask = gfp_mask;
1620 1877
1621 disable_swap_token(); 1878 disable_swap_token();
1622 1879
1880 nr_pages = 1 << order;
1623 if (nr_pages > SWAP_CLUSTER_MAX) 1881 if (nr_pages > SWAP_CLUSTER_MAX)
1624 sc.swap_cluster_max = nr_pages; 1882 sc.swap_cluster_max = nr_pages;
1625 else 1883 else
@@ -1629,14 +1887,37 @@ int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
1629 p->flags |= PF_MEMALLOC; 1887 p->flags |= PF_MEMALLOC;
1630 reclaim_state.reclaimed_slab = 0; 1888 reclaim_state.reclaimed_slab = 0;
1631 p->reclaim_state = &reclaim_state; 1889 p->reclaim_state = &reclaim_state;
1632 shrink_zone(zone, &sc); 1890
1891 /*
1892 * Free memory by calling shrink zone with increasing priorities
1893 * until we have enough memory freed.
1894 */
1895 do {
1896 sc.priority--;
1897 shrink_zone(zone, &sc);
1898
1899 } while (sc.nr_reclaimed < nr_pages && sc.priority > 0);
1900
1901 if (sc.nr_reclaimed < nr_pages && (zone_reclaim_mode & RECLAIM_SLAB)) {
1902 /*
1903 * shrink_slab does not currently allow us to determine
1904 * how many pages were freed in the zone. So we just
1905 * shake the slab and then go offnode for a single allocation.
1906 *
1907 * shrink_slab will free memory on all zones and may take
1908 * a long time.
1909 */
1910 shrink_slab(sc.nr_scanned, gfp_mask, order);
1911 sc.nr_reclaimed = 1; /* Avoid getting the off node timeout */
1912 }
1913
1633 p->reclaim_state = NULL; 1914 p->reclaim_state = NULL;
1634 current->flags &= ~PF_MEMALLOC; 1915 current->flags &= ~PF_MEMALLOC;
1635 1916
1636 if (sc.nr_reclaimed == 0) 1917 if (sc.nr_reclaimed == 0)
1637 zone->last_unsuccessful_zone_reclaim = jiffies; 1918 zone->last_unsuccessful_zone_reclaim = jiffies;
1638 1919
1639 return sc.nr_reclaimed > nr_pages; 1920 return sc.nr_reclaimed >= nr_pages;
1640} 1921}
1641#endif 1922#endif
1642 1923
diff --git a/net/802/psnap.c b/net/802/psnap.c
index 4d638944d933..34e42968b477 100644
--- a/net/802/psnap.c
+++ b/net/802/psnap.c
@@ -59,8 +59,10 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev,
59 proto = find_snap_client(skb->h.raw); 59 proto = find_snap_client(skb->h.raw);
60 if (proto) { 60 if (proto) {
61 /* Pass the frame on. */ 61 /* Pass the frame on. */
62 u8 *hdr = skb->data;
62 skb->h.raw += 5; 63 skb->h.raw += 5;
63 skb_pull(skb, 5); 64 skb_pull(skb, 5);
65 skb_postpull_rcsum(skb, hdr, 5);
64 rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev); 66 rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev);
65 } else { 67 } else {
66 skb->sk = NULL; 68 skb->sk = NULL;
diff --git a/net/Kconfig b/net/Kconfig
index d6216888c3ae..4193cdcd3ae7 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -27,6 +27,13 @@ if NET
27 27
28menu "Networking options" 28menu "Networking options"
29 29
30config NETDEBUG
31 bool "Network packet debugging"
32 help
33 You can say Y here if you want to get additional messages useful in
34 debugging bad packets, but can overwhelm logs under denial of service
35 attacks.
36
30source "net/packet/Kconfig" 37source "net/packet/Kconfig"
31source "net/unix/Kconfig" 38source "net/unix/Kconfig"
32source "net/xfrm/Kconfig" 39source "net/xfrm/Kconfig"
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index ba442883e877..da687c8dc6ff 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -104,6 +104,7 @@ static void destroy_nbp(struct net_bridge_port *p)
104{ 104{
105 struct net_device *dev = p->dev; 105 struct net_device *dev = p->dev;
106 106
107 dev->br_port = NULL;
107 p->br = NULL; 108 p->br = NULL;
108 p->dev = NULL; 109 p->dev = NULL;
109 dev_put(dev); 110 dev_put(dev);
@@ -118,13 +119,24 @@ static void destroy_nbp_rcu(struct rcu_head *head)
118 destroy_nbp(p); 119 destroy_nbp(p);
119} 120}
120 121
121/* called with RTNL */ 122/* Delete port(interface) from bridge is done in two steps.
123 * via RCU. First step, marks device as down. That deletes
124 * all the timers and stops new packets from flowing through.
125 *
126 * Final cleanup doesn't occur until after all CPU's finished
127 * processing packets.
128 *
129 * Protected from multiple admin operations by RTNL mutex
130 */
122static void del_nbp(struct net_bridge_port *p) 131static void del_nbp(struct net_bridge_port *p)
123{ 132{
124 struct net_bridge *br = p->br; 133 struct net_bridge *br = p->br;
125 struct net_device *dev = p->dev; 134 struct net_device *dev = p->dev;
126 135
127 dev->br_port = NULL; 136 /* Race between RTNL notify and RCU callback */
137 if (p->deleted)
138 return;
139
128 dev_set_promiscuity(dev, -1); 140 dev_set_promiscuity(dev, -1);
129 141
130 cancel_delayed_work(&p->carrier_check); 142 cancel_delayed_work(&p->carrier_check);
@@ -132,16 +144,13 @@ static void del_nbp(struct net_bridge_port *p)
132 144
133 spin_lock_bh(&br->lock); 145 spin_lock_bh(&br->lock);
134 br_stp_disable_port(p); 146 br_stp_disable_port(p);
147 p->deleted = 1;
135 spin_unlock_bh(&br->lock); 148 spin_unlock_bh(&br->lock);
136 149
137 br_fdb_delete_by_port(br, p); 150 br_fdb_delete_by_port(br, p);
138 151
139 list_del_rcu(&p->list); 152 list_del_rcu(&p->list);
140 153
141 del_timer_sync(&p->message_age_timer);
142 del_timer_sync(&p->forward_delay_timer);
143 del_timer_sync(&p->hold_timer);
144
145 call_rcu(&p->rcu, destroy_nbp_rcu); 154 call_rcu(&p->rcu, destroy_nbp_rcu);
146} 155}
147 156
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index c5bd631ffcd5..e330b17b6d81 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -68,6 +68,7 @@ struct net_bridge_port
68 /* STP */ 68 /* STP */
69 u8 priority; 69 u8 priority;
70 u8 state; 70 u8 state;
71 u8 deleted;
71 u16 port_no; 72 u16 port_no;
72 unsigned char topology_change_ack; 73 unsigned char topology_change_ack;
73 unsigned char config_pending; 74 unsigned char config_pending;
diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
index ce617b3dbbb8..802baf755ef4 100644
--- a/net/bridge/netfilter/ebt_ulog.c
+++ b/net/bridge/netfilter/ebt_ulog.c
@@ -46,7 +46,7 @@
46#define PRINTR(format, args...) do { if (net_ratelimit()) \ 46#define PRINTR(format, args...) do { if (net_ratelimit()) \
47 printk(format , ## args); } while (0) 47 printk(format , ## args); } while (0)
48 48
49static unsigned int nlbufsiz = 4096; 49static unsigned int nlbufsiz = NLMSG_GOODSIZE;
50module_param(nlbufsiz, uint, 0600); 50module_param(nlbufsiz, uint, 0600);
51MODULE_PARM_DESC(nlbufsiz, "netlink buffer size (number of bytes) " 51MODULE_PARM_DESC(nlbufsiz, "netlink buffer size (number of bytes) "
52 "(defaults to 4096)"); 52 "(defaults to 4096)");
@@ -98,12 +98,14 @@ static void ulog_timer(unsigned long data)
98static struct sk_buff *ulog_alloc_skb(unsigned int size) 98static struct sk_buff *ulog_alloc_skb(unsigned int size)
99{ 99{
100 struct sk_buff *skb; 100 struct sk_buff *skb;
101 unsigned int n;
101 102
102 skb = alloc_skb(nlbufsiz, GFP_ATOMIC); 103 n = max(size, nlbufsiz);
104 skb = alloc_skb(n, GFP_ATOMIC);
103 if (!skb) { 105 if (!skb) {
104 PRINTR(KERN_ERR "ebt_ulog: can't alloc whole buffer " 106 PRINTR(KERN_ERR "ebt_ulog: can't alloc whole buffer "
105 "of size %ub!\n", nlbufsiz); 107 "of size %ub!\n", n);
106 if (size < nlbufsiz) { 108 if (n > size) {
107 /* try to allocate only as much as we need for 109 /* try to allocate only as much as we need for
108 * current packet */ 110 * current packet */
109 skb = alloc_skb(size, GFP_ATOMIC); 111 skb = alloc_skb(size, GFP_ATOMIC);
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 00729b3604f8..cbd4020cc84d 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -934,6 +934,13 @@ static int do_replace(void __user *user, unsigned int len)
934 BUGPRINT("Entries_size never zero\n"); 934 BUGPRINT("Entries_size never zero\n");
935 return -EINVAL; 935 return -EINVAL;
936 } 936 }
937 /* overflow check */
938 if (tmp.nentries >= ((INT_MAX - sizeof(struct ebt_table_info)) / NR_CPUS -
939 SMP_CACHE_BYTES) / sizeof(struct ebt_counter))
940 return -ENOMEM;
941 if (tmp.num_counters >= INT_MAX / sizeof(struct ebt_counter))
942 return -ENOMEM;
943
937 countersize = COUNTER_OFFSET(tmp.nentries) * 944 countersize = COUNTER_OFFSET(tmp.nentries) *
938 (highest_possible_processor_id()+1); 945 (highest_possible_processor_id()+1);
939 newinfo = (struct ebt_table_info *) 946 newinfo = (struct ebt_table_info *)
diff --git a/net/core/dev.c b/net/core/dev.c
index 41ac7a8ddb0a..225e38ff57c4 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2541,13 +2541,14 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
2541 case SIOCBONDENSLAVE: 2541 case SIOCBONDENSLAVE:
2542 case SIOCBONDRELEASE: 2542 case SIOCBONDRELEASE:
2543 case SIOCBONDSETHWADDR: 2543 case SIOCBONDSETHWADDR:
2544 case SIOCBONDSLAVEINFOQUERY:
2545 case SIOCBONDINFOQUERY:
2546 case SIOCBONDCHANGEACTIVE: 2544 case SIOCBONDCHANGEACTIVE:
2547 case SIOCBRADDIF: 2545 case SIOCBRADDIF:
2548 case SIOCBRDELIF: 2546 case SIOCBRDELIF:
2549 if (!capable(CAP_NET_ADMIN)) 2547 if (!capable(CAP_NET_ADMIN))
2550 return -EPERM; 2548 return -EPERM;
2549 /* fall through */
2550 case SIOCBONDSLAVEINFOQUERY:
2551 case SIOCBONDINFOQUERY:
2551 dev_load(ifr.ifr_name); 2552 dev_load(ifr.ifr_name);
2552 rtnl_lock(); 2553 rtnl_lock();
2553 ret = dev_ifsioc(&ifr, cmd); 2554 ret = dev_ifsioc(&ifr, cmd);
@@ -3234,7 +3235,7 @@ static int __init net_dev_init(void)
3234 * Initialise the packet receive queues. 3235 * Initialise the packet receive queues.
3235 */ 3236 */
3236 3237
3237 for (i = 0; i < NR_CPUS; i++) { 3238 for_each_cpu(i) {
3238 struct softnet_data *queue; 3239 struct softnet_data *queue;
3239 3240
3240 queue = &per_cpu(softnet_data, i); 3241 queue = &per_cpu(softnet_data, i);
diff --git a/net/core/filter.c b/net/core/filter.c
index 9540946a48f3..93fbd01d2259 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -64,7 +64,7 @@ static inline void *load_pointer(struct sk_buff *skb, int k,
64} 64}
65 65
66/** 66/**
67 * sk_run_filter - run a filter on a socket 67 * sk_run_filter - run a filter on a socket
68 * @skb: buffer to run the filter on 68 * @skb: buffer to run the filter on
69 * @filter: filter to apply 69 * @filter: filter to apply
70 * @flen: length of filter 70 * @flen: length of filter
@@ -78,8 +78,8 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int
78{ 78{
79 struct sock_filter *fentry; /* We walk down these */ 79 struct sock_filter *fentry; /* We walk down these */
80 void *ptr; 80 void *ptr;
81 u32 A = 0; /* Accumulator */ 81 u32 A = 0; /* Accumulator */
82 u32 X = 0; /* Index Register */ 82 u32 X = 0; /* Index Register */
83 u32 mem[BPF_MEMWORDS]; /* Scratch Memory Store */ 83 u32 mem[BPF_MEMWORDS]; /* Scratch Memory Store */
84 u32 tmp; 84 u32 tmp;
85 int k; 85 int k;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index d0732e9c8560..6766f118f070 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -135,13 +135,15 @@ void skb_under_panic(struct sk_buff *skb, int sz, void *here)
135struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, 135struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
136 int fclone) 136 int fclone)
137{ 137{
138 kmem_cache_t *cache;
138 struct skb_shared_info *shinfo; 139 struct skb_shared_info *shinfo;
139 struct sk_buff *skb; 140 struct sk_buff *skb;
140 u8 *data; 141 u8 *data;
141 142
143 cache = fclone ? skbuff_fclone_cache : skbuff_head_cache;
144
142 /* Get the HEAD */ 145 /* Get the HEAD */
143 skb = kmem_cache_alloc(fclone ? skbuff_fclone_cache : skbuff_head_cache, 146 skb = kmem_cache_alloc(cache, gfp_mask & ~__GFP_DMA);
144 gfp_mask & ~__GFP_DMA);
145 if (!skb) 147 if (!skb)
146 goto out; 148 goto out;
147 149
@@ -180,7 +182,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
180out: 182out:
181 return skb; 183 return skb;
182nodata: 184nodata:
183 kmem_cache_free(skbuff_head_cache, skb); 185 kmem_cache_free(cache, skb);
184 skb = NULL; 186 skb = NULL;
185 goto out; 187 goto out;
186} 188}
diff --git a/net/core/utils.c b/net/core/utils.c
index ac1d1fcf8673..fdc4f38bc46c 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -121,7 +121,7 @@ void __init net_random_init(void)
121{ 121{
122 int i; 122 int i;
123 123
124 for (i = 0; i < NR_CPUS; i++) { 124 for_each_cpu(i) {
125 struct nrnd_state *state = &per_cpu(net_rand_state,i); 125 struct nrnd_state *state = &per_cpu(net_rand_state,i);
126 __net_srandom(state, i+jiffies); 126 __net_srandom(state, i+jiffies);
127 } 127 }
@@ -133,7 +133,7 @@ static int net_random_reseed(void)
133 unsigned long seed[NR_CPUS]; 133 unsigned long seed[NR_CPUS];
134 134
135 get_random_bytes(seed, sizeof(seed)); 135 get_random_bytes(seed, sizeof(seed));
136 for (i = 0; i < NR_CPUS; i++) { 136 for_each_cpu(i) {
137 struct nrnd_state *state = &per_cpu(net_rand_state,i); 137 struct nrnd_state *state = &per_cpu(net_rand_state,i);
138 __net_srandom(state, seed[i]); 138 __net_srandom(state, seed[i]);
139 } 139 }
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 00f983226672..dc0487b5bace 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -119,7 +119,8 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
119 if (err != 0) 119 if (err != 0)
120 goto failure; 120 goto failure;
121 121
122 err = ip_route_newports(&rt, inet->sport, inet->dport, sk); 122 err = ip_route_newports(&rt, IPPROTO_DCCP, inet->sport, inet->dport,
123 sk);
123 if (err != 0) 124 if (err != 0)
124 goto failure; 125 goto failure;
125 126
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index df074259f9c3..80c4d048869e 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -468,6 +468,7 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
468done: 468done:
469 if (opt && opt != np->opt) 469 if (opt && opt != np->opt)
470 sock_kfree_s(sk, opt, opt->tot_len); 470 sock_kfree_s(sk, opt, opt->tot_len);
471 dst_release(dst);
471 return err; 472 return err;
472} 473}
473 474
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 105039eb7629..4d1c40972a4b 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -385,7 +385,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
385 u32 daddr; 385 u32 daddr;
386 386
387 if (ip_options_echo(&icmp_param->replyopts, skb)) 387 if (ip_options_echo(&icmp_param->replyopts, skb))
388 goto out; 388 return;
389 389
390 if (icmp_xmit_lock()) 390 if (icmp_xmit_lock())
391 return; 391 return;
@@ -416,7 +416,6 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
416 ip_rt_put(rt); 416 ip_rt_put(rt);
417out_unlock: 417out_unlock:
418 icmp_xmit_unlock(); 418 icmp_xmit_unlock();
419out:;
420} 419}
421 420
422 421
@@ -525,7 +524,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, u32 info)
525 iph->tos; 524 iph->tos;
526 525
527 if (ip_options_echo(&icmp_param.replyopts, skb_in)) 526 if (ip_options_echo(&icmp_param.replyopts, skb_in))
528 goto ende; 527 goto out_unlock;
529 528
530 529
531 /* 530 /*
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index d8ce7133cd8f..0b4e95f93dad 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -970,7 +970,7 @@ int igmp_rcv(struct sk_buff *skb)
970 case IGMP_MTRACE_RESP: 970 case IGMP_MTRACE_RESP:
971 break; 971 break;
972 default: 972 default:
973 NETDEBUG(KERN_DEBUG "New IGMP type=%d, why we do not know about it?\n", ih->type); 973 break;
974 } 974 }
975 975
976drop: 976drop:
diff --git a/net/ipv4/multipath_wrandom.c b/net/ipv4/multipath_wrandom.c
index d34a9fa608e0..342d0b9098f5 100644
--- a/net/ipv4/multipath_wrandom.c
+++ b/net/ipv4/multipath_wrandom.c
@@ -228,7 +228,7 @@ static void wrandom_set_nhinfo(__u32 network,
228 struct multipath_dest *d, *target_dest = NULL; 228 struct multipath_dest *d, *target_dest = NULL;
229 229
230 /* store the weight information for a certain route */ 230 /* store the weight information for a certain route */
231 spin_lock(&state[state_idx].lock); 231 spin_lock_bh(&state[state_idx].lock);
232 232
233 /* find state entry for gateway or add one if necessary */ 233 /* find state entry for gateway or add one if necessary */
234 list_for_each_entry_rcu(r, &state[state_idx].head, list) { 234 list_for_each_entry_rcu(r, &state[state_idx].head, list) {
@@ -276,7 +276,7 @@ static void wrandom_set_nhinfo(__u32 network,
276 * we are finished 276 * we are finished
277 */ 277 */
278 278
279 spin_unlock(&state[state_idx].lock); 279 spin_unlock_bh(&state[state_idx].lock);
280} 280}
281 281
282static void __multipath_free(struct rcu_head *head) 282static void __multipath_free(struct rcu_head *head)
@@ -302,7 +302,7 @@ static void wrandom_flush(void)
302 for (i = 0; i < MULTIPATH_STATE_SIZE; ++i) { 302 for (i = 0; i < MULTIPATH_STATE_SIZE; ++i) {
303 struct multipath_route *r; 303 struct multipath_route *r;
304 304
305 spin_lock(&state[i].lock); 305 spin_lock_bh(&state[i].lock);
306 list_for_each_entry_rcu(r, &state[i].head, list) { 306 list_for_each_entry_rcu(r, &state[i].head, list) {
307 struct multipath_dest *d; 307 struct multipath_dest *d;
308 list_for_each_entry_rcu(d, &r->dests, list) { 308 list_for_each_entry_rcu(d, &r->dests, list) {
@@ -315,7 +315,7 @@ static void wrandom_flush(void)
315 __multipath_free); 315 __multipath_free);
316 } 316 }
317 317
318 spin_unlock(&state[i].lock); 318 spin_unlock_bh(&state[i].lock);
319 } 319 }
320} 320}
321 321
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index afe3d8f8177d..dd1048be8a01 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -807,6 +807,13 @@ static int do_replace(void __user *user, unsigned int len)
807 if (len != sizeof(tmp) + tmp.size) 807 if (len != sizeof(tmp) + tmp.size)
808 return -ENOPROTOOPT; 808 return -ENOPROTOOPT;
809 809
810 /* overflow check */
811 if (tmp.size >= (INT_MAX - sizeof(struct xt_table_info)) / NR_CPUS -
812 SMP_CACHE_BYTES)
813 return -ENOMEM;
814 if (tmp.num_counters >= INT_MAX / sizeof(struct xt_counters))
815 return -ENOMEM;
816
810 newinfo = xt_alloc_table_info(tmp.size); 817 newinfo = xt_alloc_table_info(tmp.size);
811 if (!newinfo) 818 if (!newinfo)
812 return -ENOMEM; 819 return -ENOMEM;
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index c9ebbe0d2d9c..e0b5926c76f9 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -1216,7 +1216,7 @@ static int ctnetlink_expect_event(struct notifier_block *this,
1216 1216
1217 b = skb->tail; 1217 b = skb->tail;
1218 1218
1219 type |= NFNL_SUBSYS_CTNETLINK << 8; 1219 type |= NFNL_SUBSYS_CTNETLINK_EXP << 8;
1220 nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg)); 1220 nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg));
1221 nfmsg = NLMSG_DATA(nlh); 1221 nfmsg = NLMSG_DATA(nlh);
1222 1222
@@ -1567,6 +1567,7 @@ static struct nfnetlink_subsystem ctnl_exp_subsys = {
1567}; 1567};
1568 1568
1569MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK); 1569MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK);
1570MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK_EXP);
1570 1571
1571static int __init ctnetlink_init(void) 1572static int __init ctnetlink_init(void)
1572{ 1573{
diff --git a/net/ipv4/netfilter/ip_conntrack_tftp.c b/net/ipv4/netfilter/ip_conntrack_tftp.c
index d3c5a371f993..4ba4463cec28 100644
--- a/net/ipv4/netfilter/ip_conntrack_tftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_tftp.c
@@ -71,6 +71,7 @@ static int tftp_help(struct sk_buff **pskb,
71 71
72 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple; 72 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
73 exp->mask.src.ip = 0xffffffff; 73 exp->mask.src.ip = 0xffffffff;
74 exp->mask.src.u.udp.port = 0;
74 exp->mask.dst.ip = 0xffffffff; 75 exp->mask.dst.ip = 0xffffffff;
75 exp->mask.dst.u.udp.port = 0xffff; 76 exp->mask.dst.u.udp.port = 0xffff;
76 exp->mask.dst.protonum = 0xff; 77 exp->mask.dst.protonum = 0xff;
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index ad438fb185b8..92c54999a19d 100644
--- a/net/ipv4/netfilter/ip_nat_standalone.c
+++ b/net/ipv4/netfilter/ip_nat_standalone.c
@@ -209,8 +209,8 @@ ip_nat_in(unsigned int hooknum,
209 && (ct = ip_conntrack_get(*pskb, &ctinfo)) != NULL) { 209 && (ct = ip_conntrack_get(*pskb, &ctinfo)) != NULL) {
210 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); 210 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
211 211
212 if (ct->tuplehash[dir].tuple.src.ip != 212 if (ct->tuplehash[dir].tuple.dst.ip !=
213 ct->tuplehash[!dir].tuple.dst.ip) { 213 ct->tuplehash[!dir].tuple.src.ip) {
214 dst_release((*pskb)->dst); 214 dst_release((*pskb)->dst);
215 (*pskb)->dst = NULL; 215 (*pskb)->dst = NULL;
216 } 216 }
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 2371b2062c2d..16f47c675fef 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -921,6 +921,13 @@ do_replace(void __user *user, unsigned int len)
921 if (len != sizeof(tmp) + tmp.size) 921 if (len != sizeof(tmp) + tmp.size)
922 return -ENOPROTOOPT; 922 return -ENOPROTOOPT;
923 923
924 /* overflow check */
925 if (tmp.size >= (INT_MAX - sizeof(struct xt_table_info)) / NR_CPUS -
926 SMP_CACHE_BYTES)
927 return -ENOMEM;
928 if (tmp.num_counters >= INT_MAX / sizeof(struct xt_counters))
929 return -ENOMEM;
930
924 newinfo = xt_alloc_table_info(tmp.size); 931 newinfo = xt_alloc_table_info(tmp.size);
925 if (!newinfo) 932 if (!newinfo)
926 return -ENOMEM; 933 return -ENOMEM;
diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
index 641dbc477650..180a9ea57b69 100644
--- a/net/ipv4/netfilter/ipt_ULOG.c
+++ b/net/ipv4/netfilter/ipt_ULOG.c
@@ -35,6 +35,10 @@
35 * each nlgroup you are using, so the total kernel memory usage increases 35 * each nlgroup you are using, so the total kernel memory usage increases
36 * by that factor. 36 * by that factor.
37 * 37 *
38 * Actually you should use nlbufsiz a bit smaller than PAGE_SIZE, since
39 * nlbufsiz is used with alloc_skb, which adds another
40 * sizeof(struct skb_shared_info). Use NLMSG_GOODSIZE instead.
41 *
38 * flushtimeout: 42 * flushtimeout:
39 * Specify, after how many hundredths of a second the queue should be 43 * Specify, after how many hundredths of a second the queue should be
40 * flushed even if it is not full yet. 44 * flushed even if it is not full yet.
@@ -76,7 +80,7 @@ MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_NFLOG);
76 80
77#define PRINTR(format, args...) do { if (net_ratelimit()) printk(format , ## args); } while (0) 81#define PRINTR(format, args...) do { if (net_ratelimit()) printk(format , ## args); } while (0)
78 82
79static unsigned int nlbufsiz = 4096; 83static unsigned int nlbufsiz = NLMSG_GOODSIZE;
80module_param(nlbufsiz, uint, 0400); 84module_param(nlbufsiz, uint, 0400);
81MODULE_PARM_DESC(nlbufsiz, "netlink buffer size"); 85MODULE_PARM_DESC(nlbufsiz, "netlink buffer size");
82 86
@@ -143,22 +147,26 @@ static void ulog_timer(unsigned long data)
143static struct sk_buff *ulog_alloc_skb(unsigned int size) 147static struct sk_buff *ulog_alloc_skb(unsigned int size)
144{ 148{
145 struct sk_buff *skb; 149 struct sk_buff *skb;
150 unsigned int n;
146 151
147 /* alloc skb which should be big enough for a whole 152 /* alloc skb which should be big enough for a whole
148 * multipart message. WARNING: has to be <= 131000 153 * multipart message. WARNING: has to be <= 131000
149 * due to slab allocator restrictions */ 154 * due to slab allocator restrictions */
150 155
151 skb = alloc_skb(nlbufsiz, GFP_ATOMIC); 156 n = max(size, nlbufsiz);
157 skb = alloc_skb(n, GFP_ATOMIC);
152 if (!skb) { 158 if (!skb) {
153 PRINTR("ipt_ULOG: can't alloc whole buffer %ub!\n", 159 PRINTR("ipt_ULOG: can't alloc whole buffer %ub!\n", n);
154 nlbufsiz);
155 160
156 /* try to allocate only as much as we need for 161 if (n > size) {
157 * current packet */ 162 /* try to allocate only as much as we need for
163 * current packet */
158 164
159 skb = alloc_skb(size, GFP_ATOMIC); 165 skb = alloc_skb(size, GFP_ATOMIC);
160 if (!skb) 166 if (!skb)
161 PRINTR("ipt_ULOG: can't even allocate %ub\n", size); 167 PRINTR("ipt_ULOG: can't even allocate %ub\n",
168 size);
169 }
162 } 170 }
163 171
164 return skb; 172 return skb;
diff --git a/net/ipv4/netfilter/ipt_policy.c b/net/ipv4/netfilter/ipt_policy.c
index 18ca8258a1c5..5a7a265280f9 100644
--- a/net/ipv4/netfilter/ipt_policy.c
+++ b/net/ipv4/netfilter/ipt_policy.c
@@ -26,10 +26,13 @@ MODULE_LICENSE("GPL");
26static inline int 26static inline int
27match_xfrm_state(struct xfrm_state *x, const struct ipt_policy_elem *e) 27match_xfrm_state(struct xfrm_state *x, const struct ipt_policy_elem *e)
28{ 28{
29#define MATCH(x,y) (!e->match.x || ((e->x == (y)) ^ e->invert.x)) 29#define MATCH_ADDR(x,y,z) (!e->match.x || \
30 ((e->x.a4.s_addr == (e->y.a4.s_addr & (z))) \
31 ^ e->invert.x))
32#define MATCH(x,y) (!e->match.x || ((e->x == (y)) ^ e->invert.x))
30 33
31 return MATCH(saddr, x->props.saddr.a4 & e->smask) && 34 return MATCH_ADDR(saddr, smask, x->props.saddr.a4) &&
32 MATCH(daddr, x->id.daddr.a4 & e->dmask) && 35 MATCH_ADDR(daddr, dmask, x->id.daddr.a4) &&
33 MATCH(proto, x->id.proto) && 36 MATCH(proto, x->id.proto) &&
34 MATCH(mode, x->props.mode) && 37 MATCH(mode, x->props.mode) &&
35 MATCH(spi, x->id.spi) && 38 MATCH(spi, x->id.spi) &&
@@ -89,7 +92,7 @@ match_policy_out(const struct sk_buff *skb, const struct ipt_policy_info *info)
89 return 0; 92 return 0;
90 } 93 }
91 94
92 return strict ? 1 : 0; 95 return strict ? i == info->len : 0;
93} 96}
94 97
95static int match(const struct sk_buff *skb, 98static int match(const struct sk_buff *skb,
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 39d49dc333a7..1b167c4bb3be 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -49,7 +49,7 @@ static int fold_prot_inuse(struct proto *proto)
49 int res = 0; 49 int res = 0;
50 int cpu; 50 int cpu;
51 51
52 for (cpu = 0; cpu < NR_CPUS; cpu++) 52 for_each_cpu(cpu)
53 res += proto->stats[cpu].inuse; 53 res += proto->stats[cpu].inuse;
54 54
55 return res; 55 return res;
diff --git a/net/ipv4/tcp_htcp.c b/net/ipv4/tcp_htcp.c
index 3284cfb993e6..128de4d7c0b7 100644
--- a/net/ipv4/tcp_htcp.c
+++ b/net/ipv4/tcp_htcp.c
@@ -230,7 +230,6 @@ static void htcp_cong_avoid(struct sock *sk, u32 ack, u32 rtt,
230 if (tp->snd_cwnd < tp->snd_cwnd_clamp) 230 if (tp->snd_cwnd < tp->snd_cwnd_clamp)
231 tp->snd_cwnd++; 231 tp->snd_cwnd++;
232 tp->snd_cwnd_cnt = 0; 232 tp->snd_cwnd_cnt = 0;
233 ca->ccount++;
234 } 233 }
235 } 234 }
236} 235}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 6ea353907af5..233bdf259965 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -236,7 +236,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
236 if (err) 236 if (err)
237 goto failure; 237 goto failure;
238 238
239 err = ip_route_newports(&rt, inet->sport, inet->dport, sk); 239 err = ip_route_newports(&rt, IPPROTO_TCP, inet->sport, inet->dport, sk);
240 if (err) 240 if (err)
241 goto failure; 241 goto failure;
242 242
@@ -1845,7 +1845,6 @@ void __init tcp_v4_init(struct net_proto_family *ops)
1845} 1845}
1846 1846
1847EXPORT_SYMBOL(ipv4_specific); 1847EXPORT_SYMBOL(ipv4_specific);
1848EXPORT_SYMBOL(inet_bind_bucket_create);
1849EXPORT_SYMBOL(tcp_hashinfo); 1848EXPORT_SYMBOL(tcp_hashinfo);
1850EXPORT_SYMBOL(tcp_prot); 1849EXPORT_SYMBOL(tcp_prot);
1851EXPORT_SYMBOL(tcp_unhash); 1850EXPORT_SYMBOL(tcp_unhash);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d328d5986143..1db50487916b 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3321,9 +3321,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
3321 3321
3322 switch (event) { 3322 switch (event) {
3323 case RTM_NEWADDR: 3323 case RTM_NEWADDR:
3324 dst_hold(&ifp->rt->u.dst); 3324 ip6_ins_rt(ifp->rt, NULL, NULL, NULL);
3325 if (ip6_ins_rt(ifp->rt, NULL, NULL, NULL))
3326 dst_release(&ifp->rt->u.dst);
3327 if (ifp->idev->cnf.forwarding) 3325 if (ifp->idev->cnf.forwarding)
3328 addrconf_join_anycast(ifp); 3326 addrconf_join_anycast(ifp);
3329 break; 3327 break;
@@ -3334,8 +3332,6 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
3334 dst_hold(&ifp->rt->u.dst); 3332 dst_hold(&ifp->rt->u.dst);
3335 if (ip6_del_rt(ifp->rt, NULL, NULL, NULL)) 3333 if (ip6_del_rt(ifp->rt, NULL, NULL, NULL))
3336 dst_free(&ifp->rt->u.dst); 3334 dst_free(&ifp->rt->u.dst);
3337 else
3338 dst_release(&ifp->rt->u.dst);
3339 break; 3335 break;
3340 } 3336 }
3341} 3337}
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 064ffab82a9f..6c9711ac1c03 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -369,12 +369,6 @@ int inet6_destroy_sock(struct sock *sk)
369 struct sk_buff *skb; 369 struct sk_buff *skb;
370 struct ipv6_txoptions *opt; 370 struct ipv6_txoptions *opt;
371 371
372 /*
373 * Release destination entry
374 */
375
376 sk_dst_reset(sk);
377
378 /* Release rx options */ 372 /* Release rx options */
379 373
380 if ((skb = xchg(&np->pktoptions, NULL)) != NULL) 374 if ((skb = xchg(&np->pktoptions, NULL)) != NULL)
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 6c05c7978bef..4420948a1bfe 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1252,8 +1252,7 @@ int igmp6_event_query(struct sk_buff *skb)
1252 } 1252 }
1253 } else { 1253 } else {
1254 for (ma = idev->mc_list; ma; ma=ma->next) { 1254 for (ma = idev->mc_list; ma; ma=ma->next) {
1255 if (group_type != IPV6_ADDR_ANY && 1255 if (!ipv6_addr_equal(group, &ma->mca_addr))
1256 !ipv6_addr_equal(group, &ma->mca_addr))
1257 continue; 1256 continue;
1258 spin_lock_bh(&ma->mca_lock); 1257 spin_lock_bh(&ma->mca_lock);
1259 if (ma->mca_flags & MAF_TIMER_RUNNING) { 1258 if (ma->mca_flags & MAF_TIMER_RUNNING) {
@@ -1268,11 +1267,10 @@ int igmp6_event_query(struct sk_buff *skb)
1268 ma->mca_flags &= ~MAF_GSQUERY; 1267 ma->mca_flags &= ~MAF_GSQUERY;
1269 } 1268 }
1270 if (!(ma->mca_flags & MAF_GSQUERY) || 1269 if (!(ma->mca_flags & MAF_GSQUERY) ||
1271 mld_marksources(ma, ntohs(mlh2->nsrcs), mlh2->srcs)) 1270 mld_marksources(ma, ntohs(mlh2->nsrcs), mlh2->srcs))
1272 igmp6_group_queried(ma, max_delay); 1271 igmp6_group_queried(ma, max_delay);
1273 spin_unlock_bh(&ma->mca_lock); 1272 spin_unlock_bh(&ma->mca_lock);
1274 if (group_type != IPV6_ADDR_ANY) 1273 break;
1275 break;
1276 } 1274 }
1277 } 1275 }
1278 read_unlock_bh(&idev->lock); 1276 read_unlock_bh(&idev->lock);
@@ -1351,7 +1349,7 @@ static int is_in(struct ifmcaddr6 *pmc, struct ip6_sf_list *psf, int type,
1351 * in all filters 1349 * in all filters
1352 */ 1350 */
1353 if (psf->sf_count[MCAST_INCLUDE]) 1351 if (psf->sf_count[MCAST_INCLUDE])
1354 return 0; 1352 return type == MLD2_MODE_IS_INCLUDE;
1355 return pmc->mca_sfcount[MCAST_EXCLUDE] == 1353 return pmc->mca_sfcount[MCAST_EXCLUDE] ==
1356 psf->sf_count[MCAST_EXCLUDE]; 1354 psf->sf_count[MCAST_EXCLUDE];
1357 } 1355 }
@@ -1966,7 +1964,7 @@ static void sf_markstate(struct ifmcaddr6 *pmc)
1966 1964
1967static int sf_setstate(struct ifmcaddr6 *pmc) 1965static int sf_setstate(struct ifmcaddr6 *pmc)
1968{ 1966{
1969 struct ip6_sf_list *psf; 1967 struct ip6_sf_list *psf, *dpsf;
1970 int mca_xcount = pmc->mca_sfcount[MCAST_EXCLUDE]; 1968 int mca_xcount = pmc->mca_sfcount[MCAST_EXCLUDE];
1971 int qrv = pmc->idev->mc_qrv; 1969 int qrv = pmc->idev->mc_qrv;
1972 int new_in, rv; 1970 int new_in, rv;
@@ -1978,8 +1976,48 @@ static int sf_setstate(struct ifmcaddr6 *pmc)
1978 !psf->sf_count[MCAST_INCLUDE]; 1976 !psf->sf_count[MCAST_INCLUDE];
1979 } else 1977 } else
1980 new_in = psf->sf_count[MCAST_INCLUDE] != 0; 1978 new_in = psf->sf_count[MCAST_INCLUDE] != 0;
1981 if (new_in != psf->sf_oldin) { 1979 if (new_in) {
1982 psf->sf_crcount = qrv; 1980 if (!psf->sf_oldin) {
1981 struct ip6_sf_list *prev = 0;
1982
1983 for (dpsf=pmc->mca_tomb; dpsf;
1984 dpsf=dpsf->sf_next) {
1985 if (ipv6_addr_equal(&dpsf->sf_addr,
1986 &psf->sf_addr))
1987 break;
1988 prev = dpsf;
1989 }
1990 if (dpsf) {
1991 if (prev)
1992 prev->sf_next = dpsf->sf_next;
1993 else
1994 pmc->mca_tomb = dpsf->sf_next;
1995 kfree(dpsf);
1996 }
1997 psf->sf_crcount = qrv;
1998 rv++;
1999 }
2000 } else if (psf->sf_oldin) {
2001 psf->sf_crcount = 0;
2002 /*
2003 * add or update "delete" records if an active filter
2004 * is now inactive
2005 */
2006 for (dpsf=pmc->mca_tomb; dpsf; dpsf=dpsf->sf_next)
2007 if (ipv6_addr_equal(&dpsf->sf_addr,
2008 &psf->sf_addr))
2009 break;
2010 if (!dpsf) {
2011 dpsf = (struct ip6_sf_list *)
2012 kmalloc(sizeof(*dpsf), GFP_ATOMIC);
2013 if (!dpsf)
2014 continue;
2015 *dpsf = *psf;
2016 /* pmc->mca_lock held by callers */
2017 dpsf->sf_next = pmc->mca_tomb;
2018 pmc->mca_tomb = dpsf;
2019 }
2020 dpsf->sf_crcount = qrv;
1983 rv++; 2021 rv++;
1984 } 2022 }
1985 } 2023 }
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 847068fd3367..74ff56c322f4 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -978,6 +978,13 @@ do_replace(void __user *user, unsigned int len)
978 if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) 978 if (copy_from_user(&tmp, user, sizeof(tmp)) != 0)
979 return -EFAULT; 979 return -EFAULT;
980 980
981 /* overflow check */
982 if (tmp.size >= (INT_MAX - sizeof(struct xt_table_info)) / NR_CPUS -
983 SMP_CACHE_BYTES)
984 return -ENOMEM;
985 if (tmp.num_counters >= INT_MAX / sizeof(struct xt_counters))
986 return -ENOMEM;
987
981 newinfo = xt_alloc_table_info(tmp.size); 988 newinfo = xt_alloc_table_info(tmp.size);
982 if (!newinfo) 989 if (!newinfo)
983 return -ENOMEM; 990 return -ENOMEM;
diff --git a/net/ipv6/netfilter/ip6t_policy.c b/net/ipv6/netfilter/ip6t_policy.c
index afe1cc4c18a5..3d39ec924041 100644
--- a/net/ipv6/netfilter/ip6t_policy.c
+++ b/net/ipv6/netfilter/ip6t_policy.c
@@ -26,8 +26,9 @@ MODULE_LICENSE("GPL");
26static inline int 26static inline int
27match_xfrm_state(struct xfrm_state *x, const struct ip6t_policy_elem *e) 27match_xfrm_state(struct xfrm_state *x, const struct ip6t_policy_elem *e)
28{ 28{
29#define MATCH_ADDR(x,y,z) (!e->match.x || \ 29#define MATCH_ADDR(x,y,z) (!e->match.x || \
30 ((ip6_masked_addrcmp((z), &e->x, &e->y)) == 0) ^ e->invert.x) 30 ((!ip6_masked_addrcmp(&e->x.a6, &e->y.a6, z)) \
31 ^ e->invert.x))
31#define MATCH(x,y) (!e->match.x || ((e->x == (y)) ^ e->invert.x)) 32#define MATCH(x,y) (!e->match.x || ((e->x == (y)) ^ e->invert.x))
32 33
33 return MATCH_ADDR(saddr, smask, (struct in6_addr *)&x->props.saddr.a6) && 34 return MATCH_ADDR(saddr, smask, (struct in6_addr *)&x->props.saddr.a6) &&
@@ -91,7 +92,7 @@ match_policy_out(const struct sk_buff *skb, const struct ip6t_policy_info *info)
91 return 0; 92 return 0;
92 } 93 }
93 94
94 return strict ? 1 : 0; 95 return strict ? i == info->len : 0;
95} 96}
96 97
97static int match(const struct sk_buff *skb, 98static int match(const struct sk_buff *skb,
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 50a13e75d70e..4238b1ed8860 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -38,7 +38,7 @@ static int fold_prot_inuse(struct proto *proto)
38 int res = 0; 38 int res = 0;
39 int cpu; 39 int cpu;
40 40
41 for (cpu=0; cpu<NR_CPUS; cpu++) 41 for_each_cpu(cpu)
42 res += proto->stats[cpu].inuse; 42 res += proto->stats[cpu].inuse;
43 43
44 return res; 44 return res;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 66d04004afda..ca9cf6853755 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -515,6 +515,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
515done: 515done:
516 if (opt && opt != np->opt) 516 if (opt && opt != np->opt)
517 sock_kfree_s(sk, opt, opt->tot_len); 517 sock_kfree_s(sk, opt, opt->tot_len);
518 dst_release(dst);
518 return err; 519 return err;
519} 520}
520 521
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 43f1ce74187d..ae86d237a456 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1620,6 +1620,7 @@ static int key_notify_sa_flush(struct km_event *c)
1620 return -ENOBUFS; 1620 return -ENOBUFS;
1621 hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); 1621 hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg));
1622 hdr->sadb_msg_satype = pfkey_proto2satype(c->data.proto); 1622 hdr->sadb_msg_satype = pfkey_proto2satype(c->data.proto);
1623 hdr->sadb_msg_type = SADB_FLUSH;
1623 hdr->sadb_msg_seq = c->seq; 1624 hdr->sadb_msg_seq = c->seq;
1624 hdr->sadb_msg_pid = c->pid; 1625 hdr->sadb_msg_pid = c->pid;
1625 hdr->sadb_msg_version = PF_KEY_V2; 1626 hdr->sadb_msg_version = PF_KEY_V2;
@@ -2385,6 +2386,7 @@ static int key_notify_policy_flush(struct km_event *c)
2385 if (!skb_out) 2386 if (!skb_out)
2386 return -ENOBUFS; 2387 return -ENOBUFS;
2387 hdr = (struct sadb_msg *) skb_put(skb_out, sizeof(struct sadb_msg)); 2388 hdr = (struct sadb_msg *) skb_put(skb_out, sizeof(struct sadb_msg));
2389 hdr->sadb_msg_type = SADB_X_SPDFLUSH;
2388 hdr->sadb_msg_seq = c->seq; 2390 hdr->sadb_msg_seq = c->seq;
2389 hdr->sadb_msg_pid = c->pid; 2391 hdr->sadb_msg_pid = c->pid;
2390 hdr->sadb_msg_version = PF_KEY_V2; 2392 hdr->sadb_msg_version = PF_KEY_V2;
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 62bb509f05d4..0ce337a1d974 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -188,7 +188,7 @@ extern struct nf_conntrack_protocol nf_conntrack_generic_protocol;
188struct nf_conntrack_protocol * 188struct nf_conntrack_protocol *
189__nf_ct_proto_find(u_int16_t l3proto, u_int8_t protocol) 189__nf_ct_proto_find(u_int16_t l3proto, u_int8_t protocol)
190{ 190{
191 if (unlikely(nf_ct_protos[l3proto] == NULL)) 191 if (unlikely(l3proto >= AF_MAX || nf_ct_protos[l3proto] == NULL))
192 return &nf_conntrack_generic_protocol; 192 return &nf_conntrack_generic_protocol;
193 193
194 return nf_ct_protos[l3proto][protocol]; 194 return nf_ct_protos[l3proto][protocol];
diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
index ab0c920f0d30..6f210f399762 100644
--- a/net/netfilter/nf_conntrack_ftp.c
+++ b/net/netfilter/nf_conntrack_ftp.c
@@ -657,8 +657,6 @@ static int __init init(void)
657 /* FIXME should be configurable whether IPv4 and IPv6 FTP connections 657 /* FIXME should be configurable whether IPv4 and IPv6 FTP connections
658 are tracked or not - YK */ 658 are tracked or not - YK */
659 for (i = 0; i < ports_c; i++) { 659 for (i = 0; i < ports_c; i++) {
660 memset(&ftp[i], 0, sizeof(struct nf_conntrack_helper));
661
662 ftp[i][0].tuple.src.l3num = PF_INET; 660 ftp[i][0].tuple.src.l3num = PF_INET;
663 ftp[i][1].tuple.src.l3num = PF_INET6; 661 ftp[i][1].tuple.src.l3num = PF_INET6;
664 for (j = 0; j < 2; j++) { 662 for (j = 0; j < 2; j++) {
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 73ab16bc7d40..9ff3463037e1 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1232,7 +1232,7 @@ static int ctnetlink_expect_event(struct notifier_block *this,
1232 1232
1233 b = skb->tail; 1233 b = skb->tail;
1234 1234
1235 type |= NFNL_SUBSYS_CTNETLINK << 8; 1235 type |= NFNL_SUBSYS_CTNETLINK_EXP << 8;
1236 nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg)); 1236 nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg));
1237 nfmsg = NLMSG_DATA(nlh); 1237 nfmsg = NLMSG_DATA(nlh);
1238 1238
@@ -1589,6 +1589,7 @@ static struct nfnetlink_subsystem ctnl_exp_subsys = {
1589}; 1589};
1590 1590
1591MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK); 1591MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK);
1592MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK_EXP);
1592 1593
1593static int __init ctnetlink_init(void) 1594static int __init ctnetlink_init(void)
1594{ 1595{
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index e10512e229b6..3b3c781b40c0 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -37,7 +37,7 @@
37#include "../bridge/br_private.h" 37#include "../bridge/br_private.h"
38#endif 38#endif
39 39
40#define NFULNL_NLBUFSIZ_DEFAULT 4096 40#define NFULNL_NLBUFSIZ_DEFAULT NLMSG_GOODSIZE
41#define NFULNL_TIMEOUT_DEFAULT 100 /* every second */ 41#define NFULNL_TIMEOUT_DEFAULT 100 /* every second */
42#define NFULNL_QTHRESH_DEFAULT 100 /* 100 packets */ 42#define NFULNL_QTHRESH_DEFAULT 100 /* 100 packets */
43 43
@@ -314,24 +314,28 @@ static struct sk_buff *nfulnl_alloc_skb(unsigned int inst_size,
314 unsigned int pkt_size) 314 unsigned int pkt_size)
315{ 315{
316 struct sk_buff *skb; 316 struct sk_buff *skb;
317 unsigned int n;
317 318
318 UDEBUG("entered (%u, %u)\n", inst_size, pkt_size); 319 UDEBUG("entered (%u, %u)\n", inst_size, pkt_size);
319 320
320 /* alloc skb which should be big enough for a whole multipart 321 /* alloc skb which should be big enough for a whole multipart
321 * message. WARNING: has to be <= 128k due to slab restrictions */ 322 * message. WARNING: has to be <= 128k due to slab restrictions */
322 323
323 skb = alloc_skb(inst_size, GFP_ATOMIC); 324 n = max(inst_size, pkt_size);
325 skb = alloc_skb(n, GFP_ATOMIC);
324 if (!skb) { 326 if (!skb) {
325 PRINTR("nfnetlink_log: can't alloc whole buffer (%u bytes)\n", 327 PRINTR("nfnetlink_log: can't alloc whole buffer (%u bytes)\n",
326 inst_size); 328 inst_size);
327 329
328 /* try to allocate only as much as we need for current 330 if (n > pkt_size) {
329 * packet */ 331 /* try to allocate only as much as we need for current
332 * packet */
330 333
331 skb = alloc_skb(pkt_size, GFP_ATOMIC); 334 skb = alloc_skb(pkt_size, GFP_ATOMIC);
332 if (!skb) 335 if (!skb)
333 PRINTR("nfnetlink_log: can't even alloc %u bytes\n", 336 PRINTR("nfnetlink_log: can't even alloc %u "
334 pkt_size); 337 "bytes\n", pkt_size);
338 }
335 } 339 }
336 340
337 return skb; 341 return skb;
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 18ed9c5d209c..cac38b2e147a 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -825,7 +825,8 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
825 } 825 }
826 826
827 if (nfqa[NFQA_MARK-1]) 827 if (nfqa[NFQA_MARK-1])
828 skb->nfmark = ntohl(*(u_int32_t *)NFA_DATA(nfqa[NFQA_MARK-1])); 828 entry->skb->nfmark = ntohl(*(u_int32_t *)
829 NFA_DATA(nfqa[NFQA_MARK-1]));
829 830
830 issue_verdict(entry, verdict); 831 issue_verdict(entry, verdict);
831 instance_put(queue); 832 instance_put(queue);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index ee93abc71cb8..9db7dbdb16e6 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -365,7 +365,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
365 */ 365 */
366 366
367 err = -EMSGSIZE; 367 err = -EMSGSIZE;
368 if(len>dev->mtu+dev->hard_header_len) 368 if (len > dev->mtu + dev->hard_header_len)
369 goto out_unlock; 369 goto out_unlock;
370 370
371 err = -ENOBUFS; 371 err = -ENOBUFS;
@@ -935,7 +935,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int add
935 * Check legality 935 * Check legality
936 */ 936 */
937 937
938 if(addr_len!=sizeof(struct sockaddr)) 938 if (addr_len != sizeof(struct sockaddr))
939 return -EINVAL; 939 return -EINVAL;
940 strlcpy(name,uaddr->sa_data,sizeof(name)); 940 strlcpy(name,uaddr->sa_data,sizeof(name));
941 941
@@ -1092,7 +1092,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
1092 * retries. 1092 * retries.
1093 */ 1093 */
1094 1094
1095 if(skb==NULL) 1095 if (skb == NULL)
1096 goto out; 1096 goto out;
1097 1097
1098 /* 1098 /*
@@ -1392,8 +1392,8 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
1392 if (level != SOL_PACKET) 1392 if (level != SOL_PACKET)
1393 return -ENOPROTOOPT; 1393 return -ENOPROTOOPT;
1394 1394
1395 if (get_user(len,optlen)) 1395 if (get_user(len, optlen))
1396 return -EFAULT; 1396 return -EFAULT;
1397 1397
1398 if (len < 0) 1398 if (len < 0)
1399 return -EINVAL; 1399 return -EINVAL;
@@ -1419,9 +1419,9 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
1419 return -ENOPROTOOPT; 1419 return -ENOPROTOOPT;
1420 } 1420 }
1421 1421
1422 if (put_user(len, optlen)) 1422 if (put_user(len, optlen))
1423 return -EFAULT; 1423 return -EFAULT;
1424 return 0; 1424 return 0;
1425} 1425}
1426 1426
1427 1427
diff --git a/net/sctp/output.c b/net/sctp/output.c
index a40991ef72c9..437cba7260a4 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -608,7 +608,7 @@ static sctp_xmit_t sctp_packet_append_data(struct sctp_packet *packet,
608 * When a Fast Retransmit is being performed the sender SHOULD 608 * When a Fast Retransmit is being performed the sender SHOULD
609 * ignore the value of cwnd and SHOULD NOT delay retransmission. 609 * ignore the value of cwnd and SHOULD NOT delay retransmission.
610 */ 610 */
611 if (!chunk->fast_retransmit) 611 if (chunk->fast_retransmit <= 0)
612 if (transport->flight_size >= transport->cwnd) { 612 if (transport->flight_size >= transport->cwnd) {
613 retval = SCTP_XMIT_RWND_FULL; 613 retval = SCTP_XMIT_RWND_FULL;
614 goto finish; 614 goto finish;
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index efb72faba20c..f148f9576dd2 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -406,7 +406,7 @@ void sctp_retransmit_mark(struct sctp_outq *q,
406 * chunks that are not yet acked should be added to the 406 * chunks that are not yet acked should be added to the
407 * retransmit queue. 407 * retransmit queue.
408 */ 408 */
409 if ((fast_retransmit && chunk->fast_retransmit) || 409 if ((fast_retransmit && (chunk->fast_retransmit > 0)) ||
410 (!fast_retransmit && !chunk->tsn_gap_acked)) { 410 (!fast_retransmit && !chunk->tsn_gap_acked)) {
411 /* RFC 2960 6.2.1 Processing a Received SACK 411 /* RFC 2960 6.2.1 Processing a Received SACK
412 * 412 *
@@ -603,7 +603,8 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
603 /* Mark the chunk as ineligible for fast retransmit 603 /* Mark the chunk as ineligible for fast retransmit
604 * after it is retransmitted. 604 * after it is retransmitted.
605 */ 605 */
606 chunk->fast_retransmit = 0; 606 if (chunk->fast_retransmit > 0)
607 chunk->fast_retransmit = -1;
607 608
608 *start_timer = 1; 609 *start_timer = 1;
609 q->empty = 0; 610 q->empty = 0;
@@ -621,7 +622,8 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
621 list_for_each(lchunk1, lqueue) { 622 list_for_each(lchunk1, lqueue) {
622 chunk1 = list_entry(lchunk1, struct sctp_chunk, 623 chunk1 = list_entry(lchunk1, struct sctp_chunk,
623 transmitted_list); 624 transmitted_list);
624 chunk1->fast_retransmit = 0; 625 if (chunk1->fast_retransmit > 0)
626 chunk1->fast_retransmit = -1;
625 } 627 }
626 } 628 }
627 } 629 }
@@ -1562,11 +1564,11 @@ static void sctp_mark_missing(struct sctp_outq *q,
1562 /* 1564 /*
1563 * M4) If any DATA chunk is found to have a 1565 * M4) If any DATA chunk is found to have a
1564 * 'TSN.Missing.Report' 1566 * 'TSN.Missing.Report'
1565 * value larger than or equal to 4, mark that chunk for 1567 * value larger than or equal to 3, mark that chunk for
1566 * retransmission and start the fast retransmit procedure. 1568 * retransmission and start the fast retransmit procedure.
1567 */ 1569 */
1568 1570
1569 if (chunk->tsn_missing_report >= 4) { 1571 if (chunk->tsn_missing_report >= 3) {
1570 chunk->fast_retransmit = 1; 1572 chunk->fast_retransmit = 1;
1571 do_fast_retransmit = 1; 1573 do_fast_retransmit = 1;
1572 } 1574 }
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 71c9a961c321..2b9a832b29a7 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -884,7 +884,7 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep,
884{ 884{
885 struct sctp_transport *transport = (struct sctp_transport *) arg; 885 struct sctp_transport *transport = (struct sctp_transport *) arg;
886 886
887 if (asoc->overall_error_count > asoc->max_retrans) { 887 if (asoc->overall_error_count >= asoc->max_retrans) {
888 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 888 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
889 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 889 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
890 SCTP_U32(SCTP_ERROR_NO_ERROR)); 890 SCTP_U32(SCTP_ERROR_NO_ERROR));
@@ -2122,7 +2122,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep,
2122 struct sctp_bind_addr *bp; 2122 struct sctp_bind_addr *bp;
2123 int attempts = asoc->init_err_counter + 1; 2123 int attempts = asoc->init_err_counter + 1;
2124 2124
2125 if (attempts >= asoc->max_init_attempts) { 2125 if (attempts > asoc->max_init_attempts) {
2126 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 2126 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
2127 SCTP_U32(SCTP_ERROR_STALE_COOKIE)); 2127 SCTP_U32(SCTP_ERROR_STALE_COOKIE));
2128 return SCTP_DISPOSITION_DELETE_TCB; 2128 return SCTP_DISPOSITION_DELETE_TCB;
@@ -4640,7 +4640,7 @@ sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep,
4640 4640
4641 SCTP_DEBUG_PRINTK("Timer T1 expired (INIT).\n"); 4641 SCTP_DEBUG_PRINTK("Timer T1 expired (INIT).\n");
4642 4642
4643 if (attempts < asoc->max_init_attempts) { 4643 if (attempts <= asoc->max_init_attempts) {
4644 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; 4644 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr;
4645 repl = sctp_make_init(asoc, bp, GFP_ATOMIC, 0); 4645 repl = sctp_make_init(asoc, bp, GFP_ATOMIC, 0);
4646 if (!repl) 4646 if (!repl)
@@ -4697,7 +4697,7 @@ sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep
4697 4697
4698 SCTP_DEBUG_PRINTK("Timer T1 expired (COOKIE-ECHO).\n"); 4698 SCTP_DEBUG_PRINTK("Timer T1 expired (COOKIE-ECHO).\n");
4699 4699
4700 if (attempts < asoc->max_init_attempts) { 4700 if (attempts <= asoc->max_init_attempts) {
4701 repl = sctp_make_cookie_echo(asoc, NULL); 4701 repl = sctp_make_cookie_echo(asoc, NULL);
4702 if (!repl) 4702 if (!repl)
4703 return SCTP_DISPOSITION_NOMEM; 4703 return SCTP_DISPOSITION_NOMEM;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index fb1821d9f338..0ea947eb6813 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -5426,7 +5426,7 @@ out:
5426 return err; 5426 return err;
5427 5427
5428do_error: 5428do_error:
5429 if (asoc->init_err_counter + 1 >= asoc->max_init_attempts) 5429 if (asoc->init_err_counter + 1 > asoc->max_init_attempts)
5430 err = -ETIMEDOUT; 5430 err = -ETIMEDOUT;
5431 else 5431 else
5432 err = -ECONNREFUSED; 5432 err = -ECONNREFUSED;
diff --git a/net/socket.c b/net/socket.c
index 8aa5f1188e9b..7e1bdef8b09e 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2075,7 +2075,7 @@ void socket_seq_show(struct seq_file *seq)
2075 int cpu; 2075 int cpu;
2076 int counter = 0; 2076 int counter = 0;
2077 2077
2078 for (cpu = 0; cpu < NR_CPUS; cpu++) 2078 for_each_cpu(cpu)
2079 counter += per_cpu(sockets_in_use, cpu); 2079 counter += per_cpu(sockets_in_use, cpu);
2080 2080
2081 /* It can be negative, by the way. 8) */ 2081 /* It can be negative, by the way. 8) */
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 9ac1b8c26c01..8d6f1a176b15 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -184,7 +184,7 @@ rpcauth_gc_credcache(struct rpc_auth *auth, struct hlist_head *free)
184 */ 184 */
185struct rpc_cred * 185struct rpc_cred *
186rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred, 186rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred,
187 int taskflags) 187 int flags)
188{ 188{
189 struct rpc_cred_cache *cache = auth->au_credcache; 189 struct rpc_cred_cache *cache = auth->au_credcache;
190 HLIST_HEAD(free); 190 HLIST_HEAD(free);
@@ -193,7 +193,7 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred,
193 *cred = NULL; 193 *cred = NULL;
194 int nr = 0; 194 int nr = 0;
195 195
196 if (!(taskflags & RPC_TASK_ROOTCREDS)) 196 if (!(flags & RPCAUTH_LOOKUP_ROOTCREDS))
197 nr = acred->uid & RPC_CREDCACHE_MASK; 197 nr = acred->uid & RPC_CREDCACHE_MASK;
198retry: 198retry:
199 spin_lock(&rpc_credcache_lock); 199 spin_lock(&rpc_credcache_lock);
@@ -202,7 +202,7 @@ retry:
202 hlist_for_each_safe(pos, next, &cache->hashtable[nr]) { 202 hlist_for_each_safe(pos, next, &cache->hashtable[nr]) {
203 struct rpc_cred *entry; 203 struct rpc_cred *entry;
204 entry = hlist_entry(pos, struct rpc_cred, cr_hash); 204 entry = hlist_entry(pos, struct rpc_cred, cr_hash);
205 if (entry->cr_ops->crmatch(acred, entry, taskflags)) { 205 if (entry->cr_ops->crmatch(acred, entry, flags)) {
206 hlist_del(&entry->cr_hash); 206 hlist_del(&entry->cr_hash);
207 cred = entry; 207 cred = entry;
208 break; 208 break;
@@ -224,7 +224,7 @@ retry:
224 rpcauth_destroy_credlist(&free); 224 rpcauth_destroy_credlist(&free);
225 225
226 if (!cred) { 226 if (!cred) {
227 new = auth->au_ops->crcreate(auth, acred, taskflags); 227 new = auth->au_ops->crcreate(auth, acred, flags);
228 if (!IS_ERR(new)) { 228 if (!IS_ERR(new)) {
229#ifdef RPC_DEBUG 229#ifdef RPC_DEBUG
230 new->cr_magic = RPCAUTH_CRED_MAGIC; 230 new->cr_magic = RPCAUTH_CRED_MAGIC;
@@ -232,13 +232,21 @@ retry:
232 goto retry; 232 goto retry;
233 } else 233 } else
234 cred = new; 234 cred = new;
235 } else if ((cred->cr_flags & RPCAUTH_CRED_NEW)
236 && cred->cr_ops->cr_init != NULL
237 && !(flags & RPCAUTH_LOOKUP_NEW)) {
238 int res = cred->cr_ops->cr_init(auth, cred);
239 if (res < 0) {
240 put_rpccred(cred);
241 cred = ERR_PTR(res);
242 }
235 } 243 }
236 244
237 return (struct rpc_cred *) cred; 245 return (struct rpc_cred *) cred;
238} 246}
239 247
240struct rpc_cred * 248struct rpc_cred *
241rpcauth_lookupcred(struct rpc_auth *auth, int taskflags) 249rpcauth_lookupcred(struct rpc_auth *auth, int flags)
242{ 250{
243 struct auth_cred acred = { 251 struct auth_cred acred = {
244 .uid = current->fsuid, 252 .uid = current->fsuid,
@@ -250,7 +258,7 @@ rpcauth_lookupcred(struct rpc_auth *auth, int taskflags)
250 dprintk("RPC: looking up %s cred\n", 258 dprintk("RPC: looking up %s cred\n",
251 auth->au_ops->au_name); 259 auth->au_ops->au_name);
252 get_group_info(acred.group_info); 260 get_group_info(acred.group_info);
253 ret = auth->au_ops->lookup_cred(auth, &acred, taskflags); 261 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
254 put_group_info(acred.group_info); 262 put_group_info(acred.group_info);
255 return ret; 263 return ret;
256} 264}
@@ -265,11 +273,14 @@ rpcauth_bindcred(struct rpc_task *task)
265 .group_info = current->group_info, 273 .group_info = current->group_info,
266 }; 274 };
267 struct rpc_cred *ret; 275 struct rpc_cred *ret;
276 int flags = 0;
268 277
269 dprintk("RPC: %4d looking up %s cred\n", 278 dprintk("RPC: %4d looking up %s cred\n",
270 task->tk_pid, task->tk_auth->au_ops->au_name); 279 task->tk_pid, task->tk_auth->au_ops->au_name);
271 get_group_info(acred.group_info); 280 get_group_info(acred.group_info);
272 ret = auth->au_ops->lookup_cred(auth, &acred, task->tk_flags); 281 if (task->tk_flags & RPC_TASK_ROOTCREDS)
282 flags |= RPCAUTH_LOOKUP_ROOTCREDS;
283 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
273 if (!IS_ERR(ret)) 284 if (!IS_ERR(ret))
274 task->tk_msg.rpc_cred = ret; 285 task->tk_msg.rpc_cred = ret;
275 else 286 else
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 8d782282ec19..bb46efd92e57 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -158,6 +158,7 @@ gss_cred_set_ctx(struct rpc_cred *cred, struct gss_cl_ctx *ctx)
158 old = gss_cred->gc_ctx; 158 old = gss_cred->gc_ctx;
159 gss_cred->gc_ctx = ctx; 159 gss_cred->gc_ctx = ctx;
160 cred->cr_flags |= RPCAUTH_CRED_UPTODATE; 160 cred->cr_flags |= RPCAUTH_CRED_UPTODATE;
161 cred->cr_flags &= ~RPCAUTH_CRED_NEW;
161 write_unlock(&gss_ctx_lock); 162 write_unlock(&gss_ctx_lock);
162 if (old) 163 if (old)
163 gss_put_ctx(old); 164 gss_put_ctx(old);
@@ -580,7 +581,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
580 } else { 581 } else {
581 struct auth_cred acred = { .uid = uid }; 582 struct auth_cred acred = { .uid = uid };
582 spin_unlock(&gss_auth->lock); 583 spin_unlock(&gss_auth->lock);
583 cred = rpcauth_lookup_credcache(clnt->cl_auth, &acred, 0); 584 cred = rpcauth_lookup_credcache(clnt->cl_auth, &acred, RPCAUTH_LOOKUP_NEW);
584 if (IS_ERR(cred)) { 585 if (IS_ERR(cred)) {
585 err = PTR_ERR(cred); 586 err = PTR_ERR(cred);
586 goto err_put_ctx; 587 goto err_put_ctx;
@@ -758,13 +759,13 @@ gss_destroy_cred(struct rpc_cred *rc)
758 * Lookup RPCSEC_GSS cred for the current process 759 * Lookup RPCSEC_GSS cred for the current process
759 */ 760 */
760static struct rpc_cred * 761static struct rpc_cred *
761gss_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int taskflags) 762gss_lookup_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags)
762{ 763{
763 return rpcauth_lookup_credcache(auth, acred, taskflags); 764 return rpcauth_lookup_credcache(auth, acred, flags);
764} 765}
765 766
766static struct rpc_cred * 767static struct rpc_cred *
767gss_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int taskflags) 768gss_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags)
768{ 769{
769 struct gss_auth *gss_auth = container_of(auth, struct gss_auth, rpc_auth); 770 struct gss_auth *gss_auth = container_of(auth, struct gss_auth, rpc_auth);
770 struct gss_cred *cred = NULL; 771 struct gss_cred *cred = NULL;
@@ -785,13 +786,8 @@ gss_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int taskflags)
785 */ 786 */
786 cred->gc_flags = 0; 787 cred->gc_flags = 0;
787 cred->gc_base.cr_ops = &gss_credops; 788 cred->gc_base.cr_ops = &gss_credops;
789 cred->gc_base.cr_flags = RPCAUTH_CRED_NEW;
788 cred->gc_service = gss_auth->service; 790 cred->gc_service = gss_auth->service;
789 do {
790 err = gss_create_upcall(gss_auth, cred);
791 } while (err == -EAGAIN);
792 if (err < 0)
793 goto out_err;
794
795 return &cred->gc_base; 791 return &cred->gc_base;
796 792
797out_err: 793out_err:
@@ -801,13 +797,34 @@ out_err:
801} 797}
802 798
803static int 799static int
804gss_match(struct auth_cred *acred, struct rpc_cred *rc, int taskflags) 800gss_cred_init(struct rpc_auth *auth, struct rpc_cred *cred)
801{
802 struct gss_auth *gss_auth = container_of(auth, struct gss_auth, rpc_auth);
803 struct gss_cred *gss_cred = container_of(cred,struct gss_cred, gc_base);
804 int err;
805
806 do {
807 err = gss_create_upcall(gss_auth, gss_cred);
808 } while (err == -EAGAIN);
809 return err;
810}
811
812static int
813gss_match(struct auth_cred *acred, struct rpc_cred *rc, int flags)
805{ 814{
806 struct gss_cred *gss_cred = container_of(rc, struct gss_cred, gc_base); 815 struct gss_cred *gss_cred = container_of(rc, struct gss_cred, gc_base);
807 816
817 /*
818 * If the searchflags have set RPCAUTH_LOOKUP_NEW, then
819 * we don't really care if the credential has expired or not,
820 * since the caller should be prepared to reinitialise it.
821 */
822 if ((flags & RPCAUTH_LOOKUP_NEW) && (rc->cr_flags & RPCAUTH_CRED_NEW))
823 goto out;
808 /* Don't match with creds that have expired. */ 824 /* Don't match with creds that have expired. */
809 if (gss_cred->gc_ctx && time_after(jiffies, gss_cred->gc_ctx->gc_expiry)) 825 if (gss_cred->gc_ctx && time_after(jiffies, gss_cred->gc_ctx->gc_expiry))
810 return 0; 826 return 0;
827out:
811 return (rc->cr_uid == acred->uid); 828 return (rc->cr_uid == acred->uid);
812} 829}
813 830
@@ -1241,6 +1258,7 @@ static struct rpc_authops authgss_ops = {
1241static struct rpc_credops gss_credops = { 1258static struct rpc_credops gss_credops = {
1242 .cr_name = "AUTH_GSS", 1259 .cr_name = "AUTH_GSS",
1243 .crdestroy = gss_destroy_cred, 1260 .crdestroy = gss_destroy_cred,
1261 .cr_init = gss_cred_init,
1244 .crmatch = gss_match, 1262 .crmatch = gss_match,
1245 .crmarshal = gss_marshal, 1263 .crmarshal = gss_marshal,
1246 .crrefresh = gss_refresh, 1264 .crrefresh = gss_refresh,
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
index 1b3ed4fd1987..df14b6bfbf10 100644
--- a/net/sunrpc/auth_unix.c
+++ b/net/sunrpc/auth_unix.c
@@ -75,7 +75,7 @@ unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags)
75 75
76 atomic_set(&cred->uc_count, 1); 76 atomic_set(&cred->uc_count, 1);
77 cred->uc_flags = RPCAUTH_CRED_UPTODATE; 77 cred->uc_flags = RPCAUTH_CRED_UPTODATE;
78 if (flags & RPC_TASK_ROOTCREDS) { 78 if (flags & RPCAUTH_LOOKUP_ROOTCREDS) {
79 cred->uc_uid = 0; 79 cred->uc_uid = 0;
80 cred->uc_gid = 0; 80 cred->uc_gid = 0;
81 cred->uc_gids[0] = NOGROUP; 81 cred->uc_gids[0] = NOGROUP;
@@ -108,12 +108,12 @@ unx_destroy_cred(struct rpc_cred *cred)
108 * request root creds (e.g. for NFS swapping). 108 * request root creds (e.g. for NFS swapping).
109 */ 109 */
110static int 110static int
111unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int taskflags) 111unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags)
112{ 112{
113 struct unx_cred *cred = (struct unx_cred *) rcred; 113 struct unx_cred *cred = (struct unx_cred *) rcred;
114 int i; 114 int i;
115 115
116 if (!(taskflags & RPC_TASK_ROOTCREDS)) { 116 if (!(flags & RPCAUTH_LOOKUP_ROOTCREDS)) {
117 int groups; 117 int groups;
118 118
119 if (cred->uc_uid != acred->uid 119 if (cred->uc_uid != acred->uid
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 9764c80ab0b2..a5c0c7b6e151 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -38,44 +38,42 @@ static kmem_cache_t *rpc_inode_cachep __read_mostly;
38 38
39#define RPC_UPCALL_TIMEOUT (30*HZ) 39#define RPC_UPCALL_TIMEOUT (30*HZ)
40 40
41static void 41static void rpc_purge_list(struct rpc_inode *rpci, struct list_head *head,
42__rpc_purge_list(struct rpc_inode *rpci, struct list_head *head, int err) 42 void (*destroy_msg)(struct rpc_pipe_msg *), int err)
43{ 43{
44 struct rpc_pipe_msg *msg; 44 struct rpc_pipe_msg *msg;
45 void (*destroy_msg)(struct rpc_pipe_msg *);
46 45
47 destroy_msg = rpci->ops->destroy_msg; 46 if (list_empty(head))
48 while (!list_empty(head)) { 47 return;
48 do {
49 msg = list_entry(head->next, struct rpc_pipe_msg, list); 49 msg = list_entry(head->next, struct rpc_pipe_msg, list);
50 list_del_init(&msg->list); 50 list_del(&msg->list);
51 msg->errno = err; 51 msg->errno = err;
52 destroy_msg(msg); 52 destroy_msg(msg);
53 } 53 } while (!list_empty(head));
54}
55
56static void
57__rpc_purge_upcall(struct inode *inode, int err)
58{
59 struct rpc_inode *rpci = RPC_I(inode);
60
61 __rpc_purge_list(rpci, &rpci->pipe, err);
62 rpci->pipelen = 0;
63 wake_up(&rpci->waitq); 54 wake_up(&rpci->waitq);
64} 55}
65 56
66static void 57static void
67rpc_timeout_upcall_queue(void *data) 58rpc_timeout_upcall_queue(void *data)
68{ 59{
60 LIST_HEAD(free_list);
69 struct rpc_inode *rpci = (struct rpc_inode *)data; 61 struct rpc_inode *rpci = (struct rpc_inode *)data;
70 struct inode *inode = &rpci->vfs_inode; 62 struct inode *inode = &rpci->vfs_inode;
63 void (*destroy_msg)(struct rpc_pipe_msg *);
71 64
72 mutex_lock(&inode->i_mutex); 65 spin_lock(&inode->i_lock);
73 if (rpci->ops == NULL) 66 if (rpci->ops == NULL) {
74 goto out; 67 spin_unlock(&inode->i_lock);
75 if (rpci->nreaders == 0 && !list_empty(&rpci->pipe)) 68 return;
76 __rpc_purge_upcall(inode, -ETIMEDOUT); 69 }
77out: 70 destroy_msg = rpci->ops->destroy_msg;
78 mutex_unlock(&inode->i_mutex); 71 if (rpci->nreaders == 0) {
72 list_splice_init(&rpci->pipe, &free_list);
73 rpci->pipelen = 0;
74 }
75 spin_unlock(&inode->i_lock);
76 rpc_purge_list(rpci, &free_list, destroy_msg, -ETIMEDOUT);
79} 77}
80 78
81int 79int
@@ -84,7 +82,7 @@ rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg)
84 struct rpc_inode *rpci = RPC_I(inode); 82 struct rpc_inode *rpci = RPC_I(inode);
85 int res = -EPIPE; 83 int res = -EPIPE;
86 84
87 mutex_lock(&inode->i_mutex); 85 spin_lock(&inode->i_lock);
88 if (rpci->ops == NULL) 86 if (rpci->ops == NULL)
89 goto out; 87 goto out;
90 if (rpci->nreaders) { 88 if (rpci->nreaders) {
@@ -100,7 +98,7 @@ rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg)
100 res = 0; 98 res = 0;
101 } 99 }
102out: 100out:
103 mutex_unlock(&inode->i_mutex); 101 spin_unlock(&inode->i_lock);
104 wake_up(&rpci->waitq); 102 wake_up(&rpci->waitq);
105 return res; 103 return res;
106} 104}
@@ -115,21 +113,29 @@ static void
115rpc_close_pipes(struct inode *inode) 113rpc_close_pipes(struct inode *inode)
116{ 114{
117 struct rpc_inode *rpci = RPC_I(inode); 115 struct rpc_inode *rpci = RPC_I(inode);
116 struct rpc_pipe_ops *ops;
118 117
119 mutex_lock(&inode->i_mutex); 118 mutex_lock(&inode->i_mutex);
120 if (rpci->ops != NULL) { 119 ops = rpci->ops;
120 if (ops != NULL) {
121 LIST_HEAD(free_list);
122
123 spin_lock(&inode->i_lock);
121 rpci->nreaders = 0; 124 rpci->nreaders = 0;
122 __rpc_purge_list(rpci, &rpci->in_upcall, -EPIPE); 125 list_splice_init(&rpci->in_upcall, &free_list);
123 __rpc_purge_upcall(inode, -EPIPE); 126 list_splice_init(&rpci->pipe, &free_list);
124 rpci->nwriters = 0; 127 rpci->pipelen = 0;
125 if (rpci->ops->release_pipe)
126 rpci->ops->release_pipe(inode);
127 rpci->ops = NULL; 128 rpci->ops = NULL;
129 spin_unlock(&inode->i_lock);
130 rpc_purge_list(rpci, &free_list, ops->destroy_msg, -EPIPE);
131 rpci->nwriters = 0;
132 if (ops->release_pipe)
133 ops->release_pipe(inode);
134 cancel_delayed_work(&rpci->queue_timeout);
135 flush_scheduled_work();
128 } 136 }
129 rpc_inode_setowner(inode, NULL); 137 rpc_inode_setowner(inode, NULL);
130 mutex_unlock(&inode->i_mutex); 138 mutex_unlock(&inode->i_mutex);
131 cancel_delayed_work(&rpci->queue_timeout);
132 flush_scheduled_work();
133} 139}
134 140
135static struct inode * 141static struct inode *
@@ -177,16 +183,26 @@ rpc_pipe_release(struct inode *inode, struct file *filp)
177 goto out; 183 goto out;
178 msg = (struct rpc_pipe_msg *)filp->private_data; 184 msg = (struct rpc_pipe_msg *)filp->private_data;
179 if (msg != NULL) { 185 if (msg != NULL) {
186 spin_lock(&inode->i_lock);
180 msg->errno = -EAGAIN; 187 msg->errno = -EAGAIN;
181 list_del_init(&msg->list); 188 list_del(&msg->list);
189 spin_unlock(&inode->i_lock);
182 rpci->ops->destroy_msg(msg); 190 rpci->ops->destroy_msg(msg);
183 } 191 }
184 if (filp->f_mode & FMODE_WRITE) 192 if (filp->f_mode & FMODE_WRITE)
185 rpci->nwriters --; 193 rpci->nwriters --;
186 if (filp->f_mode & FMODE_READ) 194 if (filp->f_mode & FMODE_READ) {
187 rpci->nreaders --; 195 rpci->nreaders --;
188 if (!rpci->nreaders) 196 if (rpci->nreaders == 0) {
189 __rpc_purge_upcall(inode, -EAGAIN); 197 LIST_HEAD(free_list);
198 spin_lock(&inode->i_lock);
199 list_splice_init(&rpci->pipe, &free_list);
200 rpci->pipelen = 0;
201 spin_unlock(&inode->i_lock);
202 rpc_purge_list(rpci, &free_list,
203 rpci->ops->destroy_msg, -EAGAIN);
204 }
205 }
190 if (rpci->ops->release_pipe) 206 if (rpci->ops->release_pipe)
191 rpci->ops->release_pipe(inode); 207 rpci->ops->release_pipe(inode);
192out: 208out:
@@ -209,6 +225,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
209 } 225 }
210 msg = filp->private_data; 226 msg = filp->private_data;
211 if (msg == NULL) { 227 if (msg == NULL) {
228 spin_lock(&inode->i_lock);
212 if (!list_empty(&rpci->pipe)) { 229 if (!list_empty(&rpci->pipe)) {
213 msg = list_entry(rpci->pipe.next, 230 msg = list_entry(rpci->pipe.next,
214 struct rpc_pipe_msg, 231 struct rpc_pipe_msg,
@@ -218,6 +235,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
218 filp->private_data = msg; 235 filp->private_data = msg;
219 msg->copied = 0; 236 msg->copied = 0;
220 } 237 }
238 spin_unlock(&inode->i_lock);
221 if (msg == NULL) 239 if (msg == NULL)
222 goto out_unlock; 240 goto out_unlock;
223 } 241 }
@@ -225,7 +243,9 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
225 res = rpci->ops->upcall(filp, msg, buf, len); 243 res = rpci->ops->upcall(filp, msg, buf, len);
226 if (res < 0 || msg->len == msg->copied) { 244 if (res < 0 || msg->len == msg->copied) {
227 filp->private_data = NULL; 245 filp->private_data = NULL;
228 list_del_init(&msg->list); 246 spin_lock(&inode->i_lock);
247 list_del(&msg->list);
248 spin_unlock(&inode->i_lock);
229 rpci->ops->destroy_msg(msg); 249 rpci->ops->destroy_msg(msg);
230 } 250 }
231out_unlock: 251out_unlock:
@@ -610,7 +630,7 @@ rpc_lookup_negative(char *path, struct nameidata *nd)
610 return ERR_PTR(error); 630 return ERR_PTR(error);
611 dir = nd->dentry->d_inode; 631 dir = nd->dentry->d_inode;
612 mutex_lock(&dir->i_mutex); 632 mutex_lock(&dir->i_mutex);
613 dentry = lookup_hash(nd); 633 dentry = lookup_one_len(nd->last.name, nd->dentry, nd->last.len);
614 if (IS_ERR(dentry)) 634 if (IS_ERR(dentry))
615 goto out_err; 635 goto out_err;
616 if (dentry->d_inode) { 636 if (dentry->d_inode) {
@@ -672,7 +692,7 @@ rpc_rmdir(char *path)
672 return error; 692 return error;
673 dir = nd.dentry->d_inode; 693 dir = nd.dentry->d_inode;
674 mutex_lock(&dir->i_mutex); 694 mutex_lock(&dir->i_mutex);
675 dentry = lookup_hash(&nd); 695 dentry = lookup_one_len(nd.last.name, nd.dentry, nd.last.len);
676 if (IS_ERR(dentry)) { 696 if (IS_ERR(dentry)) {
677 error = PTR_ERR(dentry); 697 error = PTR_ERR(dentry);
678 goto out_release; 698 goto out_release;
@@ -733,7 +753,7 @@ rpc_unlink(char *path)
733 return error; 753 return error;
734 dir = nd.dentry->d_inode; 754 dir = nd.dentry->d_inode;
735 mutex_lock(&dir->i_mutex); 755 mutex_lock(&dir->i_mutex);
736 dentry = lookup_hash(&nd); 756 dentry = lookup_one_len(nd.last.name, nd.dentry, nd.last.len);
737 if (IS_ERR(dentry)) { 757 if (IS_ERR(dentry)) {
738 error = PTR_ERR(dentry); 758 error = PTR_ERR(dentry);
739 goto out_release; 759 goto out_release;
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 7415406aa1ae..802d4fe0f55c 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -908,10 +908,10 @@ void rpc_release_task(struct rpc_task *task)
908 908
909/** 909/**
910 * rpc_run_task - Allocate a new RPC task, then run rpc_execute against it 910 * rpc_run_task - Allocate a new RPC task, then run rpc_execute against it
911 * @clnt - pointer to RPC client 911 * @clnt: pointer to RPC client
912 * @flags - RPC flags 912 * @flags: RPC flags
913 * @ops - RPC call ops 913 * @ops: RPC call ops
914 * @data - user call data 914 * @data: user call data
915 */ 915 */
916struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags, 916struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags,
917 const struct rpc_call_ops *ops, 917 const struct rpc_call_ops *ops,
@@ -930,6 +930,7 @@ EXPORT_SYMBOL(rpc_run_task);
930/** 930/**
931 * rpc_find_parent - find the parent of a child task. 931 * rpc_find_parent - find the parent of a child task.
932 * @child: child task 932 * @child: child task
933 * @parent: parent task
933 * 934 *
934 * Checks that the parent task is still sleeping on the 935 * Checks that the parent task is still sleeping on the
935 * queue 'childq'. If so returns a pointer to the parent. 936 * queue 'childq'. If so returns a pointer to the parent.
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 5760e057ecba..d64aae85c378 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -123,7 +123,17 @@ KBUILD_HAVE_NLS := $(shell \
123 then echo yes ; \ 123 then echo yes ; \
124 else echo no ; fi) 124 else echo no ; fi)
125ifeq ($(KBUILD_HAVE_NLS),no) 125ifeq ($(KBUILD_HAVE_NLS),no)
126HOSTCFLAGS += -DKBUILD_NO_NLS 126 HOSTCFLAGS += -DKBUILD_NO_NLS
127else
128 KBUILD_NEED_LINTL := $(shell \
129 if echo -e "\#include <libintl.h>\nint main(int a, char** b) { gettext(\"\"); return 0; }\n" | \
130 $(HOSTCC) $(HOSTCFLAGS) -x c - -o /dev/null> /dev/null 2>&1 ; \
131 then echo no ; \
132 else echo yes ; fi)
133 ifeq ($(KBUILD_NEED_LINTL),yes)
134 HOSTLOADLIBES_conf += -lintl
135 HOSTLOADLIBES_mconf += -lintl
136 endif
127endif 137endif
128 138
129# generated files seem to need this to find local include files 139# generated files seem to need this to find local include files
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 9fd5f5b87d1e..99fe4b7fb2f1 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -45,7 +45,7 @@ use strict;
45# Note: This only supports 'c'. 45# Note: This only supports 'c'.
46 46
47# usage: 47# usage:
48# kerneldoc [ -docbook | -html | -text | -man ] 48# kernel-doc [ -docbook | -html | -text | -man ]
49# [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile 49# [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile
50# or 50# or
51# [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile 51# [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile
@@ -59,7 +59,7 @@ use strict;
59# -nofunction funcname 59# -nofunction funcname
60# If set, then only generate documentation for the other function(s). All 60# If set, then only generate documentation for the other function(s). All
61# other functions are ignored. Cannot be used with -function together 61# other functions are ignored. Cannot be used with -function together
62# (yes thats a bug - perl hackers can fix it 8)) 62# (yes, that's a bug -- perl hackers can fix it 8))
63# 63#
64# c files - list of 'c' files to process 64# c files - list of 'c' files to process
65# 65#
@@ -90,28 +90,28 @@ use strict;
90# * my_function - does my stuff 90# * my_function - does my stuff
91# * @my_arg: its mine damnit 91# * @my_arg: its mine damnit
92# * 92# *
93# * Does my stuff explained. 93# * Does my stuff explained.
94# */ 94# */
95# 95#
96# or, could also use: 96# or, could also use:
97# /** 97# /**
98# * my_function - does my stuff 98# * my_function - does my stuff
99# * @my_arg: its mine damnit 99# * @my_arg: its mine damnit
100# * Description: Does my stuff explained. 100# * Description: Does my stuff explained.
101# */ 101# */
102# etc. 102# etc.
103# 103#
104# Beside functions you can also write documentation for structs, unions, 104# Beside functions you can also write documentation for structs, unions,
105# enums and typedefs. Instead of the function name you must write the name 105# enums and typedefs. Instead of the function name you must write the name
106# of the declaration; the struct/union/enum/typedef must always precede 106# of the declaration; the struct/union/enum/typedef must always precede
107# the name. Nesting of declarations is not supported. 107# the name. Nesting of declarations is not supported.
108# Use the argument mechanism to document members or constants. 108# Use the argument mechanism to document members or constants.
109# e.g. 109# e.g.
110# /** 110# /**
111# * struct my_struct - short description 111# * struct my_struct - short description
112# * @a: first member 112# * @a: first member
113# * @b: second member 113# * @b: second member
114# * 114# *
115# * Longer description 115# * Longer description
116# */ 116# */
117# struct my_struct { 117# struct my_struct {
@@ -122,12 +122,12 @@ use strict;
122# }; 122# };
123# 123#
124# All descriptions can be multiline, except the short function description. 124# All descriptions can be multiline, except the short function description.
125# 125#
126# You can also add additional sections. When documenting kernel functions you 126# You can also add additional sections. When documenting kernel functions you
127# should document the "Context:" of the function, e.g. whether the functions 127# should document the "Context:" of the function, e.g. whether the functions
128# can be called form interrupts. Unlike other sections you can end it with an 128# can be called form interrupts. Unlike other sections you can end it with an
129# empty line. 129# empty line.
130# Example-sections should contain the string EXAMPLE so that they are marked 130# Example-sections should contain the string EXAMPLE so that they are marked
131# appropriately in DocBook. 131# appropriately in DocBook.
132# 132#
133# Example: 133# Example:
@@ -135,7 +135,7 @@ use strict;
135# * user_function - function that can only be called in user context 135# * user_function - function that can only be called in user context
136# * @a: some argument 136# * @a: some argument
137# * Context: !in_interrupt() 137# * Context: !in_interrupt()
138# * 138# *
139# * Some description 139# * Some description
140# * Example: 140# * Example:
141# * user_function(22); 141# * user_function(22);
@@ -223,9 +223,9 @@ my %highlights = %highlights_man;
223my $blankline = $blankline_man; 223my $blankline = $blankline_man;
224my $modulename = "Kernel API"; 224my $modulename = "Kernel API";
225my $function_only = 0; 225my $function_only = 0;
226my $man_date = ('January', 'February', 'March', 'April', 'May', 'June', 226my $man_date = ('January', 'February', 'March', 'April', 'May', 'June',
227 'July', 'August', 'September', 'October', 227 'July', 'August', 'September', 'October',
228 'November', 'December')[(localtime)[4]] . 228 'November', 'December')[(localtime)[4]] .
229 " " . ((localtime)[5]+1900); 229 " " . ((localtime)[5]+1900);
230 230
231# Essentially these are globals 231# Essentially these are globals
@@ -236,7 +236,7 @@ my ($function, %function_table,%parametertypes,$declaration_purpose);
236my ($type,$declaration_name,$return_type); 236my ($type,$declaration_name,$return_type);
237my ($newsection,$newcontents,$prototype,$filelist, $brcount, %source_map); 237my ($newsection,$newcontents,$prototype,$filelist, $brcount, %source_map);
238 238
239# Generated docbook code is inserted in a template at a point where 239# Generated docbook code is inserted in a template at a point where
240# docbook v3.1 requires a non-zero sequence of RefEntry's; see: 240# docbook v3.1 requires a non-zero sequence of RefEntry's; see:
241# http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html 241# http://www.oasis-open.org/docbook/documentation/reference/html/refentry.html
242# We keep track of number of generated entries and generate a dummy 242# We keep track of number of generated entries and generate a dummy
@@ -365,7 +365,7 @@ sub dump_section {
365# parameterdescs => %parameter descriptions 365# parameterdescs => %parameter descriptions
366# sectionlist => @list of sections 366# sectionlist => @list of sections
367# sections => %descriont descriptions 367# sections => %descriont descriptions
368# 368#
369 369
370sub output_highlight { 370sub output_highlight {
371 my $contents = join "\n",@_; 371 my $contents = join "\n",@_;
@@ -400,7 +400,7 @@ sub output_section_html(%) {
400 print "<blockquote>\n"; 400 print "<blockquote>\n";
401 output_highlight($args{'sections'}{$section}); 401 output_highlight($args{'sections'}{$section});
402 print "</blockquote>\n"; 402 print "</blockquote>\n";
403 } 403 }
404} 404}
405 405
406# output enum in html 406# output enum in html
@@ -434,7 +434,7 @@ sub output_enum_html(%) {
434 print "<hr>\n"; 434 print "<hr>\n";
435} 435}
436 436
437# output tyepdef in html 437# output typedef in html
438sub output_typedef_html(%) { 438sub output_typedef_html(%) {
439 my %args = %{$_[0]}; 439 my %args = %{$_[0]};
440 my ($parameter); 440 my ($parameter);
@@ -551,7 +551,7 @@ sub output_intro_html(%) {
551 551
552sub output_section_xml(%) { 552sub output_section_xml(%) {
553 my %args = %{$_[0]}; 553 my %args = %{$_[0]};
554 my $section; 554 my $section;
555 # print out each section 555 # print out each section
556 $lineprefix=" "; 556 $lineprefix=" ";
557 foreach $section (@{$args{'sectionlist'}}) { 557 foreach $section (@{$args{'sectionlist'}}) {
@@ -778,7 +778,7 @@ sub output_enum_xml(%) {
778 print "</refsynopsisdiv>\n"; 778 print "</refsynopsisdiv>\n";
779 779
780 print "<refsect1>\n"; 780 print "<refsect1>\n";
781 print " <title>Constants</title>\n"; 781 print " <title>Constants</title>\n";
782 print " <variablelist>\n"; 782 print " <variablelist>\n";
783 foreach $parameter (@{$args{'parameterlist'}}) { 783 foreach $parameter (@{$args{'parameterlist'}}) {
784 my $parameter_name = $parameter; 784 my $parameter_name = $parameter;
@@ -1157,7 +1157,7 @@ sub output_section_text(%) {
1157 foreach $section (@{$args{'sectionlist'}}) { 1157 foreach $section (@{$args{'sectionlist'}}) {
1158 print "$section:\n\n"; 1158 print "$section:\n\n";
1159 output_highlight($args{'sections'}{$section}); 1159 output_highlight($args{'sections'}{$section});
1160 } 1160 }
1161 print "\n\n"; 1161 print "\n\n";
1162} 1162}
1163 1163
@@ -1262,8 +1262,8 @@ sub output_declaration {
1262 my $name = shift; 1262 my $name = shift;
1263 my $functype = shift; 1263 my $functype = shift;
1264 my $func = "output_${functype}_$output_mode"; 1264 my $func = "output_${functype}_$output_mode";
1265 if (($function_only==0) || 1265 if (($function_only==0) ||
1266 ( $function_only == 1 && defined($function_table{$name})) || 1266 ( $function_only == 1 && defined($function_table{$name})) ||
1267 ( $function_only == 2 && !defined($function_table{$name}))) 1267 ( $function_only == 2 && !defined($function_table{$name})))
1268 { 1268 {
1269 &$func(@_); 1269 &$func(@_);
@@ -1282,7 +1282,7 @@ sub output_intro {
1282} 1282}
1283 1283
1284## 1284##
1285# takes a declaration (struct, union, enum, typedef) and 1285# takes a declaration (struct, union, enum, typedef) and
1286# invokes the right handler. NOT called for functions. 1286# invokes the right handler. NOT called for functions.
1287sub dump_declaration($$) { 1287sub dump_declaration($$) {
1288 no strict 'refs'; 1288 no strict 'refs';
@@ -1352,7 +1352,7 @@ sub dump_enum($$) {
1352 } 1352 }
1353 1353
1354 } 1354 }
1355 1355
1356 output_declaration($declaration_name, 1356 output_declaration($declaration_name,
1357 'enum', 1357 'enum',
1358 {'enum' => $declaration_name, 1358 {'enum' => $declaration_name,
@@ -1409,7 +1409,7 @@ sub create_parameterlist($$$) {
1409 while ($args =~ /(\([^\),]+),/) { 1409 while ($args =~ /(\([^\),]+),/) {
1410 $args =~ s/(\([^\),]+),/$1#/g; 1410 $args =~ s/(\([^\),]+),/$1#/g;
1411 } 1411 }
1412 1412
1413 foreach my $arg (split($splitter, $args)) { 1413 foreach my $arg (split($splitter, $args)) {
1414 # strip comments 1414 # strip comments
1415 $arg =~ s/\/\*.*\*\///; 1415 $arg =~ s/\/\*.*\*\///;
@@ -1529,7 +1529,7 @@ sub dump_function($$) {
1529 # the following functions' documentation still comes out right: 1529 # the following functions' documentation still comes out right:
1530 # - parport_register_device (function pointer parameters) 1530 # - parport_register_device (function pointer parameters)
1531 # - atomic_set (macro) 1531 # - atomic_set (macro)
1532 # - pci_match_device (long return type) 1532 # - pci_match_device, __copy_to_user (long return type)
1533 1533
1534 if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || 1534 if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
1535 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || 1535 $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
@@ -1544,7 +1544,9 @@ sub dump_function($$) {
1544 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1544 $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1545 $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1545 $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1546 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || 1546 $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1547 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) { 1547 $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1548 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ ||
1549 $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) {
1548 $return_type = $1; 1550 $return_type = $1;
1549 $declaration_name = $2; 1551 $declaration_name = $2;
1550 my $args = $3; 1552 my $args = $3;
@@ -1556,7 +1558,7 @@ sub dump_function($$) {
1556 return; 1558 return;
1557 } 1559 }
1558 1560
1559 output_declaration($declaration_name, 1561 output_declaration($declaration_name,
1560 'function', 1562 'function',
1561 {'function' => $declaration_name, 1563 {'function' => $declaration_name,
1562 'module' => $modulename, 1564 'module' => $modulename,
@@ -1615,11 +1617,11 @@ sub reset_state {
1615 %sections = (); 1617 %sections = ();
1616 @sectionlist = (); 1618 @sectionlist = ();
1617 $prototype = ""; 1619 $prototype = "";
1618 1620
1619 $state = 0; 1621 $state = 0;
1620} 1622}
1621 1623
1622sub process_state3_function($$) { 1624sub process_state3_function($$) {
1623 my $x = shift; 1625 my $x = shift;
1624 my $file = shift; 1626 my $file = shift;
1625 1627
@@ -1638,7 +1640,7 @@ sub process_state3_function($$) {
1638 } 1640 }
1639} 1641}
1640 1642
1641sub process_state3_type($$) { 1643sub process_state3_type($$) {
1642 my $x = shift; 1644 my $x = shift;
1643 my $file = shift; 1645 my $file = shift;
1644 1646
@@ -1778,7 +1780,7 @@ sub process_file($) {
1778 } elsif (/$doc_content/) { 1780 } elsif (/$doc_content/) {
1779 # miguel-style comment kludge, look for blank lines after 1781 # miguel-style comment kludge, look for blank lines after
1780 # @parameter line to signify start of description 1782 # @parameter line to signify start of description
1781 if ($1 eq "" && 1783 if ($1 eq "" &&
1782 ($section =~ m/^@/ || $section eq $section_context)) { 1784 ($section =~ m/^@/ || $section eq $section_context)) {
1783 dump_section($section, xml_escape($contents)); 1785 dump_section($section, xml_escape($contents));
1784 $section = $section_default; 1786 $section = $section_default;
@@ -1788,7 +1790,7 @@ sub process_file($) {
1788 } 1790 }
1789 } else { 1791 } else {
1790 # i dont know - bad line? ignore. 1792 # i dont know - bad line? ignore.
1791 print STDERR "Warning(${file}:$.): bad line: $_"; 1793 print STDERR "Warning(${file}:$.): bad line: $_";
1792 ++$warnings; 1794 ++$warnings;
1793 } 1795 }
1794 } elsif ($state == 3) { # scanning for function { (end of prototype) 1796 } elsif ($state == 3) { # scanning for function { (end of prototype)
@@ -1843,7 +1845,7 @@ sub process_file($) {
1843 else 1845 else
1844 { 1846 {
1845 $contents .= $1 . "\n"; 1847 $contents .= $1 . "\n";
1846 } 1848 }
1847 } 1849 }
1848 } 1850 }
1849 } 1851 }
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 90db5c76cf6e..0c62798ac7d8 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -67,9 +67,10 @@ asmlinkage long sys_add_key(const char __user *_type,
67 description = kmalloc(dlen + 1, GFP_KERNEL); 67 description = kmalloc(dlen + 1, GFP_KERNEL);
68 if (!description) 68 if (!description)
69 goto error; 69 goto error;
70 description[dlen] = '\0';
70 71
71 ret = -EFAULT; 72 ret = -EFAULT;
72 if (copy_from_user(description, _description, dlen + 1) != 0) 73 if (copy_from_user(description, _description, dlen) != 0)
73 goto error2; 74 goto error2;
74 75
75 /* pull the payload in if one was supplied */ 76 /* pull the payload in if one was supplied */
@@ -161,9 +162,10 @@ asmlinkage long sys_request_key(const char __user *_type,
161 description = kmalloc(dlen + 1, GFP_KERNEL); 162 description = kmalloc(dlen + 1, GFP_KERNEL);
162 if (!description) 163 if (!description)
163 goto error; 164 goto error;
165 description[dlen] = '\0';
164 166
165 ret = -EFAULT; 167 ret = -EFAULT;
166 if (copy_from_user(description, _description, dlen + 1) != 0) 168 if (copy_from_user(description, _description, dlen) != 0)
167 goto error2; 169 goto error2;
168 170
169 /* pull the callout info into kernel space */ 171 /* pull the callout info into kernel space */
@@ -182,9 +184,10 @@ asmlinkage long sys_request_key(const char __user *_type,
182 callout_info = kmalloc(dlen + 1, GFP_KERNEL); 184 callout_info = kmalloc(dlen + 1, GFP_KERNEL);
183 if (!callout_info) 185 if (!callout_info)
184 goto error2; 186 goto error2;
187 callout_info[dlen] = '\0';
185 188
186 ret = -EFAULT; 189 ret = -EFAULT;
187 if (copy_from_user(callout_info, _callout_info, dlen + 1) != 0) 190 if (copy_from_user(callout_info, _callout_info, dlen) != 0)
188 goto error3; 191 goto error3;
189 } 192 }
190 193
@@ -279,9 +282,10 @@ long keyctl_join_session_keyring(const char __user *_name)
279 name = kmalloc(nlen + 1, GFP_KERNEL); 282 name = kmalloc(nlen + 1, GFP_KERNEL);
280 if (!name) 283 if (!name)
281 goto error; 284 goto error;
285 name[nlen] = '\0';
282 286
283 ret = -EFAULT; 287 ret = -EFAULT;
284 if (copy_from_user(name, _name, nlen + 1) != 0) 288 if (copy_from_user(name, _name, nlen) != 0)
285 goto error2; 289 goto error2;
286 } 290 }
287 291
@@ -583,9 +587,10 @@ long keyctl_keyring_search(key_serial_t ringid,
583 description = kmalloc(dlen + 1, GFP_KERNEL); 587 description = kmalloc(dlen + 1, GFP_KERNEL);
584 if (!description) 588 if (!description)
585 goto error; 589 goto error;
590 description[dlen] = '\0';
586 591
587 ret = -EFAULT; 592 ret = -EFAULT;
588 if (copy_from_user(description, _description, dlen + 1) != 0) 593 if (copy_from_user(description, _description, dlen) != 0)
589 goto error2; 594 goto error2;
590 595
591 /* get the keyring at which to begin the search */ 596 /* get the keyring at which to begin the search */
diff --git a/security/seclvl.c b/security/seclvl.c
index 1caac0164643..8529ea6f7aa8 100644
--- a/security/seclvl.c
+++ b/security/seclvl.c
@@ -368,8 +368,8 @@ static int seclvl_capable(struct task_struct *tsk, int cap)
368 */ 368 */
369static int seclvl_settime(struct timespec *tv, struct timezone *tz) 369static int seclvl_settime(struct timespec *tv, struct timezone *tz)
370{ 370{
371 struct timespec now; 371 if (tv && seclvl > 1) {
372 if (seclvl > 1) { 372 struct timespec now;
373 now = current_kernel_time(); 373 now = current_kernel_time();
374 if (tv->tv_sec < now.tv_sec || 374 if (tv->tv_sec < now.tv_sec ||
375 (tv->tv_sec == now.tv_sec && tv->tv_nsec < now.tv_nsec)) { 375 (tv->tv_sec == now.tv_sec && tv->tv_nsec < now.tv_nsec)) {
diff --git a/security/selinux/Kconfig b/security/selinux/Kconfig
index b59582b92283..502f78f13f5f 100644
--- a/security/selinux/Kconfig
+++ b/security/selinux/Kconfig
@@ -1,6 +1,6 @@
1config SECURITY_SELINUX 1config SECURITY_SELINUX
2 bool "NSA SELinux Support" 2 bool "NSA SELinux Support"
3 depends on SECURITY && NET && INET 3 depends on SECURITY_NETWORK && NET && INET
4 default n 4 default n
5 help 5 help
6 This selects NSA Security-Enhanced Linux (SELinux). 6 This selects NSA Security-Enhanced Linux (SELinux).
diff --git a/security/selinux/Makefile b/security/selinux/Makefile
index 06d54d9d20a5..688c0a267b62 100644
--- a/security/selinux/Makefile
+++ b/security/selinux/Makefile
@@ -4,9 +4,7 @@
4 4
5obj-$(CONFIG_SECURITY_SELINUX) := selinux.o ss/ 5obj-$(CONFIG_SECURITY_SELINUX) := selinux.o ss/
6 6
7selinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o 7selinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o netif.o
8
9selinux-$(CONFIG_SECURITY_NETWORK) += netif.o
10 8
11selinux-$(CONFIG_SECURITY_NETWORK_XFRM) += xfrm.o 9selinux-$(CONFIG_SECURITY_NETWORK_XFRM) += xfrm.o
12 10
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index b9f8d9731c3d..b7773bf68efa 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -127,7 +127,6 @@ static int task_alloc_security(struct task_struct *task)
127 if (!tsec) 127 if (!tsec)
128 return -ENOMEM; 128 return -ENOMEM;
129 129
130 tsec->magic = SELINUX_MAGIC;
131 tsec->task = task; 130 tsec->task = task;
132 tsec->osid = tsec->sid = tsec->ptrace_sid = SECINITSID_UNLABELED; 131 tsec->osid = tsec->sid = tsec->ptrace_sid = SECINITSID_UNLABELED;
133 task->security = tsec; 132 task->security = tsec;
@@ -138,10 +137,6 @@ static int task_alloc_security(struct task_struct *task)
138static void task_free_security(struct task_struct *task) 137static void task_free_security(struct task_struct *task)
139{ 138{
140 struct task_security_struct *tsec = task->security; 139 struct task_security_struct *tsec = task->security;
141
142 if (!tsec || tsec->magic != SELINUX_MAGIC)
143 return;
144
145 task->security = NULL; 140 task->security = NULL;
146 kfree(tsec); 141 kfree(tsec);
147} 142}
@@ -157,14 +152,10 @@ static int inode_alloc_security(struct inode *inode)
157 152
158 init_MUTEX(&isec->sem); 153 init_MUTEX(&isec->sem);
159 INIT_LIST_HEAD(&isec->list); 154 INIT_LIST_HEAD(&isec->list);
160 isec->magic = SELINUX_MAGIC;
161 isec->inode = inode; 155 isec->inode = inode;
162 isec->sid = SECINITSID_UNLABELED; 156 isec->sid = SECINITSID_UNLABELED;
163 isec->sclass = SECCLASS_FILE; 157 isec->sclass = SECCLASS_FILE;
164 if (tsec && tsec->magic == SELINUX_MAGIC) 158 isec->task_sid = tsec->sid;
165 isec->task_sid = tsec->sid;
166 else
167 isec->task_sid = SECINITSID_UNLABELED;
168 inode->i_security = isec; 159 inode->i_security = isec;
169 160
170 return 0; 161 return 0;
@@ -175,9 +166,6 @@ static void inode_free_security(struct inode *inode)
175 struct inode_security_struct *isec = inode->i_security; 166 struct inode_security_struct *isec = inode->i_security;
176 struct superblock_security_struct *sbsec = inode->i_sb->s_security; 167 struct superblock_security_struct *sbsec = inode->i_sb->s_security;
177 168
178 if (!isec || isec->magic != SELINUX_MAGIC)
179 return;
180
181 spin_lock(&sbsec->isec_lock); 169 spin_lock(&sbsec->isec_lock);
182 if (!list_empty(&isec->list)) 170 if (!list_empty(&isec->list))
183 list_del_init(&isec->list); 171 list_del_init(&isec->list);
@@ -192,19 +180,13 @@ static int file_alloc_security(struct file *file)
192 struct task_security_struct *tsec = current->security; 180 struct task_security_struct *tsec = current->security;
193 struct file_security_struct *fsec; 181 struct file_security_struct *fsec;
194 182
195 fsec = kzalloc(sizeof(struct file_security_struct), GFP_ATOMIC); 183 fsec = kzalloc(sizeof(struct file_security_struct), GFP_KERNEL);
196 if (!fsec) 184 if (!fsec)
197 return -ENOMEM; 185 return -ENOMEM;
198 186
199 fsec->magic = SELINUX_MAGIC;
200 fsec->file = file; 187 fsec->file = file;
201 if (tsec && tsec->magic == SELINUX_MAGIC) { 188 fsec->sid = tsec->sid;
202 fsec->sid = tsec->sid; 189 fsec->fown_sid = tsec->sid;
203 fsec->fown_sid = tsec->sid;
204 } else {
205 fsec->sid = SECINITSID_UNLABELED;
206 fsec->fown_sid = SECINITSID_UNLABELED;
207 }
208 file->f_security = fsec; 190 file->f_security = fsec;
209 191
210 return 0; 192 return 0;
@@ -213,10 +195,6 @@ static int file_alloc_security(struct file *file)
213static void file_free_security(struct file *file) 195static void file_free_security(struct file *file)
214{ 196{
215 struct file_security_struct *fsec = file->f_security; 197 struct file_security_struct *fsec = file->f_security;
216
217 if (!fsec || fsec->magic != SELINUX_MAGIC)
218 return;
219
220 file->f_security = NULL; 198 file->f_security = NULL;
221 kfree(fsec); 199 kfree(fsec);
222} 200}
@@ -233,7 +211,6 @@ static int superblock_alloc_security(struct super_block *sb)
233 INIT_LIST_HEAD(&sbsec->list); 211 INIT_LIST_HEAD(&sbsec->list);
234 INIT_LIST_HEAD(&sbsec->isec_head); 212 INIT_LIST_HEAD(&sbsec->isec_head);
235 spin_lock_init(&sbsec->isec_lock); 213 spin_lock_init(&sbsec->isec_lock);
236 sbsec->magic = SELINUX_MAGIC;
237 sbsec->sb = sb; 214 sbsec->sb = sb;
238 sbsec->sid = SECINITSID_UNLABELED; 215 sbsec->sid = SECINITSID_UNLABELED;
239 sbsec->def_sid = SECINITSID_FILE; 216 sbsec->def_sid = SECINITSID_FILE;
@@ -246,9 +223,6 @@ static void superblock_free_security(struct super_block *sb)
246{ 223{
247 struct superblock_security_struct *sbsec = sb->s_security; 224 struct superblock_security_struct *sbsec = sb->s_security;
248 225
249 if (!sbsec || sbsec->magic != SELINUX_MAGIC)
250 return;
251
252 spin_lock(&sb_security_lock); 226 spin_lock(&sb_security_lock);
253 if (!list_empty(&sbsec->list)) 227 if (!list_empty(&sbsec->list))
254 list_del_init(&sbsec->list); 228 list_del_init(&sbsec->list);
@@ -258,7 +232,6 @@ static void superblock_free_security(struct super_block *sb)
258 kfree(sbsec); 232 kfree(sbsec);
259} 233}
260 234
261#ifdef CONFIG_SECURITY_NETWORK
262static int sk_alloc_security(struct sock *sk, int family, gfp_t priority) 235static int sk_alloc_security(struct sock *sk, int family, gfp_t priority)
263{ 236{
264 struct sk_security_struct *ssec; 237 struct sk_security_struct *ssec;
@@ -270,7 +243,6 @@ static int sk_alloc_security(struct sock *sk, int family, gfp_t priority)
270 if (!ssec) 243 if (!ssec)
271 return -ENOMEM; 244 return -ENOMEM;
272 245
273 ssec->magic = SELINUX_MAGIC;
274 ssec->sk = sk; 246 ssec->sk = sk;
275 ssec->peer_sid = SECINITSID_UNLABELED; 247 ssec->peer_sid = SECINITSID_UNLABELED;
276 sk->sk_security = ssec; 248 sk->sk_security = ssec;
@@ -282,13 +254,12 @@ static void sk_free_security(struct sock *sk)
282{ 254{
283 struct sk_security_struct *ssec = sk->sk_security; 255 struct sk_security_struct *ssec = sk->sk_security;
284 256
285 if (sk->sk_family != PF_UNIX || ssec->magic != SELINUX_MAGIC) 257 if (sk->sk_family != PF_UNIX)
286 return; 258 return;
287 259
288 sk->sk_security = NULL; 260 sk->sk_security = NULL;
289 kfree(ssec); 261 kfree(ssec);
290} 262}
291#endif /* CONFIG_SECURITY_NETWORK */
292 263
293/* The security server must be initialized before 264/* The security server must be initialized before
294 any labeling or access decisions can be provided. */ 265 any labeling or access decisions can be provided. */
@@ -1483,7 +1454,6 @@ static int selinux_bprm_alloc_security(struct linux_binprm *bprm)
1483 if (!bsec) 1454 if (!bsec)
1484 return -ENOMEM; 1455 return -ENOMEM;
1485 1456
1486 bsec->magic = SELINUX_MAGIC;
1487 bsec->bprm = bprm; 1457 bsec->bprm = bprm;
1488 bsec->sid = SECINITSID_UNLABELED; 1458 bsec->sid = SECINITSID_UNLABELED;
1489 bsec->set = 0; 1459 bsec->set = 0;
@@ -2454,35 +2424,27 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
2454 prot = reqprot; 2424 prot = reqprot;
2455 2425
2456#ifndef CONFIG_PPC32 2426#ifndef CONFIG_PPC32
2457 if ((prot & PROT_EXEC) && !(vma->vm_flags & VM_EXECUTABLE) && 2427 if ((prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) {
2458 (vma->vm_start >= vma->vm_mm->start_brk && 2428 rc = 0;
2459 vma->vm_end <= vma->vm_mm->brk)) { 2429 if (vma->vm_start >= vma->vm_mm->start_brk &&
2460 /* 2430 vma->vm_end <= vma->vm_mm->brk) {
2461 * We are making an executable mapping in the brk region. 2431 rc = task_has_perm(current, current,
2462 * This has an additional execheap check. 2432 PROCESS__EXECHEAP);
2463 */ 2433 } else if (!vma->vm_file &&
2464 rc = task_has_perm(current, current, PROCESS__EXECHEAP); 2434 vma->vm_start <= vma->vm_mm->start_stack &&
2465 if (rc) 2435 vma->vm_end >= vma->vm_mm->start_stack) {
2466 return rc; 2436 rc = task_has_perm(current, current, PROCESS__EXECSTACK);
2467 } 2437 } else if (vma->vm_file && vma->anon_vma) {
2468 if (vma->vm_file != NULL && vma->anon_vma != NULL && (prot & PROT_EXEC)) { 2438 /*
2469 /* 2439 * We are making executable a file mapping that has
2470 * We are making executable a file mapping that has 2440 * had some COW done. Since pages might have been
2471 * had some COW done. Since pages might have been written, 2441 * written, check ability to execute the possibly
2472 * check ability to execute the possibly modified content. 2442 * modified content. This typically should only
2473 * This typically should only occur for text relocations. 2443 * occur for text relocations.
2474 */ 2444 */
2475 int rc = file_has_perm(current, vma->vm_file, FILE__EXECMOD); 2445 rc = file_has_perm(current, vma->vm_file,
2476 if (rc) 2446 FILE__EXECMOD);
2477 return rc; 2447 }
2478 }
2479 if (!vma->vm_file && (prot & PROT_EXEC) &&
2480 vma->vm_start <= vma->vm_mm->start_stack &&
2481 vma->vm_end >= vma->vm_mm->start_stack) {
2482 /* Attempt to make the process stack executable.
2483 * This has an additional execstack check.
2484 */
2485 rc = task_has_perm(current, current, PROCESS__EXECSTACK);
2486 if (rc) 2448 if (rc)
2487 return rc; 2449 return rc;
2488 } 2450 }
@@ -2772,8 +2734,6 @@ static void selinux_task_to_inode(struct task_struct *p,
2772 return; 2734 return;
2773} 2735}
2774 2736
2775#ifdef CONFIG_SECURITY_NETWORK
2776
2777/* Returns error only if unable to parse addresses */ 2737/* Returns error only if unable to parse addresses */
2778static int selinux_parse_skb_ipv4(struct sk_buff *skb, struct avc_audit_data *ad) 2738static int selinux_parse_skb_ipv4(struct sk_buff *skb, struct avc_audit_data *ad)
2779{ 2739{
@@ -3592,15 +3552,6 @@ static unsigned int selinux_ipv6_postroute_last(unsigned int hooknum,
3592 3552
3593#endif /* CONFIG_NETFILTER */ 3553#endif /* CONFIG_NETFILTER */
3594 3554
3595#else
3596
3597static inline int selinux_nlmsg_perm(struct sock *sk, struct sk_buff *skb)
3598{
3599 return 0;
3600}
3601
3602#endif /* CONFIG_SECURITY_NETWORK */
3603
3604static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb) 3555static int selinux_netlink_send(struct sock *sk, struct sk_buff *skb)
3605{ 3556{
3606 struct task_security_struct *tsec; 3557 struct task_security_struct *tsec;
@@ -3642,14 +3593,9 @@ static int ipc_alloc_security(struct task_struct *task,
3642 if (!isec) 3593 if (!isec)
3643 return -ENOMEM; 3594 return -ENOMEM;
3644 3595
3645 isec->magic = SELINUX_MAGIC;
3646 isec->sclass = sclass; 3596 isec->sclass = sclass;
3647 isec->ipc_perm = perm; 3597 isec->ipc_perm = perm;
3648 if (tsec) { 3598 isec->sid = tsec->sid;
3649 isec->sid = tsec->sid;
3650 } else {
3651 isec->sid = SECINITSID_UNLABELED;
3652 }
3653 perm->security = isec; 3599 perm->security = isec;
3654 3600
3655 return 0; 3601 return 0;
@@ -3658,9 +3604,6 @@ static int ipc_alloc_security(struct task_struct *task,
3658static void ipc_free_security(struct kern_ipc_perm *perm) 3604static void ipc_free_security(struct kern_ipc_perm *perm)
3659{ 3605{
3660 struct ipc_security_struct *isec = perm->security; 3606 struct ipc_security_struct *isec = perm->security;
3661 if (!isec || isec->magic != SELINUX_MAGIC)
3662 return;
3663
3664 perm->security = NULL; 3607 perm->security = NULL;
3665 kfree(isec); 3608 kfree(isec);
3666} 3609}
@@ -3673,7 +3616,6 @@ static int msg_msg_alloc_security(struct msg_msg *msg)
3673 if (!msec) 3616 if (!msec)
3674 return -ENOMEM; 3617 return -ENOMEM;
3675 3618
3676 msec->magic = SELINUX_MAGIC;
3677 msec->msg = msg; 3619 msec->msg = msg;
3678 msec->sid = SECINITSID_UNLABELED; 3620 msec->sid = SECINITSID_UNLABELED;
3679 msg->security = msec; 3621 msg->security = msec;
@@ -3684,8 +3626,6 @@ static int msg_msg_alloc_security(struct msg_msg *msg)
3684static void msg_msg_free_security(struct msg_msg *msg) 3626static void msg_msg_free_security(struct msg_msg *msg)
3685{ 3627{
3686 struct msg_security_struct *msec = msg->security; 3628 struct msg_security_struct *msec = msg->security;
3687 if (!msec || msec->magic != SELINUX_MAGIC)
3688 return;
3689 3629
3690 msg->security = NULL; 3630 msg->security = NULL;
3691 kfree(msec); 3631 kfree(msec);
@@ -4387,7 +4327,6 @@ static struct security_operations selinux_ops = {
4387 .getprocattr = selinux_getprocattr, 4327 .getprocattr = selinux_getprocattr,
4388 .setprocattr = selinux_setprocattr, 4328 .setprocattr = selinux_setprocattr,
4389 4329
4390#ifdef CONFIG_SECURITY_NETWORK
4391 .unix_stream_connect = selinux_socket_unix_stream_connect, 4330 .unix_stream_connect = selinux_socket_unix_stream_connect,
4392 .unix_may_send = selinux_socket_unix_may_send, 4331 .unix_may_send = selinux_socket_unix_may_send,
4393 4332
@@ -4409,7 +4348,6 @@ static struct security_operations selinux_ops = {
4409 .sk_alloc_security = selinux_sk_alloc_security, 4348 .sk_alloc_security = selinux_sk_alloc_security,
4410 .sk_free_security = selinux_sk_free_security, 4349 .sk_free_security = selinux_sk_free_security,
4411 .sk_getsid = selinux_sk_getsid_security, 4350 .sk_getsid = selinux_sk_getsid_security,
4412#endif
4413 4351
4414#ifdef CONFIG_SECURITY_NETWORK_XFRM 4352#ifdef CONFIG_SECURITY_NETWORK_XFRM
4415 .xfrm_policy_alloc_security = selinux_xfrm_policy_alloc, 4353 .xfrm_policy_alloc_security = selinux_xfrm_policy_alloc,
@@ -4487,7 +4425,7 @@ next_sb:
4487 all processes and objects when they are created. */ 4425 all processes and objects when they are created. */
4488security_initcall(selinux_init); 4426security_initcall(selinux_init);
4489 4427
4490#if defined(CONFIG_SECURITY_NETWORK) && defined(CONFIG_NETFILTER) 4428#if defined(CONFIG_NETFILTER)
4491 4429
4492static struct nf_hook_ops selinux_ipv4_op = { 4430static struct nf_hook_ops selinux_ipv4_op = {
4493 .hook = selinux_ipv4_postroute_last, 4431 .hook = selinux_ipv4_postroute_last,
@@ -4548,13 +4486,13 @@ static void selinux_nf_ip_exit(void)
4548} 4486}
4549#endif 4487#endif
4550 4488
4551#else /* CONFIG_SECURITY_NETWORK && CONFIG_NETFILTER */ 4489#else /* CONFIG_NETFILTER */
4552 4490
4553#ifdef CONFIG_SECURITY_SELINUX_DISABLE 4491#ifdef CONFIG_SECURITY_SELINUX_DISABLE
4554#define selinux_nf_ip_exit() 4492#define selinux_nf_ip_exit()
4555#endif 4493#endif
4556 4494
4557#endif /* CONFIG_SECURITY_NETWORK && CONFIG_NETFILTER */ 4495#endif /* CONFIG_NETFILTER */
4558 4496
4559#ifdef CONFIG_SECURITY_SELINUX_DISABLE 4497#ifdef CONFIG_SECURITY_SELINUX_DISABLE
4560int selinux_disable(void) 4498int selinux_disable(void)
diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
index 887937c8134a..54c030778882 100644
--- a/security/selinux/include/objsec.h
+++ b/security/selinux/include/objsec.h
@@ -27,7 +27,6 @@
27#include "avc.h" 27#include "avc.h"
28 28
29struct task_security_struct { 29struct task_security_struct {
30 unsigned long magic; /* magic number for this module */
31 struct task_struct *task; /* back pointer to task object */ 30 struct task_struct *task; /* back pointer to task object */
32 u32 osid; /* SID prior to last execve */ 31 u32 osid; /* SID prior to last execve */
33 u32 sid; /* current SID */ 32 u32 sid; /* current SID */
@@ -37,7 +36,6 @@ struct task_security_struct {
37}; 36};
38 37
39struct inode_security_struct { 38struct inode_security_struct {
40 unsigned long magic; /* magic number for this module */
41 struct inode *inode; /* back pointer to inode object */ 39 struct inode *inode; /* back pointer to inode object */
42 struct list_head list; /* list of inode_security_struct */ 40 struct list_head list; /* list of inode_security_struct */
43 u32 task_sid; /* SID of creating task */ 41 u32 task_sid; /* SID of creating task */
@@ -49,14 +47,12 @@ struct inode_security_struct {
49}; 47};
50 48
51struct file_security_struct { 49struct file_security_struct {
52 unsigned long magic; /* magic number for this module */
53 struct file *file; /* back pointer to file object */ 50 struct file *file; /* back pointer to file object */
54 u32 sid; /* SID of open file description */ 51 u32 sid; /* SID of open file description */
55 u32 fown_sid; /* SID of file owner (for SIGIO) */ 52 u32 fown_sid; /* SID of file owner (for SIGIO) */
56}; 53};
57 54
58struct superblock_security_struct { 55struct superblock_security_struct {
59 unsigned long magic; /* magic number for this module */
60 struct super_block *sb; /* back pointer to sb object */ 56 struct super_block *sb; /* back pointer to sb object */
61 struct list_head list; /* list of superblock_security_struct */ 57 struct list_head list; /* list of superblock_security_struct */
62 u32 sid; /* SID of file system */ 58 u32 sid; /* SID of file system */
@@ -70,20 +66,17 @@ struct superblock_security_struct {
70}; 66};
71 67
72struct msg_security_struct { 68struct msg_security_struct {
73 unsigned long magic; /* magic number for this module */
74 struct msg_msg *msg; /* back pointer */ 69 struct msg_msg *msg; /* back pointer */
75 u32 sid; /* SID of message */ 70 u32 sid; /* SID of message */
76}; 71};
77 72
78struct ipc_security_struct { 73struct ipc_security_struct {
79 unsigned long magic; /* magic number for this module */
80 struct kern_ipc_perm *ipc_perm; /* back pointer */ 74 struct kern_ipc_perm *ipc_perm; /* back pointer */
81 u16 sclass; /* security class of this object */ 75 u16 sclass; /* security class of this object */
82 u32 sid; /* SID of IPC resource */ 76 u32 sid; /* SID of IPC resource */
83}; 77};
84 78
85struct bprm_security_struct { 79struct bprm_security_struct {
86 unsigned long magic; /* magic number for this module */
87 struct linux_binprm *bprm; /* back pointer to bprm object */ 80 struct linux_binprm *bprm; /* back pointer to bprm object */
88 u32 sid; /* SID for transformed process */ 81 u32 sid; /* SID for transformed process */
89 unsigned char set; 82 unsigned char set;
@@ -102,7 +95,6 @@ struct netif_security_struct {
102}; 95};
103 96
104struct sk_security_struct { 97struct sk_security_struct {
105 unsigned long magic; /* magic number for this module */
106 struct sock *sk; /* back pointer to sk object */ 98 struct sock *sk; /* back pointer to sk object */
107 u32 peer_sid; /* SID of peer */ 99 u32 peer_sid; /* SID of peer */
108}; 100};
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 54147c1f6361..149feb410654 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -882,14 +882,20 @@ static int __devinit aaci_probe(struct amba_device *dev, void *id)
882 writel(0x1fff, aaci->base + AACI_INTCLR); 882 writel(0x1fff, aaci->base + AACI_INTCLR);
883 writel(aaci->maincr, aaci->base + AACI_MAINCR); 883 writel(aaci->maincr, aaci->base + AACI_MAINCR);
884 884
885 ret = aaci_probe_ac97(aaci);
886 if (ret)
887 goto out;
888
885 /* 889 /*
886 * Size the FIFOs. 890 * Size the FIFOs (must be multiple of 16).
887 */ 891 */
888 aaci->fifosize = aaci_size_fifo(aaci); 892 aaci->fifosize = aaci_size_fifo(aaci);
889 893 if (aaci->fifosize & 15) {
890 ret = aaci_probe_ac97(aaci); 894 printk(KERN_WARNING "AACI: fifosize = %d not supported\n",
891 if (ret) 895 aaci->fifosize);
896 ret = -ENODEV;
892 goto out; 897 goto out;
898 }
893 899
894 ret = aaci_init_pcm(aaci); 900 ret = aaci_init_pcm(aaci);
895 if (ret) 901 if (ret)
diff --git a/sound/core/info.c b/sound/core/info.c
index ae8853921464..af123e3bdb24 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -444,8 +444,8 @@ static unsigned int snd_info_entry_poll(struct file *file, poll_table * wait)
444 return mask; 444 return mask;
445} 445}
446 446
447static inline int _snd_info_entry_ioctl(struct inode *inode, struct file *file, 447static long snd_info_entry_ioctl(struct file *file, unsigned int cmd,
448 unsigned int cmd, unsigned long arg) 448 unsigned long arg)
449{ 449{
450 struct snd_info_private_data *data; 450 struct snd_info_private_data *data;
451 struct snd_info_entry *entry; 451 struct snd_info_entry *entry;
@@ -465,17 +465,6 @@ static inline int _snd_info_entry_ioctl(struct inode *inode, struct file *file,
465 return -ENOTTY; 465 return -ENOTTY;
466} 466}
467 467
468/* FIXME: need to unlock BKL to allow preemption */
469static int snd_info_entry_ioctl(struct inode *inode, struct file *file,
470 unsigned int cmd, unsigned long arg)
471{
472 int err;
473 unlock_kernel();
474 err = _snd_info_entry_ioctl(inode, file, cmd, arg);
475 lock_kernel();
476 return err;
477}
478
479static int snd_info_entry_mmap(struct file *file, struct vm_area_struct *vma) 468static int snd_info_entry_mmap(struct file *file, struct vm_area_struct *vma)
480{ 469{
481 struct inode *inode = file->f_dentry->d_inode; 470 struct inode *inode = file->f_dentry->d_inode;
@@ -499,15 +488,15 @@ static int snd_info_entry_mmap(struct file *file, struct vm_area_struct *vma)
499 488
500static struct file_operations snd_info_entry_operations = 489static struct file_operations snd_info_entry_operations =
501{ 490{
502 .owner = THIS_MODULE, 491 .owner = THIS_MODULE,
503 .llseek = snd_info_entry_llseek, 492 .llseek = snd_info_entry_llseek,
504 .read = snd_info_entry_read, 493 .read = snd_info_entry_read,
505 .write = snd_info_entry_write, 494 .write = snd_info_entry_write,
506 .poll = snd_info_entry_poll, 495 .poll = snd_info_entry_poll,
507 .ioctl = snd_info_entry_ioctl, 496 .unlocked_ioctl = snd_info_entry_ioctl,
508 .mmap = snd_info_entry_mmap, 497 .mmap = snd_info_entry_mmap,
509 .open = snd_info_entry_open, 498 .open = snd_info_entry_open,
510 .release = snd_info_entry_release, 499 .release = snd_info_entry_release,
511}; 500};
512 501
513/** 502/**
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
index 29676d800cae..112ddf705402 100644
--- a/sound/drivers/serial-u16550.c
+++ b/sound/drivers/serial-u16550.c
@@ -789,7 +789,7 @@ static int __init snd_uart16550_create(struct snd_card *card,
789 789
790 if ((err = snd_uart16550_detect(uart)) <= 0) { 790 if ((err = snd_uart16550_detect(uart)) <= 0) {
791 printk(KERN_ERR "no UART detected at 0x%lx\n", iobase); 791 printk(KERN_ERR "no UART detected at 0x%lx\n", iobase);
792 return err; 792 return -ENODEV;
793 } 793 }
794 794
795 if (irq >= 0 && irq != SNDRV_AUTO_IRQ) { 795 if (irq >= 0 && irq != SNDRV_AUTO_IRQ) {
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index bd8e23818460..fd9bb2575de8 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -109,7 +109,9 @@ module_param_array(wssdma, int, NULL, 0444);
109MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); 109MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver.");
110 110
111static struct platform_device *platform_devices[SNDRV_CARDS]; 111static struct platform_device *platform_devices[SNDRV_CARDS];
112#ifdef CONFIG_PNP
112static int pnp_registered; 113static int pnp_registered;
114#endif
113 115
114#define CMI8330_RMUX3D 16 116#define CMI8330_RMUX3D 16
115#define CMI8330_MUTEMUX 17 117#define CMI8330_MUTEMUX 17
@@ -672,8 +674,10 @@ static void __init_or_module snd_cmi8330_unregister_all(void)
672{ 674{
673 int i; 675 int i;
674 676
677#ifdef CONFIG_PNP
675 if (pnp_registered) 678 if (pnp_registered)
676 pnp_unregister_card_driver(&cmi8330_pnpc_driver); 679 pnp_unregister_card_driver(&cmi8330_pnpc_driver);
680#endif
677 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) 681 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
678 platform_device_unregister(platform_devices[i]); 682 platform_device_unregister(platform_devices[i]);
679 platform_driver_unregister(&snd_cmi8330_driver); 683 platform_driver_unregister(&snd_cmi8330_driver);
@@ -700,11 +704,13 @@ static int __init alsa_card_cmi8330_init(void)
700 cards++; 704 cards++;
701 } 705 }
702 706
707#ifdef CONFIG_PNP
703 err = pnp_register_card_driver(&cmi8330_pnpc_driver); 708 err = pnp_register_card_driver(&cmi8330_pnpc_driver);
704 if (err >= 0) { 709 if (err >= 0) {
705 pnp_registered = 1; 710 pnp_registered = 1;
706 cards += err; 711 cards += err;
707 } 712 }
713#endif
708 714
709 if (!cards) { 715 if (!cards) {
710#ifdef MODULE 716#ifdef MODULE
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index e1683337e6cd..4fa431040564 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -75,8 +75,10 @@ MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4235},"
75 75
76#ifdef CS4232 76#ifdef CS4232
77#define IDENT "CS4232" 77#define IDENT "CS4232"
78#define CS423X_DRIVER "snd_cs4232"
78#else 79#else
79#define IDENT "CS4236+" 80#define IDENT "CS4236+"
81#define CS423X_DRIVER "snd_cs4236"
80#endif 82#endif
81 83
82static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
@@ -125,10 +127,12 @@ module_param_array(dma2, int, NULL, 0444);
125MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); 127MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
126 128
127static struct platform_device *platform_devices[SNDRV_CARDS]; 129static struct platform_device *platform_devices[SNDRV_CARDS];
130#ifdef CONFIG_PNP
128static int pnpc_registered; 131static int pnpc_registered;
129#ifdef CS4232 132#ifdef CS4232
130static int pnp_registered; 133static int pnp_registered;
131#endif 134#endif
135#endif /* CONFIG_PNP */
132 136
133struct snd_card_cs4236 { 137struct snd_card_cs4236 {
134 struct snd_cs4231 *chip; 138 struct snd_cs4231 *chip;
@@ -158,7 +162,6 @@ MODULE_DEVICE_TABLE(pnp, snd_cs4232_pnpbiosids);
158#endif /* CS4232 */ 162#endif /* CS4232 */
159 163
160#ifdef CS4232 164#ifdef CS4232
161#define CS423X_DRIVER "snd_cs4232"
162#define CS423X_ISAPNP_DRIVER "cs4232_isapnp" 165#define CS423X_ISAPNP_DRIVER "cs4232_isapnp"
163static struct pnp_card_device_id snd_cs423x_pnpids[] = { 166static struct pnp_card_device_id snd_cs423x_pnpids[] = {
164 /* Philips PCA70PS */ 167 /* Philips PCA70PS */
@@ -175,11 +178,12 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = {
175 { .id = "CSC7632", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } }, 178 { .id = "CSC7632", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } },
176 /* SIC CrystalWave 32 (CS4232) */ 179 /* SIC CrystalWave 32 (CS4232) */
177 { .id = "CSCf032", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 180 { .id = "CSCf032", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
181 /* Netfinity 3000 on-board soundcard */
182 { .id = "CSCe825", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC010f" } } },
178 /* --- */ 183 /* --- */
179 { .id = "" } /* end */ 184 { .id = "" } /* end */
180}; 185};
181#else /* CS4236 */ 186#else /* CS4236 */
182#define CS423X_DRIVER "snd_cs4236"
183#define CS423X_ISAPNP_DRIVER "cs4236_isapnp" 187#define CS423X_ISAPNP_DRIVER "cs4236_isapnp"
184static struct pnp_card_device_id snd_cs423x_pnpids[] = { 188static struct pnp_card_device_id snd_cs423x_pnpids[] = {
185 /* Intel Marlin Spike Motherboard - CS4235 */ 189 /* Intel Marlin Spike Motherboard - CS4235 */
@@ -747,12 +751,14 @@ static void __init_or_module snd_cs423x_unregister_all(void)
747{ 751{
748 int i; 752 int i;
749 753
754#ifdef CONFIG_PNP
750 if (pnpc_registered) 755 if (pnpc_registered)
751 pnp_unregister_card_driver(&cs423x_pnpc_driver); 756 pnp_unregister_card_driver(&cs423x_pnpc_driver);
752#ifdef CS4232 757#ifdef CS4232
753 if (pnp_registered) 758 if (pnp_registered)
754 pnp_unregister_driver(&cs4232_pnp_driver); 759 pnp_unregister_driver(&cs4232_pnp_driver);
755#endif 760#endif
761#endif /* CONFIG_PNP */
756 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) 762 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
757 platform_device_unregister(platform_devices[i]); 763 platform_device_unregister(platform_devices[i]);
758 platform_driver_unregister(&cs423x_nonpnp_driver); 764 platform_driver_unregister(&cs423x_nonpnp_driver);
@@ -778,6 +784,7 @@ static int __init alsa_card_cs423x_init(void)
778 platform_devices[i] = device; 784 platform_devices[i] = device;
779 cards++; 785 cards++;
780 } 786 }
787#ifdef CONFIG_PNP
781#ifdef CS4232 788#ifdef CS4232
782 i = pnp_register_driver(&cs4232_pnp_driver); 789 i = pnp_register_driver(&cs4232_pnp_driver);
783 if (i >= 0) { 790 if (i >= 0) {
@@ -790,6 +797,8 @@ static int __init alsa_card_cs423x_init(void)
790 pnpc_registered = 1; 797 pnpc_registered = 1;
791 cards += i; 798 cards += i;
792 } 799 }
800#endif /* CONFIG_PNP */
801
793 if (!cards) { 802 if (!cards) {
794#ifdef MODULE 803#ifdef MODULE
795 printk(KERN_ERR IDENT " soundcard not found or device busy\n"); 804 printk(KERN_ERR IDENT " soundcard not found or device busy\n");
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index bf5de0782eb0..08f032b51107 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -1878,9 +1878,9 @@ module_param_array(dma2, int, NULL, 0444);
1878MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); 1878MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver.");
1879 1879
1880static struct platform_device *platform_devices[SNDRV_CARDS]; 1880static struct platform_device *platform_devices[SNDRV_CARDS];
1881static int pnp_registered;
1882 1881
1883#ifdef CONFIG_PNP 1882#ifdef CONFIG_PNP
1883static int pnp_registered;
1884 1884
1885static struct pnp_card_device_id snd_audiodrive_pnpids[] = { 1885static struct pnp_card_device_id snd_audiodrive_pnpids[] = {
1886 /* ESS 1868 (integrated on Compaq dual P-Pro motherboard and Genius 18PnP 3D) */ 1886 /* ESS 1868 (integrated on Compaq dual P-Pro motherboard and Genius 18PnP 3D) */
@@ -2209,8 +2209,10 @@ static void __init_or_module snd_es18xx_unregister_all(void)
2209{ 2209{
2210 int i; 2210 int i;
2211 2211
2212#ifdef CONFIG_PNP
2212 if (pnp_registered) 2213 if (pnp_registered)
2213 pnp_unregister_card_driver(&es18xx_pnpc_driver); 2214 pnp_unregister_card_driver(&es18xx_pnpc_driver);
2215#endif
2214 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) 2216 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
2215 platform_device_unregister(platform_devices[i]); 2217 platform_device_unregister(platform_devices[i]);
2216 platform_driver_unregister(&snd_es18xx_nonpnp_driver); 2218 platform_driver_unregister(&snd_es18xx_nonpnp_driver);
@@ -2237,11 +2239,13 @@ static int __init alsa_card_es18xx_init(void)
2237 cards++; 2239 cards++;
2238 } 2240 }
2239 2241
2242#ifdef CONFIG_PNP
2240 i = pnp_register_card_driver(&es18xx_pnpc_driver); 2243 i = pnp_register_card_driver(&es18xx_pnpc_driver);
2241 if (i >= 0) { 2244 if (i >= 0) {
2242 pnp_registered = 1; 2245 pnp_registered = 1;
2243 cards += i; 2246 cards += i;
2244 } 2247 }
2248#endif
2245 2249
2246 if(!cards) { 2250 if(!cards) {
2247#ifdef MODULE 2251#ifdef MODULE
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
index d1165b96fa3f..91c219116d7a 100644
--- a/sound/isa/gus/gusclassic.c
+++ b/sound/isa/gus/gusclassic.c
@@ -195,7 +195,7 @@ static int __init snd_gusclassic_probe(struct platform_device *pdev)
195 goto _err; 195 goto _err;
196 } 196 }
197 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1); 197 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1);
198 if (dma2 >= 0) 198 if (xdma2 >= 0)
199 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 199 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
200 200
201 snd_card_set_dev(card, &pdev->dev); 201 snd_card_set_dev(card, &pdev->dev);
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index ca359e0c674b..9d8431978501 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -91,8 +91,10 @@ module_param_array(opl3sa3_ymode, int, NULL, 0444);
91MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); 91MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi.");
92 92
93static struct platform_device *platform_devices[SNDRV_CARDS]; 93static struct platform_device *platform_devices[SNDRV_CARDS];
94#ifdef CONFIG_PNP
94static int pnp_registered; 95static int pnp_registered;
95static int pnpc_registered; 96static int pnpc_registered;
97#endif
96 98
97/* control ports */ 99/* control ports */
98#define OPL3SA2_PM_CTRL 0x01 100#define OPL3SA2_PM_CTRL 0x01
@@ -721,7 +723,7 @@ static int __devinit snd_opl3sa2_probe(struct snd_card *card, int dev)
721 } 723 }
722 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", 724 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
723 card->shortname, chip->port, xirq, xdma1); 725 card->shortname, chip->port, xirq, xdma1);
724 if (dma2 >= 0) 726 if (xdma2 >= 0)
725 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 727 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
726 728
727 return snd_card_register(card); 729 return snd_card_register(card);
@@ -779,7 +781,7 @@ static int snd_opl3sa2_pnp_resume(struct pnp_dev *pdev)
779#endif 781#endif
780 782
781static struct pnp_driver opl3sa2_pnp_driver = { 783static struct pnp_driver opl3sa2_pnp_driver = {
782 .name = "opl3sa2-pnpbios", 784 .name = "snd-opl3sa2-pnpbios",
783 .id_table = snd_opl3sa2_pnpbiosids, 785 .id_table = snd_opl3sa2_pnpbiosids,
784 .probe = snd_opl3sa2_pnp_detect, 786 .probe = snd_opl3sa2_pnp_detect,
785 .remove = __devexit_p(snd_opl3sa2_pnp_remove), 787 .remove = __devexit_p(snd_opl3sa2_pnp_remove),
@@ -846,7 +848,7 @@ static int snd_opl3sa2_pnp_cresume(struct pnp_card_link *pcard)
846 848
847static struct pnp_card_driver opl3sa2_pnpc_driver = { 849static struct pnp_card_driver opl3sa2_pnpc_driver = {
848 .flags = PNP_DRIVER_RES_DISABLE, 850 .flags = PNP_DRIVER_RES_DISABLE,
849 .name = "opl3sa2", 851 .name = "snd-opl3sa2-cpnp",
850 .id_table = snd_opl3sa2_pnpids, 852 .id_table = snd_opl3sa2_pnpids,
851 .probe = snd_opl3sa2_pnp_cdetect, 853 .probe = snd_opl3sa2_pnp_cdetect,
852 .remove = __devexit_p(snd_opl3sa2_pnp_cremove), 854 .remove = __devexit_p(snd_opl3sa2_pnp_cremove),
@@ -929,10 +931,12 @@ static void __init_or_module snd_opl3sa2_unregister_all(void)
929{ 931{
930 int i; 932 int i;
931 933
934#ifdef CONFIG_PNP
932 if (pnpc_registered) 935 if (pnpc_registered)
933 pnp_unregister_card_driver(&opl3sa2_pnpc_driver); 936 pnp_unregister_card_driver(&opl3sa2_pnpc_driver);
934 if (pnp_registered) 937 if (pnp_registered)
935 pnp_unregister_driver(&opl3sa2_pnp_driver); 938 pnp_unregister_driver(&opl3sa2_pnp_driver);
939#endif
936 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) 940 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
937 platform_device_unregister(platform_devices[i]); 941 platform_device_unregister(platform_devices[i]);
938 platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); 942 platform_driver_unregister(&snd_opl3sa2_nonpnp_driver);
@@ -961,6 +965,7 @@ static int __init alsa_card_opl3sa2_init(void)
961 cards++; 965 cards++;
962 } 966 }
963 967
968#ifdef CONFIG_PNP
964 err = pnp_register_driver(&opl3sa2_pnp_driver); 969 err = pnp_register_driver(&opl3sa2_pnp_driver);
965 if (err >= 0) { 970 if (err >= 0) {
966 pnp_registered = 1; 971 pnp_registered = 1;
@@ -971,6 +976,7 @@ static int __init alsa_card_opl3sa2_init(void)
971 pnpc_registered = 1; 976 pnpc_registered = 1;
972 cards += err; 977 cards += err;
973 } 978 }
979#endif
974 980
975 if (!cards) { 981 if (!cards) {
976#ifdef MODULE 982#ifdef MODULE
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index 1ea3944ef7ab..63d96be11b2b 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -1349,7 +1349,7 @@ static int snd_opti93x_pcm(struct snd_opti93x *codec, int device, struct snd_pcm
1349 int error; 1349 int error;
1350 struct snd_pcm *pcm; 1350 struct snd_pcm *pcm;
1351 1351
1352 if ((error = snd_pcm_new(codec->card, "OPTi 82C93X", device, 1, 1, &pcm))) 1352 if ((error = snd_pcm_new(codec->card, "OPTi 82C93X", device, 1, 1, &pcm)) < 0)
1353 return error; 1353 return error;
1354 1354
1355 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_opti93x_playback_ops); 1355 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_opti93x_playback_ops);
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index c0be7a5a3425..0667bd14ad60 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -179,6 +179,8 @@ static struct pnp_card_device_id snd_sb16_pnpids[] = {
179 { .id = "CTL0086", .devs = { { "CTL0041" } } }, 179 { .id = "CTL0086", .devs = { { "CTL0041" } } },
180 /* Sound Blaster Vibra16X */ 180 /* Sound Blaster Vibra16X */
181 { .id = "CTL00f0", .devs = { { "CTL0043" } } }, 181 { .id = "CTL00f0", .devs = { { "CTL0043" } } },
182 /* Sound Blaster 16 (Virtual PC 2004) */
183 { .id = "tBA03b0", .devs = { {.id="PNPb003" } } },
182#else /* SNDRV_SBAWE defined */ 184#else /* SNDRV_SBAWE defined */
183 /* Sound Blaster AWE 32 PnP */ 185 /* Sound Blaster AWE 32 PnP */
184 { .id = "CTL0035", .devs = { { "CTL0031" }, { "CTL0021" } } }, 186 { .id = "CTL0035", .devs = { { "CTL0031" }, { "CTL0021" } } },
@@ -235,8 +237,6 @@ static struct pnp_card_device_id snd_sb16_pnpids[] = {
235 { .id = "CTLXXXX" , .devs = { { "CTL0044" }, { "CTL0023" } } }, 237 { .id = "CTLXXXX" , .devs = { { "CTL0044" }, { "CTL0023" } } },
236 { .id = "CTLXXXX" , .devs = { { "CTL0045" }, { "CTL0022" } } }, 238 { .id = "CTLXXXX" , .devs = { { "CTL0045" }, { "CTL0022" } } },
237#endif /* SNDRV_SBAWE */ 239#endif /* SNDRV_SBAWE */
238 /* Sound Blaster 16 PnP (Virtual PC 2004)*/
239 { .id = "tBA03b0", .devs = { { "PNPb003" } } },
240 { .id = "", } 240 { .id = "", }
241}; 241};
242 242
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 5fb981c0a281..29bba8cc3ef3 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -69,9 +69,9 @@ module_param_array(dma, int, NULL, 0444);
69MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); 69MODULE_PARM_DESC(dma, "DMA # for SoundScape driver.");
70 70
71static struct platform_device *platform_devices[SNDRV_CARDS]; 71static struct platform_device *platform_devices[SNDRV_CARDS];
72static int pnp_registered;
73 72
74#ifdef CONFIG_PNP 73#ifdef CONFIG_PNP
74static int pnp_registered;
75static struct pnp_card_device_id sscape_pnpids[] = { 75static struct pnp_card_device_id sscape_pnpids[] = {
76 { .id = "ENS3081", .devs = { { "ENS0000" } } }, 76 { .id = "ENS3081", .devs = { { "ENS0000" } } },
77 { .id = "" } /* end */ 77 { .id = "" } /* end */
@@ -1391,8 +1391,10 @@ static void __init_or_module sscape_unregister_all(void)
1391{ 1391{
1392 int i; 1392 int i;
1393 1393
1394#ifdef CONFIG_PNP
1394 if (pnp_registered) 1395 if (pnp_registered)
1395 pnp_unregister_card_driver(&sscape_pnpc_driver); 1396 pnp_unregister_card_driver(&sscape_pnpc_driver);
1397#endif
1396 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) 1398 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
1397 platform_device_unregister(platform_devices[i]); 1399 platform_device_unregister(platform_devices[i]);
1398 platform_driver_unregister(&snd_sscape_driver); 1400 platform_driver_unregister(&snd_sscape_driver);
@@ -1466,8 +1468,10 @@ static int __init sscape_init(void)
1466 ret = sscape_manual_probe(); 1468 ret = sscape_manual_probe();
1467 if (ret < 0) 1469 if (ret < 0)
1468 return ret; 1470 return ret;
1471#ifdef CONFIG_PNP
1469 if (pnp_register_card_driver(&sscape_pnpc_driver) >= 0) 1472 if (pnp_register_card_driver(&sscape_pnpc_driver) >= 0)
1470 pnp_registered = 1; 1473 pnp_registered = 1;
1474#endif
1471 return 0; 1475 return 0;
1472} 1476}
1473 1477
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index a6dcb2f970ca..fa3ab960de17 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -84,10 +84,9 @@ module_param_array(use_cs4232_midi, bool, NULL, 0444);
84MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); 84MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
85 85
86static struct platform_device *platform_devices[SNDRV_CARDS]; 86static struct platform_device *platform_devices[SNDRV_CARDS];
87static int pnp_registered;
88
89 87
90#ifdef CONFIG_PNP 88#ifdef CONFIG_PNP
89static int pnp_registered;
91 90
92static struct pnp_card_device_id snd_wavefront_pnpids[] = { 91static struct pnp_card_device_id snd_wavefront_pnpids[] = {
93 /* Tropez */ 92 /* Tropez */
@@ -695,8 +694,10 @@ static void __init_or_module snd_wavefront_unregister_all(void)
695{ 694{
696 int i; 695 int i;
697 696
697#ifdef CONFIG_PNP
698 if (pnp_registered) 698 if (pnp_registered)
699 pnp_unregister_card_driver(&wavefront_pnpc_driver); 699 pnp_unregister_card_driver(&wavefront_pnpc_driver);
700#endif
700 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) 701 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
701 platform_device_unregister(platform_devices[i]); 702 platform_device_unregister(platform_devices[i]);
702 platform_driver_unregister(&snd_wavefront_driver); 703 platform_driver_unregister(&snd_wavefront_driver);
@@ -725,11 +726,13 @@ static int __init alsa_card_wavefront_init(void)
725 cards++; 726 cards++;
726 } 727 }
727 728
729#ifdef CONFIG_PNP
728 i = pnp_register_card_driver(&wavefront_pnpc_driver); 730 i = pnp_register_card_driver(&wavefront_pnpc_driver);
729 if (i >= 0) { 731 if (i >= 0) {
730 pnp_registered = 1; 732 pnp_registered = 1;
731 cards += i; 733 cards += i;
732 } 734 }
735#endif
733 736
734 if (!cards) { 737 if (!cards) {
735#ifdef MODULE 738#ifdef MODULE
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
index ed81eec6e732..68aa091e8961 100644
--- a/sound/isa/wavefront/wavefront_synth.c
+++ b/sound/isa/wavefront/wavefront_synth.c
@@ -866,7 +866,7 @@ wavefront_send_sample (snd_wavefront_t *dev,
866 divided by 2. 866 divided by 2.
867 */ 867 */
868 868
869 u16 sample_short; 869 u16 sample_short = 0;
870 u32 length; 870 u32 length;
871 u16 __user *data_end = NULL; 871 u16 __user *data_end = NULL;
872 unsigned int i; 872 unsigned int i;
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index b963c550dae6..bdee0502f3e2 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -462,7 +462,7 @@ stop_dac(struct au1550_state *s)
462 /* Wait for Transmit Busy to show disabled. 462 /* Wait for Transmit Busy to show disabled.
463 */ 463 */
464 do { 464 do {
465 stat = readl((void *)PSC_AC97STAT); 465 stat = au_readl(PSC_AC97STAT);
466 au_sync(); 466 au_sync();
467 } while ((stat & PSC_AC97STAT_TB) != 0); 467 } while ((stat & PSC_AC97STAT_TB) != 0);
468 468
@@ -491,7 +491,7 @@ stop_adc(struct au1550_state *s)
491 /* Wait for Receive Busy to show disabled. 491 /* Wait for Receive Busy to show disabled.
492 */ 492 */
493 do { 493 do {
494 stat = readl((void *)PSC_AC97STAT); 494 stat = au_readl(PSC_AC97STAT);
495 au_sync(); 495 au_sync();
496 } while ((stat & PSC_AC97STAT_RB) != 0); 496 } while ((stat & PSC_AC97STAT_RB) != 0);
497 497
@@ -541,7 +541,7 @@ set_xmit_slots(int num_channels)
541 /* Wait for Device ready. 541 /* Wait for Device ready.
542 */ 542 */
543 do { 543 do {
544 stat = readl((void *)PSC_AC97STAT); 544 stat = au_readl(PSC_AC97STAT);
545 au_sync(); 545 au_sync();
546 } while ((stat & PSC_AC97STAT_DR) == 0); 546 } while ((stat & PSC_AC97STAT_DR) == 0);
547} 547}
@@ -573,7 +573,7 @@ set_recv_slots(int num_channels)
573 /* Wait for Device ready. 573 /* Wait for Device ready.
574 */ 574 */
575 do { 575 do {
576 stat = readl((void *)PSC_AC97STAT); 576 stat = au_readl(PSC_AC97STAT);
577 au_sync(); 577 au_sync();
578 } while ((stat & PSC_AC97STAT_DR) == 0); 578 } while ((stat & PSC_AC97STAT_DR) == 0);
579} 579}
@@ -1995,7 +1995,7 @@ au1550_probe(void)
1995 /* Wait for PSC ready. 1995 /* Wait for PSC ready.
1996 */ 1996 */
1997 do { 1997 do {
1998 val = readl((void *)PSC_AC97STAT); 1998 val = au_readl(PSC_AC97STAT);
1999 au_sync(); 1999 au_sync();
2000 } while ((val & PSC_AC97STAT_SR) == 0); 2000 } while ((val & PSC_AC97STAT_SR) == 0);
2001 2001
@@ -2018,7 +2018,7 @@ au1550_probe(void)
2018 /* Wait for Device ready. 2018 /* Wait for Device ready.
2019 */ 2019 */
2020 do { 2020 do {
2021 val = readl((void *)PSC_AC97STAT); 2021 val = au_readl(PSC_AC97STAT);
2022 au_sync(); 2022 au_sync();
2023 } while ((val & PSC_AC97STAT_DR) == 0); 2023 } while ((val & PSC_AC97STAT_DR) == 0);
2024 2024
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 4aa5fdc5688e..a444a78c7c94 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -1621,8 +1621,27 @@ static const struct snd_kcontrol_new snd_ac97_ad1981x_jack_sense[] = {
1621 AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0), 1621 AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0),
1622}; 1622};
1623 1623
1624/* black list to avoid HP/Line jack-sense controls
1625 * (SS vendor << 16 | device)
1626 */
1627static unsigned int ad1981_jacks_blacklist[] = {
1628 0x10140554, /* Thinkpad T42p/R50p */
1629 0 /* end */
1630};
1631
1632static int check_list(struct snd_ac97 *ac97, const unsigned int *list)
1633{
1634 u32 subid = ((u32)ac97->subsystem_vendor << 16) | ac97->subsystem_device;
1635 for (; *list; list++)
1636 if (*list == subid)
1637 return 1;
1638 return 0;
1639}
1640
1624static int patch_ad1981a_specific(struct snd_ac97 * ac97) 1641static int patch_ad1981a_specific(struct snd_ac97 * ac97)
1625{ 1642{
1643 if (check_list(ac97, ad1981_jacks_blacklist))
1644 return 0;
1626 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense, 1645 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1627 ARRAY_SIZE(snd_ac97_ad1981x_jack_sense)); 1646 ARRAY_SIZE(snd_ac97_ad1981x_jack_sense));
1628} 1647}
@@ -1635,22 +1654,26 @@ static struct snd_ac97_build_ops patch_ad1981a_build_ops = {
1635#endif 1654#endif
1636}; 1655};
1637 1656
1657/* white list to enable HP jack-sense bits
1658 * (SS vendor << 16 | device)
1659 */
1660static unsigned int ad1981_jacks_whitelist[] = {
1661 0x0e11005a, /* HP nc4000/4010 */
1662 0x103c0890, /* HP nc6000 */
1663 0x103c0938, /* HP nc4220 */
1664 0x103c099c, /* HP nx6110 */
1665 0x103c0944, /* HP nc6220 */
1666 0x103c0934, /* HP nc8220 */
1667 0x103c006d, /* HP nx9105 */
1668 0x17340088, /* FSC Scenic-W */
1669 0 /* end */
1670};
1671
1638static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97) 1672static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97)
1639{ 1673{
1640 u32 subid = ((u32)ac97->subsystem_vendor << 16) | ac97->subsystem_device; 1674 if (check_list(ac97, ad1981_jacks_whitelist))
1641 switch (subid) {
1642 case 0x0e11005a: /* HP nc4000/4010 */
1643 case 0x103c0890: /* HP nc6000 */
1644 case 0x103c0938: /* HP nc4220 */
1645 case 0x103c099c: /* HP nx6110 */
1646 case 0x103c0944: /* HP nc6220 */
1647 case 0x103c0934: /* HP nc8220 */
1648 case 0x103c006d: /* HP nx9105 */
1649 case 0x17340088: /* FSC Scenic-W */
1650 /* enable headphone jack sense */ 1675 /* enable headphone jack sense */
1651 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11); 1676 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
1652 break;
1653 }
1654} 1677}
1655 1678
1656int patch_ad1981a(struct snd_ac97 *ac97) 1679int patch_ad1981a(struct snd_ac97 *ac97)
@@ -1672,6 +1695,8 @@ static int patch_ad1981b_specific(struct snd_ac97 *ac97)
1672 1695
1673 if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0) 1696 if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
1674 return err; 1697 return err;
1698 if (check_list(ac97, ad1981_jacks_blacklist))
1699 return 0;
1675 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense, 1700 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1676 ARRAY_SIZE(snd_ac97_ad1981x_jack_sense)); 1701 ARRAY_SIZE(snd_ac97_ad1981x_jack_sense));
1677} 1702}
@@ -2210,9 +2235,9 @@ static void alc850_update_jacks(struct snd_ac97 *ac97)
2210 /* Vref disable (bit12), 1kOhm (bit13) */ 2235 /* Vref disable (bit12), 1kOhm (bit13) */
2211 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13), 2236 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13),
2212 shared ? (1<<12) : (1<<13)); 2237 shared ? (1<<12) : (1<<13));
2213 /* MIC-IN = 1, CENTER-LFE = 2 */ 2238 /* MIC-IN = 1, CENTER-LFE = 5 */
2214 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4, 2239 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4,
2215 shared ? (2<<4) : (1<<4)); 2240 shared ? (5<<4) : (1<<4));
2216} 2241}
2217 2242
2218static const struct snd_kcontrol_new snd_ac97_controls_alc850[] = { 2243static const struct snd_kcontrol_new snd_ac97_controls_alc850[] = {
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index bc4d1ef08efa..e264136e8fb4 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -279,7 +279,7 @@ struct snd_ali {
279}; 279};
280 280
281static struct pci_device_id snd_ali_ids[] = { 281static struct pci_device_id snd_ali_ids[] = {
282 {0x10b9, 0x5451, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, 282 {PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5451), 0, 0, 0},
283 {0, } 283 {0, }
284}; 284};
285MODULE_DEVICE_TABLE(pci, snd_ali_ids); 285MODULE_DEVICE_TABLE(pci, snd_ali_ids);
diff --git a/sound/pci/au88x0/au88x0_eq.c b/sound/pci/au88x0/au88x0_eq.c
index 13bc8ed301c5..c8280f82eb5a 100644
--- a/sound/pci/au88x0/au88x0_eq.c
+++ b/sound/pci/au88x0/au88x0_eq.c
@@ -849,7 +849,7 @@ static int
849snd_vortex_peaks_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 849snd_vortex_peaks_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
850{ 850{
851 vortex_t *vortex = snd_kcontrol_chip(kcontrol); 851 vortex_t *vortex = snd_kcontrol_chip(kcontrol);
852 int i, count; 852 int i, count = 0;
853 u16 peaks[20]; 853 u16 peaks[20];
854 854
855 vortex_Eqlzr_GetAllPeaks(vortex, peaks, &count); 855 vortex_Eqlzr_GetAllPeaks(vortex, peaks, &count);
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index dc9cd3079b14..c840a4c08e98 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -781,6 +781,8 @@ static struct pci_device_id snd_bt87x_ids[] = {
781 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000), 781 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000),
782 /* Viewcast Osprey 200 */ 782 /* Viewcast Osprey 200 */
783 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100), 783 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100),
784 /* AVerMedia Studio No. 103, 203, ...? */
785 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x1461, 0x0003, 48000),
784 { } 786 { }
785}; 787};
786MODULE_DEVICE_TABLE(pci, snd_bt87x_ids); 788MODULE_DEVICE_TABLE(pci, snd_bt87x_ids);
@@ -808,7 +810,7 @@ static int __devinit snd_bt87x_detect_card(struct pci_dev *pci)
808 const struct pci_device_id *supported; 810 const struct pci_device_id *supported;
809 811
810 supported = pci_match_device(&driver, pci); 812 supported = pci_match_device(&driver, pci);
811 if (supported) 813 if (supported && supported->driver_data > 0)
812 return supported->driver_data; 814 return supported->driver_data;
813 815
814 for (i = 0; i < ARRAY_SIZE(blacklist); ++i) 816 for (i = 0; i < ARRAY_SIZE(blacklist); ++i)
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 6ed7c0bfa091..9477838a9c88 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -199,7 +199,8 @@ static struct snd_ca0106_details ca0106_chip_details[] = {
199 .name = "MSI K8N Diamond MB [SB0438]", 199 .name = "MSI K8N Diamond MB [SB0438]",
200 .gpio_type = 1, 200 .gpio_type = 1,
201 .i2c_adc = 1 } , 201 .i2c_adc = 1 } ,
202 /* Shuttle XPC SD31P which has an onboard Creative Labs Sound Blaster Live! 24-bit EAX 202 /* Shuttle XPC SD31P which has an onboard Creative Labs
203 * Sound Blaster Live! 24-bit EAX
203 * high-definition 7.1 audio processor". 204 * high-definition 7.1 audio processor".
204 * Added using info from andrewvegan in alsa bug #1298 205 * Added using info from andrewvegan in alsa bug #1298
205 */ 206 */
@@ -207,6 +208,15 @@ static struct snd_ca0106_details ca0106_chip_details[] = {
207 .name = "Shuttle XPC SD31P [SD31P]", 208 .name = "Shuttle XPC SD31P [SD31P]",
208 .gpio_type = 1, 209 .gpio_type = 1,
209 .i2c_adc = 1 } , 210 .i2c_adc = 1 } ,
211 /* Shuttle XPC SD11G5 which has an onboard Creative Labs
212 * Sound Blaster Live! 24-bit EAX
213 * high-definition 7.1 audio processor".
214 * Fixes ALSA bug#1600
215 */
216 { .serial = 0x30411297,
217 .name = "Shuttle XPC SD11G5 [SD11G5]",
218 .gpio_type = 1,
219 .i2c_adc = 1 } ,
210 { .serial = 0, 220 { .serial = 0,
211 .name = "AudigyLS [Unknown]" } 221 .name = "AudigyLS [Unknown]" }
212}; 222};
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
index 509aa2b63331..d4e0fb39bd06 100644
--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
+++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
@@ -675,7 +675,7 @@ cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
675 if (pass_through) { 675 if (pass_through) {
676 /* wont work with any other rate than 676 /* wont work with any other rate than
677 the native DSP rate */ 677 the native DSP rate */
678 snd_assert (rate = 48000); 678 snd_assert (rate == 48000);
679 679
680 scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb, 680 scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&src_task_scb,
681 dest,"DMAREADER",parent_scb, 681 dest,"DMAREADER",parent_scb,
diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c
index f36ede827479..02e3721030b7 100644
--- a/sound/pci/cs5535audio/cs5535audio.c
+++ b/sound/pci/cs5535audio/cs5535audio.c
@@ -46,8 +46,10 @@ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
46static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 46static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
47 47
48static struct pci_device_id snd_cs5535audio_ids[] = { 48static struct pci_device_id snd_cs5535audio_ids[] = {
49 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO, PCI_ANY_ID, 49 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO,
50 PCI_ANY_ID, 0, 0, 0, }, 50 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
51 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO,
52 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
51 {} 53 {}
52}; 54};
53 55
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index 2e86a901a0a4..2a9d12d10680 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -759,6 +759,8 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu,
759 "Master Mono Playback Volume", 759 "Master Mono Playback Volume",
760 "PCM Out Path & Mute", 760 "PCM Out Path & Mute",
761 "Mono Output Select", 761 "Mono Output Select",
762 "Front Playback Switch",
763 "Front Playback Volume",
762 "Surround Playback Switch", 764 "Surround Playback Switch",
763 "Surround Playback Volume", 765 "Surround Playback Volume",
764 "Center Playback Switch", 766 "Center Playback Switch",
@@ -829,9 +831,9 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu,
829 } 831 }
830 if (emu->audigy) { 832 if (emu->audigy) {
831 /* set master volume to 0 dB */ 833 /* set master volume to 0 dB */
832 snd_ac97_write(emu->ac97, AC97_MASTER, 0x0000); 834 snd_ac97_write_cache(emu->ac97, AC97_MASTER, 0x0000);
833 /* set capture source to mic */ 835 /* set capture source to mic */
834 snd_ac97_write(emu->ac97, AC97_REC_SEL, 0x0000); 836 snd_ac97_write_cache(emu->ac97, AC97_REC_SEL, 0x0000);
835 c = audigy_remove_ctls; 837 c = audigy_remove_ctls;
836 } else { 838 } else {
837 /* 839 /*
@@ -844,8 +846,8 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu,
844 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE|AC97SLOT_REAR_LEFT|AC97SLOT_REAR_RIGHT); 846 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE|AC97SLOT_REAR_LEFT|AC97SLOT_REAR_RIGHT);
845 } 847 }
846 /* remove unused AC97 controls */ 848 /* remove unused AC97 controls */
847 snd_ac97_write(emu->ac97, AC97_SURROUND_MASTER, 0x0202); 849 snd_ac97_write_cache(emu->ac97, AC97_SURROUND_MASTER, 0x0202);
848 snd_ac97_write(emu->ac97, AC97_CENTER_LFE_MASTER, 0x0202); 850 snd_ac97_write_cache(emu->ac97, AC97_CENTER_LFE_MASTER, 0x0202);
849 c = emu10k1_remove_ctls; 851 c = emu10k1_remove_ctls;
850 } 852 }
851 for (; *c; c++) 853 for (; *c; c++)
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index a983deba4025..fd12b6991fe4 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -75,6 +75,7 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
75 "{Intel, ICH6M}," 75 "{Intel, ICH6M},"
76 "{Intel, ICH7}," 76 "{Intel, ICH7},"
77 "{Intel, ESB2}," 77 "{Intel, ESB2},"
78 "{Intel, ICH8},"
78 "{ATI, SB450}," 79 "{ATI, SB450},"
79 "{VIA, VT8251}," 80 "{VIA, VT8251},"
80 "{VIA, VT8237A}," 81 "{VIA, VT8237A},"
@@ -1586,6 +1587,7 @@ static struct pci_device_id azx_ids[] = {
1586 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH6 */ 1587 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH6 */
1587 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */ 1588 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */
1588 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */ 1589 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */
1590 { 0x8086, 0x284b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH8 */
1589 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */ 1591 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */
1590 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ 1592 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
1591 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ 1593 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index ad9e501a9818..b76755264730 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1668,6 +1668,7 @@ static struct hda_board_config alc880_cfg_tbl[] = {
1668 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */ 1668 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
1669 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST }, 1669 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
1670 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */ 1670 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
1671 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
1671 1672
1672 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG }, 1673 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
1673 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG }, 1674 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
@@ -2475,7 +2476,7 @@ static struct hda_verb alc260_init_verbs[] = {
2475 /* LINE-2 is used for line-out in rear */ 2476 /* LINE-2 is used for line-out in rear */
2476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2477 /* select line-out */ 2478 /* select line-out */
2478 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 2479 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
2479 /* LINE-OUT pin */ 2480 /* LINE-OUT pin */
2480 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2481 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2481 /* enable HP */ 2482 /* enable HP */
@@ -2945,6 +2946,8 @@ static int alc260_auto_init(struct hda_codec *codec)
2945 */ 2946 */
2946static struct hda_board_config alc260_cfg_tbl[] = { 2947static struct hda_board_config alc260_cfg_tbl[] = {
2947 { .modelname = "basic", .config = ALC260_BASIC }, 2948 { .modelname = "basic", .config = ALC260_BASIC },
2949 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
2950 .config = ALC260_BASIC }, /* Sony VAIO */
2948 { .modelname = "hp", .config = ALC260_HP }, 2951 { .modelname = "hp", .config = ALC260_HP },
2949 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP }, 2952 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
2950 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP }, 2953 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
@@ -3414,12 +3417,12 @@ static struct snd_kcontrol_new alc882_capture_mixer[] = {
3414 * configuration and preset 3417 * configuration and preset
3415 */ 3418 */
3416static struct hda_board_config alc882_cfg_tbl[] = { 3419static struct hda_board_config alc882_cfg_tbl[] = {
3417 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, 3420 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
3418 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, 3421 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
3419 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */ 3422 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
3420 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */ 3423 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
3421 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */ 3424 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
3422 { .modelname = "auto", .config = ALC861_AUTO }, 3425 { .modelname = "auto", .config = ALC882_AUTO },
3423 {} 3426 {}
3424}; 3427};
3425 3428
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index 8f8840e6002b..250242cd6c70 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -297,6 +297,7 @@ static int patch_si3054(struct hda_codec *codec)
297struct hda_codec_preset snd_hda_preset_si3054[] = { 297struct hda_codec_preset snd_hda_preset_si3054[] = {
298 { .id = 0x163c3055, .name = "Si3054", .patch = patch_si3054 }, 298 { .id = 0x163c3055, .name = "Si3054", .patch = patch_si3054 },
299 { .id = 0x163c3155, .name = "Si3054", .patch = patch_si3054 }, 299 { .id = 0x163c3155, .name = "Si3054", .patch = patch_si3054 },
300 { .id = 0x11c13026, .name = "Si3054", .patch = patch_si3054 },
300 {} 301 {}
301}; 302};
302 303
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 61903848cd43..35c2823a0a2b 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -50,10 +50,11 @@ struct sigmatel_spec {
50 unsigned int surr_switch: 1; 50 unsigned int surr_switch: 1;
51 unsigned int line_switch: 1; 51 unsigned int line_switch: 1;
52 unsigned int mic_switch: 1; 52 unsigned int mic_switch: 1;
53 unsigned int alt_switch: 1;
53 54
54 /* playback */ 55 /* playback */
55 struct hda_multi_out multiout; 56 struct hda_multi_out multiout;
56 hda_nid_t dac_nids[4]; 57 hda_nid_t dac_nids[5];
57 58
58 /* capture */ 59 /* capture */
59 hda_nid_t *adc_nids; 60 hda_nid_t *adc_nids;
@@ -73,7 +74,7 @@ struct sigmatel_spec {
73 74
74 /* capture source */ 75 /* capture source */
75 struct hda_input_mux *input_mux; 76 struct hda_input_mux *input_mux;
76 unsigned int cur_mux[2]; 77 unsigned int cur_mux[3];
77 78
78 /* i/o switches */ 79 /* i/o switches */
79 unsigned int io_switch[2]; 80 unsigned int io_switch[2];
@@ -107,6 +108,14 @@ static hda_nid_t stac922x_mux_nids[2] = {
107 0x12, 0x13, 108 0x12, 0x13,
108}; 109};
109 110
111static hda_nid_t stac927x_adc_nids[3] = {
112 0x07, 0x08, 0x09
113};
114
115static hda_nid_t stac927x_mux_nids[3] = {
116 0x15, 0x16, 0x17
117};
118
110static hda_nid_t stac9200_pin_nids[8] = { 119static hda_nid_t stac9200_pin_nids[8] = {
111 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 120 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
112}; 121};
@@ -116,6 +125,12 @@ static hda_nid_t stac922x_pin_nids[10] = {
116 0x0f, 0x10, 0x11, 0x15, 0x1b, 125 0x0f, 0x10, 0x11, 0x15, 0x1b,
117}; 126};
118 127
128static hda_nid_t stac927x_pin_nids[14] = {
129 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
130 0x0f, 0x10, 0x11, 0x12, 0x13,
131 0x14, 0x21, 0x22, 0x23,
132};
133
119static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 134static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
120{ 135{
121 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 136 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
@@ -155,6 +170,12 @@ static struct hda_verb stac922x_core_init[] = {
155 {} 170 {}
156}; 171};
157 172
173static struct hda_verb stac927x_core_init[] = {
174 /* set master volume and direct control */
175 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
176 {}
177};
178
158static struct snd_kcontrol_new stac9200_mixer[] = { 179static struct snd_kcontrol_new stac9200_mixer[] = {
159 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), 180 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
160 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), 181 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
@@ -183,10 +204,26 @@ static struct snd_kcontrol_new stac922x_mixer[] = {
183 .put = stac92xx_mux_enum_put, 204 .put = stac92xx_mux_enum_put,
184 }, 205 },
185 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT), 206 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
207 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
186 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT), 208 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
187 { } /* end */ 209 { } /* end */
188}; 210};
189 211
212static snd_kcontrol_new_t stac927x_mixer[] = {
213 {
214 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
215 .name = "Input Source",
216 .count = 1,
217 .info = stac92xx_mux_enum_info,
218 .get = stac92xx_mux_enum_get,
219 .put = stac92xx_mux_enum_put,
220 },
221 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
222 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
223 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
224 { } /* end */
225};
226
190static int stac92xx_build_controls(struct hda_codec *codec) 227static int stac92xx_build_controls(struct hda_codec *codec)
191{ 228{
192 struct sigmatel_spec *spec = codec->spec; 229 struct sigmatel_spec *spec = codec->spec;
@@ -240,14 +277,14 @@ static unsigned int ref922x_pin_configs[10] = {
240}; 277};
241 278
242static unsigned int d945gtp3_pin_configs[10] = { 279static unsigned int d945gtp3_pin_configs[10] = {
243 0x0221401f, 0x01a19022, 0x01813021, 0x01114010, 280 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
244 0x40000100, 0x40000100, 0x40000100, 0x40000100, 281 0x40000100, 0x40000100, 0x40000100, 0x40000100,
245 0x02a19120, 0x40000100, 282 0x02a19120, 0x40000100,
246}; 283};
247 284
248static unsigned int d945gtp5_pin_configs[10] = { 285static unsigned int d945gtp5_pin_configs[10] = {
249 0x0221401f, 0x01111012, 0x01813024, 0x01114010, 286 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
250 0x01a19021, 0x01116011, 0x01452130, 0x40000100, 287 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
251 0x02a19320, 0x40000100, 288 0x02a19320, 0x40000100,
252}; 289};
253 290
@@ -274,6 +311,28 @@ static struct hda_board_config stac922x_cfg_tbl[] = {
274 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 311 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
275 .pci_subdevice = 0x0013, 312 .pci_subdevice = 0x0013,
276 .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */ 313 .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */
314 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
315 .pci_subdevice = 0x0417,
316 .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */
317 {} /* terminator */
318};
319
320static unsigned int ref927x_pin_configs[14] = {
321 0x01813122, 0x01a19021, 0x01014010, 0x01016011,
322 0x01012012, 0x01011014, 0x40000100, 0x40000100,
323 0x40000100, 0x40000100, 0x40000100, 0x01441030,
324 0x01c41030, 0x40000100,
325};
326
327static unsigned int *stac927x_brd_tbl[] = {
328 ref927x_pin_configs,
329};
330
331static struct hda_board_config stac927x_cfg_tbl[] = {
332 { .modelname = "ref",
333 .pci_subvendor = PCI_VENDOR_ID_INTEL,
334 .pci_subdevice = 0x2668, /* DFI LanParty */
335 .config = STAC_REF }, /* SigmaTel reference board */
277 {} /* terminator */ 336 {} /* terminator */
278}; 337};
279 338
@@ -408,11 +467,23 @@ static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
408 }, 467 },
409}; 468};
410 469
470static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
471 .substreams = 1,
472 .channels_min = 2,
473 .channels_max = 2,
474 .nid = 0x06, /* NID to query formats and rates */
475 .ops = {
476 .open = stac92xx_playback_pcm_open,
477 .prepare = stac92xx_playback_pcm_prepare,
478 .cleanup = stac92xx_playback_pcm_cleanup
479 },
480};
481
411static struct hda_pcm_stream stac92xx_pcm_analog_capture = { 482static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
412 .substreams = 2, 483 .substreams = 2,
413 .channels_min = 2, 484 .channels_min = 2,
414 .channels_max = 2, 485 .channels_max = 2,
415 .nid = 0x06, /* NID to query formats and rates */ 486 /* NID is set in stac92xx_build_pcms */
416 .ops = { 487 .ops = {
417 .prepare = stac92xx_capture_pcm_prepare, 488 .prepare = stac92xx_capture_pcm_prepare,
418 .cleanup = stac92xx_capture_pcm_cleanup 489 .cleanup = stac92xx_capture_pcm_cleanup
@@ -430,6 +501,14 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
430 info->name = "STAC92xx Analog"; 501 info->name = "STAC92xx Analog";
431 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; 502 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
432 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; 503 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
504 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
505
506 if (spec->alt_switch) {
507 codec->num_pcms++;
508 info++;
509 info->name = "STAC92xx Analog Alt";
510 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
511 }
433 512
434 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 513 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
435 codec->num_pcms++; 514 codec->num_pcms++;
@@ -588,6 +667,16 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
588 return 0; 667 return 0;
589} 668}
590 669
670/*
671 * XXX The line_out pin widget connection list may not be set to the
672 * desired DAC nid. This is the case on 927x where ports A and B can
673 * be routed to several DACs.
674 *
675 * This requires an analysis of the line-out/hp pin configuration
676 * to provide a best fit for pin/DAC configurations that are routable.
677 * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
678 * A and B is not supported.
679 */
591/* fill in the dac_nids table from the parsed pin configuration */ 680/* fill in the dac_nids table from the parsed pin configuration */
592static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg) 681static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
593{ 682{
@@ -602,7 +691,13 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct aut
602 AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 691 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
603 } 692 }
604 693
605 spec->multiout.num_dacs = cfg->line_outs; 694 if (cfg->line_outs)
695 spec->multiout.num_dacs = cfg->line_outs;
696 else if (cfg->hp_pin) {
697 spec->multiout.dac_nids[0] = snd_hda_codec_read(codec, cfg->hp_pin, 0,
698 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
699 spec->multiout.num_dacs = 1;
700 }
606 701
607 return 0; 702 return 0;
608} 703}
@@ -753,19 +848,21 @@ static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
753 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); 848 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
754} 849}
755 850
756static int stac922x_parse_auto_config(struct hda_codec *codec) 851static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
757{ 852{
758 struct sigmatel_spec *spec = codec->spec; 853 struct sigmatel_spec *spec = codec->spec;
759 int err; 854 int err;
760 855
761 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) 856 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
762 return err; 857 return err;
858 if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
859 return 0; /* can't find valid pin config */
860 stac92xx_auto_init_multi_out(codec);
861 stac92xx_auto_init_hp_out(codec);
763 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) 862 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
764 return err; 863 return err;
765 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) 864 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
766 return err; 865 return err;
767 if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
768 return 0; /* can't find valid pin config */
769 866
770 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 867 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
771 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 || 868 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
@@ -777,11 +874,11 @@ static int stac922x_parse_auto_config(struct hda_codec *codec)
777 spec->surr_switch = 1; 874 spec->surr_switch = 1;
778 875
779 if (spec->autocfg.dig_out_pin) { 876 if (spec->autocfg.dig_out_pin) {
780 spec->multiout.dig_out_nid = 0x08; 877 spec->multiout.dig_out_nid = dig_out;
781 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN); 878 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN);
782 } 879 }
783 if (spec->autocfg.dig_in_pin) { 880 if (spec->autocfg.dig_in_pin) {
784 spec->dig_in_nid = 0x09; 881 spec->dig_in_nid = dig_in;
785 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN); 882 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN);
786 } 883 }
787 884
@@ -827,9 +924,6 @@ static int stac92xx_init(struct hda_codec *codec)
827 924
828 snd_hda_sequence_write(codec, spec->init); 925 snd_hda_sequence_write(codec, spec->init);
829 926
830 stac92xx_auto_init_multi_out(codec);
831 stac92xx_auto_init_hp_out(codec);
832
833 return 0; 927 return 0;
834} 928}
835 929
@@ -996,7 +1090,47 @@ static int patch_stac922x(struct hda_codec *codec)
996 1090
997 spec->multiout.dac_nids = spec->dac_nids; 1091 spec->multiout.dac_nids = spec->dac_nids;
998 1092
999 err = stac922x_parse_auto_config(codec); 1093 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
1094 if (err < 0) {
1095 stac92xx_free(codec);
1096 return err;
1097 }
1098
1099 codec->patch_ops = stac92xx_patch_ops;
1100
1101 return 0;
1102}
1103
1104static int patch_stac927x(struct hda_codec *codec)
1105{
1106 struct sigmatel_spec *spec;
1107 int err;
1108
1109 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1110 if (spec == NULL)
1111 return -ENOMEM;
1112
1113 codec->spec = spec;
1114 spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
1115 if (spec->board_config < 0)
1116 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
1117 else {
1118 spec->num_pins = 14;
1119 spec->pin_nids = stac927x_pin_nids;
1120 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
1121 stac92xx_set_config_regs(codec);
1122 }
1123
1124 spec->adc_nids = stac927x_adc_nids;
1125 spec->mux_nids = stac927x_mux_nids;
1126 spec->num_muxes = 3;
1127
1128 spec->init = stac927x_core_init;
1129 spec->mixer = stac927x_mixer;
1130
1131 spec->multiout.dac_nids = spec->dac_nids;
1132
1133 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
1000 if (err < 0) { 1134 if (err < 0) {
1001 stac92xx_free(codec); 1135 stac92xx_free(codec);
1002 return err; 1136 return err;
@@ -1018,5 +1152,15 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = {
1018 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, 1152 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
1019 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, 1153 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
1020 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, 1154 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
1155 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
1156 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
1157 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
1158 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
1159 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
1160 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
1161 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
1162 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
1163 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
1164 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
1021 {} /* terminator */ 1165 {} /* terminator */
1022}; 1166};
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 5466b1fa0cd5..174237f4a22c 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -427,6 +427,7 @@ static struct pci_device_id snd_intel8x0_ids[] = {
427 { 0x10de, 0x008a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK8 */ 427 { 0x10de, 0x008a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK8 */
428 { 0x10de, 0x00da, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE3 */ 428 { 0x10de, 0x00da, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE3 */
429 { 0x10de, 0x00ea, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK8S */ 429 { 0x10de, 0x00ea, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK8S */
430 { 0x10de, 0x026b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* MCP51 */
430 { 0x1022, 0x746d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD8111 */ 431 { 0x1022, 0x746d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD8111 */
431 { 0x1022, 0x7445, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD768 */ 432 { 0x1022, 0x7445, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD768 */
432 { 0x10b9, 0x5455, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALI }, /* Ali5455 */ 433 { 0x10b9, 0x5455, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALI }, /* Ali5455 */
@@ -1805,6 +1806,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1805 }, 1806 },
1806 { 1807 {
1807 .subvendor = 0x1028, 1808 .subvendor = 0x1028,
1809 .subdevice = 0x0151,
1810 .name = "Dell Optiplex GX270", /* AD1981B */
1811 .type = AC97_TUNE_HP_ONLY
1812 },
1813 {
1814 .subvendor = 0x1028,
1808 .subdevice = 0x0163, 1815 .subdevice = 0x0163,
1809 .name = "Dell Unknown", /* STAC9750/51 */ 1816 .name = "Dell Unknown", /* STAC9750/51 */
1810 .type = AC97_TUNE_HP_ONLY 1817 .type = AC97_TUNE_HP_ONLY
@@ -1847,12 +1854,6 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1847 }, 1854 },
1848 { 1855 {
1849 .subvendor = 0x103c, 1856 .subvendor = 0x103c,
1850 .subdevice = 0x099c,
1851 .name = "HP nx6110", /* AD1981B */
1852 .type = AC97_TUNE_HP_ONLY
1853 },
1854 {
1855 .subvendor = 0x103c,
1856 .subdevice = 0x129d, 1857 .subdevice = 0x129d,
1857 .name = "HP xw8000", 1858 .name = "HP xw8000",
1858 .type = AC97_TUNE_HP_ONLY 1859 .type = AC97_TUNE_HP_ONLY
@@ -1866,7 +1867,7 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1866 { 1867 {
1867 .subvendor = 0x103c, 1868 .subvendor = 0x103c,
1868 .subdevice = 0x099c, 1869 .subdevice = 0x099c,
1869 .name = "HP nc6120", 1870 .name = "HP nx6110/nc6120",
1870 .type = AC97_TUNE_HP_MUTE_LED 1871 .type = AC97_TUNE_HP_MUTE_LED
1871 }, 1872 },
1872 { 1873 {
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index b8c0853a8278..b2cba75b6b16 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -454,7 +454,7 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream)
454 is_capture = (subs->stream == SNDRV_PCM_STREAM_CAPTURE); 454 is_capture = (subs->stream == SNDRV_PCM_STREAM_CAPTURE);
455 stream_num = is_capture ? 0 : subs->number; 455 stream_num = is_capture ? 0 : subs->number;
456 456
457 snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : addr(%p) bytes(%x) subs(%d)\n", 457 snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : addr(%p) bytes(%zx) subs(%d)\n",
458 is_capture ? 'c' : 'p', 458 is_capture ? 'c' : 'p',
459 chip->chip_idx, (void*)subs->runtime->dma_addr, 459 chip->chip_idx, (void*)subs->runtime->dma_addr,
460 subs->runtime->dma_bytes, subs->number); 460 subs->runtime->dma_bytes, subs->number);
@@ -744,13 +744,14 @@ static int pcxhr_prepare(struct snd_pcm_substream *subs)
744 /* only the first stream can choose the sample rate */ 744 /* only the first stream can choose the sample rate */
745 /* the further opened streams will be limited to its frequency (see open) */ 745 /* the further opened streams will be limited to its frequency (see open) */
746 /* set the clock only once (first stream) */ 746 /* set the clock only once (first stream) */
747 if (mgr->sample_rate == 0) { 747 if (mgr->sample_rate != subs->runtime->rate) {
748 err = pcxhr_set_clock(mgr, subs->runtime->rate); 748 err = pcxhr_set_clock(mgr, subs->runtime->rate);
749 if (err) 749 if (err)
750 break; 750 break;
751 if (mgr->sample_rate == 0)
752 /* start the DSP-timer */
753 err = pcxhr_hardware_timer(mgr, 1);
751 mgr->sample_rate = subs->runtime->rate; 754 mgr->sample_rate = subs->runtime->rate;
752
753 err = pcxhr_hardware_timer(mgr, 1); /* start the DSP-timer */
754 } 755 }
755 } while(0); /* do only once (so we can use break instead of goto) */ 756 } while(0); /* do only once (so we can use break instead of goto) */
756 757
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 3dec616bad6b..103b4d715ff4 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -3324,11 +3324,11 @@ static int __devinit snd_hdspm_preallocate_memory(struct hdspm * hdspm)
3324 snd_dma_pci_data(hdspm->pci), 3324 snd_dma_pci_data(hdspm->pci),
3325 wanted, 3325 wanted,
3326 wanted)) < 0) { 3326 wanted)) < 0) {
3327 snd_printdd("Could not preallocate %d Bytes\n", wanted); 3327 snd_printdd("Could not preallocate %zd Bytes\n", wanted);
3328 3328
3329 return err; 3329 return err;
3330 } else 3330 } else
3331 snd_printdd(" Preallocated %d Bytes\n", wanted); 3331 snd_printdd(" Preallocated %zd Bytes\n", wanted);
3332 3332
3333 return 0; 3333 return 0;
3334} 3334}
@@ -3510,7 +3510,7 @@ static int __devinit snd_hdspm_create(struct snd_card *card, struct hdspm * hdsp
3510 3510
3511 hdspm->monitor_outs = enable_monitor; 3511 hdspm->monitor_outs = enable_monitor;
3512 3512
3513 snd_printdd("kmalloc Mixer memory of %d Bytes\n", 3513 snd_printdd("kmalloc Mixer memory of %zd Bytes\n",
3514 sizeof(struct hdspm_mixer)); 3514 sizeof(struct hdspm_mixer));
3515 if ((hdspm->mixer = kmalloc(sizeof(struct hdspm_mixer), GFP_KERNEL)) 3515 if ((hdspm->mixer = kmalloc(sizeof(struct hdspm_mixer), GFP_KERNEL))
3516 == NULL) { 3516 == NULL) {
diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c
index 2b21df16ad6a..b4538045049f 100644
--- a/sound/pci/trident/trident.c
+++ b/sound/pci/trident/trident.c
@@ -64,9 +64,11 @@ module_param_array(wavetable_size, int, NULL, 0444);
64MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth."); 64MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth.");
65 65
66static struct pci_device_id snd_trident_ids[] = { 66static struct pci_device_id snd_trident_ids[] = {
67 { 0x1023, 0x2000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Trident 4DWave DX PCI Audio */ 67 {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX),
68 { 0x1023, 0x2001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Trident 4DWave NX PCI Audio */ 68 PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0},
69 { 0x1039, 0x7018, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* SiS SI7018 PCI Audio */ 69 {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_NX),
70 0, 0, 0},
71 {PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_7018), 0, 0, 0},
70 { 0, } 72 { 0, }
71}; 73};
72 74
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index ed26a155c344..423741371191 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2340,6 +2340,7 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
2340 { .subvendor = 0x1043, .subdevice = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/ 2340 { .subvendor = 0x1043, .subdevice = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/
2341 { .subvendor = 0x1043, .subdevice = 0x810d, .action = VIA_DXS_SRC }, /* ASUS */ 2341 { .subvendor = 0x1043, .subdevice = 0x810d, .action = VIA_DXS_SRC }, /* ASUS */
2342 { .subvendor = 0x1043, .subdevice = 0x812a, .action = VIA_DXS_SRC }, /* ASUS A8V Deluxe */ 2342 { .subvendor = 0x1043, .subdevice = 0x812a, .action = VIA_DXS_SRC }, /* ASUS A8V Deluxe */
2343 { .subvendor = 0x1043, .subdevice = 0x8174, .action = VIA_DXS_SRC }, /* ASUS */
2343 { .subvendor = 0x1071, .subdevice = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */ 2344 { .subvendor = 0x1071, .subdevice = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */
2344 { .subvendor = 0x1071, .subdevice = 0x8399, .action = VIA_DXS_NO_VRA }, /* Umax AB 595T (VIA K8N800A - VT8237) */ 2345 { .subvendor = 0x1071, .subdevice = 0x8399, .action = VIA_DXS_NO_VRA }, /* Umax AB 595T (VIA K8N800A - VT8237) */
2345 { .subvendor = 0x10cf, .subdevice = 0x118e, .action = VIA_DXS_ENABLE }, /* FSC laptop */ 2346 { .subvendor = 0x10cf, .subdevice = 0x118e, .action = VIA_DXS_ENABLE }, /* FSC laptop */
@@ -2358,6 +2359,7 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
2358 { .subvendor = 0x1462, .subdevice = 0x7023, .action = VIA_DXS_NO_VRA }, /* MSI K8T Neo2-FI */ 2359 { .subvendor = 0x1462, .subdevice = 0x7023, .action = VIA_DXS_NO_VRA }, /* MSI K8T Neo2-FI */
2359 { .subvendor = 0x1462, .subdevice = 0x7120, .action = VIA_DXS_ENABLE }, /* MSI KT4V */ 2360 { .subvendor = 0x1462, .subdevice = 0x7120, .action = VIA_DXS_ENABLE }, /* MSI KT4V */
2360 { .subvendor = 0x1462, .subdevice = 0x7142, .action = VIA_DXS_ENABLE }, /* MSI K8MM-V */ 2361 { .subvendor = 0x1462, .subdevice = 0x7142, .action = VIA_DXS_ENABLE }, /* MSI K8MM-V */
2362 { .subvendor = 0x1462, .subdevice = 0xb012, .action = VIA_DXS_SRC }, /* P4M800/VIA8237R */
2361 { .subvendor = 0x147b, .subdevice = 0x1401, .action = VIA_DXS_ENABLE }, /* ABIT KD7(-RAID) */ 2363 { .subvendor = 0x147b, .subdevice = 0x1401, .action = VIA_DXS_ENABLE }, /* ABIT KD7(-RAID) */
2362 { .subvendor = 0x147b, .subdevice = 0x1411, .action = VIA_DXS_ENABLE }, /* ABIT VA-20 */ 2364 { .subvendor = 0x147b, .subdevice = 0x1411, .action = VIA_DXS_ENABLE }, /* ABIT VA-20 */
2363 { .subvendor = 0x147b, .subdevice = 0x1413, .action = VIA_DXS_ENABLE }, /* ABIT KV8 Pro */ 2365 { .subvendor = 0x147b, .subdevice = 0x1413, .action = VIA_DXS_ENABLE }, /* ABIT KV8 Pro */
@@ -2371,6 +2373,9 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
2371 { .subvendor = 0x161f, .subdevice = 0x2032, .action = VIA_DXS_48K }, /* m680x machines */ 2373 { .subvendor = 0x161f, .subdevice = 0x2032, .action = VIA_DXS_48K }, /* m680x machines */
2372 { .subvendor = 0x1631, .subdevice = 0xe004, .action = VIA_DXS_ENABLE }, /* Easy Note 3174, Packard Bell */ 2374 { .subvendor = 0x1631, .subdevice = 0xe004, .action = VIA_DXS_ENABLE }, /* Easy Note 3174, Packard Bell */
2373 { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */ 2375 { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */
2376 { .subvendor = 0x1695, .subdevice = 0x300e, .action = VIA_DXS_SRC }, /* EPoX 9HEAI */
2377 { .subvendor = 0x16f3, .subdevice = 0x6405, .action = VIA_DXS_SRC }, /* Jetway K8M8MS */
2378 { .subvendor = 0x1734, .subdevice = 0x1093, .action = VIA_DXS_SRC }, /* FSC */
2374 { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */ 2379 { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */
2375 { .subvendor = 0x1849, .subdevice = 0x9761, .action = VIA_DXS_SRC }, /* ASRock mobo(?) */ 2380 { .subvendor = 0x1849, .subdevice = 0x9761, .action = VIA_DXS_SRC }, /* ASRock mobo(?) */
2376 { .subvendor = 0x1919, .subdevice = 0x200a, .action = VIA_DXS_NO_VRA }, /* Soltek SL-K8Tpro-939 */ 2381 { .subvendor = 0x1919, .subdevice = 0x200a, .action = VIA_DXS_NO_VRA }, /* Soltek SL-K8Tpro-939 */
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 1dfc7233c6a8..a1aa74b79b3d 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -1229,6 +1229,7 @@ static int snd_ymfpci_spdif_default_get(struct snd_kcontrol *kcontrol,
1229 spin_lock_irq(&chip->reg_lock); 1229 spin_lock_irq(&chip->reg_lock);
1230 ucontrol->value.iec958.status[0] = (chip->spdif_bits >> 0) & 0xff; 1230 ucontrol->value.iec958.status[0] = (chip->spdif_bits >> 0) & 0xff;
1231 ucontrol->value.iec958.status[1] = (chip->spdif_bits >> 8) & 0xff; 1231 ucontrol->value.iec958.status[1] = (chip->spdif_bits >> 8) & 0xff;
1232 ucontrol->value.iec958.status[3] = IEC958_AES3_CON_FS_48000;
1232 spin_unlock_irq(&chip->reg_lock); 1233 spin_unlock_irq(&chip->reg_lock);
1233 return 0; 1234 return 0;
1234} 1235}
@@ -1303,6 +1304,7 @@ static int snd_ymfpci_spdif_stream_get(struct snd_kcontrol *kcontrol,
1303 spin_lock_irq(&chip->reg_lock); 1304 spin_lock_irq(&chip->reg_lock);
1304 ucontrol->value.iec958.status[0] = (chip->spdif_pcm_bits >> 0) & 0xff; 1305 ucontrol->value.iec958.status[0] = (chip->spdif_pcm_bits >> 0) & 0xff;
1305 ucontrol->value.iec958.status[1] = (chip->spdif_pcm_bits >> 8) & 0xff; 1306 ucontrol->value.iec958.status[1] = (chip->spdif_pcm_bits >> 8) & 0xff;
1307 ucontrol->value.iec958.status[3] = IEC958_AES3_CON_FS_48000;
1306 spin_unlock_irq(&chip->reg_lock); 1308 spin_unlock_irq(&chip->reg_lock);
1307 return 0; 1309 return 0;
1308} 1310}
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index a642e4cfcf45..4988f873a7ba 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -1216,7 +1216,7 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1216 goto __error; 1216 goto __error;
1217 } 1217 }
1218 for (i = 0; i < 3; i ++) { 1218 for (i = 0; i < 3; i ++) {
1219 if (of_address_to_resource(np->parent, i, 1219 if (of_address_to_resource(np, i,
1220 &chip->rsrc[i])) { 1220 &chip->rsrc[i])) {
1221 printk(KERN_ERR "snd: can't translate rsrc " 1221 printk(KERN_ERR "snd: can't translate rsrc "
1222 " %d (%s)\n", i, rnames[i]); 1222 " %d (%s)\n", i, rnames[i]);
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index a1bd8040dea4..d5013383fad7 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -478,22 +478,38 @@ static int retire_playback_sync_urb_hs(struct snd_usb_substream *subs,
478/* 478/*
479 * Prepare urb for streaming before playback starts. 479 * Prepare urb for streaming before playback starts.
480 * 480 *
481 * We don't care about (or have) any data, so we just send a transfer delimiter. 481 * We don't yet have data, so we send a frame of silence.
482 */ 482 */
483static int prepare_startup_playback_urb(struct snd_usb_substream *subs, 483static int prepare_startup_playback_urb(struct snd_usb_substream *subs,
484 struct snd_pcm_runtime *runtime, 484 struct snd_pcm_runtime *runtime,
485 struct urb *urb) 485 struct urb *urb)
486{ 486{
487 unsigned int i; 487 unsigned int i, offs, counts;
488 struct snd_urb_ctx *ctx = urb->context; 488 struct snd_urb_ctx *ctx = urb->context;
489 int stride = runtime->frame_bits >> 3;
489 490
491 offs = 0;
490 urb->dev = ctx->subs->dev; 492 urb->dev = ctx->subs->dev;
491 urb->number_of_packets = subs->packs_per_ms; 493 urb->number_of_packets = subs->packs_per_ms;
492 for (i = 0; i < subs->packs_per_ms; ++i) { 494 for (i = 0; i < subs->packs_per_ms; ++i) {
493 urb->iso_frame_desc[i].offset = 0; 495 /* calculate the size of a packet */
494 urb->iso_frame_desc[i].length = 0; 496 if (subs->fill_max)
497 counts = subs->maxframesize; /* fixed */
498 else {
499 subs->phase = (subs->phase & 0xffff)
500 + (subs->freqm << subs->datainterval);
501 counts = subs->phase >> 16;
502 if (counts > subs->maxframesize)
503 counts = subs->maxframesize;
504 }
505 urb->iso_frame_desc[i].offset = offs * stride;
506 urb->iso_frame_desc[i].length = counts * stride;
507 offs += counts;
495 } 508 }
496 urb->transfer_buffer_length = 0; 509 urb->transfer_buffer_length = offs * stride;
510 memset(urb->transfer_buffer,
511 subs->cur_audiofmt->format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0,
512 offs * stride);
497 return 0; 513 return 0;
498} 514}
499 515
@@ -2477,12 +2493,13 @@ static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp
2477 if (err < 0) 2493 if (err < 0)
2478 return err; 2494 return err;
2479#if 1 2495#if 1
2480 /* FIXME: temporary hack for extigy/audigy 2 nx */ 2496 /* FIXME: temporary hack for extigy/audigy 2 nx/zs */
2481 /* extigy apparently supports sample rates other than 48k 2497 /* extigy apparently supports sample rates other than 48k
2482 * but not in ordinary way. so we enable only 48k atm. 2498 * but not in ordinary way. so we enable only 48k atm.
2483 */ 2499 */
2484 if (chip->usb_id == USB_ID(0x041e, 0x3000) || 2500 if (chip->usb_id == USB_ID(0x041e, 0x3000) ||
2485 chip->usb_id == USB_ID(0x041e, 0x3020)) { 2501 chip->usb_id == USB_ID(0x041e, 0x3020) ||
2502 chip->usb_id == USB_ID(0x041e, 0x3061)) {
2486 if (fmt[3] == USB_FORMAT_TYPE_I && 2503 if (fmt[3] == USB_FORMAT_TYPE_I &&
2487 fp->rates != SNDRV_PCM_RATE_48000 && 2504 fp->rates != SNDRV_PCM_RATE_48000 &&
2488 fp->rates != SNDRV_PCM_RATE_96000) 2505 fp->rates != SNDRV_PCM_RATE_96000)